/* ═══ سامانه مدیریت نمافر — دیزاین‌سیستم فاز ۲ ═══
   برند: سرمه‌ای #2B3054 / فیروزه‌ای #39B9C8 · فونت Estedad · RTL · تم روشن/تیره */

@font-face { font-family: 'Estedad'; font-weight: 400; font-display: swap; src: url('/fonts/Estedad-400.woff2') format('woff2'); }
@font-face { font-family: 'Estedad'; font-weight: 700; font-display: swap; src: url('/fonts/Estedad-700.woff2') format('woff2'); }
@font-face { font-family: 'Estedad'; font-weight: 900; font-display: swap; src: url('/fonts/Estedad-900.woff2') format('woff2'); }

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── توکن‌ها ── */
:root {
  --brand: #2B3054; --brand-2: #3d4373;
  --accent: #39B9C8; --accent-2: #5dcad7; --accent-soft: #e4f6f8;
  --bg: #f2f5f9; --surface: #ffffff; --surface-2: #f7f9fc;
  --border: #e4e9f0; --border-2: #d5dce6;
  --text: #1d2236; --text-2: #5b6478; --text-3: #8b93a7;
  --danger: #d94848; --danger-soft: #fdeaea;
  --warn: #c98a1e; --warn-soft: #fdf3dd;
  --ok: #2f9e6e; --ok-soft: #e6f6ee;
  --purple: #7c5cd1; --purple-soft: #efeafc;
  --shadow-1: 0 1px 3px rgba(23,28,58,.07);
  --shadow-2: 0 8px 24px rgba(23,28,58,.12);
  --shadow-3: 0 24px 64px rgba(23,28,58,.28);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --sb-w: 244px; --sb-w-min: 64px;
}
[data-theme="dark"] {
  --brand: #39B9C8; --brand-2: #2a97a5;
  --accent: #39B9C8; --accent-2: #5dcad7; --accent-soft: rgba(57,185,200,.14);
  --bg: #131628; --surface: #1b1f36; --surface-2: #222745;
  --border: #2b3052; --border-2: #3a4066;
  --text: #e8eaf5; --text-2: #a3aac4; --text-3: #6d7492;
  --danger: #ef6a6a; --danger-soft: rgba(239,106,106,.14);
  --warn: #e0a83e; --warn-soft: rgba(224,168,62,.14);
  --ok: #4dbd8c; --ok-soft: rgba(77,189,140,.14);
  --purple: #a78ae8; --purple-soft: rgba(167,138,232,.14);
  --shadow-1: 0 1px 3px rgba(0,0,0,.4);
  --shadow-2: 0 8px 24px rgba(0,0,0,.5);
  --shadow-3: 0 24px 64px rgba(0,0,0,.65);
}

html, body { height: 100%; }
body {
  font-family: 'Estedad', system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 13.5px;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;   /* چرخش گوشی نباید فونت را بزرگ کند */
}
/* وقتی منوی موبایل باز است، صفحهٔ زیرش نباید اسکرول شود */
body.no-scroll { overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.error { color: var(--danger); margin-top: .6rem; font-size: .87rem; }
a { color: var(--accent); }

input, select, textarea {
  border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: .52rem .7rem;
  font: inherit; background: var(--surface); color: var(--text); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57,185,200,.2);
}
input::placeholder { color: var(--text-3); }
button {
  font: inherit; border: 0; border-radius: var(--r-sm); padding: .55rem 1.05rem; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700;
  transition: filter .15s, transform .1s;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; color: var(--text-2); font-weight: 500; padding: .4rem .6rem; }
button.ghost:hover { color: var(--text); filter: none; background: var(--surface-2); }
button.secondary { background: var(--brand); color: #fff; }
[data-theme="dark"] button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); }
button.danger { background: var(--danger); }
button.outline { background: transparent; border: 1.5px solid var(--border-2); color: var(--text-2); font-weight: 600; }
button.outline:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.icon-btn {
  background: transparent; color: var(--text-2); padding: .35rem .55rem; border-radius: var(--r-sm);
  font-size: 1rem; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); filter: none; }
kbd {
  font-family: inherit; font-size: .68rem; background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: 5px; padding: .1rem .4rem; color: var(--text-3);
}

