* { box-sizing: border-box; }
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --ok: #4ade80;
  --warn: #facc15;
  --err: #f87171;
  --border: #334155;
}
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; }
header { background: linear-gradient(180deg, #0b1220, #1e293b); padding: 16px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
header h1 { margin: 0 0 12px 0; font-size: 20px; font-weight: 600; }
header h1 .brand { color: var(--accent); }
nav { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active { background: var(--accent); color: #0b1220; border-color: var(--accent); font-weight: 600; }

main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
h2 { margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 8px 0; font-size: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.grid-3 .card { margin: 0; }

label.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
label.row > span { flex: 1; font-size: 14px; }
label.row input[type=number] { width: 100px; }
label.block { display: block; padding: 8px 0; }
label.block > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.block input, label.block textarea { width: 100%; }
small { color: var(--muted); display: block; margin-top: 4px; font-size: 12px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 3px; font-size: 12px; }

input[type=text], input[type=number], input:not([type]), textarea, select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 8px 10px; border-radius: 6px; font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

button { background: var(--accent); color: #0b1220; border: 0; padding: 8px 14px; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 13px; }
button:hover { background: var(--accent-2); }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.actions button { background: var(--accent); }
.actions button.preview { background: transparent; color: var(--text); border: 1px solid var(--border); }
.actions button.run-now { background: var(--warn); }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; }
legend { color: var(--accent); padding: 0 6px; font-size: 13px; }

.panel.automation-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.panel#tab-config, .panel#tab-logs, .panel#tab-test, .panel#tab-dash { background: transparent; padding: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); border-radius: 6px; overflow: hidden; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: rgba(56,189,248,.05); }
td.ok { color: var(--ok); }
td.err { color: var(--err); }

pre { background: #020617; color: #94a3b8; padding: 10px; border-radius: 6px; font-size: 12px; overflow: auto; }
pre.preview-out { white-space: pre-wrap; min-height: 1em; max-height: 600px; word-break: break-word; }

#toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 10px 14px; border-radius: 6px; transform: translateY(120%); transition: transform .2s; z-index: 100; }
#toast.show { transform: translateY(0); }
#toast.ok { border-color: var(--ok); }
#toast.err { border-color: var(--err); }

.status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.status-pill.on { background: rgba(74, 222, 128, .15); color: var(--ok); }
.status-pill.off { background: rgba(148, 163, 184, .15); color: var(--muted); }

@media (max-width: 720px) {
  .grid-3 { grid-template-columns: 1fr; }
}
