/* ---------- design tokens (all customizable from Settings → Appearance) ---------- */
:root {
  --accent: #1a73e8; --radius: 16px; --font: "Google Sans", Roboto, system-ui, sans-serif;
  --bg: #f1f3f9; --surface: #ffffff; --surface-2: #f6f8fc; --text: #1f2430; --muted: #687085; --line: #e6e9f1;
  --ok: #188038; --warn: #e37400; --err: #d93025; --on-accent: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--surface));
  --accent-strong: color-mix(in srgb, var(--accent) 82%, #000);
  --radius-sm: calc(var(--radius) * .6); --pad: 22px; --gap: 18px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 6px 20px rgba(20, 30, 60, .06);
  --sb-bg: var(--surface); --sb-text: var(--text); --sb-muted: var(--muted); --sb-active-bg: var(--accent-soft); --sb-active: var(--accent); --sb-line: var(--line);
}
:root[data-theme="dark"] {
  --bg: #0e1117; --surface: #161a22; --surface-2: #1d222c; --text: #e8eaf1; --muted: #98a1b5; --line: #2a303d;
  --ok: #5bb974; --warn: #f2a53a; --err: #f28b82; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --accent-soft: color-mix(in srgb, var(--accent) 20%, var(--surface));
}
body[data-density="compact"] { --pad: 14px; --gap: 12px; font-size: 13px; }
body[data-density="spacious"] { --pad: 28px; --gap: 24px; }
body[data-sidebar="dark"] { --sb-bg: #12161f; --sb-text: #e8eaf1; --sb-muted: #8f98ad; --sb-active-bg: rgba(255, 255, 255, .09); --sb-active: #fff; --sb-line: rgba(255, 255, 255, .08); }
body[data-sidebar="accent"] { --sb-bg: var(--accent); --sb-text: #fff; --sb-muted: rgba(255, 255, 255, .72); --sb-active-bg: rgba(255, 255, 255, .2); --sb-active: #fff; --sb-line: rgba(255, 255, 255, .18); }
body[data-card="outlined"] { --shadow: none; } body[data-card="outlined"] .card { border: 1.5px solid var(--line); }
body[data-card="elevated"] { --shadow: 0 2px 4px rgba(20, 30, 60, .06), 0 14px 36px rgba(20, 30, 60, .12); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; } h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; font-size: .92em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .spacer { flex: 1; } .col { display: flex; flex-direction: column; gap: 10px; }
.ico { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: var(--sb-bg); color: var(--sb-text); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--sb-line); }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 18px; font-size: 19px; font-weight: 700; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 18px; }
body[data-sidebar="accent"] .logo { background: #fff; color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 13px; padding: 11px 14px; border-radius: calc(var(--radius) * .75); color: var(--sb-muted); font-weight: 500; text-decoration: none; transition: background .15s, color .15s; }
.nav a:hover { background: var(--sb-active-bg); color: var(--sb-text); }
.nav a.active { background: var(--sb-active-bg); color: var(--sb-active); font-weight: 600; }
.nav .badge { margin-left: auto; background: var(--err); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.sb-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--sb-line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; flex: none; }
body[data-sidebar="dark"] .avatar, body[data-sidebar="accent"] .avatar { background: rgba(255, 255, 255, .16); color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px calc(var(--pad) + 8px) 0; }
.topbar h1 { font-size: 22px; }
.page { padding: var(--gap) calc(var(--pad) + 8px) 48px; display: flex; flex-direction: column; gap: var(--gap); max-width: 1500px; width: 100%; }
.icon-btn.menu-btn { display: none; }
.grid { display: grid; gap: var(--gap); } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g-main { grid-template-columns: 1fr; } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; } .sidebar { position: fixed; z-index: 40; left: 0; width: 270px; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); } .sidebar.open { transform: none; }
  .icon-btn.menu-btn { display: inline-grid; } .g2, .g3, .g4 { grid-template-columns: 1fr; } .page, .topbar { padding-left: 14px; padding-right: 14px; }
}

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; } .card-head h2, .card-head h3 { flex: 1; }
.card.flush { padding: 0; overflow: hidden; } .card.flush > .card-head { padding: var(--pad) var(--pad) 0; }
.kpi { display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 500; }
.kpi-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi-value { font-size: 32px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.delta.up { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); } .delta.down { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); } .delta.flat { color: var(--muted); background: var(--surface-2); }
.spark { overflow: visible; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; cursor: pointer; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 16px; border-radius: 99px; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: color-mix(in srgb, var(--line) 60%, var(--muted)); } .btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; } .btn.primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn.danger { background: var(--err); color: #fff; border-color: transparent; } .btn.danger:hover:not(:disabled) { filter: brightness(.92); background: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.sm { padding: 5px 12px; font-size: 12.5px; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; } .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.input, select.input, textarea.input { font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea.input { resize: vertical; min-height: 80px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
input[type=color] { padding: 2px; height: 40px; width: 64px; cursor: pointer; } input[type=range] { accent-color: var(--accent); width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; } .field-label { font-weight: 600; font-size: 12.5px; color: var(--muted); } .hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } .form-grid .full { grid-column: 1 / -1; } @media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; } .switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.slider { width: 38px; height: 22px; background: var(--line); border-radius: 99px; position: relative; transition: background .2s; flex: none; }
.slider::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + .slider { background: var(--accent); } .switch input:checked + .slider::after { transform: translateX(16px); } .switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 99px; padding: 3px; gap: 2px; } .seg button { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 12.5px; padding: 5px 13px; border-radius: 99px; cursor: pointer; color: var(--muted); } .seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- tables, chips, status ---------- */
.table-wrap { overflow-x: auto; } table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; } td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; } tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); } tr.click { cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); } .chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); } .chip.err { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); } .chip.info { color: var(--accent); background: var(--accent-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; } .dot.running, .dot.serving { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); } .dot.stopped { background: var(--muted); } .dot.starting, .dot.backoff, .dot.stopping { background: var(--warn); animation: pulse 1s infinite; } .dot.crashed, .dot.errored { background: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; } .tab { background: none; border: 0; font: inherit; font-weight: 600; color: var(--muted); padding: 10px 16px; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; } .tab:hover { color: var(--text); } .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); } .banner.warn { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); } .banner.err { background: color-mix(in srgb, var(--err) 14%, var(--surface)); } .banner .ico { margin-top: 2px; }

