/* ═══════════════════════════════════════════════════════════════════
   سیب‌دسک — سیستم طراحی
   هویت: بایگانیِ زندهٔ پرونده‌ها. کاج عمیق (اعتماد/بیمه) + برنجی (بایگانی)
   + سبز سیبی (کنش). امضای بصری: «عطف پرونده» — نوار عمودی شمارهٔ تیکت،
   مثل پرونده‌های کنار هم روی قفسه.
   حالت روشن و تاریک، هر دو دست‌ساز. بدون فریم‌ورک.
   ═══════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn.woff2") format("woff2-variations");
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: "Estedad";
  src: url("../fonts/Estedad.woff2") format("woff2-variations");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C;
}
@font-face {
  font-family: "Estedad";
  src: url("../fonts/Estedad-latin.woff2") format("woff2-variations");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+2000-206F, U+2212;
}

/* ─── نشانه‌ها ─────────────────────────────────────────────────── */
:root {
  --bg:        #eef2ef;
  --surface:   #ffffff;
  --surface-2: #f6f9f6;
  --surface-3: #eaf0ec;
  --ink:       #0f1a17;
  --ink-2:     #4a5d57;
  --ink-3:     #7d8f89;
  --line:      #dae4de;
  --line-2:    #e9efeb;

  --pine:      #0f5346;
  --pine-2:    #0a3b32;
  --pine-3:    #16705e;
  --pine-soft: #dfeee9;
  --zest:      #5f9a26;
  --zest-soft: #e9f3de;
  --brass:     #a8792b;
  --brass-soft:#f6ecd8;

  --ok:      #157347;  --ok-soft:   #e1f1e7;
  --warn:    #9a6206;  --warn-soft: #fbefd9;
  --risk:    #a81e16;  --risk-soft: #fae7e5;
  --calm:    #55636f;  --calm-soft: #e9edf0;

  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgb(15 26 23 / .06), 0 2px 8px rgb(15 26 23 / .04);
  --sh-2: 0 2px 6px rgb(15 26 23 / .07), 0 12px 32px rgb(15 26 23 / .09);
  --sh-3: 0 8px 24px rgb(15 26 23 / .12), 0 32px 64px rgb(15 26 23 / .16);

  --sidebar-w: 244px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:        #0b1311;
  --surface:   #121d1a;
  --surface-2: #17241f;
  --surface-3: #1e2d28;
  --ink:       #e7f0eb;
  --ink-2:     #a7bab2;
  --ink-3:     #7b8e87;
  --line:      #243430;
  --line-2:    #1c2a26;

  --pine:      #3fa189;
  --pine-2:    #6cc4ae;
  --pine-3:    #2f7f6c;
  --pine-soft: #16302a;
  --zest:      #8dc44e;
  --zest-soft: #1d2c17;
  --brass:     #d4a457;
  --brass-soft:#2c2416;

  --ok:      #4cb47a;  --ok-soft:   #122a1e;
  --warn:    #d69b32;  --warn-soft: #2c2314;
  --risk:    #e8776c;  --risk-soft: #2f1a18;
  --calm:    #93a5b2;  --calm-soft: #1b242a;

  --sh-1: 0 1px 2px rgb(0 0 0 / .4);
  --sh-2: 0 4px 16px rgb(0 0 0 / .45);
  --sh-3: 0 12px 40px rgb(0 0 0 / .55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0b1311; --surface:#121d1a; --surface-2:#17241f; --surface-3:#1e2d28;
    --ink:#e7f0eb; --ink-2:#a7bab2; --ink-3:#7b8e87; --line:#243430; --line-2:#1c2a26;
    --pine:#3fa189; --pine-2:#6cc4ae; --pine-3:#2f7f6c; --pine-soft:#16302a;
    --zest:#8dc44e; --zest-soft:#1d2c17; --brass:#d4a457; --brass-soft:#2c2416;
    --ok:#4cb47a; --ok-soft:#122a1e; --warn:#d69b32; --warn-soft:#2c2314;
    --risk:#e8776c; --risk-soft:#2f1a18; --calm:#93a5b2; --calm-soft:#1b242a;
    --sh-1: 0 1px 2px rgb(0 0 0 / .4);
    --sh-2: 0 4px 16px rgb(0 0 0 / .45);
    --sh-3: 0 12px 40px rgb(0 0 0 / .55);
    color-scheme: dark;
  }
}

