/* ==========================================================================
   سامانه دبیرخانه — شیت اصلی (نسخه بازطراحی‌شده)
   همه نام‌کلاس‌های نسخه قبل حفظ شده‌اند، پس صفحاتی که دست نخورده‌اند هم
   به‌صورت خودکار ظاهر جدید می‌گیرند.
   ========================================================================== */

:root {
  --bg: #f1f4f5;
  --surface: #ffffff;
  --surface-2: #fafbfb;
  --border: #e6eaeb;
  --border-strong: #d5dedd;
  --text: #1b2b2a;
  --text-2: #465957;
  --text-muted: #6a7d7b;
  --text-faint: #92a3a1;

  --primary: #25635f;
  --primary-dark: #1c4a49;
  --primary-deep: #16403f;
  --primary-tint: #edf2f1;
  --primary-tint-2: #f4f8f7;

  --accent: #b8895b;
  --accent-tint: #f7efe6;
  --accent-text: #8a6234;

  --danger: #b3413a;
  --danger-dark: #92302a;
  --danger-bg: #fff5f4;
  --danger-border: #f3d3d0;
  --danger-text: #9c3830;

  --success: #2f7a52;
  --success-bg: #eaf6ef;
  --warn: #96631e;
  --warn-bg: #fdf3e3;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 8px;

  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.05);
  --shadow-pop: 0 10px 30px rgba(16,24,40,.12);
  --ring: 0 0 0 3px rgba(37,99,95,.14);

  --sidebar-w: 246px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Vazirmatn', 'Vazir', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* اعداد در جدول‌ها و مبالغ هم‌عرض شوند */
.num, td, th, input, .tabular { font-variant-numeric: tabular-nums; }

h1, h2, h3 { letter-spacing: -.3px; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

::selection { background: #cfe0de; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------------- چیدمان کلی ---------------- */

.container { max-width: 1240px; margin: 0 auto; padding: 30px 20px 60px; }
.container.with-sidebar {
  margin-right: var(--sidebar-w);
  margin-left: 0;
  max-width: 1240px;
  padding: 30px 34px 70px;
}

/* ---------------- سایدبار ---------------- */

.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--primary-deep); color: #fff;
  display: flex; flex-direction: column; padding: 22px 0 18px;
  overflow-y: auto; z-index: 40;
}
.sidebar .brand {
  display: block; color: #fff; padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.09); margin-bottom: 16px;
  font-size: 17px; font-weight: 700; line-height: 1.35;
}
.sidebar .brand:hover { text-decoration: none; color: #fff; }
.sidebar .brand small {
  display: block; font-size: 12px; font-weight: 400; color: #8bada9; margin-top: 2px;
}

.sidebar nav { display: flex; flex-direction: column; gap: 3px; padding: 0 12px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: #c2d6d3;
}
.sidebar nav a .dot {
  width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px;
  background: rgba(255,255,255,.28);
}
.sidebar nav a .count {
  background: rgba(255,255,255,.1); color: #e6efee;
  font-size: 11.5px; font-weight: 600; padding: 0 7px; border-radius: 7px; line-height: 1.7;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active {
  background: rgba(255,255,255,.13); color: #fff; font-weight: 600; text-decoration: none;
}
.sidebar nav a.active .dot { background: var(--accent); }
.sidebar nav a.active .count { background: rgba(255,255,255,.2); }

/* گروه «مدیریت» — فرعی‌تر از منوی اصلی */
.sidebar nav .admin-link { font-size: 13.5px; color: #b6ccc9; }

.sidebar .nav-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 14px 6px; padding: 0;
  font-size: 11px; font-weight: 600; color: #7d9f9b; letter-spacing: .04em;
  border: none;
}
.sidebar .nav-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.1);
}

