/* ==========================================================================
   پرونده‌یار — زبان بصری «دفتر وکالت»
   کاغذ کرم، جوهر سرمه‌ای، خط برنجی، لبه‌های تیز، وضعیت‌ها به شکل مُهر.
   ========================================================================== */

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    /* کاغذ */
    --paper: #f4f1ea;
    --paper-raised: #fbf9f5;
    --paper-sunken: #ebe6db;

    /* جوهر */
    --ink: #1b2432;
    --ink-strong: #0f1722;
    --ink-soft: #55606f;
    --ink-faint: #8b93a0;

    /* برنج */
    --brass: #a8853f;
    --brass-light: #c9ab6b;
    --brass-faint: #e3d6b8;

    /* مُهر */
    --seal-red: #9b2c2c;
    --seal-green: #2f6b4f;
    --seal-blue: #2a4d7a;
    --seal-amber: #8a6212;
    --seal-gray: #6b7280;

    --rule: #d8d0be;
    --rule-strong: #bdb298;

    --radius: 2px;
    --shadow-sheet: 0 1px 0 rgba(27, 36, 50, .04), 0 8px 24px -18px rgba(27, 36, 50, .5);

    --font-body: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    --font-display: 'Sakkal Majalla', 'Vazirmatn', serif;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--ink);
    background-color: var(--paper);
    /* بافت بسیار ملایم کاغذ */
    background-image:
        repeating-linear-gradient(0deg, rgba(27,36,50,.012) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(90deg, rgba(27,36,50,.012) 0 1px, transparent 1px 3px);
    line-height: 1.9;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--ink-strong);
    font-weight: 700;
    line-height: 1.5;
    margin: 0 0 .6rem;
    letter-spacing: 0;
}

a {
    color: var(--ink);
    text-decoration: none;
}

a:hover {
    color: var(--brass);
}

/* ---------- چیدمان کلی ---------------------------------------------------- */