/* ─── پایه ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px; line-height: 1.85;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .display {
  font-family: "Estedad", "Vazirmatn", sans-serif;
  letter-spacing: -.025em; line-height: 1.4; margin: 0;
}
a { color: var(--pine); text-decoration: none; }
a:hover { color: var(--pine-3); }
:focus-visible {
  outline: 2px solid var(--zest); outline-offset: 2px; border-radius: var(--r-sm);
}
::selection { background: var(--zest-soft); color: var(--ink); }
code, .ltr, .mono {
  direction: ltr; unicode-bidi: embed;
  font-family: "JetBrains Mono", Consolas, monospace; font-size: .85em;
}
code { background: var(--surface-3); border-radius: 5px; padding: .1em .4em; }
.num { font-family: "Estedad", sans-serif; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
/* تا وقتی Alpine بالا نیامده، محتوای شرطی دیده نشود */
[x-cloak] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
}

/* ─── پوستهٔ اپ ─────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100dvh; }

.side {
  width: var(--sidebar-w); flex: none;
  background: var(--surface); border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh; z-index: 40;
}
.side .brandbox {
  padding: 1.1rem 1.1rem .9rem;
  display: flex; align-items: center; gap: .6rem;
}
.brandmark { flex: none; filter: drop-shadow(0 1px 2px rgb(15 26 23 / .18)); }
.brandbox .name {
  font-family: "Estedad", sans-serif; font-weight: 800; font-size: 1.2rem;
  letter-spacing: -.03em; color: var(--ink); line-height: 1.2;
}
.brandbox .sub { font-size: .68rem; color: var(--ink-3); line-height: 1.4; }

.side nav { padding: .4rem .7rem; display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.side .grouplabel {
  font-size: .66rem; font-weight: 700; color: var(--ink-3);
  letter-spacing: .08em; padding: 1rem .6rem .3rem;
}
.side nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .65rem; border-radius: 10px;
  color: var(--ink-2); font-size: .89rem; font-weight: 500;
  position: relative; transition: background .14s var(--ease), color .14s var(--ease);
}
.side nav a svg { flex: none; opacity: .75; }
.side nav a:hover { background: var(--surface-3); color: var(--ink); }
.side nav a.on { background: var(--pine-soft); color: var(--pine); font-weight: 700; }
.side nav a.on svg { opacity: 1; }
.side nav a.on::before {
  content: ""; position: absolute; inset-inline-end: -0.7rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 3px 0 0 3px; background: var(--brass);
}
.side nav a .badge {
  margin-inline-start: auto; background: var(--surface-3); color: var(--ink-2);
  font-size: .7rem; font-weight: 700; padding: 0 .45rem; border-radius: var(--r-pill);
}
.side nav a.on .badge { background: var(--pine); color: #fff; }

.side .foot { padding: .7rem; border-top: 1px solid var(--line-2); }
.whoami { display: flex; align-items: center; gap: .55rem; padding: .3rem .35rem; }
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 10px;
  background: linear-gradient(140deg, var(--pine), var(--pine-3));
  color: #fff; display: grid; place-items: center;
  font-family: "Estedad", sans-serif; font-weight: 700; font-size: .82rem;
}
.whoami .meta { min-width: 0; line-height: 1.45; }
.whoami .meta b { display: block; font-size: .82rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whoami .meta span { display: block; font-size: .7rem; color: var(--ink-3); }
.side .foot form { margin: 0; }
.iconbtn {
  background: none; border: 1px solid transparent; border-radius: 9px;
  color: var(--ink-3); cursor: pointer; padding: .32rem;
  display: grid; place-items: center; font: inherit;
  transition: background .14s, color .14s, border-color .14s;
}
.iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.iconbtn.danger:hover { background: var(--risk-soft); color: var(--risk); }

/* ─── ناحیهٔ محتوا ─────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .8rem;
  padding: .75rem 1.6rem; min-height: 62px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-2);
}
.topbar h1 { font-size: 1.18rem; font-weight: 800; }
.topbar .crumb { font-size: .74rem; color: var(--ink-3); line-height: 1.3; }
.topbar .grow { flex: 1; }
.menubtn { display: none; }

.searchtrigger {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: .32rem .9rem;
  color: var(--ink-3); font: inherit; font-size: .82rem; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.searchtrigger:hover { border-color: var(--pine); box-shadow: var(--sh-1); }
.searchtrigger kbd {
  font-family: inherit; font-size: .68rem; background: var(--surface-3);
  border-radius: 5px; padding: 0 .35rem; color: var(--ink-3);
}

.page { padding: 1.5rem 1.6rem 4rem; max-width: 100%; width: 100%; }
.page.wide { max-width: 100%; }

/* ─── دکمه ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  background: var(--pine); color: #fff; border: 1px solid var(--pine);
  padding: .48rem 1.15rem; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: .89rem; font-weight: 600; white-space: nowrap;
  transition: transform .12s var(--ease), box-shadow .16s, background .16s, border-color .16s;
}
.btn:hover { background: var(--pine-3); border-color: var(--pine-3); color: #fff; box-shadow: var(--sh-2); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--pine); color: var(--pine); }
.btn.zest { background: var(--zest); border-color: var(--zest); }
.btn.zest:hover { filter: brightness(1.08); background: var(--zest); border-color: var(--zest); }
.btn.sm { padding: .26rem .75rem; font-size: .8rem; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ─── کارت ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1.15rem 1.35rem; box-shadow: var(--sh-1);
}
.card > h3:first-child, .card > h2:first-child { margin-top: 0; }
.card h3 { font-size: .95rem; font-weight: 700; margin: 1.3rem 0 .5rem; }
.card h3:first-child { margin-top: 0; }
.cardhead {
  display: flex; align-items: center; gap: .7rem;
  padding-bottom: .7rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line-2);
}
.cardhead h3 { margin: 0; flex: 1; }

/* ─── امضا: عطف پرونده ─────────────────────────────────────────── */
.spine {
  flex: none; width: 34px; align-self: stretch;
  background: var(--sp, var(--calm));
  border-radius: var(--r) 0 0 var(--r);
  display: grid; place-items: center; position: relative;
}
.spine span {
  writing-mode: vertical-rl; text-orientation: mixed;
  font-family: "Estedad", sans-serif; font-weight: 800; font-size: .78rem;
  color: #fff; letter-spacing: .04em; opacity: .96;
  transform: rotate(180deg);
}
.spine::after {
  content: ""; position: absolute; inset-inline-end: 0; top: 8px; bottom: 8px;
  width: 1px; background: rgb(255 255 255 / .28);
}