.sidebar-user {
  margin: 14px 14px 0; padding: 14px; border: none; border-radius: 12px;
  background: rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 11px;
  font-size: 12.5px; color: #cfd9d8;
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user-name { font-weight: 600; color: #fff; font-size: 13.5px; }
.sidebar-user-role { margin: 0; color: #8bada9; font-size: 11.5px; }
.sidebar-user form { margin: 0; }
.sidebar .link-btn {
  background: none; border: none; color: #8bada9; cursor: pointer;
  font-size: 12px; font-family: inherit; padding: 4px;
}
.sidebar .link-btn:hover { color: #fff; text-decoration: underline; }

@media (max-width: 900px) {
  .sidebar {
    position: static; width: 100%; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 8px; padding: 10px 14px;
  }
  .sidebar .brand { border-bottom: none; padding: 0; margin: 0 0 0 0; font-size: 15px; }
  .sidebar .brand small { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 0; flex: 1; }
  .sidebar .nav-divider { display: none; }
  .sidebar-user { margin: 0; padding: 6px 10px; }
  .sidebar-user .avatar { width: 28px; height: 28px; flex: 0 0 28px; font-size: 12px; }
  .container.with-sidebar { margin-right: 0; padding: 20px 16px 50px; }
}

/* ---------------- سرصفحه صفحه ---------------- */

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 26px;
}
.page-header h1 { font-size: 28px; font-weight: 700; margin: 0; }
.page-header h1 .badge { vertical-align: middle; }
.page-header .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 3px; }
.page-header .actions { display: flex; gap: 9px; flex-wrap: wrap; }

.breadcrumb {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-muted); margin-bottom: 14px;
}
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb .current { color: var(--text); }

/* ---------------- کارت ---------------- */

.card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
.card > h2:first-child + .card-sub { margin-top: -10px; }
.card-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }

/* کارتی که جدول تمام‌عرض دارد */
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 18px 22px 14px; border-bottom: 1px solid #eceff0;
}
.card.flush .card-head h2 { margin: 0; flex: 1; }
.card.flush .card-head .card-note { font-size: 12.5px; color: var(--text-muted); }
.card-head .accent-bar {
  width: 4px; height: 20px; border-radius: 2px; background: var(--primary); flex: 0 0 4px;
}
.card-head .accent-bar.is-danger { background: var(--danger); }