/* ── لاگین ── */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;   /* dvh: نوار آدرس موبایل صفحه را نبرد */
  display: flex; align-items: center; justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
           max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background:
    radial-gradient(900px 520px at 88% -8%, rgba(57,185,200,.4), transparent 60%),
    radial-gradient(700px 480px at 2% 108%, rgba(57,185,200,.2), transparent 55%),
    linear-gradient(135deg, #20243f 0%, #2B3054 55%, #1a1e38 100%);
}
.login-card {
  background: var(--surface); border-radius: 20px; padding: 2.4rem 2.2rem;
  width: min(380px, 94vw); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; gap: 1rem; position: relative; overflow: hidden;
}
.login-card::before {
  content: ''; position: absolute; inset-inline: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, #2B3054, #39B9C8);
}
.login-logo { display: flex; justify-content: center; }
.login-logo img { height: 52px; }
.login-card h1 { font-size: 1.1rem; font-weight: 900; text-align: center; }
.login-card .sub { text-align: center; color: var(--text-2); font-size: .8rem; margin-top: -.7rem; }
.login-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .84rem; color: var(--text-2); font-weight: 700; }

/* ── اپ‌شل ── */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

/* سایدبار (سمت راست RTL) */
.sidebar {
  width: var(--sb-w); flex: none; display: flex; flex-direction: column;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  transition: width .18s ease; z-index: 30;
}

/* پرده پشت منوی موبایل (فقط زیر ۷۶۰ دیده می‌شود) */
.sb-backdrop {
  display: none;            /* فقط در حالت موبایلِ باز روشن می‌شود */
  position: fixed; inset: 0; background: rgba(15,18,40,.45);
  backdrop-filter: blur(2px); z-index: 25; border: 0; padding: 0; border-radius: 0;
  animation: fade-in .15s ease;
}
/* پرده یک <button> است تا با کیبورد هم بسته شود — استایل دکمه نباید بگیردش */
.sb-backdrop:hover, .sb-backdrop:active { filter: none; transform: none; }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
.sb-header { display: flex; align-items: center; gap: .6rem; padding: 1rem .9rem .8rem; }
.sb-logo { height: 30px; }
.sb-title { font-weight: 900; font-size: 1.02rem; flex: 1; }
.sb-nav { flex: 1; overflow-y: auto; padding: .3rem .6rem 1rem; }
.sb-section { font-size: .68rem; font-weight: 700; color: var(--text-3); margin: 1rem .5rem .35rem; letter-spacing: .3px; }
.sb-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .5rem .6rem; border-radius: var(--r-sm); color: var(--text-2);
  text-decoration: none; font-size: .88rem; font-weight: 600; margin-bottom: 2px;
  background: none; cursor: pointer; transition: background .12s, color .12s;
}
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item.active { background: var(--accent-soft); color: var(--brand); font-weight: 700; }
[data-theme="dark"] .sb-item.active { color: var(--accent-2); }
.sb-item .ico { width: 20px; text-align: center; font-size: .95rem; flex: none; }
.sb-item .lbl { flex: 1; white-space: nowrap; overflow: hidden; }
.sb-item .badge-n {
  background: var(--danger); color: #fff; font-size: .66rem; font-weight: 700;
  border-radius: 999px; padding: .05rem .42rem; min-width: 18px; text-align: center;
}
.sb-footer { border-top: 1px solid var(--border); padding: .6rem; position: relative; }
.user-card {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  background: none; padding: .45rem .5rem; border-radius: var(--r-sm); text-align: right;
}
.user-card:hover { background: var(--surface-2); filter: none; }
.uc-info { display: flex; flex-direction: column; overflow: hidden; }
.uc-name { font-size: .84rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.uc-role { font-size: .68rem; color: var(--text-3); }

/* سایدبار جمع‌شده */
.app-shell.sb-collapsed .sidebar { width: var(--sb-w-min); }
.app-shell.sb-collapsed .sb-title, .app-shell.sb-collapsed .sb-item .lbl,
.app-shell.sb-collapsed .sb-section, .app-shell.sb-collapsed .uc-info,
.app-shell.sb-collapsed .sb-item .badge-n { display: none; }
.app-shell.sb-collapsed .sb-item { justify-content: center; }
.app-shell.sb-collapsed .sb-header { justify-content: center; padding-inline: .4rem; }
.app-shell.sb-collapsed #sb-collapse { position: absolute; top: 3.2rem; inset-inline-start: 50%; transform: translateX(50%); }

.popover {
  position: absolute; bottom: calc(100% + 6px); inset-inline: .6rem;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); padding: .35rem; z-index: 60;
}
.pop-item {
  display: block; width: 100%; text-align: right; background: none; color: var(--text);
  padding: .5rem .7rem; border-radius: var(--r-sm); font-size: .85rem; font-weight: 600;
}
.pop-item:hover { background: var(--surface-2); filter: none; }
.pop-item.danger { color: var(--danger); }