.filecard {
  display: flex; align-items: stretch; gap: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: .6rem; overflow: hidden;
  box-shadow: var(--sh-1); color: inherit;
  transition: transform .16s var(--ease), box-shadow .18s var(--ease), border-color .16s;
}
a.filecard:hover {
  transform: translateY(-2px); box-shadow: var(--sh-2);
  border-color: color-mix(in srgb, var(--sp) 40%, var(--line)); color: inherit;
}
.filecard .body { padding: .8rem 1.05rem; flex: 1; min-width: 0; }
.filecard h3 {
  font-size: .98rem; font-weight: 700; margin: 0 0 .25rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filecard .meta {
  display: flex; flex-wrap: wrap; gap: .2rem .95rem;
  color: var(--ink-3); font-size: .78rem; line-height: 1.7;
}
.filecard .meta b { color: var(--ink-2); font-weight: 600; }
.filecard .side-end {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
  gap: .3rem; padding: .8rem 1rem .8rem 0;
}

/* رنگ عطف بر اساس وضعیت */
.st-new      { --sp: var(--calm); }
.st-wait     { --sp: var(--warn); }
.st-queue    { --sp: var(--pine); }
.st-work     { --sp: var(--pine-2); }
.st-done     { --sp: var(--ok); }
.st-closed   { --sp: var(--ink-3); }
.st-rejected { --sp: var(--risk); }

/* ─── چیپ ──────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: var(--r-pill); padding: .08rem .68rem;
  font-size: .755rem; font-weight: 700; line-height: 1.75;
  background: var(--calm-soft); color: var(--calm); white-space: nowrap;
}
.chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .85; flex: none;
}
.chip.plain::before { display: none; }
.chip.ok, .chip.sla-ok, .chip.sla-met { background: var(--ok-soft); color: var(--ok); }
.chip.warn, .chip.sla-risk { background: var(--warn-soft); color: var(--warn); }
.chip.bad, .chip.sla-breach { background: var(--risk-soft); color: var(--risk); }
.chip.pine { background: var(--pine-soft); color: var(--pine); }
.chip.brass { background: var(--brass-soft); color: var(--brass); }
.chip.sla-paused, .chip.sla-none { background: var(--calm-soft); color: var(--calm); }
.sev { font-family: "Estedad", sans-serif; font-weight: 800; letter-spacing: .02em; }
.sev-P1 { color: var(--risk); } .sev-P2 { color: var(--warn); }
.sev-P3 { color: var(--pine); } .sev-P4 { color: var(--ink-3); }

/* ─── فیلترها ──────────────────────────────────────────────────── */
.segmented {
  display: inline-flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 3px; gap: 2px; box-shadow: var(--sh-1);
}
.segmented a {
  padding: .18rem .95rem; border-radius: var(--r-pill);
  font-size: .82rem; color: var(--ink-2); font-weight: 500;
  transition: background .16s var(--ease), color .16s;
}
.segmented a:hover { background: var(--surface-3); color: var(--ink); }
.segmented a.on { background: var(--pine); color: #fff; font-weight: 700; }
.segmented a .n { opacity: .7; font-size: .74rem; }

/* ─── کاشی آماری ───────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: .75rem; }
.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: .85rem 1.05rem; box-shadow: var(--sh-1);
  position: relative; overflow: hidden;
}
.tile::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px;
  background: var(--tint, var(--pine));
}
.tile .lbl { color: var(--ink-3); font-size: .755rem; font-weight: 500; }
.tile .val {
  font-family: "Estedad", sans-serif; font-weight: 800; font-size: 2rem;
  line-height: 1.25; letter-spacing: -.03em; color: var(--tint, var(--ink));
}
.tile .note { font-size: .72rem; color: var(--ink-3); }
.tile.t-ok   { --tint: var(--ok); }
.tile.t-warn { --tint: var(--warn); }
.tile.t-bad  { --tint: var(--risk); }
.tile.t-calm { --tint: var(--calm); }

/* ─── جدول ─────────────────────────────────────────────────────── */
.tablecard {
  background: var(--surface); border: 1px solid var(--line);
  /* clip نه hidden — hidden ظرفِ اسکرول می‌سازد و th چسبان را داخل کارت
     ۶۲px پایین می‌کشد؛ clip فقط گوشه‌ها را می‌بُرد و چسبانی با صفحه می‌ماند */
  border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: clip;
}
table.list { width: 100%; border-collapse: collapse; font-size: .855rem; }
table.list th {
  text-align: right; color: var(--ink-3); font-weight: 700; font-size: .72rem;
  letter-spacing: .03em; padding: .6rem .9rem;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 62px; z-index: 5;
}
table.list td { padding: .58rem .9rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: none; }
table.list tbody tr { transition: background .12s; }
table.list tbody tr:hover { background: var(--surface-2); }
table.list tfoot td { background: var(--surface-2); font-weight: 700; }
/* عطف کوچک در ابتدای هر ردیف صف */
td.rowspine { padding: 0 0 0 .5rem !important; width: 6px; }
td.rowspine i { display: block; width: 4px; height: 30px; border-radius: 3px; background: var(--sp, var(--calm)); }
.tickettitle { font-weight: 600; }
.tickettitle small { display: block; color: var(--ink-3); font-size: .74rem; font-weight: 400; }

/* ─── سنجه ─────────────────────────────────────────────────────── */
.meter { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .5s var(--ease); }
.meter.warn i { background: var(--warn); }
.meter.bad i  { background: var(--risk); }
.meter.pine i { background: var(--pine); }
.meter.brass i { background: var(--brass); }
.meterrow { display: flex; align-items: center; gap: .55rem; }
.meterrow .val { font-size: .75rem; color: var(--ink-3); white-space: nowrap; }

/* ─── نمودارها (SVG درون‌خطی) ──────────────────────────────────── */
.chartcard { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.donutwrap { position: relative; flex: none; }
.donutwrap .center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.donutwrap .center b {
  font-family: "Estedad", sans-serif; font-size: 1.5rem; font-weight: 800;
  letter-spacing: -.03em; display: block; line-height: 1.2;
}
.donutwrap .center span { font-size: .68rem; color: var(--ink-3); }
.legend { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 150px; }
.legend .row { display: flex; align-items: center; gap: .5rem; font-size: .8rem; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .row .n { margin-inline-start: auto; font-weight: 700; font-family: "Estedad", sans-serif; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.spark i {
  flex: 1; background: var(--pine-soft); border-radius: 3px 3px 0 0; min-height: 3px;
  position: relative; transition: background .15s;
}
.spark i.hi { background: var(--pine); }
.spark i:hover { background: var(--zest); }

/* ─── فرم ──────────────────────────────────────────────────────── */
form.stack { display: flex; flex-direction: column; gap: 1.05rem; }
.field > label, .fieldlabel {
  display: block; font-weight: 600; font-size: .86rem; margin-bottom: .3rem; color: var(--ink);
}
.field .req { color: var(--risk); margin-inline-start: .15rem; }
.field .help { color: var(--ink-3); font-size: .765rem; margin-top: .25rem; line-height: 1.65; }
.field .errors { color: var(--risk); font-size: .78rem; margin-top: .25rem; font-weight: 600; }

input[type=text], input[type=number], input[type=password], input[type=email],
input[type=search], textarea, select {
  width: 100%; font: inherit; font-size: .9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: .52rem .85rem; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; line-height: 1.8; }
select {
  appearance: none; padding-inline-end: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5L6 8.5L10 4.5' stroke='%237d8f89' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left .8rem center;
}
input:hover, textarea:hover, select:hover { border-color: var(--ink-3); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--pine);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--zest) 22%, transparent);
}
input[type=file] {
  font-size: .82rem; padding: .45rem; background: var(--surface-2);
  border: 1px dashed var(--line); border-radius: 10px; width: 100%;
}
input[type=file]::file-selector-button {
  font: inherit; font-size: .8rem; font-weight: 600; margin-inline-end: .7rem;
  background: var(--surface); color: var(--pine); border: 1px solid var(--line);
  border-radius: 7px; padding: .2rem .8rem; cursor: pointer;
}
.field input[type=radio], .field input[type=checkbox] { accent-color: var(--pine); }

/* گروه رادیو/چک‌باکس (جنگو ۵ به‌صورت div رندر می‌کند) */
.field > div[id^="id_"] { display: flex; flex-direction: column; gap: .3rem; }
.field > div[id^="id_"] > div { display: contents; }
.field > div[id^="id_"] label {
  font-weight: 400; font-size: .87rem; display: flex; align-items: center; gap: .5rem;
  margin: 0; padding: .3rem .55rem; border-radius: 8px; cursor: pointer;
  transition: background .12s;
}
.field > div[id^="id_"] label:hover { background: var(--surface-2); }

/* اولویت به‌شکل کارت انتخابی */
.prio > div[id^="id_"] { flex-direction: row; flex-wrap: wrap; gap: .5rem; }
.prio > div[id^="id_"] label {
  border: 1px solid var(--line); border-radius: 10px; padding: .35rem .9rem;
  background: var(--surface); font-size: .85rem;
}
.prio > div[id^="id_"] label:has(input:checked) {
  border-color: var(--pine); background: var(--pine-soft); color: var(--pine); font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--pine);
}

/* پرسش شرطی */
.q-dep {
  margin-inline-start: 6px; border-inline-start: 2px solid var(--zest);
  padding-inline-start: 16px; position: relative;
}
.q-dep::before {
  content: ""; position: absolute; inset-inline-start: -5px; top: .55rem;
  width: 8px; height: 8px; border-radius: 50%; background: var(--zest);
}

/* ─── ویزارد چندمرحله‌ای ───────────────────────────────────────── */
.wizard { display: grid; grid-template-columns: 210px 1fr; gap: 1.6rem; align-items: start; }
.rail { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 0; }
.rail .step {
  display: flex; gap: .7rem; align-items: flex-start; padding: .1rem 0;
  background: none; border: none; font: inherit; text-align: start;
  color: var(--ink-3); cursor: pointer; position: relative;
}
.rail .step .dot {
  width: 26px; height: 26px; flex: none; border-radius: 50%; margin-top: .18rem;
  background: var(--surface); border: 2px solid var(--line);
  display: grid; place-items: center; font-size: .74rem; font-weight: 700;
  font-family: "Estedad", sans-serif; color: var(--ink-3);
  transition: background .2s var(--ease), border-color .2s, color .2s;
}
.rail .step:not(:last-child)::after {
  content: ""; position: absolute; inset-inline-start: 12px; top: 30px; bottom: -6px;
  width: 2px; background: var(--line);
}
.rail .step .t { font-size: .85rem; font-weight: 600; padding-bottom: 1.1rem; line-height: 1.5; }
.rail .step.on { color: var(--ink); }
.rail .step.on .dot { border-color: var(--pine); background: var(--pine); color: #fff; }
.rail .step.done .dot { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.rail .step.err .dot { border-color: var(--risk); background: var(--risk-soft); color: var(--risk); }
.wizfoot {
  display: flex; gap: .6rem; align-items: center; margin-top: 1.4rem;
  padding-top: 1.1rem; border-top: 1px solid var(--line-2);
}
.wizfoot .grow { flex: 1; }
.progressbar { height: 3px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-bottom: 1.2rem; }
.progressbar i { display: block; height: 100%; background: var(--zest); transition: width .35s var(--ease); }

/* ─── انتخاب دسته ──────────────────────────────────────────────── */
.grouprow { display: flex; align-items: center; gap: .8rem; margin: 1.8rem 0 .8rem; }
.grouprow h2 { font-size: .82rem; font-weight: 700; color: var(--ink-3); letter-spacing: .06em; }
.grouprow .rule { flex: 1; height: 1px; background: var(--line); }
.catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: .8rem; }
.catcard {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 1rem 1.15rem; color: inherit; position: relative;
  box-shadow: var(--sh-1); overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .2s var(--ease), border-color .18s;
}
.catcard::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-end: 0; width: 3px;
  background: var(--pine); opacity: 0; transition: opacity .18s;
}
.catcard:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: var(--pine); color: inherit; }
.catcard:hover::after { opacity: 1; }
.catcard .ic {
  width: 40px; height: 40px; border-radius: 11px; background: var(--pine-soft);
  display: grid; place-items: center; font-size: 1.2rem; margin-bottom: .6rem;
}
.catcard.dev .ic { background: var(--brass-soft); }
.catcard.dev::after { background: var(--brass); }
.catcard.dev:hover { border-color: var(--brass); }
.catcard b { display: block; font-size: .93rem; font-weight: 700; margin-bottom: .1rem; }
.catcard span { display: block; color: var(--ink-3); font-size: .785rem; line-height: 1.65; }
.catcard .qn { margin-top: .5rem; font-size: .7rem; color: var(--ink-3); }

