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

:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f4; --border: #d9dde5;
  --text: #1c2230; --muted: #5d6679; --accent: #2458c6; --accent-soft: #e3ebfb;
  --good: #1d7a4b; --bad: #b3261e; --warn: #8a5a00;
  --good-soft: #e1f3e8; --bad-soft: #fbe5e3; --warn-soft: #fcefd6;
  --series-1: #2458c6; --series-2: #c2571a;
}
[data-theme="dark"] {
  --bg: #12151c; --surface: #1a1f29; --surface-2: #232937; --border: #313a4b;
  --text: #e5e8ef; --muted: #9aa3b5; --accent: #7aa2f7; --accent-soft: #22304d;
  --good: #5fc48f; --bad: #f08a80; --warn: #e5b45a;
  --good-soft: #173526; --bad-soft: #3d1e1c; --warn-soft: #3a2d12;
  --series-1: #7aa2f7; --series-2: #f0955a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Vazirmatn, Tahoma, sans-serif; font-size: 14px; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; font-weight: 700; }
h2 { font-size: 16px; margin: 20px 0 10px; font-weight: 700; }
small, .muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar .brand { font-weight: 700; color: var(--text); }
.topbar .brand small { font-weight: 400; margin-inline-start: 6px; }
.topbar form { margin: 0; }
.spacer { flex: 1; }
.who { color: var(--muted); }
.year-switch select { margin-inline-start: 6px; }

.layout { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 49px); }
.sidebar { background: var(--surface); border-inline-end: 1px solid var(--border); padding: 8px 0 24px; }
.sidebar h4 { margin: 14px 16px 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.sidebar a { display: block; padding: 6px 16px; color: var(--text); }
.sidebar a:hover, .sidebar a.active { background: var(--accent-soft); text-decoration: none; }
.sidebar > a { padding-inline-start: 16px; }

/* منوی آکاردئونی: هر گروه مستقل باز و بسته می‌شود و وضعیتش در مرورگر می‌ماند */
.nav-search { padding: 6px 12px 10px; }
.nav-search input { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; }
.nav-group { border-top: 1px solid var(--border); }
.nav-group:first-of-type { border-top: 0; }
.nav-group > summary { list-style: none; cursor: pointer; padding: 8px 16px; font-size: 13px; font-weight: 500;
  color: var(--muted); display: flex; align-items: center; gap: 6px; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::before { content: "▸"; font-size: 10px; transition: transform .12s ease; }
.nav-group[open] > summary::before { transform: rotate(-90deg); }
.nav-group > summary:hover { background: var(--accent-soft); color: var(--text); }
.nav-group[open] > summary { color: var(--text); }
.nav-group.has-active > summary { color: var(--accent); font-weight: 700; }
.nav-group .nav-links a { padding-inline-start: 28px; font-size: 13px; }
.sidebar.filtering .nav-group > summary { color: var(--text); }
.nav-group.hidden, .sidebar.filtering .nav-links a.hidden { display: none; }
main { padding: 20px 24px; min-width: 0; }
main.bare { display: grid; place-items: center; min-height: 100vh; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value { font-size: 20px; font-weight: 700; direction: ltr; text-align: right; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input:not([type]), select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; }
button, .btn { display: inline-block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 14px; cursor: pointer; color: var(--text); }
button:hover, .btn:hover { text-decoration: none; filter: brightness(0.97); }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .primary { color: #0e1422; }
.danger { color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar form { margin: 0; }

table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { border-bottom: 1px solid var(--border); padding: 5px 8px; text-align: right; vertical-align: top; }
th { background: var(--surface-2); font-weight: 500; position: sticky; top: 49px; }
tbody tr:hover { background: var(--accent-soft); }
td.num, th.num { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--surface-2); }
tr.group-row td { background: var(--surface-2); font-weight: 700; }
tr.sub td:first-child { padding-inline-start: 24px; }
.table-wrap { overflow-x: clip; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 1100px) { .table-wrap { overflow-x: auto; } .table-wrap th { position: static; } }

.badge { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 10px; background: var(--surface-2); white-space: nowrap; }
.state--1 { background: var(--bad-soft); color: var(--bad); }
.state-0 { background: var(--warn-soft); color: var(--warn); }
.state-1 { background: var(--accent-soft); color: var(--accent); }
.state-2 { background: var(--good-soft); color: var(--good); }
.state-3 { background: var(--surface-2); color: var(--text); }

.messages { margin-bottom: 12px; }
.msg { padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; background: var(--accent-soft); }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.success { background: var(--good-soft); color: var(--good); }
.msg.warning { background: var(--warn-soft); color: var(--warn); }
.errorlist { color: var(--bad); margin: 2px 0; padding: 0; list-style: none; font-size: 12px; }

.pager { display: flex; gap: 12px; align-items: center; margin: 12px 0; }

.form-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; max-width: 720px; }
.form-grid .help { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -6px; }
.form-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }

td.wrap { white-space: normal; min-width: 180px; }
table.plain { background: none; }
table.plain th { background: none; position: static; width: 140px; color: var(--muted); font-weight: 400; }
table.plain td, table.plain th { border-bottom: 1px dashed var(--border); }
.inline-grid { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: end; }
.inline-grid label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
.inline-grid input[type=text], .inline-grid select { max-width: 130px; }

.login { width: 340px; }
.login input { width: 100%; }

/* voucher form */
.vch-head { display: flex; gap: 16px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.vch-head label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.vch-lines td { padding: 3px 4px; }
.vch-lines input { width: 100%; }
.vch-lines .c-sl { width: 110px; } .vch-lines .c-dl { width: 105px; } .vch-lines .c-amt { width: 150px; }
.vch-lines .c-seq { width: 36px; text-align: center; color: var(--muted); } .vch-lines .c-x { width: 30px; }
.vch-lines input.amount { direction: ltr; text-align: left; }
.vch-lines input:disabled { background: var(--surface-2); border-color: transparent; }
.acc-title { font-size: 11px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.balance-bar { display: flex; gap: 24px; padding: 8px 12px; background: var(--surface-2); border-radius: 6px; margin: 8px 0; }
.balance-bar .off { color: var(--bad); font-weight: 700; }
.balance-bar .ok { color: var(--good); font-weight: 700; }
.suggest { position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / .15); max-height: 280px; overflow-y: auto; min-width: 320px; }
.suggest div { padding: 4px 10px; cursor: pointer; }
.suggest div.on, .suggest div:hover { background: var(--accent-soft); }
.suggest b { direction: ltr; display: inline-block; margin-left: 12px; }

/* access matrix */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix td:nth-child(2), .matrix th:first-child, .matrix th:nth-child(2) { text-align: right; }
.matrix select { padding: 1px 4px; font-size: 12px; }
.matrix select.allow { background: var(--good-soft); color: var(--good); }
.matrix select.deny { background: var(--bad-soft); color: var(--bad); }
.eff { font-size: 11px; display: block; }
.eff.yes { color: var(--good); } .eff.no { color: var(--muted); }

/* dashboard bars */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 200px; padding-top: 8px; }
.bars .m { display: flex; flex-direction: column; justify-content: end; height: 100%; }
.bars .pair { display: flex; gap: 2px; align-items: end; justify-content: center; flex: 1; }
.bars .b { width: 40%; border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .b1 { background: var(--series-1); } .bars .b2 { background: var(--series-2); }
.bars .lbl { font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: middle; }

.print-head { display: none; }
@media print {
  .no-print, .sidebar, .topbar, .filters, .toolbar, .pager { display: none !important; }
  .layout { display: block; } main { padding: 0; }
  body { background: #fff; color: #000; font-size: 11px; }
  th { position: static; }
  .print-head { display: block; text-align: center; margin-bottom: 8px; }
  .table-wrap, .card { border: 0; }
}
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } .sidebar { display: none; } }

/* serials, MACs and item codes keep Latin digits (the Farsi-digit font would change them) */
.code { font-family: ui-monospace, "DejaVu Sans Mono", Consolas, monospace; font-size: 12px; direction: ltr; unicode-bidi: isolate; }

.cheque-sheet { position: relative; border: 1px dashed var(--border); margin: 12px 0; background: var(--surface); }
.cheque-sheet span { position: absolute; white-space: nowrap; }
@media print { .cheque-sheet { border: 0; margin: 0; } .no-print { display: none !important; } }
