/* ============================================================
   دستیار — سیستم بصری
   الهام از Todoist: سایدبار گرم و روشن، صفحهٔ سفید، خط‌های نازک به‌جای جعبه،
   یک رنگ تأکید (قرمز-نارنجی) برای کار اصلی و جای فعلی. بقیهٔ رنگ‌ها فقط
   جایی می‌آیند که معنا دارند: وضعیت، اولویت، سررسید.

   قاعده: هر اندازه، فاصله و رنگی از توکن‌های همین بالا می‌آید. اگر چیزی غلط
   به نظر می‌رسد، توکن را درست کنید نه نمونه را.
   ============================================================ */

@font-face {
  font-family: Vazirmatn;
  src: url('/fonts/Vazirmatn.woff2') format('woff2-variations');
  font-weight: 300 800;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* سطوح */
  --bg: #ffffff;
  --sidebar: #fcfaf8;
  --surface: #ffffff;          /* کارت، مودال، پنل */
  --surface-2: #faf9f8;        /* پرکردن‌های آرام: پای جدول، ناحیه‌های فرورفته */
  --hover: #f4f2f0;            /* زیر ماوس: ردیف، آیتم منو */
  --fill: #f1efed;             /* دکمهٔ معمولی */
  --fill-hover: #e8e5e2;
  --border: #ededed;
  --border-strong: #d9d9d9;    /* لبهٔ ورودی‌ها */

  /* رنگ سری‌های نمودار — ترتیب ثابت، با validate_palette سنجیده روی همین زمینه‌ها */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --chart-grid: #ececec;
  --control: #b9b9b9;          /* لبهٔ چک‌باکس */

  /* متن — سه درجه، همه با کنتراست قابل‌قبول روی سفید */
  --text: #202020;
  --text-2: #555555;
  --muted: #737373;            /* ۴.۷:۱ روی سفید */
  --faint: #c4c4c4;            /* فقط تزئین: خط تیرهٔ خانهٔ خالی */

  /* تأکید */
  --accent: #dc4c3e;
  --accent-hover: #c53727;
  --accent-soft: #ffefe5;
  --accent-text: #b8392b;      /* متن تأکیدی روی سطح روشن */
  --on-accent: #ffffff;

  /* هیوهای معنایی — پیل‌ها و تاریخ‌ها از همین‌ها ساخته می‌شوند */
  --h-red: #d1453b;
  --h-orange: #e07a00;
  --h-amber: #b88a00;
  --h-green: #058527;
  --h-teal: #0f8a86;
  --h-blue: #246fe0;
  --h-indigo: #4f5bd5;
  --h-violet: #692ec2;
  --h-pink: #c63b80;
  --h-slate: #707070;

  --pill-bg: 12%;
  --pill-text: 78%;

  /* تایپوگرافی — یک مقیاس کوچک */
  --fs-xs: 12px;     /* سرستون، شمارنده، راهنما */
  --fs-sm: 13px;     /* خانه‌های جدول، متن دوم */
  --fs: 14px;        /* متن اصلی، ورودی، عنوان ردیف */
  --fs-lg: 16px;     /* عنوان مودال و بخش */
  --fs-xl: 20px;     /* عنوان صفحه */

  /* فاصله — مقیاس ۴ */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .12);
  --ring: color-mix(in srgb, var(--accent) 55%, transparent);
  --toast-bg: #2b2b2b;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #1f1f1f;
    --sidebar: #262626;
    --surface: #262626;
    --surface-2: #2a2a2a;
    --hover: #2f2f2f;
    --fill: #333333;
    --fill-hover: #3d3d3d;
    --border: #333333;
    --border-strong: #474747;
    --control: #6b6b6b;

    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --chart-grid: #333333;

    --text: #ececec;
    --text-2: #bdbdbd;
    --muted: #949494;
    --faint: #4a4a4a;

    --accent: #de4c4a;
    --accent-hover: #e8655f;
    --accent-soft: #3a2624;
    --accent-text: #ff8f80;
    --on-accent: #ffffff;

    --h-red: #ff7066;
    --h-orange: #ff9a3d;
    --h-amber: #e8c04a;
    --h-green: #4cc06d;
    --h-teal: #44c2b9;
    --h-blue: #6fa3ff;
    --h-indigo: #8f97ff;
    --h-violet: #b28cff;
    --h-pink: #f27fb5;
    --h-slate: #a3a3a3;

    --pill-bg: 18%;
    --pill-text: 88%;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .55);
    --toast-bg: #3a3a3a;
  }
}

/* ============================================================ پایه */

* { box-sizing: border-box; }
/* hidden همیشه برنده است، حتی روی عنصری که کلاسش display:flex/grid می‌دهد */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, 'Segoe UI', Tahoma, sans-serif;
  font-size: var(--fs);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 700; line-height: 1.4; margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

.i { flex: none; display: block; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.en { direction: ltr; unicode-bidi: isolate; font-family: 'Segoe UI', system-ui, sans-serif; font-size: .95em; }
.dash { color: var(--faint); user-select: none; }
.spacer { margin-inline-start: auto; }
.row { display: flex; gap: var(--s2); align-items: center; }
.hint { color: var(--muted); font-size: var(--fs-xs); line-height: 1.7; }

.kbd {
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  direction: ltr;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================ چیدمان */

.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.main { padding: var(--s8) var(--s10) 96px; min-width: 0; }

/* ============================================================ سایدبار */

.sidebar {
  background: var(--sidebar);
  padding: var(--s3) var(--s2);
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2) var(--s2); }
.brand .drawer-close { display: none; margin-inline-start: auto; }
/* زیرِ لوگو: حساب (هرچه جا هست) و زنگوله */
.side-tools { display: flex; align-items: center; gap: var(--s1); padding: 0 var(--s1) var(--s2) 0; margin-bottom: var(--s1); border-bottom: 1px solid var(--border); }
.side-tools .user-chip { flex: 1; max-width: none; min-width: 0; height: 34px; border-radius: var(--radius-sm); padding-inline: var(--s1) var(--s2); }
.side-tools .user-chip .user-name { flex: 1; text-align: start; }
.mobilebar, .drawer-backdrop { display: none; }
.logo-mark { display: grid; flex: none; filter: drop-shadow(0 1px 2px rgba(197, 55, 39, .25)); }
.brand b { font-size: 15px; font-weight: 700; display: block; line-height: 1.3; }
.brand .sub { color: var(--muted); font-size: var(--fs-xs); line-height: 1.3; }

.nav-label {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: var(--s4) var(--s2) var(--s1);
}

.nav-group { display: flex; flex-direction: column; gap: 1px; }

.nav-item, .quick-open {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 34px;
  padding: 0 var(--s2);
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  width: 100%;
  text-align: start;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover, .quick-open:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item .ico {
  width: 22px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
}
.nav-item.active .ico { color: var(--accent-text); }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-item .count {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.nav-item.active .count { color: var(--accent-text); }
.nav-item[draggable="true"] { position: relative; }
.nav-item .grip { position: absolute; inset-inline-end: var(--s1); top: 50%; transform: translateY(-50%); margin: 0; }
.nav-item:hover .grip { opacity: .6; }
.nav-item[draggable="true"]:hover .count { visibility: hidden; }

.quick-open { color: var(--muted); margin-bottom: var(--s1); }
.quick-open .ico { width: 22px; display: grid; place-items: center; }
.quick-open .kbd { margin-inline-start: auto; }

/* ============================================================ ریتمِ صفحه */

/* کارت‌های پشتِ سرِ هم هیچ‌وقت به هم نمی‌چسبند (حاشیه‌ها روی هم می‌افتند، پس با حاشیه‌های قبلی جمع نمی‌شود) */
.main > .card + .card, .main > .card + .integrations, .integrations > .card + .card { margin-top: var(--s4); }

/* ============================================================ سرصفحه */

.page-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head > .page-title { display: flex; align-items: center; gap: var(--s2); min-width: 0; flex: 1 1 340px; }
.page-head h1 { font-size: var(--fs-xl); overflow: hidden; text-overflow: ellipsis; }
.page-head .desc {
  color: var(--muted); font-size: var(--fs-sm); margin: 0;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.page-head .actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.page-icon { font-size: 22px; line-height: 1; width: 32px; display: grid; place-items: center; flex: none; color: var(--muted); }

/* ============================================================ دکمه */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 var(--s3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--fill-hover); }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { background: transparent; color: var(--h-red); }
.btn.danger:hover { background: color-mix(in srgb, var(--h-red) 10%, transparent); }
.btn.danger-fill { background: var(--h-red); color: #fff; }
.btn.danger-fill:hover { background: color-mix(in srgb, var(--h-red) 85%, #000); }
.btn.icon { width: 32px; padding: 0; }
.btn.sm { height: 28px; padding: 0 var(--s2); font-size: var(--fs-xs); }
.btn.sm.icon { width: 28px; padding: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary .kbd {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .28);
  color: inherit;
}

/* ============================================================ ورودی */

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--control); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 7%, transparent);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
.input.short { max-width: 160px; }

.search-box { position: relative; width: 220px; }
.search-box .i { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .input { min-height: 32px; padding-inline-start: 32px; background: var(--surface-2); border-color: var(--border); }
.search-box .input:focus { background: var(--surface); }

/* ============================================================ فرم */

.field label, .field-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}
.req { color: var(--h-red); }
.field .hint { margin-top: var(--s1); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }

.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--fs); }
.check-main { font-weight: 500; padding: 2px 0; }

/* چک‌باکس — همه‌جای برنامه یکی */
.tick,
.check input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--control);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  flex: none;
  transition: background .14s, border-color .14s, transform .1s;
}
.tick:hover, .check input[type="checkbox"]:hover { border-color: var(--text-2); }
.tick:active, .check input[type="checkbox"]:active { transform: scale(.9); }
.tick:checked, .check input[type="checkbox"]:checked { background: var(--h-green); border-color: var(--h-green); }
.tick::after, .check input[type="checkbox"]::after {
  content: '';
  position: absolute;
  inset-inline-start: 5px;
  top: 1.5px;
  width: 4.5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  opacity: 0;
}
.tick:checked::after, .check input[type="checkbox"]:checked::after { opacity: 1; }
.tick:disabled, .check input[type="checkbox"]:disabled { cursor: default; opacity: .55; }