/* ─── جزئیات پرونده ────────────────────────────────────────────── */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 26vw, 420px); gap: 1.1rem; align-items: start; }
.aside { position: sticky; top: 78px; display: flex; flex-direction: column; gap: .8rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; font-size: .83rem; align-items: baseline; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 600; text-align: end; }
.answers { display: flex; flex-direction: column; gap: .1rem; }
.answers .qa {
  display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: .3rem .9rem;
  padding: .42rem 0; border-bottom: 1px dashed var(--line-2);
}
.answers .qa:last-child { border-bottom: none; }
.answers .q { color: var(--ink-3); font-size: .8rem; }
.answers .a { font-weight: 600; font-size: .87rem; white-space: pre-wrap; }
.prose { white-space: pre-wrap; line-height: 1.95; }

/* ─── گردش پرونده ──────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; top: 10px; bottom: 14px; inset-inline-start: 9px;
  width: 2px; background: linear-gradient(var(--line), transparent);
}
.timeline li { position: relative; padding: 0 2rem .95rem 0; }
.timeline li::before {
  content: ""; position: absolute; inset-inline-start: 4px; top: 8px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2.5px solid var(--pine); z-index: 1;
}
.timeline li.ev-system::before { border-color: var(--calm); }
.timeline li.ev-note::before   { border-color: var(--brass); }
.timeline li.ev-status::before { border-color: var(--zest); }
.timeline li.ev-prompt::before { border-color: var(--brass); background: var(--brass); }
.timeline .who { font-size: .765rem; color: var(--ink-3); display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.timeline .who b { color: var(--ink); font-weight: 600; }
.timeline .txt { font-size: .88rem; white-space: pre-wrap; margin-top: .1rem; }
.timeline li.internal .txt, .timeline li.internal .who { color: var(--ink-2); }
.timeline li.internal {
  background: var(--brass-soft); border-radius: 10px;
  padding-inline: .8rem; padding-block: .35rem .55rem; margin-inline-start: -.8rem;
  margin-bottom: .5rem;
}
.timeline li.internal::before { inset-inline-start: -0.6rem; }

/* ─── پنل کارشناسی (تب‌دار) ────────────────────────────────────── */
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.tabs button {
  flex: 1; background: none; border: none; font: inherit; font-size: .78rem; font-weight: 600;
  color: var(--ink-3); padding: .3rem .5rem; border-radius: 8px; cursor: pointer;
  transition: background .15s var(--ease), color .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--surface); color: var(--pine); box-shadow: var(--sh-1); }
