/* Dualx admin panel. Colors are tokens; dark mode is its own set of steps (validated against the dark surface). */
:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #131820;
  --ink2: #4b5563;
  --muted: #6b7584;
  --line: #dde3ea;
  --accent: #2a78d6;          /* series blue */
  --track: #cde2fb;           /* lighter step of the same blue ramp */
  --primary-bg: #256abf;
  --primary-ink: #ffffff;
  --good: #0ca30c;            /* status palette: always paired with an icon and a label */
  --warn: #fab219;
  --bad: #d03b3b;
  --off: #8b94a3;
  --font: "Vazirmatn", "IRANSansX", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0e1116; --surface: #171b22; --ink: #e8ebf0; --ink2: #b4bcc8; --muted: #8a93a1; --line: #272d37;
    --accent: #3987e5; --track: #153e78; --primary-bg: #3987e5; --primary-ink: #0b0f14;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116; --surface: #171b22; --ink: #e8ebf0; --ink2: #b4bcc8; --muted: #8a93a1; --line: #272d37;
  --accent: #3987e5; --track: #153e78; --primary-bg: #3987e5; --primary-ink: #0b0f14;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.6 var(--font); -webkit-text-size-adjust: 100%; }
h1, h2, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 1em; height: 1em; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons & inputs ---------- */
.btn { font: inherit; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 6px 14px; cursor: pointer; line-height: 1.5; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary-bg); color: var(--primary-ink); border-color: var(--primary-bg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.btn.ghost { border-color: transparent; color: var(--ink2); }
.btn.ghost:hover { background: var(--line); }
.btn.small { padding: 2px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
input:hover { border-color: var(--muted); }
label { display: block; font-weight: 600; margin: 14px 0 4px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.err { color: var(--bad); margin-top: 10px; font-weight: 600; }
.num, .mono { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: var(--mono); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 28px 24px 24px; }
.login-box h1 { font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.login-sub { color: var(--ink2); margin-bottom: 8px; }
.login-box .btn { margin-top: 18px; padding: 9px 14px; }

/* ---------- top bar ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand strong { font-size: 18px; letter-spacing: -.01em; }
.brand span { color: var(--muted); }
.tools { display: flex; align-items: center; gap: 6px; }
.health { display: inline-flex; align-items: center; gap: 6px; color: var(--ink2); margin-inline-end: 8px; font-size: 13px; }
.health svg { font-size: 15px; }
.health.ok svg { color: var(--good); }
.health.down svg { color: var(--bad); }

/* ---------- page ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 16px 56px; display: grid; gap: 28px; }
.two { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px 20px; }
.panel-head { margin-bottom: 14px; }
.panel-head.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel h2 { font-size: 16px; font-weight: 700; }
.panel-sub { color: var(--muted); font-size: 12.5px; }

/* ---------- status strip (open on the page, no card) ---------- */
.strip { padding: 4px 4px 0; }
.hero { display: flex; align-items: baseline; gap: 12px; }
.hero-num { font-size: 68px; line-height: 1; font-weight: 600; letter-spacing: -.02em; }
.hero-unit { font-size: 20px; color: var(--ink2); }
.hero-text { color: var(--ink2); margin: 6px 0 16px; max-width: 70ch; }
.seg { display: flex; gap: 2px; height: 14px; }
.seg span { display: block; border-radius: 4px; min-width: 6px; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 12px; }
.seg-legend li { display: inline-flex; align-items: center; gap: 7px; }
.seg-legend svg { font-size: 15px; }
.seg-legend b { font-weight: 700; }

/* ---------- runway chart ---------- */
.runway { position: relative; }
.rw-axis, .rw-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 76px; align-items: center; column-gap: 12px; }
.rw-axis { height: 20px; margin-bottom: 2px; }
.rw-scale { position: relative; height: 100%; color: var(--muted); font-size: 11px; }
.rw-scale span { position: absolute; top: 0; transform: translateX(50%); white-space: nowrap; }
.rw-row { height: 30px; border-radius: 4px; cursor: default; }
.rw-row:hover { background: color-mix(in srgb, var(--line) 55%, transparent); }
.rw-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rw-track { position: relative; height: 100%; }
.rw-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.rw-bar { position: absolute; top: 50%; margin-top: -6px; height: 12px; inset-inline-start: 0; border-radius: 0 4px 4px 0; background: var(--accent); }
[dir="rtl"] .rw-bar { border-radius: 4px 0 0 4px; }
.rw-bar.warn { background: var(--warn); }
.rw-val { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-start; font-variant-numeric: tabular-nums; }
.rw-val svg { font-size: 14px; }
.rw-more { color: var(--muted); font-size: 12px; margin-top: 8px; }
.tip { position: fixed; z-index: 30; pointer-events: none; background: var(--ink); color: var(--surface); padding: 6px 10px; border-radius: 6px; font-size: 12px; max-width: 260px; }

/* ---------- activity ---------- */
.log li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log .what { min-width: 0; }
.log .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.log .who { color: var(--muted); font-size: 12px; grid-column: 1 / -1; }
.log-empty { color: var(--muted); padding: 6px 0; }

/* ---------- keys table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 10px; }
.toolbar input { max-width: 280px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; background: transparent; color: var(--ink2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--track); border-color: var(--accent); color: var(--ink); font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--line) 35%, transparent); }
.nm { font-weight: 600; }
.nm-note { color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.badge svg { font-size: 15px; }
.c-ok svg { color: var(--good); } .c-warn svg { color: var(--warn); } .c-bad svg { color: var(--bad); } .c-off svg { color: var(--off); }
.exp-days { color: var(--muted); font-size: 12px; }
.meter { display: inline-block; vertical-align: middle; width: 54px; height: 6px; border-radius: 3px; background: var(--track); margin-inline-end: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.full i { background: var(--warn); }
.muted { color: var(--muted); }
.id { font-size: 12px; color: var(--muted); }
.acts { display: flex; gap: 6px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 10; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 6px 24px rgba(0,0,0,.14); }
.menu-pop button { display: block; width: 100%; text-align: start; font: inherit; color: var(--ink); background: transparent; border: 0; border-radius: 6px; padding: 7px 10px; cursor: pointer; }
.menu-pop button:hover { background: var(--line); }
.menu-pop button.bad { color: var(--bad); }
.empty { color: var(--ink2); padding: 22px 4px 6px; }

/* ---------- dialog & toast ---------- */
dialog { width: min(440px, 92vw); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 22px 22px 18px; }
dialog::backdrop { background: rgba(8, 12, 18, .55); }
dialog h2 { font-size: 17px; margin-bottom: 4px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.keybox { font-family: var(--mono); direction: ltr; text-align: left; user-select: all; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 12px 0 4px; font-size: 14px; }
.warn-note { color: var(--ink); background: color-mix(in srgb, var(--warn) 22%, transparent); border-radius: 6px; padding: 8px 12px; margin-top: 10px; }
.toast { position: fixed; bottom: 22px; inset-inline: 0; margin-inline: auto; width: max-content; max-width: 90vw; background: var(--ink); color: var(--surface); padding: 9px 18px; border-radius: 6px; z-index: 40; }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .two { grid-template-columns: 1fr; }
  .rw-axis, .rw-row { grid-template-columns: 96px minmax(0, 1fr) 64px; }
  .hero-num { font-size: 56px; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .health { order: 3; width: 100%; margin: 0; }
  .page { padding-top: 20px; }
  .panel { padding: 16px 14px; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td { border: 0; padding: 0; }
  td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11.5px; }
  td.c-name { grid-column: 1 / -1; }
  td.c-name::before, td.c-act::before { content: none; }
  td.c-act { grid-column: 1 / -1; }
  .acts { justify-content: flex-start; }
  .menu-pop { inset-inline-end: auto; inset-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
