[hidden] { display: none !important; }
@font-face { font-family: Vazirmatn; src: url('/assets/fonts/Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('/assets/fonts/Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('/assets/fonts/SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('/assets/fonts/Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #1e2440;
  --ink-soft: #4f5674;
  --ink-faint: #6d7492;
  --rail: #3342a7;
  --rail-text: #dfe3f8;
  --paper: #f1f3fa;
  --surface: #ffffff;
  --line: #dbdfee;
  --line-strong: #b9bfd8;
  --accent: #3342a7;
  --accent-dark: #27328a;
  --tint: #e7eaf8;
  --gain: #2f7a22;
  --gain-bg: #e6f6dc;
  --loss: #a72b25;
  --loss-bg: #fae6e3;
  --warn: #7c5208;
  --warn-bg: #fbf0d6;
  --cat-1: #5a9f3e;
  --cat-2: #3a63c9;
  --cat-3: #b5730f;
  --cat-4: #a23fb0;
  --bar-base: #a9afc8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.75 Vazirmatn, Tahoma, sans-serif;
  font-feature-settings: 'tnum';
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.35; margin: 0; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 8px; }
:focus-visible { outline: 3px solid #8EC66A; outline-offset: 2px; border-radius: 3px; }

/* قاب پنل: ستون ثابت در راست و محتوا در کنار آن */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-text); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; }
.rail .brand { color: #fff; font-size: 15px; font-weight: 700; line-height: 1.6; padding: 0 4px; text-decoration: none; }
.brand-logo { display: block; width: 100%; max-width: 190px; background: #fff; border-radius: 6px; padding: 6px 10px; margin-bottom: 10px; }
.login-logo { display: block; width: 100%; max-width: 240px; margin: 0 auto 14px; }
.rail .panel-name { display: block; font-size: 12.5px; font-weight: 400; color: var(--rail-text); }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a { color: var(--rail-text); text-decoration: none; padding: 8px 10px; border-radius: 4px; }
.rail nav a:hover { background: #4553b8; color: #fff; }
.rail nav a[aria-current='page'] { background: #fff; color: var(--rail); font-weight: 600; }
.rail-foot { margin-top: auto; padding: 0 10px; font-size: 13px; }
.rail-foot button { background: none; border: 1px solid #99a3e0; color: #fff; padding: 4px 12px; border-radius: 4px; font: inherit; cursor: pointer; margin-top: 4px; }
.main { padding: 26px 30px 60px; max-width: 1240px; width: 100%; }
.demo-bar { background: var(--warn-bg); color: var(--warn); padding: 6px 30px; font-weight: 600; font-size: 13.5px; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head .meta { color: var(--ink-soft); font-size: 13.5px; }
.crumb { font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.section { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 18px; }
.section > header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.section > .body { padding: 16px 18px; }
.section > .note { padding: 10px 18px; color: var(--ink-soft); font-size: 13.5px; }
.hint { color: var(--ink-soft); font-size: 13.5px; }

/* ردیف اعداد خلاصه؛ خطی و یکپارچه مانند سرستون دفتر، نه کارت‌های جدا */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 18px; }
.figure { padding: 12px 18px; border-inline-start: 1px solid var(--line); margin-inline-start: -1px; border-block-end: 1px solid var(--line); margin-block-end: -1px; min-width: 0; }
.figure .k { font-size: 13px; color: var(--ink-soft); display: block; }
.figure .v { font-size: 20px; font-weight: 700; display: block; line-height: 1.5; overflow-wrap: anywhere; }
.figure .u { font-size: 12px; color: var(--ink-faint); }

.gain { color: var(--gain); }
.loss { color: var(--loss); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-weight: 600; color: var(--ink-soft); font-size: 13px; padding: 8px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; background: #f6f9f8; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f6f9f8; }
td.num, th.num { text-align: left; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.figure .v, .perf .result b, .bars .val { direction: ltr; unicode-bidi: isolate; }
.figure .v { text-align: right; }
.perf .result b { text-align: left; }
tfoot td { font-weight: 700; border-top: 1px solid var(--line-strong); border-bottom: 0; }
tr.struck td { color: var(--ink-faint); text-decoration: line-through; }
.nowrap { white-space: nowrap; }

.tag { display: inline-block; padding: 0 8px; border-radius: 3px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--tint); color: var(--accent-dark); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.done { background: var(--gain-bg); color: var(--gain); }
.tag.mute { background: #e9ebf3; color: var(--ink-soft); }
.tag.bad { background: var(--loss-bg); color: var(--loss); }

.btn, button.btn { display: inline-block; font: inherit; font-weight: 600; font-size: 14px; padding: 7px 16px; border-radius: 4px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--tint); color: var(--accent-dark); }
.btn.danger { background: var(--loss); border-color: var(--loss); }
.btn.danger.ghost { background: transparent; color: var(--loss); }
.btn.danger.ghost:hover { background: var(--loss-bg); }
.btn.small { padding: 2px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; align-items: start; }
.form .wide { grid-column: 1 / -1; }
/* توضیح زیر کادر می‌آید تا کادرهای یک ردیف همیشه هم‌تراز بمانند. */
label.field { display: flex; flex-direction: column; font-size: 13.5px; font-weight: 500; }
label.field small { order: 1; margin-top: 4px; color: var(--ink-soft); font-size: 12.5px; font-weight: 400; line-height: 1.6; }
.form-group { margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.form-group:last-of-type { border-bottom: 0; padding-bottom: 0; }
.form-group h2 { margin-bottom: 12px; }
.form-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; align-items: start; }
.form-row .span-2 { grid-column: span 2; }
input[type='text'], input[type='password'], input[type='search'], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; padding: 7px 10px; margin-top: 3px;
}
input[type='text'], input[type='password'], input[type='search'], select { height: 42px; }
input.ltr { direction: ltr; text-align: left; }
input.amount { direction: ltr; text-align: left; font-weight: 600; }
textarea { min-height: 76px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.toolbar label { font-size: 13px; }
.toolbar input, .toolbar select { width: 150px; }

.flash { padding: 9px 16px; border-radius: 4px; margin-bottom: 16px; font-weight: 500; }
.flash.success { background: var(--gain-bg); color: var(--gain); }
.flash.error { background: var(--loss-bg); color: var(--loss); }
.callout { padding: 10px 14px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); margin-bottom: 12px; }
.callout.ok { background: var(--gain-bg); color: var(--gain); }
.callout.bad { background: var(--loss-bg); color: var(--loss); }
.callout ul { margin: 4px 0 0; padding-inline-start: 18px; }

details.inline summary { cursor: pointer; color: var(--accent); font-size: 13px; }
details.inline form { margin-top: 8px; min-width: 240px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a { padding: 3px 12px; border-radius: 4px; text-decoration: none; font-size: 13.5px; color: var(--ink-soft); }
.tabs a[aria-current='true'] { background: var(--tint); color: var(--accent-dark); font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; margin: 0; }
.kv dt { color: var(--ink-soft); font-size: 13.5px; }
.kv dd { margin: 0; font-weight: 500; }

/* ترکیب حساب: یک نوار ممتد که ارزش کل را بین بخش‌های حساب نشان می‌دهد */
.worth { background: var(--rail); color: #fff; border-radius: 6px; padding: 20px 22px; margin-bottom: 18px; }
.worth .label { color: var(--rail-text); font-size: 14px; }
.worth .amount { font-size: 34px; font-weight: 700; line-height: 1.4; display: block; overflow-wrap: anywhere; }
.worth .amount small { font-size: 14px; font-weight: 400; color: var(--rail-text); }
.stack { display: flex; gap: 2px; height: 14px; margin: 14px 0 12px; background: #27328a; border-radius: 3px; overflow: hidden; }
.stack svg { display: block; width: 100%; height: 14px; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 6px; }
.legend b { display: block; font-weight: 600; font-size: 15px; }
.legend .c1 { background: #99db71; }
.legend .c2 { background: #c7d0ff; }
.legend .c3 { background: #eeb24c; }
.legend .c4 { background: #dc98e8; }
.worth .fill-1 { fill: #99db71; } .worth .fill-2 { fill: #c7d0ff; } .worth .fill-3 { fill: #eeb24c; } .worth .fill-4 { fill: #dc98e8; }

/* عملکرد تک‌تک معاملات: هر ردیف، سرمایه ورودی را با ارزش نهایی مقایسه می‌کند */
.perf { list-style: none; margin: 0; padding: 0; }
.perf > li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.5fr) auto; gap: 8px 20px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.perf > li:last-child { border-bottom: 0; }
.perf .name { font-weight: 600; }
.perf .sub { font-size: 13px; color: var(--ink-soft); }
.perf .result { text-align: left; white-space: nowrap; }
.perf .result b { display: block; font-size: 16px; }
.bars { display: grid; grid-template-columns: 74px 1fr auto; gap: 2px 8px; align-items: center; font-size: 12.5px; color: var(--ink-soft); }
.bars svg { width: 100%; height: 12px; display: block; }
.bars .val { color: var(--ink); font-weight: 500; text-align: left; white-space: nowrap; }
.bar-base { fill: var(--bar-base); }
.bar-final { fill: var(--cat-1); }
.bar-hit { fill: transparent; }

.welcome { border: 0; padding: 0; border-radius: 12px; width: calc(100% - 32px); max-width: 420px; overflow: hidden; color: var(--ink); }
.welcome::backdrop { background: rgba(30, 36, 64, .6); }
.welcome-head { background: var(--rail); color: #fff; padding: 24px 24px 20px; text-align: center; }
.welcome-head img { display: block; width: 64px; height: 64px; margin: 0 auto 10px; background: #fff; border-radius: 50%; padding: 8px; }
.welcome-head p { margin: 0; color: var(--rail-text); }
.welcome-head strong { display: block; font-size: 34px; line-height: 1.5; color: #99db71; overflow-wrap: anywhere; }
.welcome-head small { font-size: 14px; font-weight: 400; color: var(--rail-text); }
.welcome-body { padding: 18px 24px 22px; }
.welcome-body .actions { justify-content: center; margin-top: 12px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--paper); }
.login-page.admin { background: var(--rail); }
.login-box { width: 100%; max-width: 380px; background: var(--surface); padding: 26px; border-radius: 6px; border: 1px solid var(--line); }
.login-box h1 { margin-bottom: 4px; }
.login-box .form { grid-template-columns: 1fr; margin-top: 16px; }
.home-links { display: grid; gap: 10px; margin-top: 16px; }

.jcal { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px; width: 300px; box-shadow: 0 6px 18px rgba(39, 50, 138, .18); }
.jcal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-weight: 600; }
.jcal select { width: auto; margin: 0; padding: 2px 4px; font-size: 13px; }
.jcal button { font: inherit; background: none; border: 0; cursor: pointer; padding: 3px; border-radius: 3px; color: var(--ink); }
.jcal button:hover { background: var(--tint); }
.jcal .grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 13px; }
.jcal .wd { color: var(--ink-soft); font-size: 12px; }
.jcal .today { outline: 1px solid var(--accent); }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { padding: 10px 16px; gap: 6px; }
  .brand-logo { max-width: 140px; }
  .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rail nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .rail nav a { white-space: nowrap; }
  .rail-foot { display: flex; justify-content: space-between; align-items: center; padding: 0; margin: 0; }
  .main { padding: 18px 16px 48px; }
  .demo-bar { padding: 6px 16px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .perf > li { grid-template-columns: minmax(0, 1fr) auto; }
  .perf .bars { grid-column: 1 / -1; grid-row: 2; }
  .worth .amount { font-size: 27px; }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 21px; }
}

@media print {
  .rail, .demo-bar, .toolbar, .actions, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; font-size: 12px; }
  .main { padding: 0; max-width: none; }
  .section, .figures { break-inside: avoid; }
  .worth { background: #fff; color: #000; border: 1px solid #999; }
  .worth .label, .worth .amount small { color: #333; }
}

@media (prefers-reduced-motion: no-preference) {
  .welcome[open] { animation: welcome-in .3s ease-out; }
  @keyframes welcome-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
  .btn, .rail nav a { transition: background-color .12s; }
}