.tabbody { padding-top: .9rem; display: flex; flex-direction: column; gap: .8rem; }
.tabbody form { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: 0; }
.tabbody form .grow { flex: 1; min-width: 110px; }
.tabbody .lb { font-size: .78rem; color: var(--ink-3); }
.tabbody hr { border: none; border-top: 1px dashed var(--line); margin: .1rem 0; }
.filelist { display: flex; flex-direction: column; gap: .25rem; }
.filelist label {
  display: flex; align-items: center; gap: .5rem; font-size: .8rem;
  padding: .25rem .4rem; border-radius: 7px; cursor: pointer;
}
.filelist label:hover { background: var(--surface-2); }

/* ─── پالت فرمان ───────────────────────────────────────────────── */
.palette-back {
  position: fixed; inset: 0; z-index: 90; background: rgb(8 16 14 / .45);
  backdrop-filter: blur(3px); display: grid; place-items: start center; padding-top: 12vh;
}
.palette {
  width: min(580px, 92vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden;
}
.palette input {
  border: none; border-radius: 0; border-bottom: 1px solid var(--line);
  padding: .95rem 1.15rem; font-size: .98rem; background: transparent;
}
.palette input:focus { box-shadow: none; border-color: var(--line); }
.palette .results { max-height: 52vh; overflow-y: auto; padding: .35rem; }
.palette .res {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .5rem .75rem; border-radius: 9px; background: none; border: none;
  font: inherit; text-align: start; color: var(--ink); cursor: pointer;
}
.palette .res:hover, .palette .res.sel { background: var(--pine-soft); }
.palette .res .code {
  font-family: "Estedad", sans-serif; font-weight: 800; font-size: .76rem;
  background: var(--surface-3); border-radius: 6px; padding: .05rem .45rem; flex: none;
}
.palette .res .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .87rem; }
.palette .res .m { font-size: .72rem; color: var(--ink-3); flex: none; }
.palette .hint { padding: .55rem 1.15rem; border-top: 1px solid var(--line-2); font-size: .72rem; color: var(--ink-3); display: flex; gap: 1rem; }
.palette .empty-res { padding: 1.6rem; text-align: center; color: var(--ink-3); font-size: .85rem; }