/* «انجام شد»: دایره، مثل Todoist. زیر ماوس تیکش کم‌رنگ پیدا می‌شود. */
.tick.round, .check .tick.round { border-radius: 50%; border-color: var(--muted); }
.tick.round::after, .check .tick.round::after { inset-inline-start: 5px; top: 2px; border-color: var(--muted); }
.tick.round:hover:not(:checked)::after, .check .tick.round:hover:not(:checked)::after { opacity: .5; }
.tick.round:checked, .check .tick.round:checked { border-color: var(--h-green); }
.tick.round:checked::after, .check .tick.round:checked::after { border-color: #fff; }

/* ============================================================ پیل */

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--s2);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  background: color-mix(in srgb, var(--hue, var(--h-slate)) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--hue, var(--h-slate)) var(--pill-text), var(--text));
  border: 1px solid transparent;
}
.pills { display: inline-flex; flex-wrap: wrap; gap: var(--s1); vertical-align: middle; }
td .pills { flex-wrap: nowrap; }   /* در جدول، ردیف‌ها هم‌ارتفاع بمانند */
.pill[role="button"] { cursor: pointer; }
.pill[role="button"]:hover { border-color: color-mix(in srgb, var(--hue, var(--h-slate)) 40%, transparent); }

/* پیل انتخابی در فرم */
.pick {
  height: 28px;
  padding: 0 var(--s3);
  cursor: pointer;
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-strong);
  transition: background .13s, color .13s, border-color .13s;
}
.pick:hover { border-color: color-mix(in srgb, var(--hue) 55%, transparent); color: var(--text); }
.pick.on {
  background: color-mix(in srgb, var(--hue) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--hue) var(--pill-text), var(--text));
  border-color: color-mix(in srgb, var(--hue) 55%, transparent);
  font-weight: 600;
}
.pick-group { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.8;
}

/* ============================================================ تاریخ */

.date { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.date-rel { font-size: var(--fs-xs); color: var(--muted); }
.date.overdue, .date.overdue .date-rel { color: var(--h-red); }
.date.today, .date.today .date-rel { color: var(--h-green); }
.date.tomorrow, .date.tomorrow .date-rel { color: var(--h-orange); }
.date.week, .date.week .date-rel { color: var(--h-violet); }

/* ============================================================ کارت و جدول */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }
/* جدول اصلی خودش اسکرول می‌خورد تا سرستون و جمع همیشه دیده شوند */
.table-wrap.scroll-y { max-height: calc(100vh - 170px); overflow: auto; }

table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }

th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 38px;
  padding: 0 var(--s3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: start;
  user-select: none;
}
th.sortable { cursor: pointer; transition: color .12s; }
th.sortable:hover { color: var(--text); }
th .sort-mark { color: var(--accent-text); margin-inline-start: var(--s1); font-size: 10px; }

td {
  height: 44px;
  padding: var(--s1) var(--s3);
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: start;
  vertical-align: middle;
  background: var(--surface);
}
th:first-child, td:first-child { padding-inline-start: var(--s4); }
th:last-child, td:last-child { padding-inline-end: var(--s2); }
tbody tr:last-child > td { border-bottom: 0; }

tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover > td { background: var(--hover); }
tbody tr[data-id]:focus-visible { outline: none; }
tbody tr[data-id]:focus-visible > td { background: var(--hover); box-shadow: inset 0 1px 0 var(--ring), inset 0 -1px 0 var(--ring); }

td.title-cell { color: var(--text); font-size: var(--fs); max-width: 420px; }
td.wide { white-space: normal; min-width: 220px; max-width: 340px; line-height: 1.65; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.link-cell { display: inline-flex; align-items: center; gap: var(--s1); }
.cell-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  height: 40px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 0;
}
.sum-label { color: var(--muted); font-size: var(--fs-xs); margin-inline-end: 6px; }
.sum-value { color: var(--text); font-weight: 700; }

/* ستون‌های ابتدایی تا «عنوان» موقع اسکرول افقی سر جا می‌مانند.
   افست‌ها در JS اندازه گرفته می‌شوند و با تغییر اندازه دوباره حساب می‌شوند. */
td.frozen, th.frozen { position: sticky; z-index: 3; }
th.frozen { z-index: 4; }
tfoot td.frozen { z-index: 4; }
.frozen-last::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-end: -8px;
  width: 8px;
  background: linear-gradient(to left, rgba(0, 0, 0, .06), transparent);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.table-wrap.scrolled .frozen-last::after { opacity: 1; }

/* ردیف‌های تمام‌شده: خط روی عنوان، بقیه کم‌رنگ */
tbody tr.struck .title-cell .cell-text {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent);
  color: var(--muted);
}
tbody tr.struck > td { color: var(--muted); }
tbody tr.struck .pill, tbody tr.struck .date { opacity: .55; }
tbody tr.struck .date, tbody tr.struck .date .date-rel { color: var(--muted); }
tbody tr.struck .mono { opacity: .7; }

.row-actions { white-space: nowrap; width: 1%; }
.row-actions .btn { opacity: 0; transition: opacity .12s, background .12s, color .12s; }
tbody tr:hover .row-actions .btn,
tbody tr:focus-within .row-actions .btn,
.row-actions .btn:focus-visible { opacity: 1; }
@media (hover: none) { .row-actions .btn { opacity: .7; } }

.table-meta { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s3); color: var(--muted); font-size: var(--fs-xs); }

/* ============================================================ درخت */

.cell-tree { display: flex; align-items: center; min-height: 28px; }
.rail { width: 24px; flex: none; }

.twisty {
  width: 22px;
  height: 22px;
  margin-inline-end: 2px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: background .12s, color .12s;
}
.twisty:hover { background: var(--fill-hover); color: var(--text); }
.twisty-space { width: 24px; flex: none; }

.kid-count {
  display: inline-block;
  min-width: 20px;
  margin-inline-end: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.7;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.grip { color: var(--muted); opacity: 0; cursor: grab; margin-inline-end: 2px; flex: none; transition: opacity .12s; display: grid; place-items: center; }
tr:hover .grip, .field-row:hover .grip { opacity: .6; }
[draggable="true"] { -webkit-user-drag: element; }
.dragging { opacity: .4; }

tbody tr.drop-into > td { background: var(--accent-soft) !important; }
tbody tr.drop-before > td { box-shadow: inset 0 2px 0 var(--accent); }
tbody tr.drop-after > td { box-shadow: inset 0 -2px 0 var(--accent); }

/* ============================================================ حالت خالی */

.empty { padding: 56px var(--s5); text-align: center; color: var(--muted); }
.empty .big { font-size: 32px; display: flex; justify-content: center; margin-bottom: var(--s2); opacity: .55; }
.empty .title { color: var(--text); font-weight: 600; margin-bottom: var(--s1); }
.empty .actions { margin-top: var(--s4); display: flex; gap: var(--s2); justify-content: center; }

/* ============================================================ مودال */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px var(--s4);
  overflow-y: auto;
  z-index: 100;
  animation: fade-in .14s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.1);
}
.modal.wide { max-width: 760px; }
.modal.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s3) var(--s5); border-bottom: 1px solid var(--border); flex: none; }
.modal-head h2 { font-size: var(--fs-lg); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); overflow-y: auto; flex: 1; }
.modal-foot { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--border); flex: none; }
.confirm-text { color: var(--text-2); margin: 0; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* ============================================================ فهرست فیلدها */

.field-list { display: flex; flex-direction: column; gap: 6px; }
.field-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.field-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.field-row .meta { color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; }
.field-row .code { font-family: ui-monospace, 'Cascadia Mono', monospace; font-size: 11.5px; direction: ltr; unicode-bidi: isolate; }

.section { border-top: 1px solid var(--border); padding-top: var(--s4); }
.section-title { font-weight: 600; font-size: var(--fs); margin-bottom: var(--s2); }

/* ============================================================ تاریخ و تقویم */

.date-wrap { position: relative; display: flex; gap: var(--s1); align-items: center; }
.date-wrap .input { max-width: 150px; }
.date-wrap .input[type="time"] { max-width: 120px; }
.calendar {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: 264px;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 60;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }
.cal-head b { font-size: var(--fs-sm); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-grid span { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal-grid button {
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  height: 32px;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.cal-grid button:hover { background: var(--hover); color: var(--text); }
.cal-grid button.today { color: var(--accent-text); font-weight: 700; }
.cal-grid button.sel { background: var(--accent); color: var(--on-accent); }

/* ============================================================ کاشی‌ها */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s3); }
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color .12s;
}
.tile:hover { border-color: var(--border-strong); }
.tile h3 { font-size: var(--fs); font-weight: 600; }
.tile p { margin: 0 0 var(--s3); color: var(--muted); font-size: var(--fs-sm); flex: 1; }
.tile .btn, .tile .pill { align-self: flex-start; }

/* ============================================================ انتخاب آیکون */

.icon-picker { position: relative; display: inline-block; }
.icon-preview { width: 44px; height: 36px; padding: 0; justify-content: center; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); }
.icon-panel {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: 300px;
  max-height: 300px;
  overflow-y: auto;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 70;
}
.icon-group-title { color: var(--muted); font-size: 11px; font-weight: 600; margin: var(--s2) 2px var(--s1); }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.icon-cell { border: 0; background: transparent; border-radius: var(--radius-sm); height: 34px; display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.icon-cell:hover { background: var(--hover); color: var(--text); }
.icon-cell.sel { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent); }

/* آیکونِ خطیِ موجودیت و فضا، کنار اسمشان */
.ent-ico { display: inline-grid; place-items: center; flex: none; line-height: 0; }
.with-ico { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; vertical-align: middle; }
.with-ico .ent-ico { color: var(--muted); }
.act-ico { display: inline-grid; place-items: center; color: var(--muted); }
.act.structural .act-ico { color: var(--accent-text); }
.formula-err, .formula-val { display: inline-flex; align-items: center; gap: 4px; }

/* ============================================================ دستیار */

/* دکمه و پنجرهٔ دستیار سمت چپِ صفحه (انتهای خط)، تا روی سایدبار نیفتند */
#chat-toggle {
  position: fixed;
  bottom: var(--s6);
  inset-inline-end: var(--s6);
  z-index: 80;
  height: 40px;
  padding: 0 var(--s4);
  display: flex;
  gap: var(--s2);
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background .12s;
}
#chat-toggle:hover { background: var(--accent-hover); }

