/* ═══════════════════════════════════════════════════════════════
   ویمو — سیستم دیزاین «لوکس مینیمال» مشکی/زرشکی (هویت برند VIMO)
   توکن‌ها → پایه → چیدمان → کامپوننت‌ها → انیمیشن‌ها
   ═══════════════════════════════════════════════════════════════ */

/* ── فونت‌های خود-میزبان (بدون CDN؛ سازگار با CSP و بدون انسداد رندر) ── */
/* تیترها: مربّا. فقط وزن Regular آزادانه در دسترس بود؛ برای «Morabba Bold»
   واقعی، فایل fonts/Morabba-Bold.woff2 را اضافه و وزن ۷۰۰ را به آن اشاره بده. */
@font-face {
    font-family: "Morabba";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/Morabba-Regular.woff2") format("woff2");
}
@font-face {
    font-family: "Morabba";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/Morabba-Regular.woff2") format("woff2");
}

/* متن: IRANYekanX. فایل نصب‌شده نسخهٔ IRANYekan کلاسیک (معادل بصری) است؛
   برای نسخهٔ لایسنس‌دار، fonts/IRANYekanX-Regular.woff2 را جایگزین کن. */
@font-face {
    font-family: "IRANYekanX";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/IRANYekanX-Regular.woff2") format("woff2");
}
@font-face {
    font-family: "IRANYekanX";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/IRANYekanX-Regular.woff2") format("woff2");
}

/* فونت پشتیبان (fallback) */
@font-face {
    font-family: "YekanBakh";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/YekanBakh-Regular.woff2") format("woff2");
}
@font-face {
    font-family: "YekanBakh";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/YekanBakh-Bold.woff2") format("woff2");
}