/* ─── توست ─────────────────────────────────────────────────────── */
.toasts {
  position: fixed; inset-block-end: 1.2rem; inset-inline-start: 1.2rem;
  z-index: 80; display: flex; flex-direction: column; gap: .5rem; max-width: 380px;
}
.toast {
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 3px solid var(--pine);
  border-radius: var(--r); padding: .65rem 1rem; box-shadow: var(--sh-2);
  font-size: .85rem; display: flex; gap: .6rem; align-items: flex-start;
  animation: slidein .35s var(--ease);
}
.toast.success { border-inline-start-color: var(--ok); }
.toast.error   { border-inline-start-color: var(--risk); }
.toast.warning { border-inline-start-color: var(--warn); }
.toast .x { margin-inline-start: auto; }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─── حالت خالی ────────────────────────────────────────────────── */
.empty {
  text-align: center; color: var(--ink-3); padding: 3.5rem 1.5rem;
  border: 1.5px dashed var(--line); border-radius: var(--r-lg); background: var(--surface);
}
.empty .ic { font-size: 2rem; opacity: .5; display: block; margin-bottom: .4rem; }
.empty b { color: var(--ink); display: block; font-size: .98rem; font-family: "Estedad", sans-serif; }
.empty p { margin: .3rem 0 1rem; font-size: .85rem; }