/* ---------------- گرید ---------------- */

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.split { grid-template-columns: 1.35fr 1fr; align-items: start; gap: 20px; }
@media (max-width: 1100px) { .grid.split { grid-template-columns: 1fr; } }
@media (max-width: 980px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------------- کارت آماری ---------------- */

.stat-box {
  background: var(--surface); border: none; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 20px 22px; text-align: right;
}
.stat-box .label {
  font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin: 0;
}
.stat-box .num {
  font-size: 34px; font-weight: 700; color: var(--primary-deep);
  letter-spacing: -1px; line-height: 1.3;
}
.stat-box .sub { font-size: 12px; color: var(--text-faint); }

.stat-box.danger {
  background: var(--danger-bg); border: 1px solid var(--danger-border); box-shadow: none;
}
.stat-box.danger .label { color: var(--danger-text); display: flex; align-items: center; gap: 7px; }
.stat-box.danger .label::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: 0 0 7px;
}
.stat-box.danger .num { color: var(--danger); }
.stat-box.danger .sub { color: #a86b66; font-weight: 500; }

/* حالت آرام: وقتی تأخیری وجود ندارد */
.stat-box.ok { background: var(--success-bg); border: 1px solid #cdeadb; box-shadow: none; }
.stat-box.ok .num, .stat-box.ok .label { color: var(--success); }

/* ---------------- جدول ---------------- */

.table-scroll { max-height: 380px; overflow-y: auto; }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th {
  text-align: right; padding: 10px 14px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  background: var(--surface-2); border-bottom: 1px solid #eceff0;
  white-space: nowrap;
}
.table-scroll th { position: sticky; top: 0; z-index: 2; }
td { padding: 12px 14px; border-bottom: 1px solid #f2f4f5; text-align: right; }
th:first-child, td:first-child { padding-right: 22px; }
th:last-child, td:last-child { padding-left: 22px; }
tbody tr:last-child td { border-bottom: none; }
td.key { font-weight: 600; }

/* ردیف کلیک‌پذیر — جای دکمه تکراری «مشاهده» */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #f7faf9; }

/* میله ماندگاری */
.day-cell { display: flex; align-items: center; gap: 10px; }
.day-bar {
  flex: 1; min-width: 56px; height: 6px; border-radius: 3px;
  background: #eef1f1; overflow: hidden;
}
.day-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--primary); }
.day-bar.is-danger { background: #f0e5e4; }
.day-bar.is-danger > span { background: var(--danger); }
.day-num { font-size: 13px; font-weight: 600; white-space: nowrap; }
.day-num.is-danger { color: var(--danger); font-weight: 700; }

/* ---------------- برچسب ---------------- */

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; line-height: 1.7;
}
.badge.status-open { background: var(--warn-bg); color: var(--warn); border-radius: 20px; padding: 3px 12px; }
.badge.status-archived { background: var(--success-bg); color: var(--success); border-radius: 20px; padding: 3px 12px; }
.badge.status-returned { background: #eef1f8; color: #3a4a8f; border-radius: 20px; padding: 3px 12px; }
.badge.overdue { background: #f7dedc; color: var(--danger); border-radius: 20px; padding: 3px 12px; }
.badge.type { background: var(--primary-tint); color: var(--primary-dark); font-weight: 500; }
.badge.qty { background: var(--accent-tint); color: var(--accent-text); }

/* ---------------- دکمه ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: none;
  padding: 10px 18px; border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit;
  line-height: 1.5; box-shadow: 0 1px 2px rgba(16,24,40,.08);
  transition: background .15s ease;
}
.btn:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(.5px); }

.btn.secondary {
  background: #fff; color: var(--primary);
  border: 1px solid var(--border-strong); font-weight: 500; box-shadow: none;
}
.btn.secondary:hover { background: #f6f9f8; border-color: var(--primary); color: var(--primary); }

.btn.ghost {
  background: none; border: none; box-shadow: none;
  color: var(--text-muted); font-weight: 500;
}
.btn.ghost:hover { background: none; color: var(--primary); text-decoration: underline; }

.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-dark); }
.btn.danger.secondary {
  background: #fff; color: var(--danger); border-color: var(--danger-border);
}
.btn.danger.secondary:hover { background: var(--danger-bg); color: var(--danger); }

.btn.small { padding: 6px 13px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- فرم ---------------- */

form.inline { display: inline; }
table form { display: contents; }
table form td { display: table-cell; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.form-group label .req { color: var(--danger); }
.form-group .hint { color: var(--text-muted); font-size: 12.5px; margin-top: 5px; }

input[type=text], input[type=date], input[type=number], input[type=password], input[type=file],
select, textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: inherit; font-size: 14.5px; background: #fff; color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: #a9b7b6; }
textarea { min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--ring);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--text-faint); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 49%, var(--text-muted) 50%),
                    linear-gradient(-45deg, transparent 49%, var(--text-muted) 50%);
  background-size: 6px 6px, 6px 6px;
  background-position: left 16px center, left 22px center;
  background-repeat: no-repeat;
  padding-left: 36px;
}

/* چک‌باکس به‌صورت چیپ قابل کلیک — سطح کلیک بزرگ‌تر */
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.chip-group { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; background: #fff;
  user-select: none; transition: all .12s ease;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip .tick {
  width: 15px; height: 15px; border-radius: 50%; flex: 0 0 15px;
  border: 1.5px solid var(--border-strong); background: #fff;
}
.chip:hover { border-color: var(--primary); background: var(--primary-tint-2); }
.chip:has(input:checked) {
  border-color: var(--primary); background: var(--primary-tint); color: var(--primary-dark); font-weight: 600;
}
.chip:has(input:checked) .tick {
  border-color: var(--primary); background: var(--primary);
  box-shadow: inset 0 0 0 3px #fff;
}
.chip:has(input:focus-visible) { box-shadow: var(--ring); }

.form-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 4px;
}

/* ---------------- پیام‌ها ---------------- */

.alert {
  padding: 13px 16px; border-radius: var(--radius); margin-bottom: 18px;
  font-size: 14px; border: 1px solid transparent;
}
.alert.error { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert.success { background: var(--success-bg); color: var(--success); border-color: #cdeadb; }
.alert.info { background: #eef2f8; color: #33507f; border-color: #d8e2f2; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0e0c1; }

.empty-state {
  text-align: center; padding: 44px 20px; color: var(--text-muted);
}
.empty-state .title { font-size: 15px; font-weight: 600; color: var(--text-2); }
.empty-state .desc { font-size: 13.5px; margin-top: 3px; }
.empty-state .btn { margin-top: 14px; }

/* ---------------- نوار وضعیت سند ---------------- */

.status-strip {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding-bottom: 22px; border-bottom: 1px solid #eceff0; margin-bottom: 22px;
}
.status-strip .sep { width: 1px; height: 34px; background: #eceff0; }
.status-strip .spacer { flex: 1; }
.status-strip .k { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.status-strip .v { font-size: 17px; font-weight: 700; }
.status-strip .v.is-danger { color: var(--danger); }
.status-strip .v small { font-size: 13px; font-weight: 500; }

/* ---------------- استپر گردش‌کار ---------------- */

.stepper { display: flex; align-items: flex-start; flex-wrap: wrap; }
.stepper .step {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  min-width: 104px; text-align: center;
}
.stepper .step .mark {
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 2px solid #dde3e3;
}
.stepper .step .name { font-size: 12.5px; font-weight: 500; color: #8b9c9a; }
.stepper .step .days { font-size: 11.5px; color: #b3c1bf; }

.stepper .step.done .mark { background: var(--primary); border-color: var(--primary); }
.stepper .step.done .name { color: var(--primary); font-weight: 600; }
.stepper .step.done .days { color: var(--text-faint); }

.stepper .step.current .mark {
  background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px #dceae8;
}
.stepper .step.current .name { color: var(--primary-dark); font-weight: 700; }
.stepper .step.current .days { color: var(--text-muted); font-weight: 600; }

.stepper .step.current.is-late .mark { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 0 4px #f7dedc; }
.stepper .step.current.is-late .name,
.stepper .step.current.is-late .days { color: var(--danger); }

.stepper .link {
  flex: 1; min-width: 20px; height: 15px; display: flex; align-items: center;
}
.stepper .link > span { height: 2px; width: 100%; border-radius: 1px; background: #e3e8e8; }
.stepper .link.done > span { background: var(--primary); }

/* ---------------- کارت اقدام بعدی ---------------- */

.action-card { padding: 0; overflow: visible; }
.action-card .action-head {
  background: var(--primary-tint-2); border-bottom: 1px solid #e4ecea;
  padding: 16px 22px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.action-card .action-head .kicker {
  font-size: 12px; font-weight: 700; color: var(--primary); letter-spacing: .03em;
}
.action-card .action-head .title { font-size: 17px; font-weight: 700; margin-top: 2px; }
.action-card .action-head .desc { font-size: 13px; color: #567371; margin-top: 3px; }
.action-card .action-body { padding: 20px 22px; }
.action-card .action-foot {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid #f0f3f3;
  font-size: 12.5px; color: var(--text-faint);
}

/* اقدام‌های خطرناک پشت یک منوی ثانویه */
.more-actions { position: relative; display: inline-block; }
.more-actions > summary {
  list-style: none; cursor: pointer;
  color: var(--text-muted); font-size: 13.5px; font-weight: 500; padding: 6px;
}
.more-actions > summary::-webkit-details-marker { display: none; }
.more-actions > summary:hover { color: var(--primary); }
.more-actions[open] > summary { color: var(--primary); }
.more-actions .panel {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 40;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 18px 20px; width: 380px; text-align: right;
}
.more-actions .panel h3 { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.more-actions .panel .panel-note { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
@media (max-width: 640px) { .more-actions .panel { position: static; width: auto; box-shadow: none; } }

/* ---------------- ضمائم ---------------- */

.attach-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.attach-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: 1px solid #eceff0; border-radius: var(--radius);
}
.attach-item:hover { border-color: #cfdcda; background: #fafcfb; }
.attach-item .thumb {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex: 0 0 34px;
  background: var(--primary-tint);
}
.attach-item .meta { flex: 1; min-width: 0; }
.attach-item .name {
  font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-item .sub { font-size: 11.5px; color: var(--text-faint); }

.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: 11px;
  padding: 18px; text-align: center; cursor: pointer;
}
.dropzone:hover { border-color: var(--primary); background: #f8fbfa; }
.dropzone .dz-title { font-size: 13.5px; font-weight: 600; color: var(--primary); }
.dropzone .dz-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.dropzone input[type=file] { display: none; }
.dropzone.has-file { border-style: solid; border-color: var(--primary); background: var(--primary-tint-2); }

/* ---------------- جدول کلید/مقدار ---------------- */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13.5px; margin-top: 12px; }
.kv dt, .kv .k { color: var(--text-muted); margin: 0; }
.kv dd, .kv .v { font-weight: 600; margin: 0; }
.kv .v.empty { color: var(--text-faint); font-weight: 400; }

/* ---------------- تایم‌لاین ---------------- */

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: flex; gap: 16px; align-items: stretch;
  padding: 0; margin: 0; border: none; background: none; border-radius: 0;
  font-size: 14.5px;
}
.timeline li .rail {
  display: flex; flex-direction: column; align-items: center;
  flex: 0 0 15px; padding-top: 5px;
}
.timeline li .rail .mark {
  width: 11px; height: 11px; border-radius: 50%; flex: 0 0 11px; background: var(--primary);
}
.timeline li .rail .line { width: 2px; flex: 1; background: #e6ebeb; margin-top: 5px; border-radius: 1px; }
.timeline li:last-child .rail .line { background: transparent; }
.timeline li.is-open .rail .mark { background: var(--danger); box-shadow: 0 0 0 3px #f7dedc; }
.timeline li .body { flex: 1; min-width: 0; padding-bottom: 18px; }
.timeline li .body .what { font-size: 14.5px; font-weight: 600; }
.timeline li .meta { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.timeline li .note {
  font-size: 13px; color: var(--text-2); margin-top: 5px;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 7px 11px;
}

/* ---------------- ورود ---------------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.login-box {
  background: #fff; border: none; border-radius: 16px; box-shadow: 0 4px 24px rgba(16,24,40,.08);
  padding: 36px; width: 100%; max-width: 380px;
}
.login-box h1 { font-size: 21px; text-align: center; margin: 0 0 6px; }
.login-box .subtitle { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 24px; }

/* ---------------- تب و فیلتر ---------------- */

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 16px; border-radius: 999px; background: #e8edec; color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
}
.tabs a:hover { background: #dde5e4; text-decoration: none; }
.tabs a.active { background: var(--primary); color: #fff; font-weight: 600; }

.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 20px;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; flex: 1; }
.filter-bar .btn { flex: 0 0 auto; }

/* ---------------- کمکی ---------------- */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.text-left { text-align: left; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }

/* ---------------- تقویم شمسی ---------------- */

.jalali-date-field { position: relative; display: flex; }
.jalali-date-field input {
  flex: 1; border-radius: var(--radius) 0 0 var(--radius); border-left: none;
}
.jalali-date-btn {
  border: 1px solid var(--border-strong); background: #f6f8f8;
  border-radius: 0 var(--radius) var(--radius) 0; padding: 0 15px;
  cursor: pointer; font-size: 13px; font-family: inherit; color: var(--text-2);
}
.jalali-date-btn:hover { background: #eef2f2; }
.jalali-popup {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 12px; width: 262px;
}
.jalali-popup-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-size: 14px; font-weight: 700;
}
.jalali-popup-header button {
  background: none; border: none; font-size: 17px; cursor: pointer;
  color: var(--primary); padding: 2px 9px; border-radius: 6px; font-family: inherit;
}
.jalali-popup-header button:hover { background: var(--primary-tint-2); }
.jalali-popup-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jalali-popup-wd { text-align: center; font-size: 11px; color: var(--text-muted); padding: 4px 0; }
.jalali-popup-day {
  text-align: center; padding: 7px 0; border: none; background: none; border-radius: 7px;
  cursor: pointer; font-size: 13px; font-family: inherit; color: var(--text);
}
.jalali-popup-day:hover { background: var(--primary-tint); }
.jalali-popup-day.is-today { background: var(--primary); color: #fff; font-weight: 600; }
.jalali-popup-footer {
  display: flex; justify-content: space-between; margin-top: 10px;
  border-top: 1px solid var(--border); padding-top: 9px;
}
.jalali-popup-footer button {
  background: none; border: none; color: var(--primary);
  font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.jalali-popup-footer button:hover { text-decoration: underline; }

/* ---------------- مراحل گردش‌کار (صفحه مدیریت) ---------------- */

.wf-flow { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.wf-flow-box {
  background: var(--primary-tint); border: none; border-radius: var(--radius);
  padding: 11px 15px; font-size: 13px; font-weight: 600; text-align: center;
  min-width: 112px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--primary-dark);
}
.wf-flow-box.is-final { background: var(--success-bg); color: var(--success); }
.wf-flow-days { font-size: 11.5px; font-weight: 400; color: var(--text-muted); }
.wf-flow-box.is-final .wf-flow-days { color: var(--success); opacity: .8; }
.wf-flow-arrow {
  display: flex; align-items: center; color: var(--border-strong); font-size: 16px; padding: 0 2px;
}

.wf-stage-card {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 10px; background: #fff;
}
.wf-stage-card:hover { border-color: #cfdcda; }
.wf-reorder { display: flex; flex-direction: column; align-items: center; gap: 3px; flex-shrink: 0; }
.wf-reorder form { margin: 0; }
.wf-reorder-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; font-size: 10px; padding: 3px 9px; color: var(--text-2); font-family: inherit;
}
.wf-reorder-btn:hover:not(:disabled) { background: #eef1f2; }
.wf-reorder-btn:disabled { opacity: .3; cursor: default; }
.wf-order-num { font-size: 11px; color: var(--text-faint); font-weight: 700; }
.wf-info { flex: 1; min-width: 0; }
.wf-title { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.wf-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.wf-actions { display: flex; align-items: flex-start; gap: 8px; flex-shrink: 0; position: relative; }
.wf-actions form { margin: 0; }
.wf-actions details { position: relative; }
.wf-actions summary { list-style: none; cursor: pointer; }
.wf-actions summary::-webkit-details-marker { display: none; }
.wf-edit-form {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 18px; width: 330px;
}

/* ---------------- ردیف‌های تکرارشونده ---------------- */

.case-row, .bulk-row {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 44px 8px 18px; margin-bottom: 14px; background: var(--surface-2);
}
.remove-row-btn {
  position: absolute; top: 12px; left: 12px;
  background: #f7dedc; color: var(--danger); border: none; border-radius: 50%;
  width: 26px; height: 26px; cursor: pointer; font-size: 13px; line-height: 1; font-family: inherit;
}
.remove-row-btn:hover { background: #f2ceca; }

/* ---------------- پاپ‌آور ویرایش مدیر ---------------- */

.admin-edit-toggle { position: relative; display: inline-block; }
.admin-edit-toggle summary { list-style: none; cursor: pointer; }
.admin-edit-toggle summary::-webkit-details-marker { display: none; }
.admin-edit-form {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 35;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 18px; width: 340px; text-align: right;
}
.admin-edit-badge {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px;
  margin-left: 6px; vertical-align: middle;
}

/* ---------------- چاپ ---------------- */

@media print {
  :root { --bg: #fff; }
  body { background: #fff; font-size: 11.5pt; }
  .sidebar, .page-header .actions, .btn, .filter-bar, .tabs,
  .dropzone, .more-actions, .admin-edit-toggle, form, .jalali-popup { display: none !important; }
  .container, .container.with-sidebar { margin: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; page-break-inside: avoid; }
  .card.flush { overflow: visible; }
  .table-scroll { max-height: none; overflow: visible; }
  th { background: #f2f2f2 !important; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .stat-box { border: 1px solid #ddd; box-shadow: none; }
}