/* بدنه */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .7rem; padding: .65rem 1.4rem;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--border);
}
.breadcrumb { display: flex; align-items: center; gap: .45rem; font-size: .92rem; font-weight: 800; color: var(--text); min-width: 0; }
.breadcrumb .crumb-sep { color: var(--text-3); font-weight: 400; }
.breadcrumb .crumb-link { color: var(--text-2); font-weight: 600; cursor: pointer; }
.breadcrumb .crumb-link:hover { color: var(--accent); }
.spacer { flex: 1; }
.search-btn {
  display: flex; align-items: center; gap: .7rem; background: var(--surface);
  border: 1.5px solid var(--border); color: var(--text-3); font-weight: 500;
  padding: .42rem .85rem; border-radius: 10px; font-size: .82rem;
}
.search-btn:hover { border-color: var(--accent); filter: none; }
main { padding: 1.4rem; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ── کارت آماری (stat card + sparkline) ── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-1); position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.stat-card .lbl { color: var(--text-2); font-size: .78rem; font-weight: 700; }
.stat-card .num { font-size: 1.8rem; font-weight: 900; margin-top: .25rem; color: var(--text); line-height: 1.15; }
.stat-card.danger .num { color: var(--danger); }
.stat-card.ok .num { color: var(--ok); }
.stat-card .spark { position: absolute; bottom: 0; inset-inline: 0; height: 34px; opacity: .8; }
.stat-card .delta { font-size: .72rem; font-weight: 700; margin-top: .15rem; display: inline-block; }
.stat-card .delta.up { color: var(--ok); }
.stat-card .delta.down { color: var(--danger); }