.app {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---------- نوار کناری ---------------------------------------------------- */

.sidebar {
    background: var(--ink-strong);
    color: #cfd6e0;
    display: flex;
    flex-direction: column;
    border-left: 3px solid var(--brass);
}

.sidebar-brand {
    padding: 1.35rem 1.25rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand .mark {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    display: block;
    line-height: 1.3;
}

.sidebar-brand .sub {
    font-size: .72rem;
    color: var(--brass-light);
    letter-spacing: .12em;
}

.sidebar-nav {
    padding: .75rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    padding: 1rem 1.25rem .35rem;
    font-size: .68rem;
    letter-spacing: .14em;
    color: #6b7789;
    text-transform: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 1.25rem;
    color: #cfd6e0;
    font-size: .9rem;
    border-right: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, .05);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(168, 133, 63, .16);
    border-right-color: var(--brass);
    color: #fff;
    font-weight: 500;
}

.sidebar-nav a .ico {
    width: 1.15rem;
    text-align: center;
    opacity: .85;
    font-size: .95rem;
}

.sidebar-foot {
    padding: .85rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .75rem;
    color: #7c8798;
}

/* ---------- سربرگ ---------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem 1.5rem;
    background: var(--paper-raised);
    border-bottom: 1px solid var(--rule);
}

.topbar .page-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

.topbar .page-title small {
    display: block;
    font-family: var(--font-body);
    font-size: .75rem;
    font-weight: 400;
    color: var(--ink-faint);
    letter-spacing: .02em;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .85rem;
}

.topbar-user .who {
    text-align: left;
    line-height: 1.5;
}

.topbar-user .who strong {
    display: block;
    font-weight: 500;
}

.topbar-user .who span {
    color: var(--ink-faint);
    font-size: .75rem;
}

.topbar-date {
    font-size: .8rem;
    color: var(--ink-soft);
    border-right: 1px solid var(--rule);
    padding-right: .75rem;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

/* ---------- برگه (کارت) ---------------------------------------------------- */

.sheet {
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sheet);
    margin-bottom: 1.25rem;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem 1.1rem;
    border-bottom: 1px solid var(--rule);
    background: linear-gradient(to bottom, #fdfcf9, var(--paper-raised));
}

.sheet-head h2,
.sheet-head h3 {
    font-size: 1.05rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* خط برنجی کوتاه کنار تیتر برگه */
.sheet-head h2::before,
.sheet-head h3::before {
    content: '';
    width: 3px;
    height: 1.05em;
    background: var(--brass);
    display: inline-block;
}

.sheet-body {
    padding: 1.1rem;
}

.sheet-body.tight {
    padding: 0;
}

/* ---------- جدول ----------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
}

table.ledger {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

table.ledger thead th {
    background: var(--paper-sunken);
    color: var(--ink-strong);
    font-weight: 500;
    text-align: right;
    padding: .6rem .75rem;
    border-bottom: 2px solid var(--rule-strong);
    white-space: nowrap;
    font-size: .8rem;
}

table.ledger tbody td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}

table.ledger tbody tr:hover {
    background: rgba(168, 133, 63, .055);
}

table.ledger tbody tr:last-child td {
    border-bottom: 0;
}

table.ledger .num {
    color: var(--ink-faint);
    font-size: .8rem;
    width: 3rem;
}

table.ledger .actions {
    white-space: nowrap;
    width: 1%;
}

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--ink-faint);
}

.empty-state .mark {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .5rem;
    opacity: .35;
}

/* ---------- مُهر وضعیت ------------------------------------------------------ */

.seal {
    display: inline-block;
    padding: .12rem .55rem;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1.7;
    border: 1.5px solid currentColor;
    border-radius: var(--radius);
    background: transparent;
    white-space: nowrap;
    transform: rotate(-.5deg);
}

.seal-red    { color: var(--seal-red); }
.seal-green  { color: var(--seal-green); }
.seal-blue   { color: var(--seal-blue); }
.seal-amber  { color: var(--seal-amber); }
.seal-gray   { color: var(--seal-gray); }
.seal-brass  { color: var(--brass); }

/* مُهر توپر برای تأکید بیشتر */
.seal.solid {
    color: #fff;
    border-color: transparent;
}

.seal.solid.seal-red   { background: var(--seal-red); }
.seal.solid.seal-green { background: var(--seal-green); }
.seal.solid.seal-blue  { background: var(--seal-blue); }
.seal.solid.seal-amber { background: var(--seal-amber); }
.seal.solid.seal-gray  { background: var(--seal-gray); }

/* ---------- دکمه ----------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem 1rem;
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.8;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--paper-raised);
    color: var(--ink);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}

.btn:hover {
    background: var(--paper-sunken);
    border-color: var(--brass);
    color: var(--ink-strong);
}

.btn-primary {
    background: var(--ink-strong);
    border-color: var(--ink-strong);
    color: #fff;
}

.btn-primary:hover {
    background: var(--ink);
    border-color: var(--brass);
    color: #fff;
}

.btn-brass {
    background: var(--brass);
    border-color: var(--brass);
    color: #fff;
}

.btn-brass:hover {
    background: #96773a;
    border-color: #96773a;
    color: #fff;
}

.btn-danger {
    color: var(--seal-red);
    border-color: #e0bcbc;
}

.btn-danger:hover {
    background: var(--seal-red);
    border-color: var(--seal-red);
    color: #fff;
}

.btn-sm {
    padding: .2rem .55rem;
    font-size: .78rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ---------- فرم ------------------------------------------------------------ */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: .9rem 1.1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 0;
}

.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field.span-full { grid-column: 1 / -1; }

.field > label {
    font-size: .8rem;
    color: var(--ink-soft);
    font-weight: 500;
}

.field > label .req {
    color: var(--seal-red);
}

.form-control,
.form-select {
    width: 100%;
    padding: .42rem .6rem;
    font-family: var(--font-body);
    font-size: .875rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    transition: border-color .12s, box-shadow .12s;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(168, 133, 63, .15);
}

textarea.form-control {
    min-height: 6rem;
    resize: vertical;
    line-height: 1.9;
}

.form-check {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .875rem;
    padding-top: 1.4rem;
}

.form-check input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--brass);
}

