/* Vazirmatn variable font, bundled so the demo works offline */
@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn-arabic.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+200C-200E, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn-latin.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+2000-200B, U+2010-206F, U+20AC; }

:root {
  --bg: #f4f2ec; --surface: #fff; --ink: #17212b; --muted: #66707c; --line: #e3e0d6;
  --brand: #0e6b5c; --brand-dark: #0a4f44; --brand-soft: #e2f1ed; --accent: #d98a1f;
  --ok: #1d7a4d; --warn: #a8660b; --err: #b3372f; --info: #2a5f9e;
  --r: 10px; --shadow: 0 1px 2px rgba(23, 33, 43, .06), 0 6px 20px rgba(23, 33, 43, .05);
}
* { box-sizing: border-box; }
html { font-family: Vazirmatn, Tahoma, sans-serif; font-size: 14.5px; line-height: 1.75; color: var(--ink); background: var(--bg); font-variant-numeric: tabular-nums; }
body { margin: 0; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted, .dim { color: var(--muted); } .sm { font-size: .85rem; }
.grow { flex: 1; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* demo strip */
.demobar { background: #17212b; color: #c9d1da; font-size: .85rem; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 7px 20px; align-items: center; }
.demobar b { background: var(--accent); color: #17212b; padding: 0 8px; border-radius: 4px; }
.demobar a { color: #c9d1da; } .demobar a.on { color: #fff; font-weight: 700; border-bottom: 2px solid var(--accent); }
.demobar .dim { color: #8a95a3; }
.linkbtn { background: none; border: 0; color: #f0b866; font: inherit; cursor: pointer; padding: 0; }

/* controls */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 7px 16px; border-radius: 8px; cursor: pointer; white-space: nowrap; display: inline-block; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: transparent; color: var(--err); border-color: #e6c3c0; }
.btn.danger:hover { background: #fbeeed; }
.btn.sm { padding: 2px 10px; font-size: .82rem; font-weight: 500; }
.btn.lg { padding: 11px 26px; font-size: 1.05rem; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); vertical-align: middle; }
input:disabled { opacity: .45; }
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); }

/* panel shell */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 38px); }
.side { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 18px 14px; }
.logo { font-size: 1.35rem; font-weight: 800; color: var(--brand-dark); display: inline-grid; grid-template-columns: auto auto; column-gap: 10px; align-items: center; line-height: 1.25; }
.logo:hover { text-decoration: none; }
.logo::before { content: ""; width: 38px; height: 38px; background: url(logo.svg) center / contain no-repeat; }
.logo:has(small)::before { grid-row: span 2; } /* two text lines only in the panels */
.logo small { font-size: .78rem; font-weight: 500; color: var(--muted); }
.who { background: var(--bg); border-radius: var(--r); padding: 12px; margin: 16px 0; }
.who label { margin-bottom: 8px; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 8px; color: var(--ink); margin-bottom: 2px; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.on { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.side nav a.locked { color: #a9b0b8; }
.count { font-size: .78rem; background: var(--bg); border-radius: 99px; padding: 0 8px; color: var(--muted); }
main { padding: 24px 28px 60px; min-width: 0; max-width: 1360px; }
.head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.head h1 { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 18px; }
.grid.money { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.states { grid-template-columns: repeat(3, 1fr); } /* 9 states: 9x1 or 3x3, never a ragged row */
@media (min-width: 1600px) { .grid.states { grid-template-columns: repeat(9, 1fr); } }

.span2 { grid-column: span 2; }
.stat b { white-space: nowrap; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; color: inherit; display: block; }
.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.3; }
.stat span { color: var(--muted); font-size: .85rem; }
.banner { border-radius: var(--r); padding: 12px 16px; margin-bottom: 18px; background: #fbeeed; color: var(--err); border: 1px solid #e6c3c0; font-weight: 600; }
.banner.info { background: #edf3fa; color: var(--info); border-color: #c9d9ec; font-weight: 400; }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; min-width: 860px; }
th, td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #faf9f5; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); }
td.acts { white-space: nowrap; }
td.acts .btn { margin-inline-end: 4px; }
td.c, th.c { text-align: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: #eceae3; color: #555; }
.st-review { background: #e3edf9; color: var(--info); } .st-wait { background: #eceae3; color: #5b5f66; } .st-advance { background: #fdf0d9; color: var(--warn); } .st-ready { background: #e8e4f6; color: #55409a; }
.st-flight { background: #dff0f4; color: #136a80; } .st-over, .st-mismatch, .st-rejected { background: #fbe4e2; color: var(--err); } .st-blocked, .st-replpend { background: #fdf0d9; color: var(--warn); }
/* 12 stages: 6x2, 4x3, 3x4 or 2x6. Never 12 across: the labels do not fit and the row overflowed the page. */
.grid.states { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; gap: 10px; }
@media (max-width: 1300px) { .grid.states { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; } }
@media (max-width: 900px) { .grid.states { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }
@media (max-width: 560px) { .grid.states { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
.grid.states .stat { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; min-width: 0; }
.grid.states .stat b { font-size: 1.25rem; order: 2; }
.grid.states .stat .badge { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grid.states .stat.zero { background: transparent; } .grid.states .stat.zero b { color: #b3b8be; font-weight: 500; }
.st-op { background: #eceae3; color: #5b5f66; } .st-acct { background: #fdf0d9; color: var(--warn); }
.st-confirm { background: #e3edf9; color: var(--info); } .st-pay { background: #e8e4f6; color: #55409a; }
.st-sent { background: #dff0f4; color: #136a80; } .st-settled { background: #dff2e6; color: var(--ok); }
.st-returned { background: #fbe4e2; color: var(--err); } .st-suspended { background: #3a424c; color: #fff; } .st-void { background: #eceae3; color: #8b8f95; text-decoration: line-through; }
.b-ok { background: #dff2e6; color: var(--ok); } .b-warn { background: #fdf0d9; color: var(--warn); } .b-err { background: #fbe4e2; color: var(--err); }
.chip { display: inline-block; background: var(--brand-soft); color: var(--brand-dark); border-radius: 6px; padding: 0 8px; font-size: .78rem; margin: 2px 0 2px 4px; }
.chip.off { background: #eceae3; color: #8b8f95; text-decoration: line-through; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs button { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 3px 12px; cursor: pointer; color: var(--ink); }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.bar input[type=search] { max-width: 280px; }
#bulk:not(:empty) { position: sticky; bottom: 14px; margin-top: 14px; background: var(--ink); color: #fff; border-radius: var(--r); padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; box-shadow: var(--shadow); }
#bulk .btn.ghost { color: #fff; border-color: #56606c; } #bulk .btn.ghost:hover { background: #2b3642; }
.drop { border: 2px dashed #cfcabb; border-radius: var(--r); padding: 44px 20px; text-align: center; background: var(--surface); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }

.dlg { border: 0; border-radius: 14px; padding: 22px; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); }
.dlg::backdrop { background: rgba(23, 33, 43, .45); }
.dlg menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 16px 0 0; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0 0 14px; }
.dl dt { color: var(--muted); font-size: .85rem; } .dl dd { margin: 0; }
.hist { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow: auto; font-size: .85rem; }
.hist li { padding: 5px 0; border-top: 1px dashed var(--line); }

#toasts { position: fixed; bottom: 18px; left: 18px; display: grid; gap: 8px; z-index: 99; max-width: min(420px, 90vw); }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); border-inline-start: 4px solid var(--ok); }
.toast.err { border-color: #ff7a70; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { border: 0; border-bottom: 1px solid var(--line); }
  .side nav { display: flex; overflow-x: auto; gap: 4px; } .side nav a { white-space: nowrap; gap: 8px; }
  main { padding: 18px 14px 60px; }
}

/* ---- app frame ---- */
.shell { min-height: calc(100vh - 38px); }
.content { min-width: 0; display: flex; flex-direction: column; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; }
.side nav h4 { margin: 18px 12px 6px; font-size: .74rem; color: var(--muted); font-weight: 600; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .org { font-size: 1rem; }
.icon { background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--ink); display: inline-flex; position: relative; }
.icon:hover { background: var(--bg); }
.navbtn { display: none; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--bg); }
.dot { position: absolute; top: 0; inset-inline-end: 0; background: var(--err); color: #fff; font-size: .68rem; min-width: 17px; height: 17px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.uname { line-height: 1.3; font-weight: 600; } .uname small { display: block; color: var(--muted); font-weight: 400; font-size: .76rem; }
.pop { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(23, 33, 43, .16); min-width: 190px; padding: 6px; z-index: 20; }
.pop.wide { width: min(360px, 86vw); max-height: 420px; overflow: auto; }
.pop a, .pop button { display: block; width: 100%; text-align: start; padding: 8px 10px; border-radius: 8px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.pop a:hover, .pop button:hover { background: var(--bg); text-decoration: none; }
.pop a small { display: block; color: var(--muted); } .pop p { margin: 8px 10px; }
.demobar .quick { margin: 0; color: #c9d1da; display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.demobar .quick select { width: auto; padding: 1px 6px; background: #26323f; color: #fff; border-color: #3b4958; margin: 0; }

/* ---- login ---- */
.login { min-height: calc(100vh - 38px); display: grid; place-content: center; gap: 16px; padding: 24px; grid-template-columns: min(400px, 100%); }
.login .card { padding: 28px; margin: 0; } .login h1 { margin: 22px 0 16px; font-size: 1.25rem; }
.btn.wide { width: 100%; text-align: center; }
.hint { display: grid; gap: 6px; font-size: .88rem; }
.hint button { font: inherit; text-align: start; background: var(--surface); border: 1px dashed #cfcabb; border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--ink); }
.hint button:hover { border-color: var(--brand); background: var(--brand-soft); }
.linkbtn.dark { color: var(--brand); }

/* ---- feedback ---- */
.busy { border: 0; border-radius: 14px; padding: 26px 34px; text-align: center; min-width: 260px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); }
.busy::backdrop { background: rgba(23, 33, 43, .45); } .busy p { margin: 12px 0 0; } .busy progress { width: 100%; height: 10px; accent-color: var(--brand); }
.spin { width: 34px; height: 34px; margin: 0 auto; border: 4px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { border-radius: var(--r); margin-bottom: 18px; background: linear-gradient(90deg, #e9e6dd 25%, #f4f2ec 50%, #e9e6dd 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .spin, .skel { animation: none; } }
.toast.sms { background: #fff; color: var(--ink); border: 1px solid var(--line); border-inline-start: 4px solid var(--accent); font-weight: 600; }
dialog .toast { position: fixed; bottom: 18px; left: 18px; max-width: min(420px, 90vw); }
.b-unknown { background: #fdf0d9; color: var(--warn); }

/* ---- pages ---- */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: stretch; }
.cols > .card { margin-bottom: 0; } .cols { margin-bottom: 18px; }
.kpi b { font-size: 1.45rem; } .kpi small { display: block; color: var(--muted); font-size: .78rem; }
.back { display: inline-block; margin-bottom: 10px; font-size: .88rem; }
th[data-act] { cursor: pointer; user-select: none; } th[data-act]:hover { color: var(--ink); } th .arr { color: var(--brand); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 14px 0; color: var(--muted); font-size: .88rem; }
.bar select { width: auto; }
.dlg.wide { width: min(760px, 94vw); }
.fields.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.chart { width: 100%; height: auto; display: block; } .chart rect { fill: var(--brand); } .chart rect:hover { fill: var(--accent); }
.chart .axis { font-size: 11px; fill: var(--muted); } .chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; } .chart .base-line { stroke: #cfcabb; }
.hbars > div { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: .88rem; }
.hbars i { height: 10px; background: var(--brand); border-radius: 99px; justify-self: start; } .hbars b { font-weight: 600; white-space: nowrap; }
.steps-line { display: flex; margin: 0 0 18px; padding: 0; list-style: none; counter-reset: st; }
.steps-line li { flex: 1; text-align: center; font-size: .8rem; color: var(--muted); position: relative; padding-top: 34px; counter-increment: st; }
.steps-line li::before { content: counter(st, persian); position: absolute; top: 0; left: 50%; translate: -50%; width: 26px; height: 26px; border-radius: 50%; background: #e3e0d6; color: #777; display: grid; place-items: center; font-weight: 700; z-index: 1; }
.steps-line li::after { content: ""; position: absolute; top: 12px; right: 50%; width: 100%; height: 2px; background: #e3e0d6; }
.steps-line li:last-child::after { display: none; }
.steps-line li.done::before, .steps-line li.cur::before { background: var(--brand); color: #fff; } .steps-line li.done::after { background: var(--brand); }
.steps-line li.cur { color: var(--ink); font-weight: 700; } .steps-line li.cur::before { box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline { list-style: none; margin: 0; padding: 0 14px 0 0; border-inline-start: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 16px 14px 0; } .timeline li::before { content: ""; position: absolute; right: -6px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline small { display: block; color: var(--muted); }
.thread { display: grid; gap: 10px; margin-bottom: 16px; }
.msg { max-width: 78%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; } .msg.admin { justify-self: end; background: var(--brand-soft); border-color: #c6e2da; }
.msg small { display: block; color: var(--muted); margin-bottom: 2px; }
.receipt { max-width: 640px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 30px; }
.receipt header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.receipt .amount { font-size: 1.6rem; font-weight: 800; text-align: center; padding: 16px; background: var(--bg); border-radius: 10px; margin: 16px 0; }
.receipt footer { border-top: 1px dashed var(--line); margin-top: 18px; padding-top: 12px; color: var(--muted); font-size: .8rem; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 264px; z-index: 30; translate: 100% 0; transition: translate .2s; box-shadow: none; border: 0; }
  .side nav { display: block; }
  body.nav-open .side { translate: 0 0; box-shadow: 0 0 0 100vmax rgba(23, 33, 43, .45); }
  .navbtn { display: inline-flex; } .topbar { padding: 8px 12px; } .uname { display: none; }
  .fields.two { grid-template-columns: 1fr; } .hbars > div { grid-template-columns: 90px 1fr auto; }
  .steps-line li { font-size: .68rem; } .demobar .dim { display: none; }
}
@media print {
  .demobar, .side, .topbar, #toasts, .noprint { display: none !important; }
  html, body { background: #fff; } .shell { display: block; } main { padding: 0; } .receipt { border: 0; }
}

.grid.kpis { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .grid.kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid.kpis { grid-template-columns: 1fr; } }
.kpi b { font-size: clamp(1.05rem, 1.55vw, 1.45rem); }

/* Order dialog: maturity and credit line only matter once barat is the chosen method. */
.dlg form:not(:has(select[name="method"] option[value="credit"]:checked)) .only-credit,
.dlg form:has(select[name="method"] option[value="credit"]:checked) .only-transfer,
.dlg form:not(:has(select[name="who"] option[value="other"]:checked)) .only-other { display: none; }
dt small { display: block; font-weight: 400; }