/* ── توکن‌های دیزاین ── */
/* تم پیش‌فرض: تیره (مشکی/زرشکی لوکس). تم روشن با data-theme="light" فعال می‌شود. */
:root, :root[data-theme="dark"] {
    color-scheme: dark;

    /* فونت‌ها */
    --font-heading: "Morabba", "IRANYekanX", "YekanBakh", "Segoe UI", Tahoma, sans-serif;
    --font-body: "IRANYekanX", "YekanBakh", "Segoe UI", Tahoma, sans-serif;

    /* پس‌زمینه‌ها (مشکی برند) */
    --bg: #0a0a0b;
    --bg-elevated: #101012;
    --surface: #151517;
    --surface-hover: #1e1e22;

    /* زرشکی — هویت برند (روی مشکی روشن‌تر تا خوانا بماند) */
    --gold: #d8567c;
    --gold-bright: #f194b0;
    --gold-dim: #a01844;
    --gold-glow: rgba(216, 86, 124, 0.22);
    --gold-soft: rgba(216, 86, 124, 0.12);
    --gold-gradient: linear-gradient(135deg, #c22a5e 0%, #98123f 55%, #750327 100%);
    --gold-shine: rgba(255, 255, 255, 0.26);

    /* متن */
    --text: #ededee;
    --text-muted: #a0a0a6;
    --text-faint: #66666c;
    --on-gold: #ffffff;

    /* خط و مرز */
    --border: #242427;
    --border-strong: #34343a;

    /* وضعیت‌ها */
    --success: #2fbf6a;
    --success-bg: rgba(47, 191, 106, 0.13);
    --danger: #ef5350;
    --danger-bg: rgba(239, 83, 80, 0.12);

    /* سایه‌ها (theme-aware) */
    --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.42);
    --shadow-gold: 0 0 32px var(--gold-glow);
    --shadow-pop: 0 12px 48px rgba(0, 0, 0, 0.6);
    --scrim: rgba(0, 0, 0, 0.55);

    /* هندسه */
    --radius: 14px;
    --radius-sm: 9px;
    --sidebar-w: 268px;

    /* حرکت */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── تم روشن: خاکستری روشن/سفید با زرشکی برند (#750327) برای کنتراست بالا ── */
:root[data-theme="light"] {
    color-scheme: light;

    --bg: #f4f4f5;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-hover: #faf1f4;

    --gold: #750327;
    --gold-bright: #8b0430;
    --gold-dim: #4b0219;
    --gold-glow: rgba(117, 3, 39, 0.16);
    --gold-soft: rgba(117, 3, 39, 0.07);
    --gold-gradient: linear-gradient(135deg, #8b0430 0%, #750327 45%, #610220 100%);
    --gold-shine: rgba(255, 255, 255, 0.5);

    --text: #141417;
    --text-muted: #64646b;
    --text-faint: #9a9aa1;
    --on-gold: #ffffff;

    --border: #e6e6e8;
    --border-strong: #d9d9dc;

    --success: #18a957;
    --success-bg: rgba(24, 169, 87, 0.10);
    --danger: #c62828;
    --danger-bg: rgba(198, 40, 40, 0.08);

    --shadow-card: 0 4px 24px rgba(80, 10, 30, 0.08);
    --shadow-gold: 0 6px 28px rgba(117, 3, 39, 0.16);
    --shadow-pop: 0 18px 60px rgba(80, 10, 30, 0.16);
    --scrim: rgba(40, 10, 20, 0.28);
}

/* ── پایه ── */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

/* عناصر رنگ‌پذیر هنگام تعویض تم نرم منتقل شوند */
.card, .sidebar, .input, .table th, .badge, .btn-ghost, .table-wrap {
    transition: background-color 0.4s var(--ease), color 0.4s var(--ease),
                border-color 0.4s var(--ease), box-shadow 0.25s var(--ease);
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0;
}
/* عنوان‌های کلیدی رابط با فونت تیتر (مربّا) */
.page-title, .card-title, .brand-name, .stat-value,
.inv-doc-title, .inv-brand-name, .kind-name, .empty-code {
    font-family: var(--font-heading);
}
p { margin: 0; }
a { color: var(--gold); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--gold-bright); }
code { font-family: Consolas, monospace; font-size: 0.9em; color: var(--gold-bright); }

::selection { background: var(--gold); color: var(--on-gold); }

/* دسترس‌پذیری: حلقه‌ی فوکوس زرشکی واضح روی عناصر تعاملی */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* عنوان صفحه فقط برنامه‌ای و برای اعلام به صفحه‌خوان فوکوس می‌گیرد (FocusOnNavigate)؛
   کاربر با کیبورد رویش نمی‌رود، پس حلقه‌ی فوکوس دیداری آن نمایش داده نشود. */
h1:focus, h1:focus-visible, .page-title:focus, .page-title:focus-visible { outline: none; }

/* اسکرول‌بار ظریف */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ── چیدمان پوسته (سایدبار راست + محتوا) ── */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border-inline-end: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.main-area { min-width: 0; }

.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 36px 32px 64px;
}

/* ── برند ── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px 22px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--gold-gradient);
    color: var(--on-gold);
    box-shadow: 0 0 24px var(--gold-glow);
}
.brand-mark svg, .brand-mark .app-logo { width: 60%; height: 60%; }

.brand-name { font-size: 19px; font-weight: 800; }
.brand-sub { font-size: 11.5px; color: var(--text-muted); }
.brand-tagline { color: var(--text-muted); font-size: 13px; }

/* ── ناوبری ── */
.nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-section { margin-bottom: 10px; }

.nav-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    letter-spacing: 0.08em;
    padding: 12px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.18s var(--ease);
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-hover);
    transform: translateX(-3px);
}

.nav-link.active {
    color: var(--gold-bright);
    background: var(--gold-soft);
    border-color: var(--gold-glow);
    font-weight: 600;
}

/* نشانگر طلایی کنار آیتم فعال */
.nav-link.active::before {
    content: "";
    position: absolute;
    inset-inline-start: -14px;
    inset-block: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--gold-gradient);
}
.nav-link { position: relative; }

.nav-icon { display: inline-flex; align-items: center; opacity: 0.9; }
.nav-link.active .nav-icon { opacity: 1; color: var(--gold-bright); }

/* ── فوتر سایدبار (کاربر + خروج) ── */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px; }

.user-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-name {
    font-size: 12.5px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
}

.logout-form { margin: 0; }

/* ── سربرگ صفحه ── */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 26px; }
.page-sub { color: var(--text-muted); margin-top: 6px; font-size: 14px; }

/* ── کارت (shadcn-like) ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    transition: border-color 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-card);
    transform: translateY(-2px);
}

.card-title { font-size: 16px; margin-bottom: 14px; letter-spacing: -0.01em; }

/* ── شبکه‌ی آمار داشبورد ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card { position: relative; overflow: hidden; }
/* نوار طلایی نازک بالای هر کارت آمار */
.stat-card::before {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 2px;
    background: var(--gold-gradient);
    opacity: 0;
    transition: opacity 0.25s var(--ease);
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { border-color: var(--gold-dim); box-shadow: var(--shadow-gold); transform: translateY(-2px); }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-value {
    font-size: 32px;
    font-weight: 800;
    margin: 6px 0 2px;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stat-hint { font-size: 11.5px; color: var(--text-faint); }

/* ── دکمه‌ها ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    position: relative;
    overflow: hidden;
}

.btn-gold {
    background: var(--gold-gradient);
    color: var(--on-gold);
    box-shadow: 0 2px 16px var(--gold-glow);
}

.btn-gold:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-gold);
}

.btn-gold:active { transform: translateY(0); }

/* درخشش هنگام hover دکمه‌ی طلایی */
.btn-gold::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, var(--gold-shine) 50%, transparent 60%);
    transform: translateX(150%);
    transition: transform 0.6s var(--ease);
}