#chat {
  position: fixed;
  bottom: var(--s6);
  inset-inline-end: var(--s6);
  width: 400px;
  max-width: calc(100vw - 48px);
  height: min(640px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 81;
}
#chat header { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s4); border-bottom: 1px solid var(--border); }
#chat header b { font-size: var(--fs); }
#chat header .ico { color: var(--accent); display: grid; }
.chat-log { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.msg { max-width: 88%; font-size: var(--fs-sm); line-height: 1.8; }
.msg.user {
  align-self: flex-start;
  background: var(--fill);
  color: var(--text);
  padding: 6px var(--s3);
  border-radius: var(--radius-lg);
  border-end-start-radius: 4px;
  white-space: pre-wrap;
}
.msg.assistant { align-self: flex-end; width: 100%; white-space: pre-wrap; color: var(--text-2); }
.msg.thinking { color: var(--muted); }
.msg .error { color: var(--h-red); }

.act {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: 6px;
  padding: var(--s1) var(--s2) var(--s1) var(--s3);
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: normal;
}
.act.structural { border-inline-start: 3px solid var(--accent); }
.act .undo { margin-inline-start: auto; }

.chat-input { border-top: 1px solid var(--border); padding: var(--s2); display: flex; gap: var(--s2); align-items: flex-end; }
.chat-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  resize: none;
  line-height: 1.7;
}
.chat-input textarea:focus { outline: none; border-color: var(--muted); }
.chat-input .btn { height: 40px; }

/* ---- گفتگوها: عنوانِ گفتگوی فعلی، فهرست و جستجوی گفتگوهای قبلی */
#chat { width: 420px; }
.chat-view, .chat-sessions { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-view[hidden], .chat-sessions[hidden] { display: none; }
.chat-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 30px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.chat-title-btn:hover { background: var(--hover); }
.chat-title-btn .i { color: var(--muted); flex: none; }
.chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
#chat header .btn.on { background: var(--accent-soft); color: var(--accent-text); }
.chat-loading { color: var(--muted); font-size: var(--fs-sm); text-align: center; padding: var(--s6) 0; }
.chat-welcome { display: flex; flex-direction: column; gap: var(--s2); margin: auto 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; }
.chat-welcome b { color: var(--text); font-size: var(--fs); }
.chat-welcome p { margin: 0; }
.chat-ideas { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s2); }
.chat-idea {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: start;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.chat-idea:hover { background: var(--hover); border-color: var(--border-strong); color: var(--text); }
.chat-sessions-head { display: flex; gap: var(--s2); align-items: center; padding: var(--s3); border-bottom: 1px solid var(--border); }
.chat-sessions-head .search-box { flex: 1; width: auto; }
.chat-session-list { flex: 1; overflow-y: auto; padding: var(--s1) var(--s2) var(--s3); }
.chat-group { padding: var(--s3) var(--s2) var(--s1); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.chat-session {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s2);
  border-radius: var(--radius);
  cursor: pointer;
}
.chat-session:hover, .chat-session:focus-visible { background: var(--hover); outline: none; }
.chat-session.current { background: var(--accent-soft); }
.chat-session-ico { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--fill); color: var(--muted); }
.chat-session.current .chat-session-ico { color: var(--accent-text); background: var(--surface); }
.chat-session-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.6; }
.chat-session-text .input { min-height: 30px; }
.chat-session-title { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-preview { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.chat-session-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat-session-actions { display: flex; gap: 0; opacity: 0; transition: opacity .12s; }
.chat-session:hover .chat-session-actions, .chat-session:focus-within .chat-session-actions { opacity: 1; }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s8) var(--s4); color: var(--muted); font-size: var(--fs-sm); text-align: center; line-height: 1.8; }
.chat-empty .i { color: var(--faint); }
@media (hover: none) { .chat-session-actions { opacity: .7; } }

.notice {
  padding: var(--s3);
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.85;
}

/* ============================================================ توست */

#toasts {
  position: fixed;
  bottom: var(--s6);
  inset-inline: 0;
  margin-inline: auto;
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  z-index: 200;
  pointer-events: none;
}
#toasts > * { pointer-events: auto; }
.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  max-width: 400px;
  padding: 10px var(--s4);
  border-radius: var(--radius);
  background: var(--toast-bg);
  color: #f5f5f5;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow);
  animation: slide-in .18s ease;
}
.toast.err { border-inline-start: 3px solid #ff6b5e; }
.toast-action {
  margin-inline-start: auto;
  border: 0;
  background: transparent;
  color: #ff9d8f;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================ فرمول و جمع */

.formula-val { color: var(--text); font-weight: 500; }
.formula-err { color: var(--h-red); font-size: var(--fs-xs); cursor: help; }
.formula-expr { color: var(--muted); font-size: var(--fs-xs); font-family: ui-monospace, 'Cascadia Mono', monospace; }
.negative { color: var(--h-red); }

/* ============================================================ تنظیمات */

.settings-card { padding: 0 var(--s5); }
.settings-card:has(> .settings-card-head) { padding-block: var(--s4); }
.settings-card-head + .hint { margin: var(--s1) 0 var(--s2); }
.setting-row { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .select { max-width: 200px; }
.info-card { margin-top: var(--s4); padding: var(--s4) var(--s5); }
.scope-card { margin-bottom: var(--s4); padding: var(--s4) var(--s5); }
.exceptions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin-top: var(--s1); }
.exceptions .tag { margin: 0; border: 0; cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; }
.exceptions .tag:hover { background: var(--fill-hover); }

/* ============================================================ بخش تاشو و صفحهٔ رکورد */

.fold-card + .fold-card { margin-top: var(--s4); }
.fold-top { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s3) var(--s1) var(--s2); }
.fold-head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: start;
  cursor: pointer;
}
.fold-head:hover { background: var(--hover); }
.fold-arrow { color: var(--muted); display: grid; flex: none; }
.fold-title { font-weight: 600; font-size: var(--fs); flex: none; }
.fold-sub { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fold-actions { flex: none; }
.fold-body { border-top: 1px solid var(--border); }
.fold-body > .detail-grid, .fold-body > .detail-foot { padding: var(--s5); }
.fold-body > .detail-foot { padding-top: 0; }
.fold-body > .detail-tags { padding: 0 var(--s5) var(--s5); }

.modal-body .fold { border-top: 1px solid var(--border); padding-top: var(--s2); }
.modal-body .fold-top { padding: 0; }
.modal-body .fold-body { border-top: 0; padding: var(--s2) var(--s2) 0; display: flex; flex-direction: column; gap: var(--s2); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4) var(--s5); }
.detail-grid .span-2 { grid-column: 1 / -1; }

/* ============================================================ نوار بارگذاری */

#loading {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 2px;
  background: var(--accent);
  /* transform-origin مقدار منطقی ندارد؛ برنامه همیشه راست‌به‌چپ است */
  transform-origin: right;
  transform: scaleX(0);
  opacity: 0;
  z-index: 300;
  transition: transform .3s ease, opacity .25s;
  pointer-events: none;
}
#loading.on { opacity: 1; transform: scaleX(.75); transition-duration: 1.4s; }
#loading.done { opacity: 0; transform: scaleX(1); transition-duration: .18s; }

/* ============================================================ جستجوگر سریع */

.palette-overlay { padding-top: 12vh; }
.palette {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.1);
}
.palette-top { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--text); }
.palette-input:focus-visible { outline: none; }
.palette-input::placeholder { color: var(--muted); }
.palette-list { max-height: 54vh; overflow-y: auto; padding: 6px; }
.palette-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.palette-row.active { background: var(--hover); }
.palette-row .ico { width: 22px; display: grid; place-items: center; flex: none; color: var(--muted); }
.palette-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { margin-inline-start: auto; padding-inline-start: var(--s3); color: var(--muted); font-size: var(--fs-xs); flex: none; }
.palette-empty { padding: 28px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.palette-foot { display: flex; gap: var(--s4); padding: var(--s2) var(--s4); border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); }

/* ============================================================ فضای کار در سایدبار */

