@font-face {
  font-family: "Vazirmatn";
  src: local("Vazirmatn"), url("/fonts/Vazirmatn-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #0b2d52;
  --ink-2: #14406f;
  --blue: #0066ff;
  --blue-press: #0053d4;
  --sky: #00b4ff;
  --paper: #f4f7ff;
  --white: #ffffff;
  --line: #dce5f5;
  --line-2: #c5d3ea;
  --text: #0b2d52;
  --muted: #5a7190;
  --ok: #0c8a5f;
  --ok-bg: #e3f6ee;
  --warn: #9a6200;
  --warn-bg: #fff2d6;
  --bad: #c8304a;
  --bad-bg: #fde8ec;
  --focus: 0 0 0 3px rgba(0, 180, 255, 0.45);
  --font: "Vazirmatn", Tahoma, "Noto Sans Arabic", "Segoe UI", system-ui, sans-serif;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --side: 15.5rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; line-height: 1.4; font-weight: 700; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- دکمه‌ها و فرم ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.5rem; padding: .4rem 1.1rem; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background: var(--white); color: var(--ink);
  cursor: pointer; font-weight: 600; transition: background .15s, border-color .15s;
}
.btn:hover { background: #eef3ff; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-press); }
.btn.danger { color: var(--bad); border-color: #efb9c3; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.small { min-height: 2rem; padding: .15rem .75rem; font-size: .875rem; border-radius: var(--r-sm); }

.field { display: grid; gap: .3rem; }
.field > span { font-size: .875rem; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 2.5rem; padding: .35rem .8rem; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background: var(--white);
}
.input:focus { outline: none; border-color: var(--sky); box-shadow: var(--focus); }
.input.ltr { direction: ltr; text-align: left; }
.hint { font-size: .8125rem; color: var(--muted); }
.err { font-size: .875rem; color: var(--bad); }
.check { display: flex; align-items: center; gap: .55rem; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--blue); }

/* ---------- ورود ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-hero {
  background: var(--ink); color: #fff; padding: 3rem clamp(1.5rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-hero .brand { display: flex; align-items: center; gap: .8rem; font-size: 1.35rem; font-weight: 800; }
.auth-hero .brand img { width: 3rem; height: 3rem; }
.auth-hero .claim { font-size: clamp(1.4rem, 2.6vw, 2.1rem); line-height: 1.65; font-weight: 700; max-width: 22ch; }
.auth-hero .sub { color: #a8bddb; max-width: 40ch; margin-top: 1rem; }
.trail { position: absolute; inset-inline-start: -4rem; top: 30%; width: 120%; height: 1.5rem; pointer-events: none; }
.trail i { display: block; height: .4rem; border-radius: 1rem; background: linear-gradient(270deg, var(--sky), rgba(0, 180, 255, 0)); margin: .55rem 0; }
.trail i:nth-child(2) { width: 62%; margin-inline-start: auto; opacity: .7; }
.trail i:nth-child(3) { width: 38%; margin-inline-start: auto; opacity: .45; }
.auth-form { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-form form { width: min(24rem, 100%); display: grid; gap: 1.1rem; }
.auth-form .mark { display: none; }
.swap { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .9rem; }

/* ---------- قالب برنامه ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.side {
  background: var(--ink); color: #cfe0f6; display: flex; flex-direction: column; padding: 1.25rem .9rem;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 800; font-size: 1.2rem; padding: .25rem .6rem 1.4rem; }
.side .brand img { width: 2.3rem; height: 2.3rem; }
.nav { display: grid; gap: .2rem; }
.nav a {
  display: flex; align-items: center; gap: .75rem; padding: .55rem .8rem; border-radius: var(--r-md);
  color: #cfe0f6; font-weight: 600; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.nav a[aria-current="page"] { background: rgba(0, 180, 255, .16); color: #fff; }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; inset-inline-start: -.9rem; top: .5rem; bottom: .5rem; width: .3rem; border-radius: 0 .3rem .3rem 0; background: var(--sky);
}
[dir="rtl"] .nav a[aria-current="page"]::before { border-radius: .3rem 0 0 .3rem; }
.nav svg { width: 1.2rem; height: 1.2rem; flex: none; }
.side .who { margin-top: auto; padding: .8rem .6rem 0; border-top: 1px solid rgba(255, 255, 255, .12); font-size: .875rem; }
.side .who { display: grid; gap: .15rem; justify-items: start; }
.side .who b { display: block; color: #fff; }
.side .who .num { direction: ltr; }
.side .who button { margin-top: .5rem; background: none; border: 0; color: #9fc1ea; cursor: pointer; padding: 0; text-decoration: underline; }

.main { min-width: 0; }
.page { max-width: 72rem; margin: 0 auto; padding: 1.75rem clamp(1rem, 3vw, 2.25rem) 4rem; display: grid; gap: 1.6rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: .15rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel > .p-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.panel > .p-body { padding: 1.1rem 1.25rem; }
.empty { padding: 2.2rem 1.25rem; text-align: center; color: var(--muted); display: grid; gap: .6rem; justify-items: center; }

/* ---------- ظرفیت روزانه ---------- */
.capacity { padding: 1.4rem 1.5rem; display: grid; gap: .9rem; }
.capacity .top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.capacity .big { font-size: 2rem; font-weight: 800; line-height: 1.2; }
.capacity .big small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.meter { position: relative; height: .9rem; border-radius: 1rem; background: #e6edfb; overflow: hidden; }
.meter > i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 1rem; background: linear-gradient(270deg, var(--blue), var(--sky)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.meter.full > i { background: linear-gradient(270deg, var(--bad), #ff7a8c); }
.notice { display: flex; gap: .8rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .85rem 1rem; border-radius: var(--r-md); background: var(--warn-bg); color: var(--warn); font-weight: 600; }

/* ---------- جدول و فهرست ---------- */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: start; font-size: .8125rem; color: var(--muted); font-weight: 600; padding: .55rem 1.25rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .7rem 1.25rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f6f9ff; }
.amount { font-weight: 800; font-size: 1.05rem; }
.amount small { font-weight: 500; color: var(--muted); font-size: .8rem; }
.dep { color: var(--ok); }
.wd { color: var(--bad); }

.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .65rem; border-radius: 2rem; font-size: .8125rem; font-weight: 600; background: #eaf0fc; color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.c-PERSONAL { background: #e9f1ff; color: #1f4fb2; }
.chip.c-BANK { background: #def5ea; color: #0b704c; }
.chip.c-GOVERNMENT { background: #ece8fb; color: #4a3aa8; }
.chip.c-COMPANY { background: #e0f2f7; color: #106480; }
.chip.c-PROMOTIONAL { background: #fff0d9; color: #8d5a00; }
.chip.c-OPERATOR { background: #fbe6f0; color: #9b2a62; }
.chip.c-UNKNOWN { background: #eceff4; color: #53637a; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .8rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.filters .wide { grid-column: span 2; }
.cats { display: flex; gap: .4rem; flex-wrap: wrap; padding: .75rem 1.25rem 0; }
.cats button { cursor: pointer; border: 1px solid var(--line-2); background: var(--white); border-radius: 2rem; padding: .1rem .85rem; font-size: .875rem; font-weight: 600; }
.cats button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.day { position: sticky; top: 0; z-index: 1; background: #f1f5fd; padding: .4rem 1.25rem; font-size: .85rem; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.msg { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) auto; gap: .9rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--line); cursor: pointer; align-items: start; }
.msg:hover { background: #f6f9ff; }
.msg .time { color: var(--muted); font-size: .85rem; padding-top: .1rem; }
.msg .who { font-weight: 700; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.msg .dir { width: 1.1rem; height: 1.1rem; flex: none; }
.msg .dir.in { color: var(--blue); }
.msg .dir.out { color: var(--muted); }
.msg .preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.msg.open .preview { display: none; }
.msg .body { display: none; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .35rem; padding: .7rem .9rem; background: var(--paper); border-radius: var(--r-md); border: 1px solid var(--line); }
.msg.open .body { display: block; }
.msg .side-meta { display: grid; gap: .3rem; justify-items: end; font-size: .8rem; color: var(--muted); }

.trailrow { display: inline-flex; align-items: center; gap: .25rem; font-size: .8125rem; color: var(--muted); }
.trailrow .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--line-2); }
.trailrow .dot.on { background: var(--blue); }
.trailrow .dot.done { background: var(--ok); }
.trailrow .ln { width: .9rem; height: 2px; background: var(--line-2); }
.trailrow .ln.on { background: var(--blue); }

.more { padding: 1rem; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.stat { padding: 1rem 1.25rem; border-inline-start: 1px solid var(--line); }
.stat:first-child { border-inline-start: 0; }
.stat b { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.3; }
.stat span { color: var(--muted); font-size: .875rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 8rem; padding-top: .5rem; }
.bars i { flex: 1; background: linear-gradient(0deg, var(--blue), var(--sky)); border-radius: 3px 3px 0 0; min-height: 2px; }
.cat-row { display: grid; grid-template-columns: 6rem minmax(0, 1fr) 4rem; align-items: center; gap: .8rem; padding: .35rem 0; }
.cat-row .bar { height: .6rem; border-radius: 1rem; background: #e6edfb; overflow: hidden; }
.cat-row .bar > i { display: block; height: 100%; background: var(--blue); border-radius: 1rem; }

/* ---------- پنجره و اعلان ---------- */
.overlay { position: fixed; inset: 0; background: rgba(11, 45, 82, .5); display: grid; place-items: center; padding: 1rem; z-index: 50; }
.dialog { background: var(--white); border-radius: var(--r-lg); width: min(34rem, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(11, 45, 82, .3); }
.dialog > header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dialog > .body { padding: 1.25rem; display: grid; gap: 1rem; }
.dialog > footer { padding: .9rem 1.25rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; justify-content: flex-start; flex-wrap: wrap; }
.secret { display: grid; gap: .3rem; }
.secret code { direction: ltr; text-align: left; display: block; padding: .6rem .8rem; background: var(--ink); color: #d6e8ff; border-radius: var(--r-md); overflow-wrap: anywhere; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.toasts { position: fixed; inset-inline-start: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: .65rem 1rem; border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(11, 45, 82, .3); max-width: 22rem; }
.toast.bad { background: var(--bad); }
.skeleton { height: 3rem; margin: .7rem 1.25rem; border-radius: var(--r-md); background: linear-gradient(90deg, #eaf0fc, #f6f9ff, #eaf0fc); background-size: 200% 100%; animation: sk 1.4s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- موبایل ---------- */
@media (max-width: 56rem) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-form .mark { display: block; width: 3.4rem; margin-bottom: .5rem; }
  .app { grid-template-columns: 1fr; padding-bottom: 4.4rem; }
  .side { position: fixed; inset: auto 0 0 0; top: auto; height: auto; flex-direction: row; padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom)); z-index: 40; border-top: 1px solid rgba(255, 255, 255, .12); }
  .side .brand, .side .who { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .nav a { flex-direction: column; gap: .1rem; font-size: .72rem; padding: .35rem .1rem; text-align: center; }
  .nav a[aria-current="page"]::before { display: none; }
  .filters .wide { grid-column: span 1; }
  .msg { grid-template-columns: minmax(0, 1fr) auto; }
  .msg .time { grid-column: 2; grid-row: 1; text-align: end; }
  .msg .content { grid-column: 1; grid-row: 1; }
  .msg .side-meta { grid-column: 1 / -1; justify-items: start; grid-auto-flow: column; justify-content: start; }
  .topbar-m { display: flex !important; }
  .stat { border-inline-start: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
}
.topbar-m { display: none; justify-content: space-between; align-items: center; padding: .7rem 1rem; background: var(--ink); color: #fff; }
.topbar-m button { background: none; border: 0; color: #9fc1ea; cursor: pointer; }
.topbar-m .brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; }
.topbar-m img { width: 1.8rem; height: 1.8rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