.form-actions {
    display: flex;
    gap: .6rem;
    padding-top: 1.1rem;
    margin-top: 1.1rem;
    border-top: 1px solid var(--rule);
}

.field-error,
.validation-message {
    color: var(--seal-red);
    font-size: .76rem;
}

.validation-summary ul {
    margin: 0;
    padding-right: 1.1rem;
}

/* تاریخ شمسی */
input.jdate {
    text-align: center;
    letter-spacing: .04em;
}

/* ---------- پیام ----------------------------------------------------------- */

.alert {
    padding: .65rem 1rem;
    border: 1px solid;
    border-right-width: 3px;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #f0f6f2;
    border-color: var(--seal-green);
    color: #244f3b;
}

.alert-danger {
    background: #fbf1f1;
    border-color: var(--seal-red);
    color: #7a2323;
}

.alert-info {
    background: #f1f4f9;
    border-color: var(--seal-blue);
    color: #23405f;
}

.alert-warning {
    background: #fbf6ea;
    border-color: var(--seal-amber);
    color: #6b4c0e;
}

/* ---------- نوار ابزار فهرست ------------------------------------------------ */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .6rem;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--rule);
    background: var(--paper-raised);
}

.toolbar .field {
    min-width: 150px;
}

.toolbar .grow {
    flex: 1;
    min-width: 200px;
}

.toolbar .spacer {
    flex: 1;
}

/* ---------- آمار داشبورد ---------------------------------------------------- */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat {
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-top: 3px solid var(--brass);
    border-radius: var(--radius);
    padding: .9rem 1.1rem;
    box-shadow: var(--shadow-sheet);
}

.stat .label {
    font-size: .78rem;
    color: var(--ink-soft);
}

/* ارقام با فونت متن — رقم صفر فارسی در فونت تیتر بیش از حد ریز است. */
.stat .value {
    font-family: var(--font-body);
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--ink-strong);
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.stat .hint {
    font-size: .72rem;
    color: var(--ink-faint);
}

.stat.accent-red   { border-top-color: var(--seal-red); }
.stat.accent-green { border-top-color: var(--seal-green); }
.stat.accent-blue  { border-top-color: var(--seal-blue); }
.stat.accent-amber { border-top-color: var(--seal-amber); }

/* ---------- صفحه ورود ------------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.login-aside {
    background: var(--ink-strong);
    color: #cfd6e0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
    position: relative;
    border-left: 4px solid var(--brass);
}

.login-aside .mark {
    font-family: var(--font-display);
    font-size: 3.25rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.login-aside .rule {
    width: 64px;
    height: 3px;
    background: var(--brass);
    margin: 1.25rem 0;
}

.login-aside p {
    max-width: 30ch;
    color: #9ba5b4;
    font-size: .92rem;
}

.login-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 340px;
}

.login-card h1 {
    font-size: 1.5rem;
}

.login-card .lede {
    color: var(--ink-soft);
    font-size: .85rem;
    margin-bottom: 1.5rem;
}

.demo-box {
    margin-top: 1.75rem;
    padding: .75rem .9rem;
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    font-size: .78rem;
    color: var(--ink-soft);
    background: var(--paper-sunken);
}

.demo-box strong {
    color: var(--ink-strong);
}

.demo-box table {
    width: 100%;
    margin-top: .35rem;
    border-collapse: collapse;
}

.demo-box td {
    padding: .1rem 0;
}

/* ---------- کمکی ----------------------------------------------------------- */

.muted { color: var(--ink-faint); }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.flex { display: flex; }
.gap { gap: .5rem; }
.items-center { align-items: center; }
.between { justify-content: space-between; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem 1.1rem;
    border-top: 1px solid var(--rule);
    font-size: .82rem;
    color: var(--ink-soft);
}

.pager .pages {
    display: flex;
    gap: .25rem;
}

.pager .pages a,
.pager .pages span {
    padding: .15rem .55rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
}

.pager .pages .current {
    background: var(--ink-strong);
    color: #fff;
    border-color: var(--ink-strong);
}

