/* ==========================================================================
   tabdeal-trader — design system (پرتابل از پروتوتایپ screens/)
   توکن‌ها + پوسته (od-*) + کامپوننت‌ها. هیچ رنگ hex خارج از این فایل.
   ========================================================================== */

:root {
  /* palette */
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --ink: #17203a;
  --muted: #66708a;
  --border: #e5e9f2;
  --border-strong: #d6dbe8;

  --accent: #4c6ef5;
  --accent-strong: #4059e0;
  --accent-weak: rgba(76, 110, 245, .10);

  --success: #0ecb81;
  --success-weak: rgba(14, 203, 129, .12);
  --danger: #f6465d;
  --danger-weak: rgba(246, 70, 93, .10);
  --warning: #eaaa11;
  --warning-weak: rgba(234, 170, 17, .14);
  --info: #3b82f6;
  --info-weak: rgba(59, 130, 246, .12);

  /* hero gradient (kpi-hero / card-hero) */
  --hero-grad: linear-gradient(135deg, #4c6ef5 0%, #7048e8 100%);

  /* geometry */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;

  /* spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 44px;

  /* type scale */
  --text-xs: 11.5px;
  --text-sm: 12.75px;
  --text-md: 13.5px;
  --text-lg: 15px;
  --text-xl: 20px;
  --text-2xl: 25px;
  --text-3xl: 31px;

  --shadow-1: 0 1px 2px rgba(23, 32, 58, .05), 0 4px 16px rgba(23, 32, 58, .05);
  --shadow-2: 0 12px 34px rgba(23, 32, 58, .16);

  --font: "Vazirmatn", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w: 250px;
  --motion: .18s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- reset / base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: 1.65;
}
h1, h2, h3, h4, h5, h6, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::placeholder { color: #9aa3ba; }

svg.i {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- utilities ---------- */
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  direction: ltr; unicode-bidi: isolate;
  font-size: .92em;
  letter-spacing: -.01em;
}
td.num, th.num { direction: ltr; text-align: left; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mut { color: var(--muted); }
.muted { color: var(--muted); font-size: .9rem; }
.strong { font-weight: 700; }
.pos { color: var(--success); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
.val-up, .text-success { color: var(--success); font-weight: 600; }
.val-down, .text-danger { color: var(--danger); font-weight: 600; }
.warn { color: var(--warning); font-weight: 600; }
.text-muted { color: var(--muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.fs-xs { font-size: var(--text-xs); }
.mono { font-family: var(--mono); font-size: .92em; }
.sp { color: var(--muted); font-size: var(--text-sm); }
.hint { color: var(--muted); font-size: var(--text-xs); margin: var(--space-1) 0 0; line-height: 1.7; }
.d-none { display: none !important; }

/* ---------- skip link ---------- */
.od-skip {
  position: fixed; top: -48px; inset-inline-start: var(--space-4); z-index: 3000;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px;
  transition: top var(--motion); font-size: var(--text-sm);
}
.od-skip:focus { top: 12px; color: #fff; }

/* ---------- app shell ---------- */
.od-app { display: flex; min-height: 100vh; }

.od-sidebar {
  width: var(--sidebar-w); flex: none;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: var(--space-5) var(--space-3) var(--space-4);
  scrollbar-width: thin;
  z-index: 120;
}
.od-brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2) var(--space-4); }
.od-brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  background: var(--hero-grad); color: #fff;
  display: grid; place-items: center;
}
.od-brand-mark .i { width: 20px; height: 20px; }
.od-brand-name { font-weight: 800; font-size: var(--text-lg); display: block; line-height: 1.3; }
.od-brand-sub { color: var(--muted); font-size: var(--text-xs); display: block; }
.od-nav-close { display: none; margin-inline-start: auto; }

.od-nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
.od-nav-sec {
  color: var(--muted); font-size: var(--text-xs); font-weight: 700;
  letter-spacing: .04em; padding: var(--space-4) var(--space-3) var(--space-1);
}
.od-nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink); font-size: var(--text-md); font-weight: 500;
  transition: background var(--motion), color var(--motion);
}
.od-nav-item .i { width: 17px; height: 17px; color: var(--muted); transition: color var(--motion); }
.od-nav-item:hover { background: var(--surface-2); color: var(--ink); }
.od-nav-item:hover .i { color: var(--ink); }
.od-nav-item.on {
  background: var(--accent-weak); color: var(--accent-strong); font-weight: 700;
}
.od-nav-item.on .i { color: var(--accent); }
.od-nav-item[data-soon] { color: #a3abc2; cursor: default; }
.od-nav-item[data-soon] .i { color: #c2c9db; }
.od-nav-item[data-soon]:hover { background: transparent; color: #a3abc2; }

.od-side-foot { display: grid; gap: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.od-engine-chip {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px var(--space-3);
  font-size: var(--text-xs); color: var(--muted);
}
.od-engine-chip .dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-weak); }
.od-engine-chip .t { font-weight: 700; color: var(--ink); }
.od-engine-chip .eq { margin-inline-start: auto; display: grid; line-height: 1.4; text-align: end; }
.od-engine-chip .eq .v { font-size: 10px; }
.od-engine-chip .eq .num { font-size: var(--text-xs); font-weight: 600; color: var(--ink); }
.od-logout {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 8px var(--space-3); border-radius: var(--radius-sm);
  color: var(--muted); font-size: var(--text-sm); font-weight: 600;
}
.od-logout:hover { background: var(--danger-weak); color: var(--danger); }
.od-version { text-align: center; color: #a3abc2; font-size: 10.5px; padding-top: var(--space-1); }

.od-scrim {
  display: none; position: fixed; inset: 0; z-index: 110;
  background: rgba(23, 32, 58, .45); border: 0; padding: 0; cursor: pointer;
}

.od-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.od-topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  background: rgba(243, 245, 249, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.od-burger { display: none; }
.od-topbar-titles { min-width: 0; }
.od-topbar-titles h1 { font-size: var(--text-lg); font-weight: 800; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.od-topbar-titles p { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.od-topbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-2); }
.od-clockbox {
  display: grid; justify-items: center; line-height: 1.35;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px var(--space-3);
}
.od-clockbox .t { font-family: var(--mono); font-size: var(--text-sm); font-weight: 600; direction: ltr; }
.od-clockbox .d { font-size: 10.5px; color: var(--muted); }

.od-content {
  flex: 1 1 auto; width: 100%;
  max-width: 1200px; margin: 0 auto;
  padding: var(--space-5) var(--space-6) var(--space-7);
  display: flex; flex-direction: column; gap: var(--space-5);
}

.od-footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  flex-wrap: wrap;
  max-width: 1200px; width: 100%; margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  color: var(--muted); font-size: var(--text-xs);
  border-top: 1px solid var(--border);
}

@media (max-width: 1024px) {
  .od-sidebar {
    position: fixed; top: 0; bottom: 0;
    inset-inline-start: 0; /* RTL: لبهٔ راست (جای فعلی سایدبار) · LTR: چپ */
    transform: translateX(-110%);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-2);
  }
  [dir="rtl"] .od-sidebar { transform: translateX(110%); }
  .od-app.nav-open .od-sidebar { transform: none; }
  .od-app.nav-open .od-scrim { display: block; }
  .od-nav-close { display: grid; }
  .od-burger { display: grid; }
  .od-topbar { padding: var(--space-3) var(--space-4); }
  .od-content { padding: var(--space-4) var(--space-4) var(--space-6); }
  .od-footer { padding: var(--space-4); }
}

/* ---------- sections ---------- */
.sec { display: flex; flex-direction: column; gap: var(--space-3); }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.sec-title { font-size: var(--text-lg); font-weight: 800; }
.sec-hint { color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }
.sec-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- grid ---------- */
.grid { display: grid; gap: var(--space-4); }
.grid.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1200px) {
  .grid.g-4, .grid.g-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid.g-3, .grid.g-4, .grid.g-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .grid.g-2, .grid.g-3, .grid.g-4, .grid.g-5 { grid-template-columns: 1fr; }
}

/* ---------- KPI ---------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.kpi-label { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.kpi-value {
  font-size: var(--text-2xl); font-weight: 800; line-height: 1.35;
  direction: ltr; unicode-bidi: isolate; text-align: end;
  font-family: var(--mono);
  transition: color var(--motion);
}
[dir="rtl"] .kpi-value { text-align: start; }
.kpi-value.fa, .kpi-value.fa * { font-family: var(--font); }
.kpi-foot { color: var(--muted); font-size: var(--text-xs); margin-top: var(--space-1); }
.kpi-foot .delta { font-family: var(--mono); font-weight: 700; margin-inline-end: var(--space-2); }
.kpi-foot .delta.up { color: var(--success); }
.kpi-foot .delta.down { color: var(--danger); }
.kpi .unit { font-size: var(--text-sm); font-weight: 600; color: var(--muted); margin-inline-start: var(--space-2); }
.kpi-hero.card-hero {
  background: var(--hero-grad); border-color: transparent; color: #fff;
}
.kpi-hero.card-hero .kpi-label { color: rgba(255, 255, 255, .78); }
.kpi-hero.card-hero .kpi-foot { color: rgba(255, 255, 255, .82); }
.kpi-hero.card-hero .kpi-foot .delta.up { color: #7cf5c8; }
.kpi-hero.card-hero .kpi-foot .delta.down { color: #ffb3c0; }
.kpi-hero.card-hero .unit { color: rgba(255, 255, 255, .8); }

/* ---------- strip (نوار ۴بخشی) ---------- */
.strip {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-5);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  padding: var(--space-4) var(--space-5);
}
.strip .lab { color: var(--muted); font-size: var(--text-xs); }
.strip .val { font-size: var(--text-md); font-weight: 700; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-top: 2px; }
@media (max-width: 900px) { .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .strip { grid-template-columns: 1fr; } }

.mk { display: inline-flex; align-items: center; gap: 7px; }
.mk-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.mk-on { background: var(--success); box-shadow: 0 0 0 3px var(--success-weak); }
.mk-off { background: #c6cdde; box-shadow: 0 0 0 3px rgba(23, 32, 58, .06); }

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column;
  min-width: 0;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5) 0;
}
.card-titles { min-width: 0; }
.card-title { font-weight: 700; font-size: var(--text-md); }
.card-sub { color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }
.card-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.card-body { padding: var(--space-4) var(--space-5) var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.card-body.flush { padding: 0; gap: 0; }
.card-body.flush .tbl-scroll { border-radius: var(--radius); }
.card-body.flush .tbl-note { margin: var(--space-3) var(--space-5); }
.card.card-danger { border-color: rgba(246, 70, 93, .35); }
.card.card-danger .card-title { color: var(--danger); }

/* ---------- table ---------- */
.tbl-scroll { overflow-x: auto; }
.tbl-scroll.y { max-height: 460px; overflow-y: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl thead th {
  text-align: start;
  color: var(--muted); font-size: var(--text-xs); font-weight: 700;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.tbl tbody td {
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl-note { color: var(--muted); font-size: var(--text-xs); }

/* ---------- badge / chip / tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 10px;
  font-size: var(--text-xs); font-weight: 700; line-height: 1.6;
  white-space: nowrap;
}
.badge-ok { background: var(--success-weak); color: #079761; }
.badge-warn { background: var(--warning-weak); color: #9c6f06; }
.badge-err { background: var(--danger-weak); color: #d43a4f; }
.badge-mut { background: rgba(23, 32, 58, .07); color: var(--muted); }
.badge-info { background: var(--info-weak); color: #2563eb; }
.badge-plain { background: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 999px; padding: 3px 11px;
  font-size: var(--text-xs); font-weight: 600; line-height: 1.7;
}
.chip-sample { background: var(--info-weak); border-color: transparent; color: #2563eb; }
.chip-paper { background: var(--success-weak); border-color: transparent; color: #079761; }
.chip-paper .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.chip-src-s { border-color: var(--accent); color: var(--accent-strong); }
.chip-src-g { border-color: var(--success); color: #079761; }
.chip-src-l { border-color: var(--danger); color: #d43a4f; }

.side-tag {
  display: inline-block; border-radius: 7px; padding: 2px 9px;
  font-size: var(--text-xs); font-weight: 800; font-family: var(--mono);
}
.side-long { background: var(--success-weak); color: #079761; }
.side-short { background: var(--danger-weak); color: #d43a4f; }

.vtag {
  display: inline-block; border-radius: 7px; padding: 2px 9px;
  font-size: var(--text-xs); font-weight: 800;
  background: rgba(23, 32, 58, .07); color: var(--muted);
}
.vtag.active { background: var(--accent-weak); color: var(--accent-strong); }
.vtag.retired { background: rgba(23, 32, 58, .06); color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 8px var(--space-4);
  font-size: var(--text-md); font-weight: 700; line-height: 1.6;
  cursor: pointer; text-decoration: none;
  transition: background var(--motion), color var(--motion), border-color var(--motion), box-shadow var(--motion);
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn .i { width: 16px; height: 16px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e13a50; color: #fff; }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-sm { padding: 5px 12px; font-size: var(--text-sm); border-radius: 9px; }
.btn-lg { padding: 11px var(--space-6); font-size: var(--text-lg); border-radius: 12px; }
.btn-block { width: 100%; }
.btn-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.btn-icon {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background var(--motion), color var(--motion);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon.sm { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.btn-icon.sm:hover { background: var(--surface-2); }
.row-actions { display: inline-flex; align-items: center; gap: 6px; }

.backlink {
  display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer;
  font-size: var(--text-sm); font-weight: 600; font-family: inherit;
}
.backlink:hover { color: var(--accent); }

/* ---------- segmented / ticker / tabs ---------- */
.seg {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 2px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 8px; padding: 5px 14px;
  font-size: var(--text-sm); font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background var(--motion), color var(--motion);
}
.seg button.on { background: var(--accent); color: #fff; }

.ticker {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); border-radius: 999px; padding: 4px 12px;
  font-size: var(--text-xs); font-weight: 600;
}

.tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; width: fit-content; max-width: 100%;
}
.tab-btn {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 9px; padding: 7px var(--space-4);
  font-size: var(--text-sm); font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background var(--motion), color var(--motion);
}
.tab-btn.on { background: var(--accent-weak); color: var(--accent-strong); }
.tab-panel { display: flex; flex-direction: column; gap: var(--space-5); }
.tab-panel[hidden] { display: none; }

/* ---------- forms ---------- */
.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
}
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: var(--text-sm); font-weight: 600; color: var(--ink); }
.input {
  width: 100%;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px var(--space-3);
  font-size: var(--text-md);
  transition: border-color var(--motion), box-shadow var(--motion);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea.input { resize: vertical; min-height: 84px; direction: rtl; text-align: start; }
select.input { cursor: pointer; }
.err-msg { display: none; color: var(--danger); font-size: var(--text-xs); }
.field.invalid .err-msg { display: block; }
.field.invalid .input { border-color: var(--danger); }
.form-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-5); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: #cdd4e4; transition: background var(--motion); pointer-events: none;
}
.switch .track::before {
  content: ""; position: absolute; width: 18px; height: 18px;
  inset-inline-start: 3px; top: 3px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(23, 32, 58, .3);
  transition: transform var(--motion);
}
.switch input:checked + .track { background: var(--success); }
[dir="rtl"] .switch input:checked + .track::before { transform: translateX(-16px); }
[dir="ltr"] .switch input:checked + .track::before { transform: translateX(16px); }

.switch-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) 0; flex-wrap: wrap;
}
.switch-row .st { font-weight: 700; font-size: var(--text-md); }
.switch-row .sd { color: var(--muted); font-size: var(--text-xs); }