/* ─── صفحهٔ ورود ───────────────────────────────────────────────── */
.loginpage {
  min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr;
}
.loginpage .art {
  background: linear-gradient(150deg, var(--pine-2), var(--pine) 55%, #0d4a3f);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.loginpage .art::before {
  content: ""; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 62px, rgb(255 255 255 / .05) 62px 64px),
    radial-gradient(420px 300px at 80% 15%, rgb(168 121 43 / .3), transparent);
}
.loginpage .art > * { position: relative; }
.loginpage .art h2 {
  font-size: 1.9rem; font-weight: 800; line-height: 1.6; max-width: 15em; color: #fff;
}
.loginpage .art p { color: rgb(255 255 255 / .8); font-size: .9rem; max-width: 26em; }
.loginpage .art .shelf { display: flex; gap: 5px; align-items: flex-end; height: 96px; }
.loginpage .art .shelf i {
  width: 15px; border-radius: 3px 3px 0 0; background: rgb(255 255 255 / .18);
  animation: rise .9s var(--ease) backwards;
}
@keyframes rise { from { height: 0 !important; opacity: 0; } }
.loginpage .form { display: grid; place-items: center; padding: 2rem; background: var(--bg); }
.loginbox { width: 100%; max-width: 350px; }
.loginbox .lead { text-align: center; margin-bottom: 1.6rem; }
.loginbox .lead .name { font-family: "Estedad", sans-serif; font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; }
.loginbox .lead p { color: var(--ink-3); font-size: .84rem; margin: .1rem 0 0; }