/* ---------- واکنش‌گرا ------------------------------------------------------- */

@media (max-width: 980px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .sidebar.open {
        display: flex;
        position: fixed;
        inset: 0 0 0 auto;
        width: 250px;
        z-index: 50;
    }

    .login-page {
        grid-template-columns: 1fr;
    }

    .login-aside {
        display: none;
    }
}

@media (max-width: 640px) {
    .app-content { padding: 1rem; }
    .form-grid { grid-template-columns: 1fr; }
    .field.span-2, .field.span-3 { grid-column: span 1; }
}

/* ---------- چاپ ------------------------------------------------------------- */

@media print {
    .sidebar, .topbar, .toolbar, .form-actions, .no-print { display: none !important; }
    .app { display: block; }
    body { background: #fff; }
    .sheet { border: 0; box-shadow: none; }
}

/* ---------- تقویم شمسی ------------------------------------------------------ */

.jdp {
    position: fixed;
    display: none;
    z-index: 200;
    width: 244px;
    padding: .5rem;
    background: var(--paper-raised);
    border: 1px solid var(--rule-strong);
    border-top: 3px solid var(--brass);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px -12px rgba(27, 36, 50, .45);
    font-family: var(--font-body);
}

.jdp.open { display: block; }

.jdp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--rule);
}

.jdp-title {
    font-weight: 500;
    font-size: .9rem;
    color: var(--ink-strong);
}

.jdp-nav {
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.jdp-nav:hover { border-color: var(--brass); color: var(--brass); }

.jdp-week,
.jdp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.jdp-week {
    padding: .35rem 0 .2rem;
}

.jdp-week span {
    text-align: center;
    font-size: .7rem;
    color: var(--ink-faint);
}

.jdp-day,
.jdp-empty {
    height: 1.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-body);
}

.jdp-empty { cursor: default; }

.jdp-day:hover { background: var(--paper-sunken); border-color: var(--brass-faint); }

.jdp-day.is-today { border-color: var(--brass); color: var(--brass); font-weight: 700; }

.jdp-day.is-selected {
    background: var(--ink-strong);
    border-color: var(--ink-strong);
    color: #fff;
    font-weight: 500;
}

.jdp-foot {
    display: flex;
    gap: .35rem;
    padding-top: .45rem;
    margin-top: .35rem;
    border-top: 1px solid var(--rule);
}

.jdp-foot button {
    flex: 1;
    padding: .2rem;
    font-size: .76rem;
    font-family: var(--font-body);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink-soft);
    cursor: pointer;
}

.jdp-foot button:hover { border-color: var(--brass); color: var(--brass); }

/* ---------- نردبان مسیر (نمای گرافیکی فرایند) -------------------------------
   هم برای الگوی نوع پرونده استفاده می‌شود، هم برای مسیر واقعی هر پرونده.
   وضعیت مرحله با کلاس‌های is-done / is-current / is-skipped روی li اعمال می‌شود.
   -------------------------------------------------------------------------- */

.ladder {
    list-style: none;
    margin: 0;
    padding: 0 1.35rem 0 0;
    position: relative;
}

/* خط عمودی پیوسته پشت گره‌ها */
.ladder::before {
    content: '';
    position: absolute;
    top: 1.1rem;
    bottom: 1.1rem;
    right: .68rem;
    width: 1px;
    background: var(--rule-strong);
}

.ladder-step {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .45rem 0;
}

.ladder-node {
    position: absolute;
    right: -1.35rem;
    top: .5rem;
    width: 1.4rem;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    line-height: 1;
    color: var(--ink-soft);
    background: var(--paper-raised);
    border: 1px solid var(--rule-strong);
    border-radius: 50%;
    z-index: 1;
}

.ladder-body {
    flex: 1;
    min-width: 0;
    padding-right: .35rem;
}

.ladder-title {
    font-weight: 500;
    color: var(--ink-strong);
    line-height: 1.7;
}

.ladder-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem .85rem;
    font-size: .76rem;
    color: var(--ink-faint);
}