.nav-space { font-weight: 600; }
.nav-space .count { font-weight: 400; }
.nav-toggle {
  width: 18px;
  height: 18px;
  margin-inline-end: -4px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
}
.nav-toggle:hover { background: var(--fill-hover); color: var(--text); }
/* خط راهنمای عمودی: موجودیت‌های یک فضا زیر سرتیترش آویزان دیده می‌شوند */
.nav-space-block + .nav-space-block { margin-top: 2px; }
.nav-group.nested {
  margin-inline-start: 18px;
  padding-inline-start: 6px;
  border-inline-start: 1px solid var(--border-strong);
}
/* زیرکارپوشه‌ها: همان خطِ راهنما، یک لایه جلوتر؛ قبل از موجودیت‌های خودِ کارپوشه */
.nav-children { margin-inline-start: 18px; padding-inline-start: 6px; border-inline-start: 1px solid var(--border-strong); display: flex; flex-direction: column; gap: 1px; }
.nav-children[hidden] { display: none; }
.nav-children .nav-group.nested, .nav-children .nav-children { margin-inline-start: 12px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.crumbs .crumb + .crumb::before { content: '‹'; color: var(--faint); margin-inline-end: 4px; }
.member-row.inherited { opacity: .85; }
/* ---- نمای گانت. در RTL زمان از راست به چپ جلو می‌رود؛ ستونِ عنوان‌ها سمتِ راست ثابت است */
.gantt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.gantt-card { padding: 0; overflow: hidden; }
.gantt { --g-label: 230px; --g-row: 36px; }
.gantt.compact { --g-label: 190px; --g-row: 32px; }
.g-scroll { overflow: auto; max-height: calc(100vh - 230px); overscroll-behavior: contain; }
.gantt.compact .g-scroll { max-height: 440px; }
.g-grid { width: calc(var(--g-label) + var(--g-track)); position: relative; }
.g-row { display: flex; min-height: var(--g-row); }
.g-label {
  position: sticky; inset-inline-start: 0; z-index: 3; flex: none; width: var(--g-label);
  display: flex; align-items: center; gap: 6px; padding: 0 var(--s3);
  background: var(--surface); border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border);
  min-width: 0; font-size: var(--fs-sm);
}
.g-title { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: start; padding: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-title:hover { color: var(--accent-text); }
.g-row.struck .g-title { text-decoration: line-through; color: var(--muted); }
.g-track { position: relative; flex: none; border-bottom: 1px solid var(--border); }
.g-head { position: sticky; top: 0; z-index: 5; min-height: 52px; }
.g-head .g-label { z-index: 6; background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.g-head .g-track { background: var(--surface-2); }
.g-months { position: relative; height: 26px; border-bottom: 1px solid var(--border); }
.g-month { position: absolute; top: 0; height: 26px; border-inline-start: 1px solid var(--border-strong); padding-inline: 6px; font-size: var(--fs-xs); font-weight: 600; line-height: 26px; white-space: nowrap; overflow: hidden; }
.g-ticks { position: relative; height: 25px; }
.g-tick { position: absolute; top: 0; height: 25px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10.5px; color: var(--muted); line-height: 1.1; font-variant-numeric: tabular-nums; }
.g-tick small { font-size: 9px; color: var(--faint); }
.g-tick.off { color: var(--h-red); }
.g-body { position: relative; }
.g-lines { position: absolute; inset-block: 0; inset-inline-start: var(--g-label); pointer-events: none; }
.g-line { position: absolute; inset-block: 0; width: 1px; background: var(--border); opacity: .6; }
.g-line.month { background: var(--border-strong); opacity: 1; }
.g-off { position: absolute; inset-block: 0; background: var(--fill); opacity: .6; }
.g-today { position: absolute; inset-block: 0; width: 2px; margin-inline-start: -1px; background: var(--h-red); z-index: 2; }
.g-bounds { position: absolute; inset-block: 0; background: var(--accent-soft); opacity: .45; border-inline: 1px dashed var(--accent); }
.g-group .g-label { background: var(--surface-2); gap: var(--s2); }
.g-group .g-label b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-group .g-label .muted { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.g-group .g-track { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.g-summary { position: absolute; top: 50%; height: 8px; margin-top: -4px; border-radius: 4px; background: var(--text-2); opacity: .55; }
.g-bar {
  position: absolute; top: 50%; height: 24px; margin-top: -12px; z-index: 1;
  display: flex; align-items: center; overflow: hidden; padding: 0;
  border: 0; border-radius: 6px; cursor: grab; font: inherit;
  background: color-mix(in srgb, var(--g-hue) 22%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--g-hue) 55%, transparent);
  color: var(--text); transition: box-shadow .12s;
}
.g-bar:hover { box-shadow: inset 0 0 0 1.5px var(--g-hue), var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, .12)); }
.g-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.g-bar.dragging { cursor: grabbing; opacity: .85; z-index: 4; }
.g-bar.done { opacity: .55; }
.g-bar.late { box-shadow: inset 0 0 0 1.5px var(--h-red); }
.g-bar.outside { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--h-amber) 25%, transparent) 6px 9px); }
.g-fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: color-mix(in srgb, var(--g-hue) 45%, transparent); pointer-events: none; }
.g-bar-text { position: relative; padding-inline: 8px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.g-h { position: absolute; inset-block: 0; width: 7px; cursor: ew-resize; z-index: 2; }
.g-h.start { inset-inline-start: 0; }
.g-h.end { inset-inline-end: 0; }
.g-h:hover { background: color-mix(in srgb, var(--g-hue) 45%, transparent); }
.g-milestone { position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px; transform: rotate(45deg); border: 0; border-radius: 3px; background: var(--g-hue); cursor: grab; z-index: 1; }
.g-side { position: absolute; top: 50%; transform: translateY(-50%); font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; pointer-events: none; }
.g-undated { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: var(--s3); border-top: 1px solid var(--border); }
.project-plan { padding-bottom: 0; overflow: hidden; margin-bottom: var(--s4); }
.project-plan .card-head h2 { display: flex; align-items: center; gap: var(--s2); }
.plan-stats { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: 0 var(--s4) var(--s3); }
.plan-progress { flex: 1 1 240px; display: flex; flex-direction: column; gap: 6px; }
.plan-progress-head { display: flex; align-items: baseline; gap: var(--s2); }
.plan-progress-head b { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--h-green); }
.plan-flag { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 var(--s2); border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.plan-flag.late { background: color-mix(in srgb, var(--h-red) 12%, transparent); color: var(--h-red); }
.plan-flag.outside { background: color-mix(in srgb, var(--h-amber) 15%, transparent); color: var(--h-amber); }
.project-plan .gantt { border-top: 1px solid var(--border); }
@media (max-width: 860px) {
  .gantt { --g-label: 130px; }
  .gantt.compact { --g-label: 120px; }
  .g-label .avatar { display: none; }
}

/* ---- چیدمان: درختِ راست‌چینِ کارپوشه‌ها و موجودیت‌ها؛ تورفتگی با --level از سمتِ راست */
.arrange { padding: var(--s2) 0; }
.arr-row {
  display: flex; align-items: center; gap: var(--s2); min-height: 44px;
  padding-block: 4px; padding-inline: calc(var(--s4) + var(--level) * 26px) var(--s4);
  position: relative;
}
.arr-row + .arr-row { border-top: 1px solid var(--border); }
.arr-row:hover { background: var(--hover); }
.arr-row[style*="--level:1"]::before, .arr-row[style*="--level:2"]::before, .arr-row[style*="--level:3"]::before {
  content: ''; position: absolute; inset-block: 0; inset-inline-start: calc(var(--s4) + var(--level) * 26px - 14px);
  border-inline-start: 1px solid var(--border-strong);
}
.arr-ico { display: grid; place-items: center; width: 24px; flex: none; color: var(--muted); }
.arr-folder .arr-ico { color: var(--text-2); }
.arr-name { border: 0; background: none; padding: 0; font: inherit; color: var(--text); text-align: start; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arr-name:hover { color: var(--accent-text); }
.arr-name.static { cursor: default; }
.arr-name.static:hover { color: var(--text); }
.arr-folder .arr-name { font-weight: 700; }
.arr-meta { font-size: var(--fs-xs); white-space: nowrap; }
.arr-tools { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; flex: none; }
.arr-tools .select { width: 190px; margin-inline: var(--s2); }
.arr-general { background: var(--surface-2); }
.arr-grip { display: grid; place-items: center; width: 22px; height: 30px; flex: none; color: var(--faint); cursor: grab; touch-action: none; border-radius: var(--radius-sm); }
.arr-grip:hover { color: var(--text-2); background: var(--fill); }
.arr-grip.off { cursor: default; background: none; }
.arr-row.dragging { opacity: .4; }
.arr-row.drop-into { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.arr-row.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.arr-row.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.arr-row.drop-no { background: var(--fill); cursor: no-drop; }
.arr-ghost { position: fixed; z-index: 200; pointer-events: none; padding: 6px var(--s3); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
body:has(.arr-ghost) { cursor: grabbing; user-select: none; }
/* زباله‌دان */
.trash-list { padding: 0; }
.trash-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); }
.trash-row + .trash-row { border-top: 1px solid var(--border); }
.trash-ico { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius-sm); background: var(--fill); color: var(--muted); }
.trash-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.7; }
.trash-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-text .muted { font-size: var(--fs-xs); }
.trash-left { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.trash-left.soon { color: var(--h-red); font-weight: 600; }
.trash-actions { display: flex; align-items: center; gap: var(--s1); flex: none; }
@media (max-width: 860px) { .trash-row { flex-wrap: wrap; } .trash-actions { width: 100%; justify-content: flex-end; } }
.arr-empty { font-size: var(--fs-xs); min-height: 32px; }
@media (max-width: 860px) {
  .arr-row { flex-wrap: wrap; padding-inline: calc(var(--s3) + var(--level) * 16px) var(--s3); }
  .arr-row::before { display: none; }
  .arr-tools { width: 100%; margin-inline-start: 0; flex-wrap: wrap; }
  .arr-tools .select { flex: 1; width: auto; margin-inline: 0 var(--s2); }
}

/* برچسب‌ها */
.tag-chip { display: inline-flex; align-items: center; height: 22px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; max-width: 180px; }
.tag-chip.sm { height: 19px; font-size: 11px; font-weight: 500; }
.tag-chip-name { border: 0; background: none; color: inherit; font: inherit; padding: 0 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; height: 100%; border-radius: 999px; }
.tag-chip-name:hover { text-decoration: underline; }
.tag-chip-x { display: grid; place-items: center; width: 18px; height: 18px; margin-inline-end: 2px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: .7; }
.tag-chip-x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.tag-chip-name:has(+ .tag-chip-x) { padding-inline-end: 2px; }
.row-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-inline-start: var(--s2); vertical-align: middle; }
.tag-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 36px; padding: 3px var(--s2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: text; transition: border-color .12s, box-shadow .12s; }
.tag-editor:hover { border-color: var(--control); }
.tag-editor:focus-within { border-color: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 7%, transparent); }
.tag-editor > .i { color: var(--muted); flex: none; }
.tag-editor-chips { display: contents; }
.tag-editor-input { flex: 1; min-width: 140px; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: var(--fs-sm); height: 28px; }
.field-wide { grid-column: 1 / -1; }
.record-form > .field { margin-top: var(--s3); }
.detail-tags { margin-top: var(--s4); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s4); }
.tag-cloud-item { display: inline-flex; align-items: center; gap: var(--s2); height: 34px; padding: 0 var(--s3); border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.tag-cloud-item:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.tag-cloud-item .count { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.tag-group { margin-bottom: var(--s4); }
.tag-group .card-head h2 { display: flex; align-items: center; gap: var(--s2); }
.kcard-labels .tag-chip { max-width: 140px; }

/* حافظهٔ روزبان */
.memory { display: flex; flex-direction: column; gap: var(--s3); }
.memory-list { border: 1px solid var(--border); border-radius: var(--radius); }
.memory-row { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3); }
.memory-row + .memory-row { border-top: 1px solid var(--border); }
.memory-ico { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--fill); color: var(--muted); margin-top: 2px; }
.memory-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.8; overflow-wrap: anywhere; }
.memory-text .muted { font-size: var(--fs-xs); }
.memory-actions { display: flex; flex: none; opacity: .55; transition: opacity .12s; }
.memory-row:hover .memory-actions, .memory-row:focus-within .memory-actions { opacity: 1; }
.memory-edit { flex: 1; display: flex; flex-direction: column; gap: var(--s2); }
.memory-empty { display: flex; align-items: center; gap: var(--s2); padding: var(--s3); color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.memory-add { display: flex; flex-direction: column; gap: var(--s2); }
.memory-add .row { align-items: center; gap: var(--s3); }
@media (hover: none) { .memory-actions { opacity: 1; } }
/* منوی راست‌کلیک و لمسِ طولانیِ سایدبار */
.sidebar .nav-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.nav-menu { min-width: 230px; }
.nav-menu .menu-head { padding-block: var(--s1); color: var(--muted); }

.delete-choices { display: flex; flex-direction: column; gap: var(--s2); }
.delete-choice { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.delete-choice:hover:not(:disabled) { background: var(--hover); border-color: var(--border-strong); }
.delete-choice > div { display: flex; flex-direction: column; gap: 2px; line-height: 1.8; }
.delete-choice span { color: var(--muted); font-size: var(--fs-sm); }
.delete-choice > .i { color: var(--muted); flex: none; margin-top: 3px; }
.delete-choice.danger > .i, .delete-choice.danger b { color: var(--danger, var(--h-red)); }
.delete-choice.danger:hover:not(:disabled) { border-color: var(--danger, var(--h-red)); }
.delete-choice:disabled { opacity: .5; cursor: not-allowed; }
.widget-list.sub-spaces { border-bottom: 1px solid var(--border); }
.nav-divider { border: 0; border-top: 1px solid var(--border); margin: var(--s3) var(--s2) 0; }
/* دکمه‌های ساختن: کم‌رنگ‌تر از آیتم‌های فهرست، چون «جا» نیستند، «کار»ند */
.nav-actions { margin-top: var(--s2); }
.nav-create { color: var(--muted); }
.nav-create:hover { color: var(--text); }
.nav-create .ico { color: var(--accent-text); }
.nav-group[hidden] { display: none; }
.nav-empty {
  margin: 0 var(--s2) 2px;
  padding: 2px var(--s2);
  border: 1px dashed transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--fs-xs);
}
.nav-dragging .nav-empty { border-color: var(--border-strong); padding-block: var(--s1); }
.nav-space.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.crumb {
  display: inline-block;
  padding: 0;
  margin-bottom: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.crumb:hover { color: var(--accent-text); text-decoration: underline; }

/* ============================================================ صفحهٔ خانه */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: start;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.stat:hover { border-color: var(--border-strong); background: var(--surface-2); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.3; color: var(--text); }
.stat-label { font-size: var(--fs-xs); color: var(--muted); }
.stat.overdue .stat-value { color: var(--h-red); }
.stat.today .stat-value { color: var(--h-green); }
.stat.done .stat-value { color: var(--h-green); }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.home-col { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }

.card-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); font-weight: 600; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-head h2 .i { color: var(--muted); }
.card-head .count { color: var(--muted); font-size: var(--fs-xs); }
.card-body { padding: var(--s4); }

/* دستورکار — فهرستی مثل Todoist، نه جدول */
.agenda-section + .agenda-section { border-top: 1px solid var(--border); }
.agenda-title {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  margin: 0;
  padding: var(--s3) var(--s4) var(--s1);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.agenda-title.overdue { color: var(--h-red); }
.agenda-title.today { color: var(--h-green); }
.agenda-title .count { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.agenda-list { padding: 0 var(--s2) var(--s2); }
.agenda-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 48px;
  padding: 6px var(--s2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, opacity .25s;
}
.agenda-row:hover, .agenda-row:focus-visible { background: var(--hover); outline: none; }
.agenda-row.done { opacity: .45; }
.agenda-row.done .agenda-text { text-decoration: line-through; }
.agenda-dot { width: 18px; height: 18px; flex: none; display: grid; place-items: center; }
.agenda-dot::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.agenda-main { flex: 1; min-width: 0; }
.agenda-text { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-meta { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--fs-xs); line-height: 1.6; }
.agenda-meta .pill { height: 18px; font-size: 11px; padding: 0 6px; }
.agenda-col { white-space: nowrap; }
.agenda-row .date { font-size: var(--fs-xs); flex: none; }
.agenda-more {
  margin: var(--s1) var(--s2);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.agenda-more:hover { text-decoration: underline; }

/* گزارش */
.report-title { font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1); }
.report-when { font-size: var(--fs-xs); margin-bottom: var(--s3); }
.report-chips { display: flex; flex-wrap: wrap; gap: var(--s1); margin-bottom: var(--s3); }
.report-text { white-space: pre-wrap; color: var(--text-2); line-height: 1.9; font-size: var(--fs-sm); }
.report-list { margin-top: var(--s3); }
.report-list-title { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.report-list ul { margin: var(--s1) 0 0; padding-inline-start: var(--s5); color: var(--text-2); font-size: var(--fs-sm); }
.report-history { display: flex; flex-direction: column; gap: var(--s3); }
.report-history .fold-card + .fold-card { margin-top: 0; }

/* نماهای سنجاق‌شده */
.widget-list { padding: var(--s1) var(--s2); }
.widget-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 40px;
  padding: var(--s1) var(--s2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.widget-row:hover, .widget-row:focus-visible { background: var(--hover); outline: none; }
.widget-row + .widget-row { border-top: 1px solid var(--border); }
.widget-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.widget-row.struck .widget-title { text-decoration: line-through; color: var(--muted); }
.widget-cells { display: flex; align-items: center; gap: var(--s2); flex: none; font-size: var(--fs-xs); color: var(--text-2); }
.widget-cell .pill { height: 20px; font-size: 11px; }
.widget-foot { display: flex; flex-wrap: wrap; gap: var(--s4); padding: var(--s2) var(--s4); border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); }

.home-hint { padding: var(--s4); }
.home-hint .title { display: flex; align-items: center; gap: var(--s2); font-weight: 600; margin-bottom: var(--s1); }
.home-hint p { margin: 0 0 var(--s3); color: var(--muted); font-size: var(--fs-sm); }

/* چیدمان با کشیدن: دستگیره بالای هر کارت، فقط زیر ماوس */
.home-card { position: relative; }
.home-col { min-height: 80px; }
.card-grip {
  position: absolute;
  top: -1px;
  inset-inline: 0;
  margin-inline: auto;
  width: 40px;
  height: 14px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0 0 6px 6px;
  background: var(--fill);
  color: var(--muted);
  cursor: grab;
  opacity: 0;
  z-index: 3;
  transition: opacity .12s;
}
.card-grip .i { transform: rotate(90deg); }
.home-card:hover > .card-grip, .card-grip:focus-visible { opacity: 1; }
.card-grip:active { cursor: grabbing; }
@media (hover: none) { .card-grip { opacity: .7; } }
.home-card.dragging { opacity: .45; }
.home-grid.arranging .home-col {
  outline: 2px dashed var(--border-strong);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
}

/* برنامهٔ امروز */
.schedule-day { padding: var(--s2) var(--s2) 0; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.schedule-time { flex: none; min-width: 64px; font-size: var(--fs-sm); color: var(--accent-text); font-weight: 600; }
.agenda-title .i { color: var(--muted); }

@media (max-width: 1100px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================ اتصال‌ها */

.section-heading { font-size: var(--fs-lg); font-weight: 700; margin: var(--s8) 0 var(--s3); }
.integration-body { display: flex; flex-direction: column; gap: var(--s4); }
.integration-setup, .integration-sync { display: flex; flex-direction: column; gap: var(--s4); }
.steps { margin: 0; padding-inline-start: var(--s5); display: flex; flex-direction: column; gap: var(--s2); color: var(--text-2); font-size: var(--fs-sm); line-height: 1.9; }
.copyable {
  display: inline-block;
  padding: 2px var(--s2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  font-size: 12px;
  user-select: all;
  overflow-wrap: anywhere;
}
.push-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); }
.push-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); }
.push-row + .push-row { border-top: 1px solid var(--border); }
.push-row .select { max-width: 200px; }
.error-text { color: var(--h-red); }

/* ============================================================ ورود و ثبت‌نام */

body.auth-mode .app { grid-template-columns: minmax(0, 1fr); }
body.auth-mode .sidebar { display: none; }
body.auth-mode .main { padding: 0; }

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s8) var(--s4);
  background:
    radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--sidebar);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--s8) var(--s8) var(--s6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: var(--s4); }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-sub { color: var(--muted); text-align: center; font-size: var(--fs-sm); margin: var(--s1) 0 var(--s6); }
