/* ============ فونت: پلاک (فقط وزن Bold موجود است؛ برای همه‌ی وزن‌ها به‌کار می‌رود) ============ */
@font-face {
    font-family: "PelakFA";
    src: url("fonts/PelakFA-Bold.otf") format("opentype");
    font-weight: 100 900; font-style: normal; font-display: swap;
    /* رقم‌های لاتین (0-9) را از فونت پلاک بیرون می‌گذارد: پلاک آن‌ها را به شکل رقم فارسی می‌کشد و نام‌هایی مثل A7III شبیه AVIII می‌شود.
       رقم‌های فارسی (۰-۹) همچنان با پلاک نمایش داده می‌شوند. برای برگرداندن، همین یک خط را پاک کنید. */
    unicode-range: U+0000-002F, U+003A-10FFFF;
}

/* ============ تم: شیشه‌ای (Liquid Glass) با درخشش نارنجی — دارک و لایت ============ */
:root, :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #07080b;
    --bg-image:
        radial-gradient(900px 620px at 88% -12%, rgba(255, 122, 26, .30), transparent 62%),
        radial-gradient(760px 520px at -6% 38%, rgba(255, 92, 0, .11), transparent 62%),
        radial-gradient(900px 640px at 58% 112%, rgba(255, 165, 70, .16), transparent 62%);
    --beam: linear-gradient(180deg, transparent, rgba(255, 176, 80, .38) 45%, rgba(255, 140, 40, .18) 70%, transparent);
    --ink: #f4efe8;
    --muted: #a69d92;
    --line: rgba(255, 255, 255, .10);
    --glass: rgba(255, 255, 255, .055);
    --glass-2: rgba(255, 255, 255, .095);
    --glass-border: rgba(255, 255, 255, .16);
    --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .015) 42%, rgba(255, 255, 255, .05));
    --glass-hi: inset 0 1px 0 rgba(255, 255, 255, .2), inset 0 -1px 0 rgba(255, 255, 255, .04);
    --shadow: 0 14px 44px rgba(0, 0, 0, .45);
    --field: rgba(0, 0, 0, .34);
    --field-hover: rgba(0, 0, 0, .46);
    --accent: #ff7a1a;
    --accent-hover: #ff9440;
    --accent-ink: #1b0e02;
    --accent-text: #ff8f3d;
    --accent-soft: rgba(255, 122, 26, .15);
    --danger: #ff7b7b;
    --ok: #46dba3;
    --warn: #ffbf5e;
    --warn-soft: rgba(255, 191, 94, .13);
    --sticky: rgba(17, 18, 23, .94);
    --dialog: rgba(24, 25, 31, .86);
    --dialog-solid: #17181e;
}
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f7f0e8;
    --bg-image:
        radial-gradient(900px 620px at 88% -12%, rgba(255, 138, 42, .32), transparent 62%),
        radial-gradient(760px 520px at -6% 38%, rgba(255, 190, 120, .30), transparent 62%),
        radial-gradient(900px 640px at 58% 112%, rgba(255, 150, 70, .22), transparent 62%);
    --beam: linear-gradient(180deg, transparent, rgba(255, 170, 80, .40) 45%, rgba(255, 140, 40, .15) 70%, transparent);
    --ink: #261b12;
    --muted: #7a6a5b;
    --line: rgba(80, 50, 20, .13);
    --glass: rgba(255, 255, 255, .55);
    --glass-2: rgba(255, 255, 255, .75);
    --glass-border: rgba(255, 255, 255, .9);
    --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, .1) 45%, rgba(255, 255, 255, .35));
    --glass-hi: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 rgba(120, 70, 20, .06);
    --shadow: 0 14px 40px rgba(120, 70, 20, .16);
    --field: rgba(255, 255, 255, .72);
    --field-hover: rgba(255, 255, 255, .92);
    --accent: #ff7a1a;
    --accent-hover: #ff9440;
    --accent-ink: #2a1200;
    --accent-text: #c24d00;
    --accent-soft: rgba(255, 122, 26, .16);
    --danger: #c42b2b;
    --ok: #0f7a52;
    --warn: #b96a00;
    --warn-soft: rgba(255, 170, 40, .18);
    --sticky: rgba(255, 248, 240, .96);
    --dialog: rgba(255, 252, 248, .9);
    --dialog-solid: #fffaf4;
}

* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }
html { background: var(--bg); }
body {
    margin: 0; color: var(--ink); min-height: 100vh;
    background: var(--bg-image), var(--bg); background-attachment: fixed;
    font: 15px/1.8 "PelakFA", Tahoma, "Segoe UI", system-ui, sans-serif; font-synthesis: none;
    -webkit-font-smoothing: antialiased;
}
/* پرتو نور عمودی پشت شیشه‌ها */
body::before {
    content: ""; position: fixed; top: -10vh; bottom: -10vh; inset-inline-start: 64%; width: 9vw; min-width: 70px;
    background: var(--beam); filter: blur(34px); opacity: .55; pointer-events: none; z-index: -1;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 700; }
h1 small { color: var(--muted); font-weight: normal; font-size: 15px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---- شیشه ---- */
.card, .glass {
    position: relative;
    background: var(--glass-sheen), var(--glass);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    box-shadow: var(--glass-hi), var(--shadow);
    padding: 20px; overflow-x: auto;
}

/* ---- بالای صفحه ---- */
.top {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    position: sticky; top: 10px; z-index: 30;
    width: min(1120px, calc(100% - 24px)); margin: 10px auto 0; padding: 8px 12px 8px 16px;
    background: var(--glass-sheen), var(--glass);
    -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
    border: 1px solid var(--glass-border); border-radius: 999px;
    box-shadow: var(--glass-hi), var(--shadow);
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 10px; color: var(--ink); white-space: nowrap; }
.brand::before {
    content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 16px 2px rgba(255, 122, 26, .75);
}
.top-nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.top-nav a { color: var(--muted); padding: 5px 15px; border-radius: 999px; transition: .15s; font-size: 14px; }
.top-nav a:hover { color: var(--ink); background: var(--glass-2); }
.top-nav a.on { color: var(--accent-ink); background: var(--accent); font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions .who, .drawer .who { font-size: 13px; color: var(--muted); }
.logout { margin: 0; }
.theme-btn {
    width: 34px; height: 34px; border-radius: 50%; padding: 0; display: inline-grid; place-items: center;
    background: var(--glass-2); color: var(--ink); border: 1px solid var(--glass-border); cursor: pointer; font-size: 16px; line-height: 1;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.theme-btn .sun { display: none; }
:root[data-theme="light"] .theme-btn .sun { display: inline; }
:root[data-theme="light"] .theme-btn .moon { display: none; }

/* ---- دکمه‌ی منو و منوی کشویی (فقط موبایل) ---- */
.menu-btn {
    display: none; width: 38px; height: 38px; border-radius: 50%; padding: 0; cursor: pointer; flex: none;
    background: var(--glass-2); border: 1px solid var(--glass-border); place-items: center; align-content: center; gap: 4px;
}
.menu-btn span { display: block; width: 17px; height: 2px; border-radius: 2px; background: var(--ink); transition: .2s; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { border-color: var(--accent); }
.menu-btn:hover span, .menu-btn[aria-expanded="true"] span { background: var(--accent-text); }
.drawer-bd { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .52); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; transition: opacity .2s; }
.drawer-bd.on { opacity: 1; }
.drawer-bd[hidden] { display: none; }
.drawer {
    position: fixed; top: 0; bottom: 0; right: 0; z-index: 100; width: min(310px, 84vw);
    display: flex; flex-direction: column; gap: 6px; padding: 16px 14px 18px; overflow-y: auto; overscroll-behavior: contain;
    background: var(--glass-sheen), var(--dialog);
    -webkit-backdrop-filter: blur(28px) saturate(170%); backdrop-filter: blur(28px) saturate(170%);
    border-inline-start: 1px solid var(--glass-border); border-radius: 26px 0 0 26px;
    box-shadow: var(--glass-hi), -20px 0 60px rgba(0, 0, 0, .45);
    transform: translateX(106%); visibility: hidden; transition: transform .24s ease, visibility 0s .24s;
}
.drawer.open { transform: none; visibility: visible; transition: transform .24s ease; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px; }
.drawer-nav { display: flex; flex-direction: column; gap: 4px; }
.drawer-nav a { display: block; padding: 12px 16px; border-radius: 16px; color: var(--ink); font-size: 16px; border: 1px solid transparent; }
.drawer-nav a:hover, .drawer-nav a:focus-visible { background: var(--glass-2); border-color: var(--glass-border); outline: none; }
.drawer-nav a.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.drawer-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.drawer-foot form { margin: 0; }
.drawer-foot .btn { width: 100%; }
.drawer-user { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 6px; }
html.no-scroll { overflow: hidden; }

main { max-width: 1120px; margin: 26px auto; padding: 0 14px 50px; }
main.wide { max-width: 1560px; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.bar h1 { margin-bottom: 10px; }
.search { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search input[name=q] { flex: 1; min-width: 180px; }

/* ---- جدول ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--glass); }
th:first-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }
th:last-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--glass); }
tbody tr:last-child td { border-bottom: 0; }
td.act { white-space: nowrap; text-align: left; }
td.act form { display: inline; }
td.act .btn { margin-inline-start: 4px; }
a.plain { color: var(--ink); }
a.plain:hover { color: var(--accent-text); }

/* ---- فرم‌ها ---- */
input, select, textarea {
    font: inherit; color: var(--ink); background: var(--field);
    border: 1px solid var(--glass-border); border-radius: 12px; padding: 9px 13px; width: 100%;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:hover, select:hover, textarea:hover { background: var(--field-hover); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
option { background: #1c1d23; color: #f4efe8; }
:root[data-theme="light"] option { background: #fff; color: #261b12; }
.search input, .search select { width: auto; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
label input, label select, label textarea { margin-top: 5px; font-size: 15px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
input[type=file] { padding: 8px; }
.form { max-width: 600px; }
.row { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; display: block; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid .span2 { grid-column: 1 / -1; }

/* ---- دکمه‌ها ---- */
.btn {
    display: inline-block; background: var(--accent); color: var(--accent-ink);
    border: 1px solid var(--accent); border-radius: 999px; padding: 8px 20px;
    font: inherit; font-weight: 700; cursor: pointer; transition: .15s; line-height: 1.6;
    box-shadow: 0 6px 20px rgba(255, 122, 26, .28);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 3px 14px; font-size: 13px; font-weight: 600; box-shadow: none; }
.btn.ghost { background: var(--glass-2); color: var(--ink); border-color: var(--glass-border); box-shadow: none; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(255, 110, 110, .4); box-shadow: none; }
.btn.danger:hover { background: rgba(255, 110, 110, .13); border-color: var(--danger); color: var(--danger); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btns form { margin: 0; }

/* ---- پیام‌ها و برچسب‌ها ---- */
.flash { padding: 11px 16px; border-radius: 14px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: rgba(70, 219, 163, .12); color: var(--ok); border-color: rgba(70, 219, 163, .32); }
.flash.bad { background: rgba(255, 110, 110, .12); color: var(--danger); border-color: rgba(255, 110, 110, .34); }
.tag { display: inline-block; white-space: nowrap; padding: 1px 12px; border-radius: 999px; font-size: 12.5px; background: var(--glass-2); color: var(--muted); border: 1px solid var(--glass-border); }
.tag.available { background: rgba(70, 219, 163, .12); color: var(--ok); border-color: rgba(70, 219, 163, .3); }
.tag.out { background: var(--warn-soft); color: var(--warn); border-color: rgba(255, 191, 94, .35); }
.tag.repair { background: rgba(255, 110, 110, .12); color: var(--danger); border-color: rgba(255, 110, 110, .3); }
.neg, .debtor { color: var(--danger); }
.pos, .creditor { color: var(--ok); }
.bal { font-weight: 600; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-border); margin-bottom: 14px; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.tabs a { padding: 6px 20px; border-radius: 999px; color: var(--muted); font-size: 14px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.tabs a small { opacity: .75; margin-inline-start: 4px; }

/* ---- ورود / راه‌اندازی ---- */
body.auth { display: grid; place-items: center; min-height: 100vh; }
.auth-card { width: min(400px, 92vw); padding: 30px; }
.auth-card h1 { text-align: center; color: var(--accent-text); margin-bottom: 22px; }
.auth-card .btn { width: 100%; padding: 10px; margin-top: 4px; }

/* ---- خانه ---- */
.dash { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.dash > .card { min-height: 232px; display: flex; flex-direction: column; overflow: hidden; }
.kpi { color: var(--ink); text-align: right; transition: transform .18s, border-color .18s; }
a.kpi:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--ink); }
.kpi .k-label { font-size: 14px; color: var(--muted); }
.kpi .k-num { margin: auto 0; text-align: center; font-size: 46px; font-weight: 700; color: var(--accent-text); line-height: 1.3; }
.kpi .k-sub { text-align: center; color: var(--muted); font-size: 13px; }
.fin .f-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fin h3 { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--muted); }
.fin .f-toggle { font-size: 12px; padding: 3px 12px; border-radius: 999px; background: var(--glass-2); color: var(--ink); border: 1px solid var(--glass-border); cursor: pointer; font-family: inherit; }
.fin .f-toggle:hover { border-color: var(--accent); color: var(--accent-text); }
.fin .v-text, .fin .v-chart { flex: 1; display: none; }
.fin[data-mode="text"] .v-text { display: flex; }
.fin[data-mode="chart"] .v-chart { display: flex; }
.fin .v-text { flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.fin .big { font-size: 33px; font-weight: 700; line-height: 1.3; color: var(--ink); }
.fin.is-debt .big { color: var(--danger); }
.fin.is-income .big { color: var(--accent-text); }
.fin .words { font-size: 13.5px; color: var(--muted); }
.fin .extra { font-size: 12.5px; color: var(--ok); margin-top: 4px; }
.fin .v-chart { align-items: center; gap: 14px; padding-top: 6px; }
.pie { width: 128px; height: 128px; flex: none; }
.pie circle.sl { transition: stroke-width .15s, opacity .15s; cursor: default; }
.pie circle.sl:hover { stroke-width: 22; }
.pie text { fill: var(--ink); font-size: 11px; font-weight: 700; text-anchor: middle; }
.pie .ring-empty { stroke: var(--line); }
.legend { list-style: none; margin: 0; padding: 0; font-size: 12.5px; flex: 1; min-width: 0; }
.legend li { display: flex; align-items: center; gap: 7px; padding: 2px 0; min-width: 0; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .pc { color: var(--muted); }
.legend .empty { color: var(--muted); }

/* ---- فاکتور و حساب ---- */
.inv-form .card { margin-bottom: 14px; }
.info { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 16px; margin-bottom: 14px; }
.info > div { display: flex; flex-direction: column; font-size: 14px; }
.info span { font-size: 12px; color: var(--muted); }
.info .span2 { grid-column: span 2; }
table.items td, table.items th { padding: 6px 4px; }
table.items input { padding: 6px 9px; font-size: 14px; min-width: 60px; border-radius: 10px; }
table.items .w-title { min-width: 220px; }
table.items td:nth-child(2) input { min-width: 220px; }
table.items .f-start { min-width: 105px; }
table.items .f-days, table.items .f-qty { min-width: 56px; width: 64px; }
table.items .f-price { min-width: 120px; }
table.items td.end, table.items td.sum { white-space: nowrap; color: var(--muted); }
table.items td.sum { color: var(--ink); font-weight: 700; }
table.items td.n { color: var(--muted); }
.items-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 16px; }
.totals > div { display: flex; flex-direction: column; }
.totals span { font-size: 12px; color: var(--muted); }
.totals b { font-size: 16px; }
.totals .grand { grid-column: 1 / -1; background: var(--accent-soft); border: 1px solid rgba(255, 122, 26, .38); border-radius: 16px; padding: 10px 16px; flex-direction: row; justify-content: space-between; align-items: center; }
.totals .grand b { font-size: 22px; color: var(--accent-text); }
.totals .words { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.pay-sum { display: flex; gap: 30px; flex-wrap: wrap; margin-bottom: 12px; }
.pay-sum > div { display: flex; flex-direction: column; }
.pay-sum span { font-size: 12px; color: var(--muted); }
.payform { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.payform label { margin: 0; flex: 1; min-width: 150px; }
.payform .btn { margin-bottom: 1px; }
.logo-prev { display: block; max-height: 70px; margin: 6px 0; background: #fff; padding: 4px; border-radius: 10px; }
.share { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.share input { flex: 1; min-width: 220px; direction: ltr; font-size: 13px; }
.theme-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }

/* متن پایین تنظیمات */
.made-by { text-align: center; color: var(--muted); font-size: 12.5px; line-height: 2; margin: 34px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---- تقویم رزرو ---- */
.sheet-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.sheet-bar form { display: flex; gap: 8px; align-items: center; margin: 0; flex-wrap: wrap; }
.sheet-bar input { width: 124px; padding: 6px 12px; direction: ltr; text-align: center; }
.legend-row { display: flex; gap: 14px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; margin-inline-start: auto; }
.legend-row i { display: inline-block; width: 22px; height: 12px; border-radius: 5px; vertical-align: middle; margin-inline-end: 5px; }
.cal { padding: 14px; overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-head { margin-bottom: 8px; }
.cal-head div { text-align: center; font-size: 13px; color: var(--muted); padding: 4px 0; }
.cal-head .fri { color: var(--danger); }
.cal-cell { min-height: 116px; border: 1px solid var(--line); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 5px; cursor: pointer; background: var(--glass); text-align: right; overflow: hidden; transition: border-color .15s, background .15s; }
.cal-cell.pad { background: transparent; border-color: transparent; cursor: default; }
.cal-cell:not(.pad):hover, .cal-cell:not(.pad):focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.cal-cell.fri:not(.pad) { background-image: linear-gradient(rgba(255, 90, 90, .07), rgba(255, 90, 90, .07)); }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 6px 24px rgba(255, 122, 26, .16); }
.cal-cell .dn { font-weight: 800; font-size: 16px; line-height: 1.2; }
.cal-cell.today .dn { color: var(--accent-text); }
.chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chip { display: block; height: 22px; line-height: 22px; border-radius: 8px; padding: 0 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip b { margin-inline-start: 5px; opacity: .85; }
.chip.final { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chip.pre { background: var(--warn-soft); border: 1px dashed var(--warn); color: var(--ink); line-height: 20px; }
.chip.more { background: transparent; color: var(--muted); padding: 0 2px; }
.ongo { font-size: 11px; color: var(--muted); margin-top: auto; }
dialog.glass-dialog {
    width: min(500px, 92vw); padding: 22px 24px; color: var(--ink);
    background: var(--glass-sheen), var(--dialog);
    -webkit-backdrop-filter: blur(26px) saturate(160%); backdrop-filter: blur(26px) saturate(160%);
    border: 1px solid var(--glass-border); border-radius: 24px; box-shadow: var(--glass-hi), 0 30px 80px rgba(0, 0, 0, .5);
}
dialog.glass-dialog::backdrop { background: rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
dialog.glass-dialog h3 { margin: 0 0 4px; font-size: 17px; }
dialog.glass-dialog .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
dialog.glass-dialog .err { color: var(--danger); font-size: 13px; margin: 0 0 10px; min-height: 0; }

@media (max-width: 860px) {
    .dash { grid-template-columns: 1fr; }
    .dash > .card { min-height: 0; }
    .grid, .info, .totals { grid-template-columns: 1fr 1fr; }
    .info .span2 { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
    .top { flex-wrap: nowrap; gap: 10px; padding: 6px 10px 6px 12px; top: 8px; margin-top: 8px; width: calc(100% - 20px); }
    .menu-btn { display: inline-grid; }
    .top-nav, .top-actions .who, .top-actions .logout { display: none; }
    .top-actions { margin-inline-start: auto; }
    .brand { font-size: 16px; }
}
@media (min-width: 821px) { .drawer, .drawer-bd { display: none !important; } }
@media (max-width: 640px) {
    /* جدول‌های لیستی در موبایل به شکل کارت: هر ردیف یک کارت دو ستونه با برچسب کوچک بالای هر مقدار */
    table.rtable, table.rtable tbody { display: block; }
    table.rtable thead { display: none; }
    table.rtable tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
    table.rtable tr:last-child { border-bottom: 0; }
    table.rtable td { display: block; padding: 0; border: 0; min-width: 0; font-size: 13.5px; }
    table.rtable td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); margin-bottom: 1px; }
    table.rtable td.full { grid-column: 1 / -1; font-size: 15px; }
    table.rtable td:not([data-label]) { grid-column: 1 / -1; }
    table.rtable td.act { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
    table.rtable td.act form { margin: 0; }
    /* کارت‌های جمع‌بندی: هر کدام یک خط فشرده */
    .stats .stat { flex-direction: row-reverse; justify-content: space-between; align-items: center; padding: 10px 16px; }
    .stats .stat .n, .stats .stat .n.small { font-size: 17px; }
    th, td { padding: 8px 6px; font-size: 13px; }
    main { margin-top: 16px; }
    .legend-row { margin-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- خانه: حالت نمودار ---- */
.fin .v-chart { flex-direction: column; align-items: stretch; gap: 8px; padding-top: 6px; }
.fin .v-chart .f-sum { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.5; }
.fin .v-chart .f-sum .muted { font-weight: 400; font-size: 12px; }
.fin .pc-row { display: flex; align-items: center; gap: 14px; flex: 1; }

/* ---- کارت‌های خلاصه (پرونده‌ی مشتری) ---- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; margin: 0; }
.stat .n { font-size: 26px; font-weight: 800; line-height: 1.3; }
.stat .n.small { font-size: 21px; }
.stat > span:last-child { color: var(--muted); font-size: 13px; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr; } }


/* فاصله‌ی کارت‌های زیر هم */
main > .card, main > form > .card { margin-bottom: 14px; }

.quick-pay { margin-bottom: 12px; }
.quick-pay form { display: inline-block; margin: 0; }

/* ---- پنجره‌ی روز ---- */
dialog.day-dlg { width: min(900px, 96vw); max-height: 92vh; padding: 0; overflow: auto; overscroll-behavior: contain; }
.dd-head { position: sticky; top: 0; z-index: 6; display: flex; justify-content: space-between; align-items: center; padding: 16px 22px 8px; background: var(--dialog-solid); }
.dd-head h3 { margin: 0; font-size: 18px; }
.dd-x { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--glass-border); background: var(--glass); color: var(--ink); cursor: pointer; font: inherit; }
.dd-x:hover { border-color: var(--accent); color: var(--accent-text); }
.dd-tabs { margin: 0 22px 10px; }
.dd-tabs a { cursor: pointer; }
.dd-pane { padding: 0 22px 18px; }
#pane-add { padding-bottom: 0; }
.rv { border: 1px solid var(--glass-border); border-inline-start: 4px solid var(--warn); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; background: var(--glass); }
.rv.final { border-inline-start-color: var(--accent); }
.rv-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.rv-head b { font-size: 15px; }
.rv ul { list-style: none; margin: 0 0 8px; padding: 0; }
.rv li { display: flex; gap: 12px; align-items: center; padding: 5px 0; border-bottom: 1px dotted var(--line); }
.rv li .t { flex: 1; font-weight: 600; min-width: 0; }
.rv li .d { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.rv .rm { width: 24px; height: 24px; border-radius: 50%; padding: 0; border: 1px solid var(--danger); background: transparent; color: var(--danger); cursor: pointer; font-size: 11px; }
.rv-act { display: flex; gap: 8px; }
.tag.start { background: var(--accent-soft); color: var(--accent-text); }
.tag.cont { color: var(--muted); border: 1px solid var(--line); background: transparent; }
dialog.glass-dialog .err { color: var(--danger); font-size: 13px; margin: 6px 0 0; }

/* فرم فاکتور در حالت فشرده (داخل پنجره) */
.items-wrap { overflow-x: auto; }
.compact .card { padding: 12px 14px; border-radius: 16px; margin-bottom: 10px; -webkit-backdrop-filter: none; backdrop-filter: none; }
.compact label { font-size: 12.5px; margin-bottom: 8px; }
.compact input, .compact select, .compact textarea { padding: 7px 12px; font-size: 14px; }
.compact .grid { gap: 0 12px; }
.compact .items-bar { margin-bottom: 6px; }
.compact .items-bar .hint { display: none; }
.compact table.items th, .compact table.items td { padding: 4px 3px; font-size: 12.5px; }
.compact table.items input { padding: 5px 7px; font-size: 13px; min-width: 52px; }
.compact table.items .w-title, .compact table.items td:nth-child(2) input { min-width: 150px; }
.compact table.items .f-price { min-width: 100px; }
.compact .totals { grid-template-columns: repeat(4, 1fr) 1.7fr; gap: 6px 12px; align-items: center; }
.compact .totals .grand { grid-column: auto; padding: 6px 12px; }
.compact .totals .grand b { font-size: 17px; }
.compact .grid { grid-template-columns: repeat(4, 1fr); }
.compact .grid .c2 { grid-column: span 2; }
.compact .grid.adj { grid-template-columns: repeat(3, 1fr); }
.compact .grid.adj .span2 { grid-column: 1 / -1; }
.compact .sticky-foot { position: sticky; bottom: 0; z-index: 5; background: var(--dialog-solid); padding: 8px 0 14px; border-top: 1px solid var(--line); }
.compact .sticky-foot .card { margin-bottom: 8px; }
.compact #inv-err { margin-bottom: 10px; white-space: pre-line; }

@media (max-width: 700px) {
    .compact .grid, .compact .grid.adj { grid-template-columns: 1fr 1fr; }
    .compact .grid .c2 { grid-column: 1 / -1; }
    .compact .totals { grid-template-columns: 1fr; }
    .compact .totals > div:not(.grand) { display: none; }
    .compact .totals .grand { grid-column: 1 / -1; }
    .cal { padding: 8px; }
    .cal-head, .cal-grid { gap: 4px; }
    .cal-head div { font-size: 10.5px; }
    .cal-cell { min-height: 74px; padding: 4px; border-radius: 10px; gap: 3px; }
    .cal-cell .dn { font-size: 13px; }
    .chip { height: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; border-radius: 5px; }
    .chip.pre { line-height: 14px; }
    .chip b, .ongo { display: none; }
    .dd-head { padding: 12px 14px 6px; }
    .dd-tabs { margin: 0 14px 8px; }
    .dd-pane { padding: 0 14px 14px; }
    .rv li { flex-wrap: wrap; gap: 4px 12px; }
}