/* ── پنل ── */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 1.15rem 1.25rem; margin-bottom: 1.1rem; box-shadow: var(--shadow-1);
}
.panel > h2 {
  font-size: .95rem; font-weight: 900; margin-bottom: .95rem;
  display: flex; align-items: center; gap: .5rem;
}
.panel > h2 .count {
  background: var(--accent-soft); color: var(--brand); font-size: .7rem;
  padding: .08rem .55rem; border-radius: 999px; font-weight: 700;
}
[data-theme="dark"] .panel > h2 .count { color: var(--accent-2); }
.grid-2 { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1.1rem; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
.chart-box { position: relative; height: 230px; }
@media (max-width: 860px) { .grid-2, .grid-2-even { grid-template-columns: 1fr; } }

/* ── جدول ── */
.table-wrap { overflow-x: auto; border-radius: var(--r-sm); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th {
  background: var(--surface-2); color: var(--text-2); font-weight: 700; text-align: right;
  padding: .55rem .7rem; border-bottom: 2px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; cursor: default; user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--accent); }
th .sort-ind { font-size: .65rem; opacity: .7; }
td { padding: .58rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.id {
  font-family: Consolas, monospace; color: var(--text-2); font-size: .76rem;
  direction: ltr; unicode-bidi: embed; background: var(--surface-2); white-space: nowrap;
  padding: .12rem .42rem; border-radius: 6px; border: 1px solid var(--border);
}

/* ── pill های وضعیت ── */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .62rem; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.in_progress { background: var(--accent-soft); color: #14727e; }
[data-theme="dark"] .pill.in_progress { color: var(--accent-2); }
.pill.done, .pill.published { background: var(--ok-soft); color: var(--ok); }
.pill.cancelled, .pill.not_started { background: var(--surface-2); color: var(--text-2); }
.pill.paused { background: var(--purple-soft); color: var(--purple); }
.pill.with_client, .pill.review { background: var(--warn-soft); color: var(--warn); }
.pill.overdue { background: var(--danger-soft); color: var(--danger); }
.pill.plain::before { display: none; }

/* ── آواتار ── */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 900; color: #fff; letter-spacing: -.5px;
}
.avatar.lg { width: 42px; height: 42px; font-size: .95rem; }
.avatar-chip { display: inline-flex; align-items: center; gap: .42rem; font-size: .8rem; font-weight: 600; }
.avatar-stack { display: inline-flex; flex-direction: row-reverse; }
.avatar-stack .avatar { margin-inline-start: -8px; border: 2px solid var(--surface); width: 26px; height: 26px; font-size: .62rem; }
.avatar-stack .avatar:last-child { margin-inline-start: 0; }

/* ── toolbar و filter chips ── */
.toolbar { display: flex; gap: .55rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar input[type="text"] { width: 220px; }
.toolbar select { width: auto; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-soft);
  color: var(--brand); border-radius: 999px; padding: .22rem .7rem; font-size: .76rem; font-weight: 700;
}
[data-theme="dark"] .chip { color: var(--accent-2); }
.chip button { background: none; color: inherit; padding: 0 .1rem; font-size: .8rem; }
.chip button:hover { filter: none; opacity: .7; }

/* ── segmented control ── */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { background: none; color: var(--text-2); padding: .34rem .85rem; border-radius: 7px; font-size: .8rem; font-weight: 700; }
.segmented button:hover { filter: none; color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ── کانبان ── */
.kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: .7rem; min-height: 120px; }
.kanban-col.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.kanban-col > h3 {
  font-size: .8rem; font-weight: 900; margin: .1rem .3rem .65rem;
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-col > h3 .count { color: var(--text-3); font-size: .72rem; font-weight: 700; }
.kanban-card {
  background: var(--surface); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .5rem;
  box-shadow: var(--shadow-1); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  font-size: .8rem; cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.kanban-card.overdue { border-inline-start-color: var(--danger); }
.kanban-card.dragging { opacity: .45; }
.kanban-card .kc-title { font-weight: 700; line-height: 1.55; margin-bottom: .35rem; }
.kanban-card .kc-meta { display: flex; gap: .45rem; align-items: center; color: var(--text-3); font-size: .7rem; flex-wrap: wrap; }
.kanban-card .kc-meta .proj { background: var(--surface-2); border-radius: 6px; padding: .06rem .4rem; }

/* ── progress ── */
.progress-bar { height: 7px; background: var(--border); border-radius: 999px; overflow: hidden; min-width: 80px; flex: 1; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2B3054, #39B9C8); border-radius: 999px; transition: width .3s; }
[data-theme="dark"] .progress-fill { background: linear-gradient(90deg, #39B9C8, #5dcad7); }
.progress-cell { display: flex; align-items: center; gap: .5rem; min-width: 130px; }
.progress-cell span { font-size: .74rem; color: var(--text-2); font-weight: 700; min-width: 32px; }

/* ── درا (side panel) ── */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,18,40,.45); backdrop-filter: blur(2px);
  z-index: 70; display: flex; justify-content: flex-start; /* RTL: درا از لبه‌ی چپ */
}
.drawer {
  width: min(480px, 94vw); height: 100%; background: var(--surface);
  box-shadow: var(--shadow-3); display: flex; flex-direction: column;
  animation: drawer-in .2s ease;
}
/* درا به لبهٔ راست (flex-start در RTL) می‌چسبد، پس باید از راست بیاید تو */
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-head {
  display: flex; align-items: center; gap: .7rem; padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.drawer-head .breadcrumb { flex: 1; font-size: .86rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem 1.2rem 2rem; }
.drawer-body h3 { font-size: 1rem; font-weight: 900; margin-bottom: 1rem; line-height: 1.7; }
.field { margin-bottom: .85rem; }
.field > label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-2); margin-bottom: .32rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.actions { display: flex; gap: .55rem; margin-top: 1.15rem; flex-wrap: wrap; }
.danger-zone { border-top: 1px dashed var(--border-2); margin-top: 1.4rem; padding-top: 1rem; }

/* ── کامند پالت ── */
.palette-backdrop {
  position: fixed; inset: 0; background: rgba(15,18,40,.5); backdrop-filter: blur(3px);
  z-index: 80; display: flex; justify-content: center; padding-top: 12vh;
}
.palette {
  width: min(560px, 92vw); max-height: 60vh; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden;
  display: flex; flex-direction: column; border: 1px solid var(--border-2);
  align-self: flex-start;
}
.palette input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: .95rem 1.1rem; font-size: .95rem; }
.palette input:focus { box-shadow: none; }
.palette-results { overflow-y: auto; padding: .4rem; }
.pal-item {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem;
  border-radius: var(--r-sm); cursor: pointer; font-size: .86rem;
}
.pal-item .ico { width: 22px; text-align: center; }
.pal-item .sub { color: var(--text-3); font-size: .72rem; margin-inline-start: auto; }
.pal-item.selected, .pal-item:hover { background: var(--accent-soft); }
.pal-group { font-size: .68rem; font-weight: 700; color: var(--text-3); padding: .5rem .7rem .2rem; }

/* ── توست ── */
.toasts { position: fixed; bottom: 1.2rem; inset-inline-start: 1.2rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-2);
  border-inline-start: 4px solid var(--accent); border-radius: var(--r-md);
  padding: .7rem 1rem; box-shadow: var(--shadow-2); font-size: .85rem; font-weight: 600;
  min-width: 220px; max-width: 340px; animation: toast-in .18s ease;
}
.toast.error { border-inline-start-color: var(--danger); }
.toast.ok { border-inline-start-color: var(--ok); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── skeleton ── */
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; height: 14px; margin-bottom: .7rem; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── empty state ── */
.empty { text-align: center; padding: 2rem 1rem; color: var(--text-3); }
.empty .ico { font-size: 2rem; display: block; margin-bottom: .5rem; }
.empty .txt { font-size: .86rem; font-weight: 600; }

/* ── لیست ── */
.list-item { padding: .55rem .1rem; border-bottom: 1px solid var(--border); display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; font-size: .84rem; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 130px; }

/* ── فید فعالیت ── */
.feed-item { display: flex; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .81rem; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .f-ico {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
.feed-item .f-body { flex: 1; min-width: 0; line-height: 1.9; }
.feed-item .f-time { color: var(--text-3); font-size: .7rem; white-space: nowrap; }

/* ── کارت تیم ── */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: .95rem; }
.team-card {
  background: var(--surface); border-radius: var(--r-lg); padding: 1rem; border: 1px solid var(--border);
  box-shadow: var(--shadow-1); transition: transform .15s, box-shadow .15s; cursor: pointer;
  display: flex; gap: .75rem; align-items: flex-start;
}
.team-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.team-card .tc-name { font-weight: 900; font-size: .88rem; }
.team-card .tc-unit { color: var(--text-2); font-size: .74rem; margin: .12rem 0 .45rem; }
.team-card .tc-stats { display: flex; gap: .7rem; font-size: .7rem; color: var(--text-3); font-weight: 700; flex-wrap: wrap; }

/* ── تب داخل صفحه ── */
.tabs { display: flex; gap: .1rem; border-bottom: 2px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; }
.tabs button {
  background: none; color: var(--text-2); border-radius: 0; padding: .55rem 1rem;
  border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 700; font-size: .86rem; white-space: nowrap;
}
.tabs button:hover { filter: none; color: var(--text); }
.tabs button.active { color: var(--text); border-color: var(--accent); }

/* ── جلالی date picker ── */
.jal-pop {
  position: absolute; z-index: 90; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: .7rem; width: 250px;
}
.jal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; font-weight: 800; font-size: .84rem; }
.jal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jal-grid .dow { font-size: .62rem; color: var(--text-3); text-align: center; padding: .2rem 0; font-weight: 700; }
.jal-grid button { background: none; color: var(--text); padding: .3rem 0; font-size: .76rem; border-radius: 6px; font-weight: 600; }
.jal-grid button:hover { background: var(--accent-soft); filter: none; }
.jal-grid button.today { outline: 1.5px solid var(--accent); }
.jal-grid button.sel { background: var(--accent); color: #fff; }

/* ── موبایل و تبلت ──
   ۹۰۰px نه ۷۶۰px: آی‌پدِ عمودی (۷۶۸/۸۲۰) با سایدبارِ ثابتِ ۲۴۴px فقط ۵۲۰px
   برای محتوا می‌گذاشت و ستون «عنوان» جدول عمودی خرد می‌شد. */
.mobile-only { display: none; }
@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }

  /* سایدبار کشویی: در RTL به لبهٔ راست بچسبد (inline-start) و از راست بیرون برود.
     پیش‌تر inset-inline-end بود که در RTL یعنی چپ — نتیجه‌اش این بود که منو
     همیشه ۱۳۱ پیکسل از سمت راستِ محتوا را می‌پوشاند، باز و بسته. */
  .sidebar {
    position: fixed; inset-inline-start: 0; inset-inline-end: auto; top: 0;
    width: min(var(--sb-w), 84vw);
    transform: translateX(100%);
    transition: transform .22s ease; box-shadow: var(--shadow-3);
    padding-top: env(safe-area-inset-top);
  }
  .app-shell.sb-mobile-open .sidebar { transform: none; }
  .app-shell.sb-mobile-open .sb-backdrop { display: block; }

  /* ترجیحِ «منوی جمع‌شده»ی دسکتاپ نباید منوی کشویی را آیکون‌فقط کند */
  .app-shell.sb-collapsed .sidebar { width: min(var(--sb-w), 84vw); }
  .app-shell.sb-collapsed .sb-title,
  .app-shell.sb-collapsed .sb-item .lbl,
  .app-shell.sb-collapsed .sb-section,
  .app-shell.sb-collapsed .uc-info,
  .app-shell.sb-collapsed .sb-item .badge-n { display: revert; }
  .app-shell.sb-collapsed .sb-item { justify-content: flex-start; }
  .app-shell.sb-collapsed .sb-header { justify-content: flex-start; padding-inline: .9rem; }
  #sb-collapse { display: none; }              /* جمع‌کردن اینجا بی‌معنی است */

  .topbar {
    padding-inline: max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-left));
    padding-top: calc(.65rem + env(safe-area-inset-top));
  }
  main { padding-bottom: calc(1.6rem + env(safe-area-inset-bottom)); }
  .icon-btn { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .sb-item { padding: .68rem .6rem; }
  /* ۴ کارت در یک ردیف به‌جای ۳ + یک یتیم در ردیف بعد */
  .cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* ── فقط گوشی ── */
@media (max-width: 620px) {
  main { padding: .9rem .9rem calc(1.6rem + env(safe-area-inset-bottom)); }
  .topbar { padding-bottom: .55rem; }
  .search-btn span, .search-btn kbd { display: none; }
  .search-btn::before { content: '🔍'; font-size: .95rem; }
  .grid-2, .grid-2-even { grid-template-columns: 1fr; }

  /* کارت‌های آماری دوتایی — تک‌ستونه بیخود بلند می‌شد */
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
  .stat-card { padding: .8rem .85rem; }
  .stat-card .num { font-size: 1.45rem; }
  .stat-card:hover { transform: none; box-shadow: var(--shadow-1); }

  /* نوار ابزار: کنترل‌ها تمام‌عرض به‌جای عرضِ ثابت ۲۲۰px که سرریز می‌کرد */
  .toolbar { gap: .45rem; }
  .toolbar input[type="search"], .toolbar input[type="text"] { width: 100%; flex: 1 1 100%; }
  .toolbar select { flex: 1 1 45%; width: auto; min-width: 0; }
  .toolbar .segmented, .toolbar > button { flex: 0 0 auto; }

  .panel { padding: .9rem .85rem; }
  .field-row { grid-template-columns: 1fr; }   /* دو ستون در ۳۰۰px جا نمی‌شود */
  .drawer-body { padding: 1rem .9rem calc(2rem + env(safe-area-inset-bottom)); }
  .toasts { inset-inline: .8rem; bottom: calc(.8rem + env(safe-area-inset-bottom)); }
  .toast { max-width: none; min-width: 0; }
  .team-grid, .kanban { grid-template-columns: 1fr; }
}

/* جدول‌های پهن: اسکرول افقیِ روان + سرریزنکردنِ صفحه */
.table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; max-width: 100%; }
@media (max-width: 620px) {
  th, td { padding: .5rem .55rem; }
  table { font-size: .8rem; }
  th { position: static; }   /* sticky داخل اسکرولِ افقی روی موبایل می‌لرزد */
  /* جدولِ پرستون را نفشار: بگذار افقی اسکرول شود تا عنوان‌ها حرف‌به‌حرف نشکنند */
  .table-wrap table:has(th:nth-child(4)) { min-width: 30rem; }
  .table-wrap table:has(th:nth-child(6)) { min-width: 40rem; }
  .table-wrap table:has(th:nth-child(8)) { min-width: 50rem; }
}

/* حالت نصب‌شده (PWA): فاصلهٔ امنِ بالای صفحه در آیفون */
@media (display-mode: standalone) {
  .login-wrap { padding-top: max(1rem, calc(env(safe-area-inset-top) + .5rem)); }
}

/* احترام به «کاهش حرکت» سیستم */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── تقویم «ماه من» ── */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.cal-title { font-size: 1rem; font-weight: 900; min-width: 130px; text-align: center; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-dow > div { text-align: center; font-size: .74rem; font-weight: 700; color: var(--text-3); padding: .2rem 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  min-height: 96px; min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: .35rem; display: flex; flex-direction: column; gap: .25rem;
  transition: background .12s, border-color .12s;
}
.cal-cell.empty-cell { background: transparent; border: 0; }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-cell.drag-over { background: var(--accent-soft); border-color: var(--accent); }
.cal-daynum { font-size: .78rem; font-weight: 700; color: var(--text-2); display: flex; align-items: center; gap: .3rem; }
.cal-today { font-size: .6rem; background: var(--accent); color: #fff; border-radius: 999px; padding: .02rem .4rem; font-weight: 700; }
.cal-chips { display: flex; flex-direction: column; gap: 3px; overflow: hidden; min-width: 0; }
.cal-chip {
  font-size: .72rem; font-weight: 600; line-height: 1.5; padding: .12rem .4rem;
  border-radius: 5px; background: var(--accent-soft); color: var(--brand);
  border-inline-start: 3px solid var(--accent); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
[data-theme="dark"] .cal-chip { color: var(--accent-2); }
.cal-chip.over { background: var(--danger-soft); color: var(--danger); border-inline-start-color: var(--danger); }
.cal-chip.paused { background: var(--purple-soft); color: var(--purple); border-inline-start-color: var(--purple); }
.cal-chip.done { background: var(--ok-soft); color: var(--ok); border-inline-start-color: var(--ok); opacity: .75; cursor: default; }
.cal-chip.dragging { opacity: .4; }
.cal-tray {
  margin-top: 1rem; background: var(--surface-2); border: 1px dashed var(--border-2);
  border-radius: var(--r-md); padding: .7rem .9rem; transition: background .12s, border-color .12s;
}
.cal-tray.drag-over { background: var(--danger-soft); border-color: var(--danger); }
.cal-tray-label { font-size: .82rem; font-weight: 700; margin-bottom: .5rem; }
.cal-tray-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.cal-tray-chips .cal-chip { max-width: 200px; }
@media (max-width: 640px) {
  .cal-cell { min-height: 68px; }
  .cal-chip { font-size: .64rem; }
}

/* نمایش رمز */
.show-pass { flex-direction: row !important; align-items: center; gap: .4rem; font-weight: 500 !important; color: var(--text-2); cursor: pointer; margin-top: -.4rem; }
.show-pass input { width: auto; }

/* ── تعهدهای ماهانه ── */
.duty-card { padding-top: .9rem; }
.duty-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .9rem; flex-wrap: wrap; }
.duty-head .muted { font-size: .78rem; margin-inline-start: auto; }
.duty-row {
  display: flex; gap: .8rem; align-items: flex-start; justify-content: space-between;
  padding: .7rem .2rem; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.duty-row:first-of-type { border-top: 0; }
.duty-row.met .dr-title { color: var(--ok); }
.dr-main { flex: 1 1 18rem; min-width: 0; }
.dr-title { font-weight: 700; font-size: .88rem; margin-bottom: .3rem; }
.dr-title .muted { font-weight: 500; font-size: .76rem; }
.dr-meta { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .76rem; }
.dr-note { font-size: .78rem; margin-top: .45rem; line-height: 1.9; }
.dr-side { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; flex: 0 1 auto; }
.dr-side .progress-cell { min-width: 11rem; }
.dr-side .ok { color: var(--ok); }
/* نوار روزشمار: هر خانه یک روز ماه */
.day-strip { display: flex; flex-wrap: wrap; gap: 3px; margin-top: .55rem; }
.day-cell {
  width: 1.55rem; height: 1.55rem; border-radius: 6px; font-size: .68rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.day-cell.on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.day-cell.future { opacity: .35; }
.day-cell.clickable { cursor: pointer; }
.day-cell.clickable:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 560px) {
  .day-cell { width: 1.35rem; height: 1.35rem; font-size: .62rem; }
  /* در موبایل ردیف می‌شکند؛ سمتِ کنشی تمام‌عرض شود تا دکمه‌ها زیر هم پرت نشوند */
  .dr-side { width: 100%; justify-content: flex-start; }
  .dr-side .progress-cell { min-width: 0; flex: 1 1 8rem; }
}

/* راهنمای یک‌خطی زیر هر کار + انتخاب مدل در فرم ساخت */
.dr-hint { font-size: .78rem; color: var(--text-2); line-height: 1.8; }
.model-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.model-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; text-align: right;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border);
  border-radius: var(--r-sm, 10px); padding: .7rem .75rem; font-weight: 500; cursor: pointer;
}
.model-card:hover { border-color: var(--accent); filter: none; }
.model-card.on { border-color: var(--accent); background: var(--accent-soft); }
.model-card .mc-ico { font-size: 1.2rem; }
.model-card .mc-desc { font-size: .76rem; color: var(--text-2); line-height: 1.7; }
.model-card .mc-ex { font-size: .72rem; color: var(--accent); }
.target-line { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
details.adv { margin: .4rem 0 1rem; }
details.adv summary { cursor: pointer; font-size: .82rem; color: var(--text-2); margin-bottom: .6rem; }
@media (max-width: 560px) { .model-grid { grid-template-columns: 1fr; } }

/* ── کارنامهٔ ماهِ نفر (قابل‌چاپ) ── */
a.btn-link {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 700;
  color: var(--accent); text-decoration: none; padding: .3rem .55rem; border-radius: 8px;
}
a.btn-link:hover { background: var(--accent-soft); }
.duty-head a.btn-link { margin-inline-start: .2rem; }
.ksheet { max-width: 860px; margin-inline: auto; padding: 1.6rem 1.8rem; }
.k-head { display: flex; align-items: center; gap: 1rem; padding-bottom: 1rem; border-bottom: 2px solid var(--border); }
.k-logo { width: 52px; height: 52px; }
.k-head h1 { margin: .1rem 0; font-size: 1.35rem; }
.k-kicker { font-size: .78rem; color: var(--accent); font-weight: 700; }
.k-score { margin-inline-start: auto; text-align: center; }
.k-num { font-size: 2.1rem; font-weight: 900; line-height: 1.1; }
.k-sub { font-size: .72rem; color: var(--text-2); }
.k-score.ok .k-num, .kv.ok { color: var(--ok); }
.k-score.mid .k-num, .kv.mid { color: var(--warn); }
.k-score.bad .k-num, .kv.bad { color: var(--danger); }
.kv { font-weight: 700; font-size: .8rem; }
.k-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin: 1.1rem 0 .4rem; }
.k-stats > div { background: var(--surface-2); border-radius: 10px; padding: .6rem .7rem; display: flex; flex-direction: column; gap: .15rem; }
.k-stats b { font-size: 1.05rem; }
.k-stats span { font-size: .72rem; color: var(--text-2); }
.ksheet h2 { font-size: .98rem; margin: 1.4rem 0 .6rem; }
.k-per { font-size: .72rem; font-weight: 500; }
.k-detail { margin-bottom: .8rem; font-size: .84rem; }
.k-detail ul, .k-tasks { margin: .3rem 0 0; padding-inline-start: 1.2rem; font-size: .82rem; line-height: 1.9; }
.k-foot { margin-top: 1.6rem; padding-top: .7rem; border-top: 1px solid var(--border); font-size: .72rem; }
@media (max-width: 640px) {
  .ksheet { padding: 1rem; }
  .k-head { flex-wrap: wrap; }
  .k-stats { grid-template-columns: 1fr 1fr; }
}
@media print {
  #sidebar, .topbar, .no-print, #drawer, #sb-backdrop, .toast { display: none !important; }
  .app-shell { display: block !important; }
  #main { padding: 0 !important; margin: 0 !important; }
  body { background: #fff !important; }
  .ksheet { box-shadow: none !important; border: 0 !important; max-width: none; padding: 0; }
  .k-stats > div { border: 1px solid #ddd; }
  a { color: inherit; }
  tr { break-inside: avoid; }
}

/* ── فرمِ گزارشِ نگهداشت ── */
.up-sec { margin: 1rem 0; }
.up-sec > b { display: block; margin-bottom: .5rem; font-size: .88rem; }
.up-empty { font-size: .8rem; line-height: 1.9; }
.up-ind { margin-bottom: .6rem; }
.up-ind label { font-size: .82rem; font-weight: 600; display: block; margin-bottom: .25rem; }
.up-target { font-size: .72rem; color: var(--accent); margin-inline-start: .4rem; font-weight: 500; }
.up-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.up-row input { flex: 1 1 8rem; min-width: 0; }
.up-add summary { cursor: pointer; color: var(--accent); font-size: .82rem; font-weight: 700; margin: .3rem 0 .5rem; }
.up-choice { display: flex; gap: .5rem; }
.up-choice button { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border); }
.up-choice button.on.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.up-choice button.on.bad { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.up-req { color: var(--danger); font-weight: 700; font-size: .76rem; }
.up-files { list-style: none; padding: 0; margin: .3rem 0 .6rem; font-size: .82rem; line-height: 2; }
.up-upload { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; color: var(--accent); font-weight: 700; font-size: .82rem;
  border: 1.5px dashed var(--accent); border-radius: 10px; padding: .45rem .8rem; }
.model-fold summary { cursor: pointer; font-size: .84rem; padding: .55rem .7rem; background: var(--surface-2); border-radius: 10px; }
.model-fold[open] summary { margin-bottom: .6rem; }