.auth-form { display: flex; flex-direction: column; gap: var(--s4); }
.auth-form .input { min-height: 42px; }
.auth-submit { height: 42px; font-size: var(--fs); margin-top: var(--s1); }
.auth-error {
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--h-red) 10%, transparent);
  color: var(--h-red);
  font-size: var(--fs-sm);
}
.auth-link { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; cursor: pointer; }
.auth-link:hover { text-decoration: underline; }
.auth-link.small { align-self: flex-start; font-weight: 500; font-size: var(--fs-xs); margin-top: calc(-1 * var(--s2)); }
.auth-switch { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.auth-done { display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center; color: var(--text-2); }
.auth-done .i { color: var(--h-green); }

/* ============================================================ کاربر و منو */

.brand .spacer { margin-inline-start: auto; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 150px;
  height: 30px;
  padding: 0 6px 0 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.user-chip:hover { background: var(--hover); }
.user-chip .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.user-chip .tag { margin: 0; }
.avatar {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hue, var(--h-blue)) 18%, var(--surface));
  color: color-mix(in srgb, var(--hue, var(--h-blue)) 85%, var(--text));
  font-size: 12px;
  font-weight: 700;
}
.menu-pop {
  position: fixed;
  z-index: 150;
  min-width: 220px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: pop-in .14s ease;
}
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: var(--s1) 0; }
.menu-head { display: flex; flex-direction: column; padding: var(--s2) var(--s3); line-height: 1.5; }
.menu-head .muted { font-size: var(--fs-xs); }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: 34px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: start;
  cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item .i { color: var(--muted); }
.menu-item.danger, .menu-item.danger .i { color: var(--h-red); }

/* ============================================================ زبانه‌ها و پنل مدیریت */

.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin-bottom: var(--s5); overflow-x: auto; }
.tab {
  height: 38px;
  padding: 0 var(--s3);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent-text); border-bottom-color: var(--accent); }