/* جداکننده نقطه‌ای بین آیتم‌های فرعی */
.ladder-meta span + span::before {
    content: '·';
    margin-left: .55rem;
    color: var(--rule-strong);
}

.ladder-note {
    margin-top: .25rem;
    font-size: .8rem;
    color: var(--ink-soft);
    border-right: 2px solid var(--brass-faint);
    padding-right: .5rem;
}

/* ---- وضعیت مراحل (فاز ۳) ---- */

.ladder-step.is-done .ladder-node {
    background: var(--seal-green);
    border-color: var(--seal-green);
    color: #fff;
}

.ladder-step.is-current .ladder-node {
    background: var(--brass);
    border-color: var(--brass);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(168, 133, 63, .2);
}

.ladder-step.is-current .ladder-title {
    color: var(--brass);
    font-weight: 700;
}

.ladder-step.is-skipped .ladder-title {
    color: var(--ink-faint);
    text-decoration: line-through;
}

.ladder-step.is-failed .ladder-node {
    background: var(--seal-red);
    border-color: var(--seal-red);
    color: #fff;
}

/* مرحله‌ای که دستی به پرونده اضافه شده */
.ladder-step.is-custom .ladder-node {
    border-style: dashed;
}

/* ---------- جدول مشخصات (صفحه پرونده) -------------------------------------- */

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: .35rem 1.5rem;
}

.facts > div {
    display: flex;
    gap: .5rem;
    align-items: baseline;
    border-bottom: 1px dotted var(--rule);
    padding: .2rem 0;
    min-width: 0;
}

.facts .k {
    color: var(--ink-faint);
    font-size: .78rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.facts .v {
    color: var(--ink-strong);
    font-weight: 500;
    font-size: .88rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ---------- نوار پیشرفت ------------------------------------------------------ */

.progress {
    height: 5px;
    background: var(--paper-sunken);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--brass);
    transition: width .2s;
}

/* ---------- دکمه‌های مرحله در نمای مسیر --------------------------------------- */

.ladder-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .45rem;
    opacity: .45;
    transition: opacity .12s;
}

.ladder-step:hover .ladder-actions,
.ladder-actions:focus-within {
    opacity: 1;
}

.ladder-step.is-current .ladder-actions {
    opacity: 1;
}

/* فاصله بیشتر بین مراحل وقتی دکمه دارند */
.ladder-step:has(.ladder-actions) {
    padding: .6rem 0;
}

/* ---------- تقویم ماهانه ----------------------------------------------------- */

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-head {
    margin-bottom: 2px;
}

.cal-dow {
    text-align: center;
    padding: .4rem 0;
    font-size: .78rem;
    font-weight: 500;
    color: var(--ink-soft);
    background: var(--paper-sunken);
    border-bottom: 2px solid var(--rule-strong);
}

.cal-cell {
    min-height: 92px;
    padding: .3rem;
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.cal-cell.is-blank {
    background: transparent;
    border-color: transparent;
}

.cal-cell.is-today {
    border-color: var(--brass);
    box-shadow: inset 0 0 0 1px var(--brass);
}

.cal-day {
    font-size: .78rem;
    color: var(--ink-faint);
    text-align: left;
    line-height: 1.4;
}

.cal-cell.is-today .cal-day {
    color: var(--brass);
    font-weight: 700;
}

.cal-event {
    display: block;
    padding: .12rem .3rem;
    font-size: .72rem;
    line-height: 1.55;
    border-right: 2px solid var(--brass);
    background: rgba(168, 133, 63, .1);
    color: var(--ink);
    border-radius: var(--radius);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event:hover {
    background: rgba(168, 133, 63, .22);
    color: var(--ink-strong);
}

.cal-event .t {
    color: var(--ink-faint);
    margin-left: .2rem;
}

.cal-event.is-done {
    border-right-color: var(--seal-green);
    background: rgba(47, 107, 79, .1);
}

.cal-event.is-canceled {
    border-right-color: var(--seal-gray);
    background: var(--paper-sunken);
    text-decoration: line-through;
    color: var(--ink-faint);
}

@media (max-width: 900px) {
    .cal-cell { min-height: 64px; }
    .cal-event .n { display: none; }
}

/* ---------- اسناد ------------------------------------------------------------ */

.doc-group + .doc-group {
    border-top: 1px solid var(--rule);
}

.doc-group-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1.1rem;
    background: var(--paper-sunken);
    border-bottom: 1px solid var(--rule);
}

/* ---------- ویرایشگر لایحه ---------------------------------------------------- */

.brief-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem;
    margin-top: 1.1rem;
}

