/* ==========================================================
   سامانه حسابداری مجتمع آموزشی — شیوه‌نامه
   ========================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg:          #eef1f6;
  --panel:       #ffffff;
  --panel-2:     #f7f9fc;
  --border:      #e2e8f0;
  --border-soft: #dbe3ec;
  --text:        #16202e;
  --muted:       #64748b;
  --faint:       #94a3b8;

  --brand:       #0f766e;
  --brand-dark:  #0b5a54;
  --brand-light: #14a297;
  --brand-soft:  #e6f4f2;

  --gold:        #b45309;
  --gold-soft:   #fef3e2;
  --danger:      #be123c;
  --danger-soft: #fff1f3;
  --ok:          #15803d;
  --ok-soft:     #ecfdf3;
  --info:        #1d4ed8;
  --info-soft:   #eff4ff;

  --sidebar:     #10242e;
  --sidebar-2:   #0b1a22;
  --sidebar-tx:  #a9c3ca;

  --shadow-sm:   0 1px 2px rgba(15,23,42,.06);
  --shadow:      0 1px 3px rgba(15,23,42,.07), 0 8px 24px -8px rgba(15,23,42,.10);
  --shadow-lg:   0 12px 40px -12px rgba(15,23,42,.22);
  --radius:      14px;
  --radius-sm:   9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', 'IRANSans', 'Segoe UI', Tahoma, sans-serif;
  font-size: 14px;
  line-height: 1.85;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand-dark); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------- چیدمان ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 242px;
  flex: 0 0 242px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-tx);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.sidebar .brand {
  padding: 17px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 11px;
}
.sidebar .brand .logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  display: grid; place-items: center;
  font-size: 17px;
  flex: 0 0 36px;
  box-shadow: 0 4px 12px rgba(20,162,151,.3);
}
.sidebar .brand b { display: block; color: #fff; font-size: 14.5px; line-height: 1.4; }
.sidebar .brand span { font-size: 11.5px; color: #6f929c; }

/* direction:ltr روی ظرف، اسکرول‌بار را به سمت چپِ نوار (لبه‌ی بیرونی) می‌برد
   و direction:rtl روی محتوا، متن را فارسی/راست‌چین نگه می‌دارد */
.nav { padding: 10px 9px 16px; overflow-y: auto; flex: 1; direction: ltr; }
.nav > * { direction: rtl; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 8px; border-color: transparent; }
.nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--sidebar-tx);
  margin-bottom: 2px;
  font-size: 13.5px;
  position: relative;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active {
  background: linear-gradient(90deg, var(--brand) 0%, rgba(15,118,110,.55) 100%);
  color: #fff;
  font-weight: 500;
}
.nav a.active::before {
  content: '';
  position: absolute;
  right: -9px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--brand-light);
  border-radius: 0 3px 3px 0;
}
.nav .sep {
  margin: 14px 12px 6px;
  font-size: 10.5px;
  color: #587b85;
  letter-spacing: .8px;
  font-weight: 500;
}
.nav .ico { width: 19px; text-align: center; opacity: .92; font-size: 14px; }