.pick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
@media (max-width: 860px) { .pick-grid { grid-template-columns: 1fr; } }
.pick {
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4);
  cursor: pointer; transition: border-color var(--motion), background var(--motion);
}
.pick:hover { border-color: var(--accent); }
.pick.on { border-color: var(--accent); background: var(--accent-weak); }
.pick input { margin-top: 4px; accent-color: var(--accent); }
.pick .pt { font-weight: 700; font-size: var(--text-md); display: block; direction: ltr; text-align: start; }
.pick .pd { color: var(--muted); font-size: var(--text-xs); }

/* ---------- accordion ---------- */
.acc { display: flex; flex-direction: column; gap: var(--space-3); }
.acc-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.acc-head {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; text-align: start;
  background: none; border: 0; cursor: pointer;
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-md); font-weight: 700; color: var(--ink); font-family: inherit;
}
.acc-head:hover { background: var(--surface-2); }
.acc-meta { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.acc-head .chev { margin-inline-start: auto; color: var(--muted); transition: transform var(--motion); }
.acc-item.open .acc-head .chev { transform: rotate(180deg); }
.acc-body { display: none; padding: 0 var(--space-5) var(--space-5); border-top: 1px solid var(--border); padding-top: var(--space-4); }
.acc-item.open .acc-body { display: block; }

/* ---------- alert ---------- */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); line-height: 1.8;
}
.alert .i { width: 17px; height: 17px; margin-top: 4px; flex: none; }
.alert-warn { background: var(--warning-weak); color: #8a6205; }
.alert-err { background: var(--danger-weak); color: #c23245; }
.alert-ok { background: var(--success-weak); color: #07754d; }
.alert-info { background: var(--info-weak); color: #1d4ed8; }

/* ---------- progress ---------- */
.prog {
  height: 8px; border-radius: 999px; background: rgba(23, 32, 58, .08);
  overflow: hidden;
}
.prog > span {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  background: var(--hero-grad);
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}
.prog > span.done { background: var(--success); }
.warm-row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2); align-items: center; font-size: var(--text-sm); }

/* ---------- timeline (ارزیابی‌ها) ---------- */
.tl { display: flex; flex-direction: column; gap: var(--space-3); }
.tl-item {
  border-inline-start: 3px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-3) var(--space-4);
}
.tl-item.ok { border-inline-start-color: var(--success); }
.tl-item.acc { border-inline-start-color: var(--info); }
.tl-item.warn { border-inline-start-color: var(--warning); }
.tl-item.err { border-inline-start-color: var(--danger); }
.tl-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.tl-title { font-weight: 700; font-size: var(--text-md); }
.tl-date { margin-inline-start: auto; color: var(--muted); font-size: var(--text-xs); font-family: var(--mono); }
.tl-body { color: var(--muted); font-size: var(--text-sm); margin-top: 4px; line-height: 1.8; }

/* ---------- lessons ---------- */
.lesson-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 1000px) { .lesson-grid { grid-template-columns: 1fr; } }
.lesson {
  display: flex; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  padding: var(--space-4);
}
.lesson .ic {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  background: var(--accent-weak); color: var(--accent-strong);
  display: grid; place-items: center;
}
.lesson .ic .i { width: 17px; height: 17px; }
.lesson b { font-size: var(--text-md); display: block; margin-bottom: 3px; }
.lesson p { color: var(--muted); font-size: var(--text-xs); line-height: 1.9; }