.btn-gold:hover::after { transform: translateX(-150%); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-strong);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--gold-dim);
    background: var(--surface-hover);
}

/* دکمه‌ی مخرب (حذف/ابطال) */
.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── فرم‌ها ── */
.field { margin-bottom: 18px; }

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 7px;
}

.input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.input::placeholder { color: var(--text-faint); }
.input:hover { border-color: var(--border-strong); }

.input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

/* select ها هم استایل input بگیرند */
select.input { cursor: pointer; }

/* انتخاب‌گر تاریخ شمسی (سه منو) */
.pdate { display: flex; gap: 8px; }
.pdate-part { flex: 1; min-width: 0; padding-inline: 8px; }

.field-error { display: block; color: var(--danger); font-size: 12.5px; margin-top: 5px; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 22px;
    cursor: pointer;
}

.checkbox-row input { accent-color: var(--gold); width: 16px; height: 16px; }

/* ── هشدارها ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 18px;
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--danger);
}

/* ── صفحه‌ی ورود ── */
.auth-shell { min-height: 100vh; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(ellipse 60% 40% at 50% -10%, var(--gold-glow), transparent),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 42px 38px;
    box-shadow: var(--shadow-pop);
    position: relative;
    overflow: hidden;
}

/* هاله‌ی طلایی بالای کارت ورود */
.login-card::before {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 3px;
    background: var(--gold-gradient);
}

.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand .brand-mark { margin: 0 auto 14px; width: 54px; height: 54px; font-size: 28px; }
.login-brand .brand-name { font-size: 24px; margin-bottom: 4px; }

/* ── حالت خالی / خطا ── */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.empty-code {
    font-size: 72px;
    font-weight: 800;
    line-height: 1;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.9;
}

.muted { color: var(--text-muted); }

/* ── جدول (برای صفحه‌های مدیریتی) ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
    text-align: right;
    padding: 12px 16px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tbody tr { transition: background 0.15s var(--ease); }
.table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-hover) 45%, transparent); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* سلول‌های عددی: چپ‌چین با ارقام هم‌عرض */
.table .num-cell { direction: ltr; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td [dir="ltr"] { white-space: nowrap; }

/* جدول کارت‌شونده: در موبایل هر ردیف یک کارت با برچسبِ کنار هر مقدار (بدون اسکرول افقی) */
@media (max-width: 640px) {
    .table-wrap-cards { overflow: visible; border: none; border-radius: 0; }
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody { display: block; width: 100%; }
    .table-cards tbody tr,
    .table-cards tbody tr:nth-child(even),
    .table-cards tbody tr:hover {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 2px 14px;
        margin-bottom: 10px;
    }
    .table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        direction: rtl;
        padding: 9px 0;
        border-bottom: 1px dashed var(--border);
    }
    .table-cards tr td:last-child { border-bottom: none; }
    .table-cards td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-weight: 600;
        font-size: 12.5px;
    }
    .table-cards td.num-cell { direction: rtl; font-variant-numeric: tabular-nums; }
}