/* ─── ریز ─────────────────────────────────────────────────────── */
.pagehead { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.pagehead .grow { flex: 1; }
.sectitle { font-size: 1rem; font-weight: 700; margin: 1.7rem 0 .7rem; display: flex; align-items: center; gap: .6rem; }
.sectitle .chip { font-weight: 600; }
.muted { color: var(--ink-3); font-size: .82rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }
[x-cloak] { display: none !important; }
.pagehelp {
  margin: 0 1.6rem; margin-top: .9rem; padding: .85rem 1.1rem;
  background: var(--pine-soft); border: 1px solid color-mix(in srgb, var(--pine) 25%, transparent);
  border-radius: var(--r-lg); font-size: .84rem; line-height: 1.95; color: var(--ink);
}
.pagehelp b { color: var(--pine); }
.pagehelp p { margin: .2rem 0; }
@media (max-width: 760px) { .pagehelp { margin-inline: 1rem; } }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
pre.promptbox {
  direction: rtl; text-align: right; white-space: pre-wrap; font-family: "Vazirmatn", sans-serif;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.3rem 1.5rem; font-size: .875rem; line-height: 2.05; box-shadow: var(--sh-1);
}

/* ─── واکنش‌گرا ────────────────────────────────────────────────── */
@media (max-width: 1040px) {
  .detail { grid-template-columns: 1fr; }
  .aside { position: static; }
}
@media (max-width: 860px) {
  .wizard { grid-template-columns: 1fr; }
  .rail {
    position: static; flex-direction: row; overflow-x: auto; gap: .3rem;
    padding-bottom: .6rem; margin-bottom: .4rem;
  }
  .rail .step { flex-direction: column; align-items: center; min-width: 74px; gap: .25rem; }
  .rail .step::after { display: none; }
  .rail .step .t { font-size: .68rem; padding: 0; text-align: center; }
}
@media (max-width: 760px) {
  .side {
    /* در RTL «inline-start» یعنی لبهٔ راست — همان سمتی که سایدبار دسکتاپ است.
       inset-inline-end (لبهٔ چپ) + translateX(100%) کشو را وسط صفحه می‌آورد. */
    position: fixed; inset-block: 0; inset-inline-start: 0;
    transform: translateX(100%); transition: transform .28s var(--ease);
    box-shadow: var(--sh-3);
  }
  .side.open { transform: none !important; }
  .menubtn { display: grid; }
  .page, .topbar { padding-inline: 1rem; }
  table.list th { top: 0; position: static; }
  /* جدول پهن روی موبایل باید داخل کارت اسکرول افقی بخورد (th دیگر چسبان نیست) */
  .tablecard { overflow-x: auto; }
  .loginpage { grid-template-columns: 1fr; }
  .loginpage .art { display: none; }
  .searchtrigger .lbl { display: none; }
}
.scrim {
  position: fixed; inset: 0; background: rgb(8 16 14 / .4); z-index: 39;
  backdrop-filter: blur(2px);
}
@media (min-width: 761px) { .scrim { display: none; } }

@media print {
  .side, .topbar, .toasts, .btn, .tabbody { display: none !important; }
  body { background: #fff; }
  .card, .tablecard { box-shadow: none; border-color: #ccc; }
}