/* ---------- chart ---------- */
.chart-wrap { width: 100%; height: 320px; }
.chart-legend { display: flex; gap: var(--space-4); color: var(--muted); font-size: var(--text-xs); flex-wrap: wrap; }
.chart-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; }
.chart-fallback { display: flex; flex-direction: column; gap: 6px; padding: var(--space-3) 0; }
.chart-fallback .bar-row { display: grid; grid-template-columns: 84px 1fr 90px; align-items: center; gap: var(--space-2); font-size: var(--text-xs); }
.chart-fallback .bar-track { height: 14px; border-radius: 6px; background: rgba(23, 32, 58, .05); overflow: hidden; direction: ltr; }
.chart-fallback .bar-fill { height: 100%; border-radius: 6px; }
.chart-fallback .bar-fill.up { background: var(--success); }
.chart-fallback .bar-fill.down { background: var(--danger); }
.chart-fallback .bar-fill.cum { background: var(--accent); height: 4px; border-radius: 2px; }
.chart-fallback .bar-val { font-family: var(--mono); text-align: end; }

/* ---------- pager ---------- */
.pager { display: flex; gap: var(--space-2); justify-content: center; align-items: center; flex-wrap: wrap; margin-top: var(--space-4); }
.pg-info, .page-info { color: var(--muted); font-size: var(--text-sm); }