.brief-body {
    font-family: var(--font-body);
    line-height: 2.1;
    min-height: 26rem;
    resize: vertical;
}

/* پیش‌نمایش شبیه برگه واقعی لایحه دیده می‌شود */
.brief-preview {
    min-height: 26rem;
    max-height: 40rem;
    overflow-y: auto;
    padding: 1.25rem 1.4rem;
    background: #fff;
    border: 1px solid var(--rule-strong);
    border-top: 3px solid var(--brass);
    border-radius: var(--radius);
    line-height: 2.2;
    text-align: justify;
    font-size: .88rem;
}

.brief-preview p {
    margin: 0 0 .5rem;
    text-indent: 1.4rem;
}

.brief-preview h4 {
    font-family: var(--font-body);
    font-size: .95rem;
    margin: 1rem 0 .35rem;
}

.brief-preview .muted {
    text-indent: 0;
}

@media (max-width: 1100px) {
    .brief-editor { grid-template-columns: 1fr; }
    .brief-preview { max-height: 24rem; }
}

code {
    font-family: var(--font-body);
    background: var(--paper-sunken);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0 .25rem;
    font-size: .95em;
}

/* ---------- نمودار میله‌ای افقی (گزارش‌ها) ----------------------------------- */

.bars {
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(6rem, 11rem) 1fr 2.5rem;
    align-items: center;
    gap: .6rem;
    font-size: .82rem;
}

.bar-label {
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-track {
    height: 14px;
    background: var(--paper-sunken);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
}

.bar-fill {
    display: block;
    height: 100%;
    background: var(--brass);
    min-width: 2px;
}

.bar-value {
    text-align: left;
    color: var(--ink-strong);
    font-weight: 500;
}

/* ---------- جمع ستون‌ها در جدول ---------------------------------------------- */

table.ledger tfoot th {
    background: var(--paper-sunken);
    border-top: 2px solid var(--rule-strong);
    padding: .6rem .75rem;
    text-align: right;
    font-weight: 700;
    color: var(--ink-strong);
    font-size: .85rem;
}

/* ---------- بخش بازشو (details) ---------------------------------------------- */

details > summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
}

details > summary::-webkit-details-marker { display: none; }

details[open] > summary {
    border-color: var(--brass);
    color: var(--brass);
}

/* ---------- نشانگر مستندات و گزارش روی هر مرحله ------------------------------ */

.stage-chips {
    display: flex;
    gap: .4rem;
    margin-top: .4rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .1rem .5rem;
    font-family: var(--font-body);
    font-size: .75rem;
    line-height: 1.8;
    color: var(--ink-faint);
    background: transparent;
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .12s, color .12s, background .12s;
}

.chip:hover {
    border-style: solid;
    border-color: var(--brass);
    color: var(--brass);
    background: rgba(168, 133, 63, .07);
}

/* مرحله‌ای که واقعاً سند یا گزارش دارد باید از دور پیدا باشد */
.chip.has-items {
    border-style: solid;
    border-color: var(--brass-light);
    background: rgba(168, 133, 63, .1);
    color: var(--ink);
}

.chip-ico {
    font-size: .85rem;
    line-height: 1;
}

.chip-count {
    min-width: 1.2rem;
    text-align: center;
    padding: 0 .2rem;
    border-radius: var(--radius);
    background: var(--paper-sunken);
    color: var(--ink-soft);
    font-size: .72rem;
}

.chip.has-items .chip-count {
    background: var(--brass);
    color: #fff;
    font-weight: 500;
}