.sidebar .foot {
  padding: 11px 15px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px;
  color: #7fa1ab;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .foot .av {
  width: 27px; height: 27px; border-radius: 50%;
  background: rgba(255,255,255,.1);
  display: grid; place-items: center;
  color: #cfe3e8; font-size: 12px; flex: 0 0 27px;
}
.sidebar .foot a { color: #f2a99f; margin-right: auto; }

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

.topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 11px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 16.5px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
.topbar .chip {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 3px 11px;
  border-radius: 20px;
}

.content { padding: 22px; flex: 1; max-width: 1700px; width: 100%; margin-inline: auto; }

/* ---------- کارت ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.card > h2 {
  margin: 0;
  padding: 13px 17px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fbfcfe, var(--panel-2));
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card > h2 .spacer { flex: 1; }
.card .body { padding: 17px; }
.card .body.tight { padding: 0; }

/* ---------- شبکه ---------- */
.grid { display: grid; gap: 15px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1250px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 980px)  { .grid.c2, .grid.c3 { grid-template-columns: 1fr; } }
@media (max-width: 620px)  { .grid.c4 { grid-template-columns: 1fr; } }

/* ---------- کارت شاخص ---------- */
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand);
}
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 3px;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}
.kpi .unit  { font-size: 11.5px; color: var(--faint); font-weight: 400; letter-spacing: 0; }
.kpi.ok::before   { background: var(--ok); }
.kpi.bad::before  { background: var(--danger); }
.kpi.gold::before { background: var(--gold); }
.kpi.gray::before { background: var(--faint); }
.kpi .delta { font-size: 11.5px; margin-top: 1px; color: var(--faint); }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  white-space: nowrap;
}
table.tbl th, table.tbl td {
  border-bottom: 1px solid var(--border-soft);
  border-left: 1px solid var(--border-soft);
  padding: 8px 10px;
  text-align: center;
}
table.tbl th:first-child, table.tbl td:first-child { border-left: 0; }
table.tbl tbody tr:nth-child(even) { background: #fafbfd; }
table.tbl thead th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl thead th.group {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-bottom-color: #c9e3df;
}
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: #f6fafa; }
table.tbl tfoot td, table.tbl tr.sum td {
  background: var(--panel-2);
  font-weight: 700;
  border-top: 1px solid var(--border);
  border-bottom: none;
}
table.tbl tfoot td { position: sticky; bottom: 0; }
table.tbl td.num, table.tbl th.num { font-variant-numeric: tabular-nums; }
table.tbl td.right { text-align: right; }
table.tbl td.pos { color: var(--ok); font-weight: 500; }
table.tbl td.neg { color: var(--danger); font-weight: 500; }
table.tbl td.holiday { color: var(--danger); }
table.tbl td a { font-weight: 500; }
.table-scroll { max-height: 72vh; overflow: auto; }


/* ---------- جدول‌های پهن: ستون نام چسبان می‌ماند ---------- */
table.tbl.sticky-name th:nth-child(2),
table.tbl.sticky-name td:nth-child(2) {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--panel);
  box-shadow: -6px 0 8px -6px rgba(15,23,42,.18);
}
table.tbl.sticky-name thead th:nth-child(2) { background: var(--panel-2); z-index: 3; }
table.tbl.sticky-name tbody tr:hover td:nth-child(2) { background: #f6fafa; }
table.tbl.compact th, table.tbl.compact td { padding: 6px 7px; font-size: 12.5px; }
table.tbl.compact input.cell { min-width: 72px; padding: 2px 5px; }
table.tbl td input[type=text], table.tbl td select {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12.5px;
  width: 100%;
}
table.tbl td input[type=text]:focus, table.tbl td select:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 2px rgba(20,162,151,.15);
  outline: 0;
}

/* راهنمای اسکرول افقی */
.scroll-hint { font-size: 11.5px; color: var(--faint); padding: 6px 16px 0; }
@media (min-width: 1500px) { .scroll-hint { display: none; } }