.admin-body { display: flex; flex-direction: column; gap: var(--s3); }
.admin-body .stats { margin-bottom: 0; }
.stat.static { cursor: default; }
.stat.static:hover { background: var(--surface); border-color: var(--border); }
.mail-body {
  margin: var(--s3) 0 0;
  padding: var(--s3);
  background: var(--surface-2);
  border-radius: var(--radius);
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* ============================================================ خوشامد */

.onboard {
  max-width: 760px;
  margin: 6vh auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s3);
}
.onboard h1 { font-size: 26px; }
.onboard-sub { color: var(--text-2); max-width: 520px; margin: 0 0 var(--s4); }
.onboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s3); width: 100%; }
.onboard-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.onboard-choice:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.onboard-choice.primary { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.onboard-ico { font-size: 22px; color: var(--accent-text); display: grid; }
.onboard-title { font-weight: 700; font-size: var(--fs-lg); }
.onboard-text { color: var(--muted); font-size: var(--fs-sm); line-height: 1.8; }

/* چیدنِ اولیه با دستیار */
.onboard-chat { max-width: 680px; margin-top: 3vh; text-align: start; align-items: stretch; }
.onboard-chat h1 { text-align: center; }
.onboard-chat-log {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-height: 160px;
  max-height: 52vh;
  overflow-y: auto;
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.onboard-chat-log .msg { font-size: var(--fs); }
.onboard-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.onboard-examples .pick { --hue: var(--accent); height: auto; min-height: 28px; padding: 4px var(--s3); white-space: normal; text-align: start; }
.onboard-input { display: flex; gap: var(--s2); align-items: flex-end; }
.onboard-input .textarea { flex: 1; resize: none; }
.onboard-title .tag { margin-inline-start: var(--s2); vertical-align: middle; }

/* ============================================================ اشتراک و پلن‌ها */

.menu-plan { margin-top: var(--s1); }
.current-plan { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.plan-name { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: var(--s2); }
.usage { display: flex; flex-direction: column; gap: var(--s2); max-width: 420px; }
.usage-label { font-size: var(--fs-sm); color: var(--text-2); }
.usage-bar { height: 6px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.usage-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.period-toggle { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--fill); }
.period-toggle .tab { height: 30px; border: 0; margin: 0; border-radius: calc(var(--radius) - 2px); }
.period-toggle .tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm, 0 1px 2px rgb(0 0 0 / .08)); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s4); }
.plan-card {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.plan-card.featured {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 3%, var(--surface));
  box-shadow: var(--shadow);
}
.plan-card > .btn { margin-top: auto; justify-content: center; }
.plan-title { font-size: var(--fs-lg); font-weight: 700; }
.plan-price { font-size: 24px; font-weight: 700; }
.plan-price .muted { font-size: var(--fs-sm); font-weight: 400; }
.plan-desc { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; }
.plan-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); font-size: var(--fs-sm); }
.plan-features li { display: flex; align-items: center; gap: var(--s2); }
.plan-features li.yes .i { color: var(--h-green); }
.plan-features li.no { color: var(--muted); }
.plan-features li.no .i { color: var(--muted); }

.upgrade { display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center; }
.upgrade .plan-features { align-self: stretch; text-align: start; }
.upgrade-ico {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.upgrade-text { margin: 0; font-weight: 600; }
.upgrade-notice { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }

/* ============================================================ گزارش‌ها */

.report-cats { margin-bottom: var(--s4); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s3); }
.report-card {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.report-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.report-card-head { display: flex; align-items: center; gap: var(--s2); }
.report-card-ico { color: var(--accent-text); display: grid; }
.report-card-title { font-size: var(--fs-lg); }
.report-card-desc { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; }
.report-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.report-card-foot { display: flex; gap: var(--s2); font-size: var(--fs-xs); margin-top: auto; }
.report-empty p { max-width: 520px; margin: var(--s2) auto 0; color: var(--text-2); line-height: 1.9; }
.report-empty .actions { flex-wrap: wrap; }
.report-empty .select { max-width: 240px; }

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  padding: var(--s3);
  margin-bottom: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.report-toolbar .select { width: auto; max-width: 280px; }
.report-run { display: flex; flex-direction: column; gap: var(--s4); }
.report-period { font-size: var(--fs-sm); }
.report-status { padding: var(--s4) var(--s5); }
.report-status-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.report-status-ico { color: var(--accent-text); display: grid; }
.report-status-body { white-space: pre-wrap; line-height: 2; color: var(--text); }

.report-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s3); }
.kpi { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s1); }
.kpi-label { color: var(--text-2); font-size: var(--fs-sm); }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.3; }
.kpi-delta { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); }
.kpi-delta.good { color: var(--h-green); }
.kpi-delta.bad { color: var(--h-red); }
.kpi-delta .muted { color: var(--muted); }

/* dense: بلوک‌های نیم‌عرض کنار هم می‌نشینند، حتی اگر یک بلوکِ تمام‌عرض بینشان باشد */
.report-blocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; gap: var(--s3); }
.report-block { display: flex; flex-direction: column; min-width: 0; }
.report-block.full { grid-column: 1 / -1; }
.report-block-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4) 0; }
.report-block-tools { display: flex; align-items: center; gap: var(--s1); font-size: var(--fs-xs); }
.report-block-body { padding: var(--s3) var(--s4); min-width: 0; }
.report-block-foot { padding: 0 var(--s4) var(--s3); font-size: var(--fs-xs); }
.report-block-error { display: flex; align-items: center; gap: var(--s2); padding: var(--s4); color: var(--h-red); font-size: var(--fs-sm); }
.report-text { white-space: pre-wrap; line-height: 2; }
.empty.small { padding: var(--s5); font-size: var(--fs-sm); }
.link-btn { border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; text-align: start; font: inherit; }
.link-btn:hover { color: var(--accent-text); text-decoration: underline; }
tfoot td { font-weight: 600; background: var(--surface-2); }

.progress-big { display: flex; flex-direction: column; gap: var(--s3); }
.progress-num { font-size: 34px; font-weight: 700; line-height: 1; }
.progress-meter { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--series-1) 18%, var(--surface)); overflow: hidden; }
.progress-meter span { display: block; height: 100%; border-radius: inherit; background: var(--series-1); }
.progress-legend { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: var(--fs-sm); color: var(--text-2); }
.progress-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch.track { background: color-mix(in srgb, var(--series-1) 18%, var(--surface)); }
.overdue-note { color: var(--h-red); }

/* ویرایشگر گزارش */
.block-list { display: flex; flex-direction: column; gap: var(--s2); margin: var(--s3) 0; }
.block-editor { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); background: var(--surface-2); }
.block-editor-head { display: flex; align-items: center; gap: var(--s2); }
.block-editor-head .input { flex: 1; }
.block-editor-head .flip .i { transform: rotate(180deg); }