/* ---------- modal ---------- */
.od-modal { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: var(--space-5); }
.od-modal.open { display: flex; }
.od-modal-scrim { position: absolute; inset: 0; background: rgba(23, 32, 58, .5); border: 0; padding: 0; cursor: default; }
.od-modal-box {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  width: 100%; max-width: 460px;
  padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-3);
  max-height: calc(100vh - 3rem); overflow-y: auto;
  animation: od-pop .16s cubic-bezier(.4, 0, .2, 1);
}
.od-modal-box.wide { max-width: 680px; }
@keyframes od-pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.od-modal-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--danger-weak); color: var(--danger);
}
.od-modal-icon.info { background: var(--info-weak); color: var(--info); }
.od-modal-icon.ok { background: var(--success-weak); color: var(--success); }
.od-modal-title { font-size: var(--text-lg); font-weight: 800; }
.od-modal-text { color: var(--muted); font-size: var(--text-sm); line-height: 1.9; }
.od-modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* ---------- toast ---------- */
.od-toast {
  position: fixed; top: var(--space-4); left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 2500;
  background: var(--ink); color: #fff;
  border-radius: 12px; padding: 10px var(--space-5);
  font-size: var(--text-sm); font-weight: 600;
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transition: opacity var(--motion), transform var(--motion);
  max-width: min(92vw, 480px);
}
.od-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.od-toast.ok { background: #0a9e67; }
.od-toast.err { background: #d43a4f; }
.od-toast.info { background: var(--accent-strong); }

/* ---------- fade swap (پولر دکتر) ---------- */
.fade-swap { animation: od-fade .25s ease; }
@keyframes od-fade { from { opacity: .35; } }

/* ---------- auth (login / setup) ---------- */
.auth-stage {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(700px 380px at 85% -8%, rgba(76, 110, 245, .16), transparent 60%),
    radial-gradient(640px 360px at 8% 108%, rgba(112, 72, 232, .14), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  padding: var(--space-7) var(--space-6);
}
.auth-brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.auth-title { font-size: var(--text-xl); font-weight: 800; margin-top: var(--space-2); }
.auth-sub { color: var(--muted); font-size: var(--text-sm); margin-top: var(--space-1); line-height: 1.9; }
.auth-note { color: var(--muted); font-size: var(--text-xs); margin-top: var(--space-5); line-height: 1.9; border-top: 1px solid var(--border); padding-top: var(--space-4); }

/* ==========================================================================
   لایهٔ سازگاری با مارک‌آپ قدیمی (JS رندرشده / صفحات پرت‌نشده) — موقت
   ========================================================================== */
.flash { padding: 10px var(--space-4); border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: 600; }
.flash.ok { background: var(--success-weak); color: #07754d; }
.flash.err { background: var(--danger-weak); color: #c23245; }

.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
@media (max-width: 768px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); box-shadow: var(--shadow-1); min-width: 0; }
.stat .k { font-size: var(--text-xs); color: var(--muted); font-weight: 600; }
.stat .v { font-weight: 700; font-size: var(--text-lg); margin-top: 2px; word-break: break-word; }

.badge--safe { background: var(--success-weak); color: #079761; }
.badge--warn { background: var(--warning-weak); color: #9c6f06; }
.badge--danger { background: var(--danger-weak); color: #d43a4f; }
.badge--info { background: var(--info-weak); color: #2563eb; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #e13a50; color: #fff; }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--gemini { background: #1a73e8; color: #fff; }
.btn--sm, .btn--mini { padding: 4px 10px; font-size: var(--text-xs); border-radius: 8px; }
.btn--mini { background: var(--surface); border: 1px solid var(--border-strong); color: var(--ink); cursor: pointer; }
.btn--mini:hover { background: var(--surface-2); }
.btn--block { width: 100%; }
.btn--danger.btn--mini { background: var(--danger); border-color: var(--danger); color: #fff; }

.setting-row {
  display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap;
  padding: var(--space-3) 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row > label:not(.switch):not(.check) { width: 260px; min-width: 200px; font-size: var(--text-sm); font-weight: 600; }
.setting-row .grow { flex: 1 1 160px; }
.check-row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; padding: var(--space-3) 0; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); font-weight: 600; }
.check input[type=checkbox], input[type=checkbox].model-cb, .form-check-input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; cursor: pointer; }

.toggle { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; vertical-align: middle; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; inset: 0; background: #cdd4e4; border-radius: 9999px; transition: .2s; cursor: pointer; }
.toggle .slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(23, 32, 58, .3); }
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider:before { transform: translateX(18px); }

.form-control, .form-select {
  width: 100%;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px var(--space-3);
  font-size: var(--text-md);
}
.form-control:focus, .form-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.form-control-sm, .form-select-sm { padding: 6px 10px; font-size: var(--text-sm); width: auto; }
input[type=number].form-control, input[type=number].input { direction: ltr; text-align: left; }

.searchbar {
  width: 100%; padding: 10px var(--space-4); font-size: var(--text-md);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.searchbar:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

.alert--ok { background: var(--success-weak); color: #07754d; }
.alert--err { background: var(--danger-weak); color: #c23245; }
.alert--warn { background: var(--warning-weak); color: #8a6205; }

code { background: var(--surface-2); padding: 2px 7px; border-radius: 6px; color: var(--accent-strong); font-size: .9em; font-family: var(--mono); }
.code-block {
  font-family: var(--mono); direction: ltr; text-align: left;
  background: var(--surface-2); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm); font-size: var(--text-sm);
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  border: 1px solid var(--border); color: var(--ink); margin: 0;
}
.code-block--nowrap { white-space: pre; word-break: normal; }

.pager .btn, .pager a.btn { text-decoration: none; }

.progress-bar { height: 8px; background: rgba(23, 32, 58, .08); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--hero-grad); transition: width 2s; }
.progress-fill.done { background: var(--success); }
.candle-progress-title { font-weight: 700; margin-bottom: var(--space-2); }

.card--highlight { border-color: var(--accent) !important; }
.card--nested { background: var(--surface-2); }
.card--narrow { max-width: 420px; margin: var(--space-7) auto; }

.accordion { margin-bottom: var(--space-2); }
.accordion-header {
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  padding: var(--space-3) var(--space-4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-weight: 700; color: var(--ink);
}
.accordion-header:hover { background: var(--surface-2); }
.acc-chevron { transition: transform .2s; color: var(--muted); display: inline-block; }
.accordion-open > .accordion-header { border-start-start-radius: var(--radius-sm); border-start-end-radius: var(--radius-sm); border-end-end-radius: 0; border-end-start-radius: 0; }
.accordion-open > .accordion-header .acc-chevron { transform: rotate(90deg); }
.accordion-content {
  display: none; padding: var(--space-4);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface);
}
.accordion-open > .accordion-content { display: block; }
summary.accordion-header { list-style: none; }
summary.accordion-header::-webkit-details-marker { display: none; }

.modal-overlay { position: fixed; inset: 0; background: rgba(23, 32, 58, .5); display: none; align-items: center; justify-content: center; z-index: 2000; padding: var(--space-5); }
.modal-overlay.open { display: flex; }
.modal-content { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-6); max-width: 640px; width: 100%; box-shadow: var(--shadow-2); max-height: calc(100vh - 3rem); overflow-y: auto; }
.modal-content h3 { margin-top: 0; font-size: var(--text-lg); font-weight: 800; }
.modal-actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-4); }

.toast { position: fixed; top: var(--space-4); left: 50%; transform: translateX(-50%); padding: 10px var(--space-5); border-radius: 12px; font-size: var(--text-sm); font-weight: 700; z-index: 2500; opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; max-width: 90%; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
.toast-success { background: #0a9e67; color: #fff; }
.toast-error { background: #d43a4f; color: #fff; }

.ovr { font-size: var(--text-xs); color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: 100%; inset-inline-start: 0; z-index: 50;
  min-width: 160px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2); padding: 6px; margin: 4px 0 0;
}
.dropdown-item { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 7px 10px; border-radius: 7px; color: var(--danger); font-size: var(--text-sm); cursor: pointer; font-family: inherit; }
.dropdown-item:hover { background: var(--danger-weak); }