/* ---------- رنگ ردیف بر اساس وضعیت ---------- */
table.tbl tbody tr.row-withdrawn   { background: #fff5f6; }
table.tbl tbody tr.row-withdrawn:hover { background: #ffe9ec; }
table.tbl tbody tr.row-withdrawn td:nth-child(2) { background: #fff5f6; }
table.tbl tbody tr.row-withdrawn td { color: #8f2338; }

table.tbl tbody tr.row-transferred { background: #fff8ed; }
table.tbl tbody tr.row-transferred:hover { background: #fdf0dc; }
table.tbl tbody tr.row-transferred td:nth-child(2) { background: #fff8ed; }
table.tbl tbody tr.row-transferred td { color: #8a4a08; }


/* ---------- ردیف تسویه‌شده ---------- */
table.tbl tbody tr.row-settled { background: #f4fdf7; }
table.tbl tbody tr.row-settled:hover { background: #e9f9ef; }
table.tbl tbody tr.row-settled td:nth-child(2) { background: #f4fdf7; }

/* ---------- حالت تمام‌عرض ---------- */
body.wide .sidebar { display: none; }
body.wide .content { padding: 12px; max-width: none; }
body.wide .topbar { padding: 8px 12px; }


/* ---------- ستون عملیات چسبان (سمت چپ) ---------- */
table.tbl.sticky-action th:last-child,
table.tbl.sticky-action td:last-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel);
  box-shadow: 6px 0 8px -6px rgba(15,23,42,.18);
}
table.tbl.sticky-action thead th:last-child { background: var(--panel-2); z-index: 3; }
table.tbl.sticky-action tbody tr:hover td:last-child { background: #f6fafa; }

/* ---------- ستون مانده کل ---------- */
table.tbl td.total-due { font-weight: 700; background: #fbfcfe; }
table.tbl tbody tr:hover td.total-due { background: #f1f7f6; }

/* ---------- شبکه‌ی پرداخت ترکیبی ---------- */
table.tbl.pay-grid { width: auto; min-width: 420px; }
table.tbl.pay-grid input.cell { min-width: 108px; text-align: left; direction: ltr; }
table.tbl.pay-grid td[data-row-total] { font-weight: 700; color: var(--brand-dark); min-width: 90px; }


/* ---------- نوار روزهای ماه ---------- */
.day-strip { display: flex; flex-wrap: wrap; gap: 4px; }
.day-strip .day {
  min-width: 34px; padding: 5px 0; text-align: center;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text); background: var(--panel);
  font-variant-numeric: tabular-nums; transition: all .12s;
}
.day-strip .day:hover { background: var(--brand-soft); border-color: var(--brand-light); text-decoration: none; }
.day-strip .day.on {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700;
  box-shadow: 0 2px 6px rgba(15,118,110,.28);
}
.day-strip .day.fri { color: var(--danger); }
.day-strip .day.fri.on { color: #fff; }

/* ---------- جعبه‌های خلاصه‌ی بخش‌ها ---------- */
.dept-summary {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px; padding: 16px;
}
.dept-box { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.dept-box thead th { background: var(--brand-soft); color: var(--brand-dark); }
.dept-box tfoot td { background: var(--panel-2); }


/* ---------- عدد دریافتی قابل کلیک ---------- */
a.paid-link {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--brand-light);
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
a.paid-link::after { content: " ✎"; font-size: 11px; opacity: .75; }
a.paid-link:hover {
  background: var(--brand-soft);
  border-color: var(--brand-light);
  border-style: solid;
  color: var(--brand-dark);
  text-decoration: none;
}


/* ---------- جدول ورود سریع به تفکیک بخش ---------- */
.dept-entry { border-top: 1px solid var(--border); }
.dept-entry:first-of-type { border-top: none; }
.dept-entry-head {
  padding: 9px 16px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-bottom: 1px solid var(--border);
}
table.entry-grid input.cell { min-width: 92px; }
table.entry-grid tfoot td { font-size: 12px; }
table.entry-grid tfoot [data-check] { white-space: nowrap; font-weight: 700; }


/* ---------- جعبه‌ی جمع‌های پایان روز ---------- */
table.tbl.totals-box {
  border: 2px solid var(--brand);
  border-radius: 10px;
  overflow: hidden;
}
table.tbl.totals-box thead th { background: var(--brand); color: #fff; }
/* جعبه‌های جمع نباید چسبان باشند وگرنه روی جعبه‌ی بغلی می‌افتند */
table.tbl.totals-box thead th,
table.tbl.totals-box tfoot td { position: static; }
table.tbl.totals-box td { white-space: normal; }
table.tbl.totals-box td.num { white-space: nowrap; }
table.tbl.totals-box tfoot td { background: var(--brand-soft); color: var(--brand-dark); font-size: 14px; font-weight: 700; }
table.tbl.count-box { border-color: var(--border); }
table.tbl.count-box thead th { background: var(--brand-soft); color: var(--brand-dark); }
table.tbl.count-box tfoot td { background: #fff; }
table.tbl tr.sep td { border-top: 2px solid var(--border); }
table.tbl tfoot tr.sub-foot td {
  background: #fff7ed;
  color: #9a3412;
  font-weight: 500;
  font-size: 12px;
}

.count-form { display: flex; gap: 6px; align-items: center; }
.count-form input { width: 70px; text-align: center; }


/* ================= دفتر مالی شبانه ================= */

/* کادر هر بخش */
details.dept-card { padding: 0; }
details.dept-card > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 14px;
  user-select: none;
}
details.dept-card > summary::-webkit-details-marker { display: none; }
details.dept-card > summary::before {
  content: '▸';
  color: var(--brand);
  font-size: 13px;
  transition: transform .15s;
}
details.dept-card[open] > summary::before { transform: rotate(-90deg); }
details.dept-card > summary b { color: var(--brand-dark); font-size: 14.5px; }
details.dept-card:not([open]) > summary { border-bottom: 0; border-radius: var(--radius); }

.dept-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--panel-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* رنگ ردیف بر اساس نوع پرداخت */
table.night-grid tbody tr.m-card    td { background: #f2f8ff; }
table.night-grid tbody tr.m-cash    td { background: #f3fdf6; }
table.night-grid tbody tr.m-transfer td { background: #fdf6ec; }
table.night-grid tbody tr.new-row   td { background: #fff; }
table.night-grid tbody tr:hover td { filter: brightness(.985); }

table.night-grid tfoot tr.m-card    td { background: #e6f1ff; }
table.night-grid tfoot tr.m-cash    td { background: #e6f8ec; }
table.night-grid tfoot tr.m-transfer td { background: #fbeed8; }
table.night-grid tfoot tr.grand-row td {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
}
table.night-grid tfoot td.dept-foot-name {
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  vertical-align: middle;
}
table.night-grid tfoot td { position: static; }

/* رنگ سطرهای جدول جمع نوع پرداخت */
table.totals-box tbody tr.m-card    td { background: #f2f8ff; }
table.totals-box tbody tr.m-cash    td { background: #f3fdf6; }
table.totals-box tbody tr.m-transfer td { background: #fdf6ec; }

/* رنگ خود کشوی نوع پرداخت */
select.method-pick { font-weight: 600; }
tr.m-card    select.method-pick { color: #1d4ed8; border-color: #b6cdf5; }
tr.m-cash    select.method-pick { color: #15803d; border-color: #b3e2c4; }
tr.m-transfer select.method-pick { color: #b45309; border-color: #edcc9b; }

/* نوار ذخیره‌ی چسبان */
.save-bar {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 22px;
  padding: 12px 16px;
  background: var(--panel);
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.btn.icon { padding: 3px 7px; }

/* ---------- فرم ---------- */
label.f { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 11px center;
  padding-left: 28px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input.money { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; vertical-align: -2px; }

table.tbl input.cell {
  border: 1px solid transparent;
  background: transparent;
  padding: 3px 6px;
  text-align: left;
  direction: ltr;
  border-radius: 7px;
  min-width: 96px;
  font-variant-numeric: tabular-nums;
}
table.tbl input.cell:hover { border-color: var(--border); background: #fff; }
table.tbl input.cell:focus { background: #fff; border-color: var(--brand-light); }
table.tbl input.cell.changed { background: #fffbeb; border-color: #fcd34d; }

.form-row { display: flex; gap: 11px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { flex: 1; min-width: 120px; }

/* ---------- دکمه ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: #cbd5e1; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--brand-light), var(--brand));
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15,118,110,.3);
}
.btn.primary:hover { background: linear-gradient(180deg, var(--brand), var(--brand-dark)); color: #fff; }
.btn.danger { background: #fff; border-color: #fbcfd8; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- انتخاب دوره ---------- */
.period {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 5px 8px;
  box-shadow: var(--shadow-sm);
}
.period select { width: auto; min-width: 96px; }
.period .btn { padding: 3px 10px; box-shadow: none; }

/* ---------- برچسب و پیام ---------- */
.badge {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid rgba(15,118,110,.14);
}
.badge.gray { background: #f1f5f9; color: var(--muted); border-color: var(--border); }
.badge.ok   { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.badge.bad  { background: var(--danger-soft); color: var(--danger); border-color: #fecdd3; }
.badge.gold { background: var(--gold-soft); color: var(--gold); border-color: #fde3c0; }
a.badge:hover { filter: brightness(.96); }

.alert {
  padding: 11px 15px;
  border-radius: 11px;
  margin-bottom: 15px;
  font-size: 13px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: slide-in .3s ease;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.alert::before { font-size: 15px; line-height: 1.4; }
.alert.success { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }
.alert.success::before { content: '✓'; }
.alert.error   { background: var(--danger-soft); border-color: #fecdd3; color: #881337; }
.alert.error::before { content: '!'; font-weight: 700; }
.alert.info    { background: var(--info-soft); border-color: #c7d7fe; color: #1e3a8a; }
.alert.info::before { content: 'i'; font-weight: 700; font-style: italic; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { text-align: center; color: var(--faint); padding: 34px; font-size: 13px; }
.nowrap { white-space: nowrap; }
.text-left { text-align: left; direction: ltr; }

/* ---------- تب ---------- */
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); padding: 0 13px; background: var(--panel-2); flex-wrap: wrap; }
.tabs a {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  transition: color .15s, border-color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------- نوار پیشرفت ---------- */
.meter { height: 8px; background: #eef2f7; border-radius: 6px; overflow: hidden; margin-top: 4px; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-light), var(--brand)); border-radius: 6px; transition: width .5s ease; }
.meter.gold > i { background: linear-gradient(90deg, #f59e0b, var(--gold)); }

/* ---------- نمودار میله‌ای ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: 10px 4px 0; }
.bars .bar {
  flex: 1;
  background: linear-gradient(180deg, var(--brand-light), var(--brand));
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: background .15s, filter .15s;
  cursor: default;
}
.bars .bar:hover { filter: brightness(1.15) saturate(1.2); }
.bars .bar.neg { background: linear-gradient(180deg, #f43f5e, var(--danger)); }
.bar-axis { display: flex; gap: 3px; padding: 4px 4px 0; border-top: 1px solid var(--border-soft); }
.bar-axis div { flex: 1; text-align: center; font-size: 9.5px; color: var(--faint); }

/* ---------- صفحه ورود ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #0b1a22 0%, #10242e 45%, var(--brand-dark) 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before, .login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20,162,151,.28), transparent 70%);
}
.login-page::before { width: 520px; height: 520px; top: -160px; right: -120px; }
.login-page::after  { width: 420px; height: 420px; bottom: -150px; left: -100px; }
.login-box {
  background: #fff;
  border-radius: 18px;
  padding: 34px 32px;
  width: 100%;
  max-width: 385px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-box .logo {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  display: grid; place-items: center;
  font-size: 24px;
  box-shadow: 0 8px 20px rgba(15,118,110,.3);
}
.login-box h1 { font-size: 18px; margin: 0 0 4px; text-align: center; }
.login-box p.sub { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 24px; }
.login-box .field { margin-bottom: 14px; }

/* ---------- موبایل ---------- */
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    right: 0; top: 0;
    transform: translateX(100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 15px; }
  .topbar { padding: 10px 15px; }
  .card > h2 { font-size: 13.5px; padding: 11px 14px; }
  .kpi .value { font-size: 19px; }
}
.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 25;
}
.scrim.show { display: block; }

/* ---------- چاپ ---------- */
@media print {
  @page { size: A4 landscape; margin: 8mm; }

  .sidebar, .topbar, .no-print, .btn, .scrim,
  .kpi, .alert, .scroll-hint, #term-search, form[method="get"] { display: none !important; }

  /* در صفحه‌ی لیست کلاس فقط خود جدول چاپ شود */
  .print-head { display: block !important; font-size: 11pt; margin-bottom: 5px; }

  html, body { background: #fff; font-size: 8.5pt; line-height: 1.35; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; margin: 0 0 6px; border-radius: 0; break-inside: auto; }
  .card > h2 { display: none; }
  .card .body { padding: 0; }
  .table-wrap, .table-scroll { overflow: visible !important; max-height: none !important; }

  table.tbl { width: 100%; font-size: 8pt; white-space: normal; }
  table.tbl th, table.tbl td { padding: 2px 3px; border: 1px solid #999; }
  table.tbl thead th {
    background: #eee !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    position: static;
  }
  table.tbl tfoot td { position: static; background: #f2f2f2 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.tbl tbody tr { break-inside: avoid; }

  /* ستون چسبان در چاپ معنا ندارد */
  table.tbl.sticky-name th:nth-child(2),
  table.tbl.sticky-name td:nth-child(2),
  table.tbl.sticky-action th:last-child,
  table.tbl.sticky-action td:last-child { position: static; box-shadow: none; }

  /* ورودی‌ها به‌صورت متن ساده چاپ شوند */
  table.tbl input.cell {
    border: none !important; background: transparent !important;
    padding: 0; min-width: 0; width: auto; font-size: 8pt;
  }
  input[type=checkbox] { transform: scale(.85); }
  .badge { border: none; padding: 0 2px; font-size: 7.5pt; background: transparent !important; }
  table.tbl tbody tr.row-withdrawn td,
  table.tbl tbody tr.row-transferred td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.tbl tbody tr.row-withdrawn { background: #ffe9ec !important; }
  table.tbl tbody tr.row-transferred { background: #fdf0dc !important; }
}

/* ---------- مالی شبانه ---------- */
table.night-grid input.cert-group.off {
  background: #f1f5f9;
  color: var(--faint);
  border-style: dashed;
}
table.night-grid tbody tr.extra-row td { background: #fbfdff; }
table.night-grid td.row-sum { font-weight: 600; }
table.night-grid tfoot tr.grand-row td { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
table.night-grid tbody tr.m-card     td:first-child { box-shadow: inset 3px 0 0 #1d4ed8; }
table.night-grid tbody tr.m-cash     td:first-child { box-shadow: inset 3px 0 0 #15803d; }
table.night-grid tbody tr.m-transfer td:first-child { box-shadow: inset 3px 0 0 #b45309; }
table.night-grid tbody tr.m-transfer td { background: #fffaf2; }
.dept-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 9px 14px; }

.hidden { display: none !important; }

/* ---------- هشدار پرداخت‌های بدون کلاس ---------- */
.card.warn-card { border-color: #f0cf9e; }
.card.warn-card > h2 { background: var(--gold-soft); color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-warn {
  display: inline-flex; gap: 6px; align-items: center;
  background: var(--gold-soft); color: var(--gold);
  border: 1px solid #f0cf9e; border-radius: 20px;
  padding: 3px 11px; font-size: 12px;
}
.chip-warn b { font-weight: 700; }

/* دکمه‌ی بستن پیام‌ها */
.alert { position: relative; }
.alert .alert-x {
  position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer;
  font-size: 19px; line-height: 1; color: inherit; opacity: .55; padding: 2px 6px;
}
.alert .alert-x:hover { opacity: 1; }