/* نمودارها */
.chart { position: relative; min-width: 0; }
.chart-canvas { width: 100%; min-width: 0; }
.chart-svg { display: block; overflow: visible; font-family: inherit; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-base { stroke: var(--border-strong); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-label { fill: var(--text-2); font-size: 12px; }
.chart-value { fill: var(--text-2); font-size: 11px; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { opacity: .1; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-cross { stroke: var(--border-strong); stroke-width: 1; }
.chart-hit { fill: transparent; cursor: default; }
.chart-hit.on { fill: color-mix(in srgb, var(--text) 4%, transparent); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-bottom: var(--s2); font-size: var(--fs-xs); color: var(--text-2); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 140px;
  max-width: 260px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: var(--fs-xs);
  pointer-events: none;
}
.chart-tip-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.chart-tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip-name { flex: 1; }
.chart-tip-row b { color: var(--text); }
.chart-table td, .chart-table th { white-space: nowrap; }
.donut-body { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.donut-track { fill: none; stroke: var(--surface-2); }
.donut-seg { cursor: default; }
.donut-total { fill: var(--text); font-size: 20px; font-weight: 700; }
.donut-legend { display: flex; flex-direction: column; gap: var(--s2); flex: 1; min-width: 160px; font-size: var(--fs-sm); }
.donut-row { display: flex; align-items: center; gap: var(--s2); }
.donut-name { flex: 1; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-val { color: var(--text); }
.donut-pct { width: 40px; text-align: end; }

@media (max-width: 860px) {
  .report-blocks { grid-template-columns: minmax(0, 1fr); }
  .report-toolbar { align-items: stretch; }
}

/* چاپ / PDF: فقط خودِ گزارش */
/* ============================================================ روتین‌ها */

.routine-list { display: flex; flex-direction: column; gap: var(--s3); }
.routine-card { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.routine-card.off { background: var(--surface-2); }
.routine-card.off .routine-title, .routine-card.off .routine-prompt { color: var(--text-2); }
.routine-head { display: flex; align-items: center; gap: var(--s2); }
.routine-title { font-size: var(--fs-lg); min-width: 0; }
.routine-prompt {
  margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.9;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.routine-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.routine-chan {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--text-2);
}
.routine-chan.warn { color: var(--h-orange); border-color: currentColor; }
.routine-last summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: var(--fs-sm); color: var(--text-2);
}
.routine-last summary .ico, .routine-last summary svg { color: var(--h-red); }
.routine-output {
  margin-top: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--radius);
  background: var(--surface-2); white-space: pre-wrap; line-height: 2; color: var(--text);
}
.routine-output.failed { color: var(--h-red); }
.routine-runs { display: flex; flex-direction: column; gap: var(--s3); max-height: 60vh; overflow: auto; }
.routine-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.routine-say {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  margin-top: var(--s4); padding: var(--s3) var(--s4);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  color: var(--text-2); font-size: var(--fs-sm); line-height: 1.9;
}
.routine-say > span:nth-child(2) { flex: 1 1 260px; }
.routine-say-ico { color: var(--accent-text); display: grid; }
.routine-empty p { max-width: 520px; margin: var(--s2) auto 0; color: var(--text-2); line-height: 1.9; }
.routine-empty + .routine-templates { margin-top: var(--s4); }
.routine-upgrade { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }
.routine-upgrade p { margin: 0; color: var(--text-2); line-height: 1.9; }

/* کلیدِ روشن/خاموش */
.switch { position: relative; display: inline-flex; cursor: pointer; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background .15s;
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: inset-inline-start .15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { inset-inline-start: 18px; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================ نما: جدول | تخته */

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--fill);
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.select.sm { min-height: 28px; height: 28px; padding: 0 8px; font-size: var(--fs-xs); width: auto; }

/* ============================================================ تخته (کانبان) */

.board-bar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); min-height: 28px; }
.board-group-by { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.board-count { font-size: var(--fs-xs); }
.board-tip { margin-inline-start: auto; font-size: var(--fs-xs); }

.board {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  overflow-x: auto;
  padding-bottom: var(--s4);
  /* تخته تا لبهٔ صفحه می‌رود تا ستون‌های بیشتری جا شوند */
  margin-inline: calc(-1 * var(--s10));
  padding-inline: var(--s10);
  scroll-padding-inline: var(--s10);
  min-height: 60vh;
}
.kcol {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 210px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color .12s, background .12s;
}
.kcol.drop { border-color: color-mix(in srgb, var(--hue, var(--accent)) 55%, transparent); background: color-mix(in srgb, var(--hue, var(--accent)) 5%, var(--surface-2)); }
.kcol-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s3) var(--s2);
  border-top: 3px solid color-mix(in srgb, var(--hue, var(--h-slate)) 70%, transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kcol.none .kcol-head { border-top-style: dashed; }
.kcol-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hue, var(--h-slate)); flex: none; }
.kcol-title { font-size: var(--fs-sm); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcol-count {
  margin-inline-start: auto;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.kcol-cards {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s1) var(--s2) var(--s2);
  overflow-y: auto;
  min-height: 48px;
  flex: 1;
}
.kcol-add { padding: 0 var(--s2) var(--s2); display: flex; flex-direction: column; gap: var(--s2); }
.kcol-add .row { gap: var(--s1); }
.kcol-add-btn {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  height: 34px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.kcol-add-btn:hover { background: var(--hover); color: var(--text); }
.kcol.add-col { background: transparent; border-style: dashed; padding: var(--s2); gap: var(--s2); }
.kcard-input { min-height: 60px; resize: none; }

.kcard {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: 10px var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.kcard:hover { border-color: var(--border-strong); box-shadow: 0 2px 6px rgba(0, 0, 0, .07); }
.kcard:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.kcard.lifted { transform: scale(1.02); box-shadow: var(--shadow); }
.kcard-title { display: flex; align-items: flex-start; gap: var(--s2); font-size: var(--fs); line-height: 1.6; overflow-wrap: anywhere; }
.kcard-title .tick { margin-top: 3px; flex: none; }
.kcard.struck .kcard-title span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.kcard-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.pill.sm { height: 18px; padding: 0 6px; font-size: 11px; }
.kcard-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
  unicode-bidi: isolate;
}
.kchip .i { color: var(--muted); flex: none; }
.kchip.done { background: color-mix(in srgb, var(--h-green) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-green) var(--pill-text), var(--text)); }
.kchip.done .i { color: inherit; }
.date-chip.overdue { background: color-mix(in srgb, var(--h-red) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-red) var(--pill-text), var(--text)); }
.date-chip.today { background: color-mix(in srgb, var(--h-green) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-green) var(--pill-text), var(--text)); }
.date-chip.tomorrow { background: color-mix(in srgb, var(--h-orange) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-orange) var(--pill-text), var(--text)); }
.date-chip.overdue .i, .date-chip.today .i, .date-chip.tomorrow .i { color: inherit; }
.kcard-people { display: inline-flex; margin-inline-start: auto; }
.kcard-people .avatar + .avatar { margin-inline-start: -6px; }
.kcard-people .avatar { box-shadow: 0 0 0 2px var(--surface); }

/* کارتی که در دست است؛ مختصاتِ fixed از خودِ اشاره‌گر می‌آید (فیزیکی، نه منطقی) */
.kcard-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow);
  opacity: .96;
  transition: none;
}
.kcard-placeholder {
  border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--border-strong));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  flex: none;
}
body.board-dragging, body.board-dragging * { cursor: grabbing !important; user-select: none; }

/* ============================================================ آدم‌ها */

.avatar.ghost { background: var(--fill); color: var(--muted); }
.avatar.more { background: var(--fill); color: var(--text-2); font-size: 11px; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-pick { gap: var(--s1); }
.person-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding-block: 0;
  padding-inline: 4px var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.person-pick:hover { background: var(--hover); }
.person-pick.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.shared-mark { display: inline-flex; margin-inline-start: 6px; color: var(--muted); vertical-align: -1px; }
.row-comments {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-inline-start: 6px;
  color: var(--muted);
  font-size: 11px;
  vertical-align: middle;
  unicode-bidi: isolate;
  flex: none;
}

.member-stack {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding-block: 0;
  padding-inline: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.member-stack:hover { background: var(--hover); }
.member-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.member-stack .avatar + .avatar { margin-inline-start: -8px; }
.member-stack .stack-label { margin-inline: var(--s2) 6px; }

.members { display: flex; flex-direction: column; gap: var(--s4); }
.invite-form { display: flex; flex-direction: column; gap: var(--s2); }
.invite-row { display: flex; gap: var(--s2); align-items: center; }
.invite-row .input { flex: 1; min-width: 0; }
.invite-row .select { width: auto; flex: none; }
.invite-result {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--h-green) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--h-green) 25%, transparent);
  font-size: var(--fs-sm);
  line-height: 1.8;
}
.invite-result .i { color: var(--h-green); vertical-align: -3px; }
.member-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); }
.member-row { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); }
.member-row + .member-row { border-top: 1px solid var(--border); }
.member-row.pending { background: var(--surface-2); }
.member-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.5; }
.member-text b { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-text span { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-help { font-size: var(--fs-sm); color: var(--text-2); }
.role-help summary { cursor: pointer; color: var(--muted); }
.role-help ul { margin: var(--s2) 0 0; padding-inline-start: var(--s5); line-height: 1.9; }

.backup-actions { text-align: end; white-space: nowrap; width: 1%; }

/* ---- اشتراک‌گذاری: راهنمای همکاری و انتخابِ فضا برای موجودیتِ بی‌فضا */
.collab-how { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: var(--s2) var(--s3); font-size: var(--fs-sm); color: var(--text-2); }
.collab-how summary { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--text); list-style: none; }
.collab-how summary::-webkit-details-marker { display: none; }
.collab-how ol { margin: var(--s2) 0 var(--s1); padding-inline-start: var(--s5); line-height: 1.9; }
.shared-scope { display: flex; align-items: flex-start; gap: 6px; line-height: 1.8; }
.shared-scope .i { flex: none; margin-top: 4px; }
.share-lead { margin: 0 0 var(--s4); line-height: 1.9; color: var(--text-2); }
.share-choices { display: flex; flex-direction: column; gap: var(--s2); }
.share-choice { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.share-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.share-choice input[type=radio] { margin-top: 5px; accent-color: var(--accent); }
.share-choice > div { display: flex; flex-direction: column; gap: var(--s2); flex: 1; min-width: 0; }
.share-choice .input:disabled, .share-choice .select:disabled { opacity: .5; }
.upgrade-note { display: flex; align-items: center; gap: var(--s2); }
.upgrade-note .btn { margin-inline-start: auto; }
.invite-banner { display: flex; gap: var(--s2); align-items: flex-start; margin-bottom: var(--s3); background: color-mix(in srgb, var(--h-blue) 7%, var(--surface)); border-color: color-mix(in srgb, var(--h-blue) 22%, transparent); }
.invite-banner .i { color: var(--h-blue); flex: none; margin-top: 4px; }

/* ============================================================ زنگولهٔ اعلان */

.bell-btn { position: relative; color: var(--text-2); }
.bell-badge {
  position: absolute;
  top: 2px;
  inset-inline-end: 1px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--sidebar);
}
.note-pop {
  position: fixed;
  z-index: 150;
  width: 380px;
  max-height: min(560px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.1);
}
.note-head { display: flex; align-items: center; gap: var(--s1); padding-block: var(--s3) var(--s2); padding-inline: var(--s4) var(--s2); }
.note-head b { font-size: var(--fs); }
.note-head .spacer { flex: 1; }
.note-tabs { display: flex; gap: var(--s1); padding: 0 var(--s3); border-bottom: 1px solid var(--border); }
.note-tab {
  height: 34px;
  padding: 0 var(--s2);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.note-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.note-list { overflow-y: auto; padding: var(--s1); display: flex; flex-direction: column; }
.note-item {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  width: 100%;
  padding: 10px var(--s3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: start;
  font: inherit;
  cursor: pointer;
}
.note-item:hover { background: var(--hover); }
.note-item.static { cursor: default; }
.note-item.unread { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.note-item.unread:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.note-ico {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  --hue: var(--h-slate);
  background: color-mix(in srgb, var(--hue) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--hue) var(--pill-text), var(--text));
}
.note-ico.k-reminder { --hue: var(--h-orange); }
.note-ico.k-assign { --hue: var(--h-blue); }
.note-ico.k-mention, .note-ico.k-comment { --hue: var(--h-violet); }
.note-ico.k-invite { --hue: var(--h-green); }
.note-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; line-height: 1.6; }
.note-text.linkish { border: 0; background: none; padding: 0; text-align: start; font: inherit; color: inherit; cursor: pointer; }
.note-title { font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.note-item:not(.unread) .note-title { font-weight: 500; }
.note-body { font-size: var(--fs-xs); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; align-items: center; gap: var(--s2); font-size: 11.5px; color: var(--muted); }
.note-sent { display: inline-flex; gap: 3px; }
.note-dot { width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.note-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s8) var(--s5); text-align: center; color: var(--muted); font-size: var(--fs-sm); line-height: 1.8; }
.note-empty b { color: var(--text); }
.note-empty .i { color: var(--faint); }
.note-foot { padding: var(--s2) var(--s3); border-top: 1px solid var(--border); margin-top: var(--s1); }

/* ============================================================ گفتگوی رکورد */

.modal.record-modal { max-width: 1040px; }
.record-modal .modal-body { padding: 0; overflow: hidden; }
.record-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; height: 100%; }
.record-form { padding: var(--s5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); max-height: calc(100vh - 210px); }
.record-form .form-grid { display: flex; flex-direction: column; gap: var(--s4); }
.record-side { border-inline-start: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 210px); }
.record-tools { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.reminder-chips { display: inline-flex; flex-wrap: wrap; gap: var(--s1); }
.reminder-chips:empty { display: none; }
.reminder-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding-inline: 8px 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--h-orange) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--h-orange) var(--pill-text), var(--text));
  font-size: var(--fs-xs);
  font-weight: 500;
}
.chip-x { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: .7; }
.chip-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }

