/* MayaOps panel. Colors are role tokens (light / dark), from the validated
   reference palette: categorical slots 1-3 for the three Iran entries, the
   fixed status palette for state, always with an icon and a label. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --seq-0: #cde2fb;
  --seq-1: #86b6ef;
  --seq-2: #3987e5;
  --seq-3: #1c5cab;
  --seq-4: #0d366b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good-text: #0ca30c;
    --accent: #3987e5;
    --seq-0: #184f95;
    --seq-1: #1c5cab;
    --seq-2: #2a78d6;
    --seq-3: #5598e7;
    --seq-4: #9ec5f4;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --good-text: #0ca30c;
  --accent: #3987e5;
  --seq-0: #184f95;
  --seq-1: #1c5cab;
  --seq-2: #2a78d6;
  --seq-3: #5598e7;
  --seq-4: #9ec5f4;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Vazirmatn, "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

button, input, select { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* --- top bar ------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.summary { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  border-radius: 999px; border: 1px solid var(--border); font-size: 14px; }
.updated { color: var(--muted); font-size: 13px; margin-inline-start: auto; }
.icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 10px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

nav.tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto;
  border-block-end: 1px solid var(--border); background: var(--surface); }
nav.tabs button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer;
  border-block-end: 2px solid transparent; color: var(--ink-2); white-space: nowrap; }
nav.tabs button[aria-selected="true"] { color: var(--ink); border-block-end-color: var(--accent);
  font-weight: 600; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
section.view > * + * { margin-block-start: 16px; }

.banner { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); }
.banner.warn { border-inline-start: 4px solid var(--warning); }

/* --- cards & grids ------------------------------------------------------------- */

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--accent); }
.card.selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.card h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card .sub { color: var(--muted); font-size: 13px; }

.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 1px 8px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; }
.status.good .dot { background: var(--good); }
.status.warning .dot { background: var(--warning); }
.status.serious .dot { background: var(--serious); }
.status.critical .dot { background: var(--critical); }
.status.critical { color: var(--critical); font-weight: 600; }

.hero { font-size: 34px; font-weight: 700; line-height: 1.2; margin-block: 8px 2px;
  font-variant-numeric: tabular-nums; }
.hero small { font-size: 14px; font-weight: 400; color: var(--muted); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.legs { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.legs li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0;
  border-block-start: 1px dashed var(--grid); }
.legs li:first-child { border-block-start: 0; }
.legs .ltr { direction: ltr; unicode-bidi: isolate; }

/* meters: a value against 100% with a status color past its threshold */
.meter { display: grid; grid-template-columns: 44px 1fr 48px; align-items: center; gap: 8px;
  font-size: 13px; }
.meter .track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.meter .fill.warning { background: var(--warning); }
.meter .fill.critical { background: var(--critical); }
.meter .val { text-align: end; font-variant-numeric: tabular-nums; }
.meters > * + * { margin-block-start: 6px; }

/* --- charts -------------------------------------------------------------------- */

.chart-card .head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; }
.chart-card h4 { margin: 0; font-size: 15px; }
.chart { width: 100%; height: 260px; direction: ltr; }
.chart.tall { height: 320px; }
.chart.short { height: 200px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* --- tables -------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: start; padding: 7px 10px; border-block-end: 1px solid var(--grid);
  vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.danger { color: var(--critical); border-color: var(--critical); }

/* --- login --------------------------------------------------------------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin: 0 0 16px; }
.login label { display: block; font-size: 14px; color: var(--ink-2); margin-block: 12px 4px; }
.login input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--axis);
  background: var(--surface); }
.login input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.login input.code { letter-spacing: 6px; text-align: center; direction: ltr; font-size: 20px; }
.login button { width: 100%; margin-block-start: 18px; padding: 10px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.login button:disabled { opacity: 0.6; cursor: wait; }
.login .error { color: var(--critical); min-height: 1.6em; margin-block-start: 10px; font-size: 14px; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .hero { font-size: 28px; }
  .chart { height: 220px; }
}