/* ── نشان (Badge) ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
}

.badge-gold { background: var(--gold-soft); color: var(--gold-bright); border: 1px solid var(--gold-glow); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.badge-muted { background: var(--surface-hover); color: var(--text-muted); border: 1px solid var(--border-strong); }

/* ── نمودارها (SVG سبک) ── */
.chart-wrap { width: 100%; }
.chart-title { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.chart-svg { width: 100%; height: 180px; display: block; }
.chart-empty { padding: 40px; text-align: center; font-size: 13px; }

.chart-axis {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 8px;
    direction: ltr;
}
.chart-peak { color: var(--gold-dim); }

/* نمودار میله‌ای */
.barchart { display: flex; flex-direction: column; gap: 12px; }
.barchart-row { display: grid; grid-template-columns: 100px 1fr 70px; align-items: center; gap: 12px; }
.barchart-label { font-size: 13px; color: var(--text-muted); }
.barchart-track { height: 10px; background: var(--bg-elevated); border-radius: 5px; overflow: hidden; }
.barchart-fill {
    height: 100%;
    background: var(--gold-gradient);
    border-radius: 5px;
    transition: width 0.6s var(--ease);
    box-shadow: 0 0 12px var(--gold-glow);
}
.barchart-value { font-size: 13px; font-weight: 600; text-align: left; direction: ltr; }

/* نمودار دایره‌ای */
.donut-layout { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 160px; height: 160px; transform: rotate(0deg); }
.donut-center { fill: var(--text); font-size: 6px; font-weight: 700; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 140px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend-item .muted { margin-inline-start: auto; }
.donut-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* نمودار ستونی عمودی */
.colchart-svg { width: 100%; height: auto; display: block; }
.colchart-xlabel { fill: var(--text-muted); font-size: 9px; }
.colchart-ylabel { fill: var(--text-faint); font-size: 8.5px; }
.colchart-legend {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--text-muted);
}
.colchart-key { display: flex; align-items: center; gap: 6px; }
.colchart-dot { width: 11px; height: 11px; border-radius: 3px; }

/* شبکه‌ی کارت‌های نمودار (دو ستون در دسکتاپ) */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 820px) {
    .chart-grid { grid-template-columns: 1fr; }
}

/* ── راهنمای درون‌صفحه‌ای ── */
.page-help {
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
    transition: border-color 0.2s var(--ease);
}
.page-help.is-open { border-color: var(--gold-glow); }

.page-help-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 11px 14px;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.page-help-toggle:hover { color: var(--gold); background: var(--gold-soft); }
.page-help.is-open .page-help-toggle { color: var(--gold); }
.page-help-toggle .icon { color: var(--gold); flex-shrink: 0; }
.page-help-title { flex: 1; }
.page-help-chevron { display: inline-flex; opacity: 0.7; }

.page-help-body {
    padding: 4px 16px 16px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
    line-height: 2;
    color: var(--text-muted);
    animation: fade 0.25s var(--ease);
}
.page-help-purpose { margin: 12px 0 10px; color: var(--text); }
.page-help-steps { margin: 0; padding-inline-start: 20px; }
.page-help-steps li { margin-bottom: 5px; }
.page-help-steps li::marker { color: var(--gold); font-weight: 700; }

.page-help-tips {
    margin: 12px 0 0;
    padding: 10px 12px;
    list-style: none;
    background: var(--gold-soft);
    border: 1px solid var(--gold-glow);
    border-radius: var(--radius-sm);
}
.page-help-tips li { display: flex; align-items: flex-start; gap: 7px; }
.page-help-tips li + li { margin-top: 6px; }
.page-help-tips .icon { color: var(--gold); flex-shrink: 0; margin-top: 5px; }

/* در چاپ، راهنما نمایش داده نشود */
@media print { .page-help { display: none !important; } }

/* ── آیکون‌های SVG ── */
.icon {
    display: inline-block;
    vertical-align: -0.15em;
    flex-shrink: 0;
}
/* آیکون داخل دکمه‌ها و لینک‌ها هم‌راستا */
.btn .icon, .nav-link .icon, .attention-label .icon { vertical-align: middle; }

/* ── مرکز فرمان مالی (ساده و راهنما) ── */
.finance-hero {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    border-radius: var(--radius);
    background: var(--gold-soft);
    border: 1px solid var(--gold-glow);
    color: var(--text);
    font-size: 14px;
}
.finance-hero .hero-icon { font-size: 22px; }

/* کاشی‌های کار سریع */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.quick-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    text-align: start;
    font-family: inherit;
    transition: all 0.22s var(--ease);
    position: relative;
    overflow: hidden;
}
.quick-tile:hover {
    border-color: var(--gold-dim);
    transform: translateY(-3px);
    box-shadow: var(--shadow-gold);
}
.quick-tile .tile-icon {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--gold-soft);
    font-size: 22px;
    margin-bottom: 6px;
}
.quick-tile .tile-title { font-size: 15px; font-weight: 700; color: var(--text); }
.quick-tile .tile-sub { font-size: 12.5px; color: var(--text-muted); }

/* بخش نیاز به توجه */
.attention-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    margin-bottom: 10px;
    transition: border-color 0.2s var(--ease);
}
.attention-item:hover { border-color: var(--border-strong); }
.attention-item.is-alert { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-bg); }
.attention-label { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.attention-emoji { font-size: 18px; }
.attention-value { font-weight: 700; font-size: 15px; }
.attention-ok { display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--success); font-size: 14px; }