.thread { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.thread-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); color: var(--text-2); }
.thread-head b { color: var(--text); font-size: var(--fs-sm); }
.thread-head .spacer { flex: 1; }
.thread-count { font-size: var(--fs-xs); }
.thread-toggle { font-size: var(--fs-xs); color: var(--muted); gap: 6px; }
.thread-list { flex: 1; overflow-y: auto; padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s3); min-height: 120px; }
.thread-empty { color: var(--muted); font-size: var(--fs-sm); line-height: 1.9; padding: var(--s4) 0; text-align: center; }
.comment { display: flex; gap: var(--s2); align-items: flex-start; }
.comment-main { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; font-size: var(--fs-xs); }
.comment-meta b { font-size: var(--fs-sm); }
.comment-actions { display: inline-flex; gap: var(--s2); margin-inline-start: auto; opacity: 0; transition: opacity .12s; }
.comment:hover .comment-actions, .comment:focus-within .comment-actions { opacity: 1; }
.comment-actions .link-btn { font-size: var(--fs-xs); color: var(--muted); }
.comment-actions .link-btn.danger:hover { color: var(--h-red); }
.comment-body {
  margin-top: 4px;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-start-start-radius: 4px;
  font-size: var(--fs-sm);
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment.mine .comment-body { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 14%, var(--border)); }
.comment-edit { display: flex; flex-direction: column; gap: var(--s2); margin-top: 4px; }
.mention { color: var(--h-blue); font-weight: 600; }
.event { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--fs-xs); color: var(--text-2); line-height: 1.8; padding-inline-start: 9px; }
.event-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; flex: none; background: var(--border-strong); }
.event-dot.k-completed { background: var(--h-green); }
.event-dot.k-created { background: var(--h-blue); }
.event-dot.k-reopened { background: var(--h-amber); }
.event-text b { color: var(--text); font-weight: 600; }

.composer { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4); border-top: 1px solid var(--border); background: var(--surface); }
.composer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; position: relative; }
.composer-input { min-height: 40px; max-height: 220px; resize: none; line-height: 1.8; }
.composer-foot { display: flex; align-items: center; gap: var(--s2); }
.composer-hint { font-size: 11px; color: var(--muted); flex: 1; }
.onboard-joined { display: flex; align-items: center; gap: var(--s3); max-width: 720px; margin: 0 auto var(--s5); text-align: start; }
.onboard-joined > .i { color: var(--h-blue); flex: none; }
.onboard-joined .btn { flex: none; }
.switch input:disabled + .switch-track { opacity: .45; cursor: not-allowed; }
.kbd-inline { font-family: inherit; direction: ltr; unicode-bidi: isolate; }
.mention-pop {
  position: absolute;
  bottom: calc(100% + 4px);
  inset-inline-start: 0;
  z-index: 5;
  min-width: 200px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mention-opt { display: flex; align-items: center; gap: var(--s2); width: 100%; height: 34px; padding: 0 var(--s2); border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: start; }
.mention-opt.on, .mention-opt:hover { background: var(--hover); }

.detail-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s4); align-items: start; margin-bottom: var(--s4); }
.detail-split > .card { margin: 0; }
.thread-card { padding: 0; overflow: hidden; position: sticky; top: var(--s4); max-height: calc(100vh - 40px); display: flex; }
.thread-card .thread { width: 100%; }

/* ============================================================ یادآوری و ترجیح اعلان‌ها */

.reminder-presets { gap: var(--s1); }
.rule-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; flex-wrap: wrap; }
.rule-row + .rule-row { border-top: 1px solid var(--border); }
.rule-row .spacer { flex: 1; }
.rule-row .select { width: auto; }
.rule-row .row { gap: var(--s2); align-items: center; }
.rule-row .input[type=time] { width: 110px; }
.rule-row.off b { color: var(--muted); }
.rule-row.off .select, .rule-row.off .row { opacity: .45; pointer-events: none; }

.settings-card-head { display: flex; align-items: center; gap: var(--s2); color: var(--text-2); }
.settings-card-head h2 { font-size: var(--fs-lg); color: var(--text); }
#notify-settings { display: flex; flex-direction: column; gap: var(--s2); scroll-margin-top: var(--s4); }
.pref-title { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; margin: var(--s3) 0 0; }
.pref-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; }
.pref-row + .pref-row { border-top: 1px solid var(--border); }
.pref-row > .i { color: var(--muted); flex: none; }
.pref-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.6; }
.pref-text b { font-weight: 500; font-size: var(--fs-sm); }
.pref-text .muted { font-size: var(--fs-xs); }
.pref-text > .ltr { align-self: flex-start; }

/* ============================================================ قالب‌ها */

.section-head { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); font-weight: 700; margin: var(--s6) 0 var(--s3); }
.section-head .i { color: var(--muted); }
.section-head .muted { font-weight: 400; font-size: var(--fs-sm); }
.page-head + .section-head { margin-top: 0; }
.inline-field { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }
.inline-field .select { width: auto; min-width: 160px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); }
.tpl {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.tpl:hover { border-color: var(--border-strong); box-shadow: 0 2px 10px rgba(0, 0, 0, .06); }
.tpl-preview {
  height: 92px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--tpl) 9%, var(--surface-2));
  border-bottom: 1px solid var(--border);
}
.tpl-body { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); flex: 1; }
.tpl-body h3 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); }
.tpl-body h3 .ent-ico { color: var(--tpl); }
.tpl-body p { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; flex: 1; }
.tpl-foot { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.tpl-foot .spacer { flex: 1; }
.pv-board { display: flex; gap: 6px; align-items: flex-start; }
.pv-col { width: 46px; padding: 5px; border-radius: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.pv-col i { height: 3px; border-radius: 2px; background: var(--hue); }
.pv-col b { height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--tpl) 22%, var(--fill)); }
.pv-table { width: 150px; padding: 6px; border-radius: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 5px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.pv-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 5px; }
.pv-row b { height: 6px; border-radius: 3px; background: var(--fill-hover); }
.pv-row.head b { background: color-mix(in srgb, var(--tpl) 35%, var(--fill)); }

@media (max-width: 1100px) {
  .record-split, .detail-split { grid-template-columns: minmax(0, 1fr); }
  .record-side { border-inline-start: 0; border-top: 1px solid var(--border); max-height: none; }
  .record-form { max-height: none; overflow: visible; }
  .record-modal .modal-body { overflow-y: auto; }
  .thread-card { position: static; max-height: none; }
  .thread-list { max-height: 420px; }
}

@media (max-width: 860px) {
  .board { margin-inline: calc(-1 * var(--s4)); padding-inline: var(--s4); scroll-padding-inline: var(--s4); scroll-snap-type: x proximity; }
  .kcol { flex-basis: 84vw; max-width: 320px; scroll-snap-align: start; max-height: calc(100vh - 200px); }
  .board-tip { display: none; }
  .seg-label { display: none; }
  .seg-btn { padding: 0 var(--s2); }
  .btn-label { display: none; }
  .note-pop {
    inset: auto 0 0 0;
    width: auto;
    max-height: 80vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: sheet-up .2s cubic-bezier(.2, .9, .3, 1);
  }
  .invite-row { flex-wrap: wrap; }
  .invite-row .btn { flex: 1; }
  .member-stack .stack-label { display: none; }
  .inline-field { width: 100%; }
  .inline-field .select { flex: 1; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }


@media print {
  body.printing-report .sidebar, body.printing-report #chat-toggle, body.printing-report #chat,
  body.printing-report .report-toolbar, body.printing-report .page-head .actions, body.printing-report .crumb,
  body.printing-report .report-block-tools, body.printing-report .toast { display: none !important; }
  body.printing-report .app { display: block; }
  body.printing-report main { padding: 0; max-width: none; }
  body.printing-report .card { box-shadow: none; break-inside: avoid; }
  body.printing-report .report-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ربات تلگرام و بله */
.plan-features.levels { flex-direction: row; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.link-steps { display: flex; flex-direction: column; gap: var(--s2); }
.link-steps p { margin: 0; }

/* مصرف و هزینه: نمودار ستونی ساده */
.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
  padding-top: var(--s2);
  direction: ltr;              /* زمان از چپ به راست، مثل محور نمودار */
}
.usage-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}
.usage-fill {
  width: 100%;
  max-width: 28px;
  border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--accent) 75%, transparent);
  transition: background .12s;
}
.usage-col:hover .usage-fill { background: var(--accent); }
.usage-x { font-size: 10px; color: var(--muted); line-height: 1; }

/* پنل مدیریت: ویرایش پلن */
.plan-editor { display: flex; flex-direction: column; gap: var(--s4); }
.check-grid { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); }
.card-body > b { font-size: var(--fs); }
.admin-body .card-body { display: flex; flex-direction: column; gap: var(--s3); }

/* ============================================================ واکنش‌گرا */

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  /* گوشی: نوارِ بالا با دکمهٔ همبرگری؛ سایدبار کشویی است که از سمتِ راست باز می‌شود */
  .mobilebar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 45;
    align-items: center;
    gap: var(--s1);
    height: 54px;
    padding: 0 var(--s2);
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
  }
  body.auth-mode .mobilebar { display: none; }
  .mobilebar .spacer { flex: 1; }
  .mobilebar .btn.icon { width: 40px; height: 40px; }
  .mobilebar-brand { display: flex; align-items: center; gap: var(--s2); border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; padding: 0 var(--s1); cursor: pointer; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 60;
    width: min(300px, 86vw);
    height: 100dvh;
    padding: var(--s3) var(--s2) var(--s6);
    box-shadow: var(--shadow);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s .22s;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  .drawer-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .2s; display: block; }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  body.drawer-open #chat-toggle { display: none; }
  .brand .drawer-close { display: inline-flex; }
  .nav-item, .quick-open { min-height: 42px; }
  .quick-open .kbd { display: none; }

  .main { padding: var(--s5) var(--s4) 96px; }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .search-box { width: 100%; }
  .page-head .actions { width: 100%; }
  .page-head .actions .search-box { flex: 1; }
  .table-wrap.scroll-y { max-height: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-toggle { width: 28px; height: 28px; }
}