/* ---------- مودال ------------------------------------------------------------ */

dialog.modal {
    width: min(760px, 94vw);
    max-height: 88vh;
    padding: 0;
    border: 1px solid var(--rule-strong);
    border-top: 3px solid var(--brass);
    border-radius: var(--radius);
    background: var(--paper-raised);
    color: var(--ink);
    box-shadow: 0 24px 60px -20px rgba(15, 23, 34, .55);
    /* overflow نباید hidden باشد وگرنه تقویم شمسی داخل مودال بریده می‌شود */
    overflow: visible;
}

/* مودال عریض‌تر برای فرم‌های چندستونه مثل جزئیات مرحله */
dialog.modal.modal-wide {
    width: min(960px, 95vw);
}

dialog.modal::backdrop {
    background: rgba(15, 23, 34, .45);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem 1.1rem;
    border-bottom: 1px solid var(--rule);
    background: linear-gradient(to bottom, #fdfcf9, var(--paper-raised));
}

.modal-head h3 {
    margin: 0;
    font-size: 1.02rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.modal-head h3::before {
    content: '';
    width: 3px;
    height: 1.05em;
    background: var(--brass);
    display: inline-block;
}

.modal-body {
    padding: 0;
    overflow-y: auto;
    max-height: calc(88vh - 3.2rem);
}

.modal-body > .alert {
    margin: .8rem 1.1rem 0;
}

.modal-body table.ledger {
    font-size: .84rem;
}

/* فرم پایین پنل، جدا از فهرست */
.panel-form {
    padding: 1rem 1.1rem;
    border-top: 1px solid var(--rule);
    background: var(--paper);
}

/* ---------- فهرست گزارش‌های مرحله -------------------------------------------- */

.report-list {
    display: flex;
    flex-direction: column;
}

.report-item {
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--rule);
}

.report-item:last-child {
    border-bottom: 0;
}

.report-body {
    margin: .4rem 0 .5rem;
    padding-right: .6rem;
    border-right: 2px solid var(--brass-faint);
    color: var(--ink-soft);
    font-size: .85rem;
    line-height: 2;
    white-space: pre-wrap;
}

/* ---------- نوار ابزار پرونده --------------------------------------------------
   دکمه‌های بخش‌های پرونده که هرکدام مودال مدیریت خودشان را باز می‌کنند.
   ------------------------------------------------------------------------------ */

.case-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .55rem .6rem;
    margin-bottom: 1.25rem;
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-right: 3px solid var(--brass);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sheet);
}

.case-bar-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .7rem;
    font-family: var(--font-body);
    font-size: .84rem;
    line-height: 1.9;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}

.case-bar-btn:hover {
    background: var(--paper-sunken);
    border-color: var(--rule-strong);
    color: var(--ink-strong);
}

/* بخشی که محتوا دارد باید از بخش خالی قابل تشخیص باشد */
.case-bar-btn.has-items {
    color: var(--ink-strong);
    font-weight: 500;
}

.case-bar-btn .ico {
    font-size: .95rem;
    opacity: .7;
    line-height: 1;
}

.case-bar-btn.has-items .ico {
    opacity: 1;
    color: var(--brass);
}

.case-bar-btn .n {
    min-width: 1.3rem;
    text-align: center;
    padding: 0 .25rem;
    font-size: .74rem;
    border-radius: var(--radius);
    background: var(--paper-sunken);
    color: var(--ink-faint);
}

.case-bar-btn.has-items .n {
    background: var(--brass);
    color: #fff;
}

@media (max-width: 820px) {
    .case-bar-btn .txt { display: none; }
    .case-bar-btn { padding: .35rem .5rem; }
}

/* ---------- برگه‌های داخل مودال ------------------------------------------------ */

/* پارشال‌ها بیرون از مودال «برگه» مستقل‌اند؛ داخل مودال نباید قاب دوم بسازند. */
.modal-body > .sheet {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}

.modal-body > .sheet + .sheet {
    border-top: 1px solid var(--rule);
}

.modal-body > .sheet > .sheet-head {
    background: var(--paper-sunken);
}