/* ── انیمیشن‌ها ── */
@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-rise { animation: rise 0.5s var(--ease) both; animation-delay: var(--delay, 0ms); }
.animate-fade { animation: fade 0.35s ease both; }

@media (prefers-reduced-motion: reduce) {
    .animate-rise, .animate-fade { animation: none; }
    * { transition: none !important; }
}

/* ── خطای Blazor ── */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 16px;
    inset-inline: 16px;
    background: var(--surface);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    color: var(--text);
    padding: 14px 18px;
    z-index: 1000;
    box-shadow: var(--shadow-pop);
}

#blazor-error-ui .reload { margin-inline-start: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; float: left; }

/* ── دکمه‌ی تغییر تم (روشن/تیره) ── */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-hover);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.theme-toggle:hover { color: var(--gold-bright); border-color: var(--gold-dim); }
.theme-toggle .toggle-icon { font-size: 15px; line-height: 1; }

/* دکمه‌ی شناور تغییر تم در صفحه‌ی ورود */
.theme-toggle-float {
    position: fixed;
    inset-block-start: 20px;
    inset-inline-end: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--gold);
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    display: grid;
    place-items: center;
    transition: all 0.2s var(--ease);
    box-shadow: var(--shadow-card);
}
.theme-toggle-float:hover { border-color: var(--gold-dim); transform: rotate(20deg); }
/* آیکن بر اساس تم فعلی (ماه در روشن، خورشید در تیره) */
.theme-toggle-float .tt-moon { display: none; }
.theme-toggle-float .tt-sun { display: inline-block; }
:root[data-theme="light"] .theme-toggle-float .tt-sun { display: none; }
:root[data-theme="light"] .theme-toggle-float .tt-moon { display: inline-block; }

/* ── واکنش‌گرایی ── */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .content { padding: 24px 16px 48px; }
}

/* ── سند فاکتور ── */
.invoice-doc {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 32px 34px;
    max-width: 860px;
    margin: 0 auto;
    color: var(--text);
}

.inv-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gold);
    margin-bottom: 24px;
}
.inv-brand { display: flex; align-items: center; gap: 12px; }
.inv-brand .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 24px;
    color: var(--on-gold);
    background: var(--gold-gradient);
    box-shadow: 0 0 18px var(--gold-glow);
}
.inv-brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.inv-brand-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.inv-meta { text-align: left; min-width: 190px; }
.inv-doc-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--gold-bright);
    margin-bottom: 10px;
}
.inv-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    font-size: 13px;
    padding: 3px 0;
}

/* هشدارِ «شماره‌ی پیش‌نویس موقت است» — فقط روی فاکتور رسمیِ صادرنشده */
.inv-meta-note {
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-muted);
    background: var(--surface-hover);
    border-inline-start: 2px solid var(--gold);
    border-radius: 4px;
    padding: 5px 8px;
    margin: 4px 0 6px;
}
.inv-meta-row span:first-child { color: var(--text-muted); }
.inv-meta-row b { font-weight: 600; }

.inv-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 22px;
}
.inv-party {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.inv-party-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.inv-party-name { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.inv-party-line { font-size: 12.5px; color: var(--text-muted); line-height: 1.9; }
.inv-party-line span { color: var(--text); }

.inv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 22px;
}
.inv-table thead th {
    background: var(--surface-hover);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-align: right;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border-strong);
    white-space: nowrap;
}
.inv-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.inv-table tbody tr:last-child td { border-bottom: none; }
/* هم‌ترازی سرستون و سلول باید یکی باشد تا عدد دقیقاً زیر تیتر خودش بیفتد */
.inv-table .inv-c { text-align: center; }
.inv-table tbody .inv-c { color: var(--text-muted); }
.inv-table .inv-n { text-align: right; font-variant-numeric: tabular-nums; direction: ltr; }

