/* Shared tokens and components for portal, admin and panel. RTL-first. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --card: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #77756f;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #006300;
  --bad: #b42318;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --danger-bg: #fdecea;
  --radius: 14px;
  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --card: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7;
    --muted: #9a988f; --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --accent-wash: rgba(57, 135, 229, 0.14); --series-1: #3987e5; --series-2: #d95926;
    --good: #0ca30c; --bad: #f97066; --warn-bg: #3a2f12; --warn-ink: #f3d68a; --danger-bg: #3a1a17;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --card: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7;
  --muted: #9a988f; --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --accent-wash: rgba(57, 135, 229, 0.14); --series-1: #3987e5; --series-2: #d95926;
  --good: #0ca30c; --bad: #f97066; --warn-bg: #3a2f12; --warn-ink: #f3d68a; --danger-bg: #3a1a17;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); }
body { font-size: 15px; line-height: 1.6; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 24px; margin: 2px 0 0; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 4px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
.sub { color: var(--ink-2); font-size: 13px; margin: 0 0 14px; }
.eyebrow { color: var(--muted); font-size: 13px; margin: 0; }
.muted { color: var(--muted); }
button, select, input, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 12px; min-height: 38px;
}
textarea { min-height: 80px; width: 100%; }
button { cursor: pointer; font-weight: 500; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
a { color: var(--accent); }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); margin-bottom: 12px; }
.two { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 2px; line-height: 1.3; overflow-wrap: anywhere; }
.tile .note { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.tile.hero { grid-column: span 2; }
.tile.hero .value { font-size: 40px; }
.delta-up { color: var(--good); font-weight: 600; }
.section { margin-top: 24px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 34px; padding: 5px 12px; background: transparent; }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); font-weight: 700; }
.chart { position: relative; width: 100%; direction: ltr; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; }
.tip {
  position: absolute; pointer-events: none; background: var(--card); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); white-space: nowrap; direction: rtl; z-index: 5; display: none;
}
.tip strong { display: block; font-size: 15px; }
.tip .k { color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.key { display: inline-block; width: 12px; height: 2px; border-radius: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin: 4px 0 8px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; font-size: 12.5px; white-space: nowrap; position: sticky; top: 0; background: var(--card); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.void td { color: var(--muted); text-decoration: line-through; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filters input { flex: 1 1 220px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-wash); font-size: 12px; }
.pill.off { background: var(--grid); color: var(--ink-2); }
.banner { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13.5px; }
.banner.danger { background: var(--danger-bg); color: var(--bad); }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-2); }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; text-decoration: underline; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field .help { font-size: 12px; color: var(--muted); }
.field input, .field select { width: 100%; }
.switch { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.switch:last-child { border-bottom: 0; }
.switch input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; margin-top: 3px; accent-color: var(--accent); flex: none; }
.switch .t { font-weight: 500; }
.switch .h { font-size: 12.5px; color: var(--muted); }
.toast {
  position: fixed; inset-inline-start: 16px; bottom: 16px; background: var(--ink); color: var(--page);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: min(420px, calc(100vw - 32px));
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.error { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--ink); padding: 18px; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; direction: ltr; }
pre { background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 10px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; text-align: left; }
.loading { opacity: .55; transition: opacity .2s; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 520px) {
  .card { padding: 12px; }
  .tile .value { font-size: 19px; }
  .tile.hero .value { font-size: 30px; }
}