/* ---------- charts ---------- */
.chart { position: relative; } .chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 5; } .chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; } .chart .dotc { fill: var(--surface); stroke-width: 3; }
.tip { position: absolute; top: 0; z-index: 3; pointer-events: none; background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 10px; font-size: 12px; box-shadow: var(--shadow); min-width: 120px; } .tip-row { display: flex; align-items: center; gap: 6px; } .tip-row i { width: 8px; height: 8px; border-radius: 50%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; } .gauge-track { stroke: var(--surface-2); } .gauge-val { fill: var(--text); font-size: 22px; font-weight: 600; font-family: var(--font); } .gauge-label { font-weight: 600; }
.hbars { display: flex; flex-direction: column; gap: 12px; } .hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; } .hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hbar-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; } .hbar-fill { height: 100%; border-radius: 99px; min-width: 3px; }
.stat-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; } .stat-list dt { color: var(--muted); } .stat-list dd { margin: 0; text-align: right; font-weight: 500; word-break: break-all; }

/* ---------- events / logs ---------- */
.events { display: flex; flex-direction: column; } .event { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); } .event:last-child { border: 0; }
.event-ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); } .event-ico.error { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); } .event-ico.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); } .event-ico.info { background: var(--accent-soft); color: var(--accent); }
.logbox { background: #0d1117; color: #d6dde8; border-radius: var(--radius-sm); padding: 12px 14px; height: 480px; overflow: auto; font: 12.5px/1.55 ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.logbox .l { display: block; } .logbox .t { color: #6b7686; margin-right: 8px; } .logbox .err { color: #ff8b81; } .logbox .sys { color: #7fb3ff; } .logbox .warn { color: #f2c46d; }
.joblog { background: #0d1117; color: #c9d4e3; border-radius: var(--radius-sm); padding: 12px; max-height: 260px; overflow: auto; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; } .joblog .error { color: #ff8b81; } .joblog .warn { color: #f2c46d; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; } .progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; } .dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- overlays ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 24, .5); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: calc(var(--radius) + 4px); width: min(520px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 24px 80px rgba(0, 0, 0, .35); animation: pop .18s; } .modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; padding: 18px 22px 8px; } .modal-head h3 { flex: 1; font-size: 18px; } .modal-body { padding: 8px 22px 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; } .modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow); max-width: 380px; animation: pop .2s; } .toast.out { opacity: 0; transition: opacity .25s; } .toast.error { background: var(--err); color: #fff; } .toast.success { background: var(--ok); color: #fff; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; } @keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; } .empty-art { width: 72px; height: 72px; border-radius: 24px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.auth-card { width: min(440px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 34px; } .auth-card .logo { width: 48px; height: 48px; font-size: 24px; border-radius: 15px; }
.qr { background: #fff; padding: 10px; border-radius: 14px; align-self: center; } .codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .codes code { padding: 8px; text-align: center; font-size: 13px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; } .swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--line); } .swatch.on { border-color: var(--surface); box-shadow: 0 0 0 2px var(--text); }
.status-modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; } .mode { border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; background: var(--surface); text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 4px; } .mode:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); } .mode.on { border-color: var(--accent); background: var(--accent-soft); } .mode b { display: flex; align-items: center; gap: 8px; } .mode span { font-size: 12px; color: var(--muted); }
.preview-frame { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.k { font-weight: 600; } .link-btn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; } .link-btn:hover { text-decoration: underline; }