.inv-bottom {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: start;
    margin-bottom: 20px;
}
.inv-words {
    background: var(--gold-soft);
    border: 1px solid var(--gold-glow);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    align-self: stretch;
}
.inv-words-label {
    display: block;
    font-size: 11.5px;
    color: var(--gold);
    font-weight: 700;
    margin-bottom: 6px;
}
.inv-words-value { font-size: 14px; font-weight: 600; line-height: 1.8; }
.inv-totals { min-width: 260px; }
.inv-total-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 7px 0;
    font-size: 13.5px;
    border-bottom: 1px dashed var(--border);
}
.inv-total-row span:first-child { color: var(--text-muted); }
.inv-total-row .inv-n { direction: ltr; font-variant-numeric: tabular-nums; font-weight: 600; }
.inv-grand {
    border-bottom: none;
    border-top: 2px solid var(--gold);
    margin-top: 4px;
    padding-top: 12px;
    font-size: 16px;
    font-weight: 800;
}
.inv-grand span:first-child { color: var(--text) !important; }
.inv-grand .inv-n { color: var(--gold-bright); }
.inv-paid .inv-n { color: var(--success); }
.inv-due .inv-n { color: var(--danger); }

.inv-notes {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 22px;
}
.inv-notes b { color: var(--text); }

.inv-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 34px;
    padding-top: 10px;
}
.inv-sign {
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
    padding-top: 46px;
    border-top: 1px solid var(--border-strong);
}

.inv-kind-badge {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 999px;
    margin-bottom: 10px;
}
.inv-kind-badge.is-official {
    color: var(--on-gold);
    background: var(--gold-gradient);
    box-shadow: 0 0 14px var(--gold-glow);
}
.inv-kind-badge.is-simple {
    color: var(--text-muted);
    background: var(--surface-hover);
    border: 1px solid var(--border-strong);
}

.inv-legal {
    margin-top: 18px;
    padding: 10px 14px;
    font-size: 11.5px;
    line-height: 1.9;
    color: var(--text-muted);
    background: var(--gold-soft);
    border: 1px solid var(--gold-glow);
    border-radius: var(--radius-sm);
    text-align: center;
}

@media (max-width: 640px) {
    .inv-head { flex-direction: column; }
    .inv-meta { text-align: right; min-width: 0; width: 100%; }
    .inv-parties { grid-template-columns: 1fr; }
    .inv-bottom { grid-template-columns: 1fr; }
    .inv-totals { min-width: 0; }
    .invoice-doc { padding: 22px 18px; }
}

/* ── انتخابگر مدل فاکتور (فرم ثبت) ── */
.kind-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.kind-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: right;
    padding: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    font-family: inherit;
}
.kind-card:hover { border-color: var(--gold-dim); background: var(--surface-hover); }
.kind-card.is-active {
    border-color: var(--gold);
    background: var(--gold-soft);
    box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow-gold);
}
.kind-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--surface-hover);
    color: var(--gold-bright);
}
.kind-card.is-active .kind-icon { background: var(--gold-gradient); color: var(--on-gold); }
.kind-name { font-size: 15px; font-weight: 700; color: var(--text); }
.kind-desc { font-size: 12px; color: var(--text-muted); line-height: 1.7; }

.inline-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 14px;
    padding: 10px 14px;
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--text);
    background: var(--gold-soft);
    border: 1px solid var(--gold-glow);
    border-radius: var(--radius-sm);
}
.inline-note .icon { color: var(--gold-bright); flex-shrink: 0; margin-top: 2px; }

@media (max-width: 560px) {
    .kind-select { grid-template-columns: 1fr; }
}

/* ── چاپ: فقط سند فاکتور، سیاه روی سفید ── */
@media print {
    .no-print { display: none !important; }
    .shell { display: block !important; }
    .sidebar, .topbar, .theme-toggle-float { display: none !important; }
    .content { padding: 0 !important; margin: 0 !important; }
    body, .shell, .content { background: #fff !important; }

    .invoice-doc {
        box-shadow: none !important;
        border: none !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #000 !important;
        background: #fff !important;
    }
    .invoice-doc * { color: #000 !important; }
    .inv-head { border-bottom-color: #000 !important; }
    .inv-brand .brand-mark {
        background: #000 !important;
        color: #fff !important;
        box-shadow: none !important;
    }
    .inv-doc-title, .inv-party-title, .inv-words-label { color: #000 !important; }
    .inv-party, .inv-words, .inv-notes {
        background: #fff !important;
        border-color: #999 !important;
    }
    .inv-table thead th { background: #f0f0f0 !important; border-bottom-color: #000 !important; }
    .inv-table tbody td { border-bottom-color: #ccc !important; }
    .inv-grand { border-top-color: #000 !important; }
    .inv-sign { border-top-color: #000 !important; }
    .badge { border: 1px solid #000 !important; background: #fff !important; }
    .inv-kind-badge {
        background: #fff !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    .inv-legal { background: #fff !important; border-color: #000 !important; }
    @page { margin: 1.4cm; }
}
