:root {
    --paper: #f0ede6;
    --paper-raised: #f8f6f1;
    --ink: #201d18;
    --ink-soft: #5c574c;
    --steel: #2f4f5e;
    --steel-dark: #1c333e;
    --steel-soft: #6f8c99;
    /* رنگ سایدبار عمداً جدا از --steel-dark تعریف شده و کمی روشن‌تر است، تا
       ظاهر anbardari با ظاهر پروژه‌ی بانک (که از --steel-dark تیره برای
       سایدبار استفاده می‌کند) در نگاه اول قابل تشخیص باشد. */
    --sidebar-bg: #46697a;
    --sidebar-active-bg: #587f92;
    --rust: #c2601f;
    --rust-soft: #ecd2bc;
    --sage: #4a7a53;
    --sage-soft: #d9e6d4;
    --line: #d9d3c5;
    --line-strong: #c3bcaa;
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
a { color: inherit; text-decoration: none; }

/* --- Shell / sidebar layout --- */
/* direction:ltr اینجا عمدیه — چون CSS Grid با dir="rtl" کل صفحه، ترتیب
   ستون‌ها رو خودکار معکوس می‌کنه (ستون اول میره راست، نه چپ)؛ با قفل‌کردن
   جهت خود این کانتینر، مطمئن می‌شیم <main> همیشه چپ و <aside> (منو) همیشه
   راست می‌مونه، صرف‌نظر از این رفتار. بعدش هرکدوم جدا RTL رو برای متن
   داخل خودشون برمی‌گردونیم. */
.shell {
    display: grid;
    grid-template-columns: 1fr 236px;
    min-height: 100vh;
    direction: ltr;
}

.main, .sidebar {
    direction: rtl;
}

.sidebar {
    background: var(--sidebar-bg);
    color: #e9eef0;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 34px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
    width: 34px; height: 34px;
    border: 2px solid #c9d4d8;
    border-radius: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    padding: 3px;
    flex: none;
}
.brand-mark span { background: #c9d4d8; border-radius: 1px; }
.brand-mark span:nth-child(3) { background: var(--rust); }
.brand-name { font-weight: 800; font-size: 15px; }
.brand-sub { font-size: 11px; color: #9fb0b6; margin-top: 1px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; color: #7f929a; font-weight: 600; margin: 14px 8px 6px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 7px;
    font-size: 13.5px; color: #cfd9dc;
    transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
    background: var(--sidebar-active-bg); color: #fff; font-weight: 600;
    box-shadow: inset 3px 0 0 var(--rust);
}
.nav-ic { width: 17px; height: 17px; flex: none; display: grid; place-items: center; opacity: .85; }
.nav-ic svg { width: 100%; height: 100%; }

.sidebar-foot {
    margin-top: auto;
    display: flex; align-items: center; gap: 10px;
    padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1);
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--steel-soft); color: var(--steel-dark);
    display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.who-name { font-size: 12.5px; font-weight: 600; }
.who-role { font-size: 11px; color: #93a4ab; }

.main { padding: 26px 34px 60px; min-width: 0; }

/* --- Topbar --- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; gap: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 20px; font-weight: 800; }
.topbar .date-line { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 18px; border-radius: 8px;
    font-size: 13.5px; font-weight: 700;
    border: none; cursor: pointer;
}
.btn-primary { background: var(--rust); color: #fff; }
.btn-primary:hover { background: #a8531b; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-ghost:hover { background: var(--paper-raised); }

/* --- Panels --- */
.panel {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 22px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.panel-head h3, .panel-head h2 { font-size: 14.5px; font-weight: 800; margin: 0; }
.panel-head .see-all { font-size: 12px; color: var(--steel); font-weight: 700; }
.panel p.subtitle { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; max-width: 60ch; }

.page-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 20px; }
.page-header i { font-size: 1.3rem; color: var(--steel); }
.page-header h1 { font-size: 20px; font-weight: 800; margin: 0; }

.report-summary {
    background: var(--sage-soft);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #2f5b36;
}

/* --- Table --- */
table.data-table, table.table-app { width: 100%; border-collapse: collapse; }
table.data-table thead th, table.table-app thead th {
    text-align: right; font-size: 11.5px; color: var(--ink-soft); font-weight: 600;
    padding: 0 10px 12px; border-bottom: 1px solid var(--line-strong);
}
table.data-table tbody td, table.table-app tbody td { padding: 13px 10px; font-size: 13px; border-bottom: 1px solid var(--line); }
table.data-table tbody tr:last-child td, table.table-app tbody tr:last-child td { border-bottom: none; }
.scroll-panel {
    max-height: 65vh;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
}
.scroll-panel table.data-table, .scroll-panel table.table-app {
    margin-bottom: 0;
}
.scroll-panel table.data-table thead th, .scroll-panel table.table-app thead th {
    position: sticky;
    top: 0;
    background: var(--paper-raised);
    z-index: 1;
}

table.data-table tbody tr:hover, table.table-app tbody tr:hover { background: rgba(47,79,94,.04); cursor: pointer; }
table.data-table tbody tr.selected-row, table.table-app tbody tr.selected-row {
    background: var(--sage-soft) !important;
    box-shadow: inset 3px 0 0 var(--sage);
    font-weight: 600;
}

.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pill-paid { background: var(--sage-soft); color: #2f5b36; }
.pill-partial { background: var(--rust-soft); color: #8a4517; }
.pill-plain { background: var(--line); color: var(--ink-soft); }

/* --- Form controls (re-themed, still using Bootstrap markup) --- */
.form-select, .form-control, textarea.form-control {
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--ink);
}
.form-select:focus, .form-control:focus {
    border-color: var(--steel);
    box-shadow: 0 0 0 .2rem rgba(47,79,94,.15);
}
.form-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }

/* --- Log box --- */
.log-box {
    background: var(--steel-dark);
    color: #cfd9dc;
    border-radius: 10px;
    padding: 1rem;
    font-family: "Consolas", monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    min-height: 90px;
}

/* --- Cheque calendar --- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-nav-btn {
    background: var(--paper); border: 1px solid var(--line-strong); border-radius: 8px;
    width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.cal-nav-btn:hover { background: var(--line); }
.cal-title { font-size: 16px; font-weight: 800; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { text-align: center; font-size: 11.5px; color: var(--ink-soft); font-weight: 700; padding-bottom: 6px; }
.cal-cell {
    background: #fff; border: 1px solid var(--line);
    border-radius: 8px; min-height: 84px;
    padding: 6px 7px; font-size: 11px;
    display: flex; flex-direction: column; gap: 3px;
}
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.has-cheque { background: var(--rust-soft); border-color: var(--rust); }
.cal-day-num { font-weight: 800; font-size: 12.5px; }
.cal-cheque-item { background: rgba(255,255,255,.55); border-radius: 5px; padding: 2px 5px; font-size: 10px; }
.cal-cheque-item .amt { font-weight: 700; }
.cal-more { font-size: 10px; color: var(--rust); font-weight: 700; }

@media (max-width: 980px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; align-items: center; overflow-x: auto; padding: 14px 16px; gap: 22px; }
    .nav-group { flex-direction: row; }
    .nav-label { display: none; }
    .sidebar-foot { display: none; }
    .main { padding: 20px 18px 40px; }
}

/* --- Dashboard stat cards (اضافه‌شده برای Anbardari.Web) --- */
.cards-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 22px;
    min-width: 160px;
}
.stat-num { font-size: 26px; font-weight: 800; color: var(--steel-dark); }
.stat-label { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

/* --- ردیف‌های قابل‌کلیک برای ویرایش (Tenants/Warehouses) --- */
.row-clickable { cursor: pointer; transition: background .12s ease; }
.row-clickable:hover { background: var(--paper-raised); }
.row-clickable.table-active { background: var(--rust-soft) !important; }

/* --- انبار اشغال‌شده (غیرقابل‌انتخاب) در فرم پکیج --- */
.form-check-locked { opacity: .55; cursor: not-allowed; }

/* --- جعبه‌ی برآورد زنده‌ی مبلغ ماهانه در فرم پکیج --- */
.calc-box {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 18px;
    max-width: 420px;
}
.calc-title { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; color: var(--steel-dark); }
.calc-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; color: var(--ink-soft); }
.calc-total {
    border-top: 1px dashed var(--line);
    margin-top: 6px; padding-top: 8px;
    font-weight: 800; font-size: 15px; color: var(--rust);
}

/* --- صفحه‌ی تخصیص پرداخت: دو لیست کنار هم --- */
.mini-panel-head { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; color: var(--steel-dark); }
.mini-sum {
    margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
    font-weight: 700; font-size: 14px; text-align: left;
}

/* --- هشدار تراکنش احتمالاً تکراری در واردات بانکی --- */
.row-duplicate-warning { background: #ffebcd !important; }

/* --- نقشه اشغال واحدها (صفحه اصلی) --- */
.occ-legend-item { display: inline-flex; align-items: center; gap: 5px; margin-inline-start: 14px; font-size: 12.5px; }
.occ-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.occ-swatch-debtor { background: var(--rust); }
.occ-swatch-settled { background: var(--steel-dark); }
.occ-swatch-empty { background: #fff; border: 1px solid var(--line); }

.occ-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.occ-cell {
    width: 108px; height: 72px; border-radius: 8px;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 8px 10px; box-sizing: border-box;
}
.occ-code { font-size: 13px; font-weight: 800; }
.occ-status { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.occ-cell-debtor { background: var(--rust); color: #fff; }
.occ-cell-settled { background: var(--steel-dark); color: #fff; }
.occ-cell-empty { background: #fff; border: 1px dashed var(--line); color: var(--ink-soft); }

/* --- بیشترین بدهکاران --- */
.debtor-row { margin-bottom: 14px; }
.debtor-row:last-child { margin-bottom: 0; }
.debtor-row-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.debtor-bar-track { background: var(--paper-raised); border-radius: 5px; height: 8px; overflow: hidden; }
.debtor-bar-fill { background: var(--rust); height: 100%; border-radius: 5px; }

/* --- فعالیت اخیر --- */
.activity-item { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.activity-item:last-child { margin-bottom: 0; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rust); margin-top: 6px; flex: none; }
.activity-title { font-size: 13px; font-weight: 700; }
.activity-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* --- تقویم پرداخت‌ها --- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: 12px; font-weight: 800; color: var(--steel-dark); padding: 6px 0; }
.cal-cell {
    border: 1px solid var(--line); border-radius: 6px;
    min-height: 96px; padding: 5px 6px; box-sizing: border-box;
    cursor: pointer; overflow: hidden; transition: box-shadow .1s ease;
}
.cal-cell:hover { box-shadow: 0 0 0 2px var(--rust) inset; }
.cal-cell-blank { border: none; cursor: default; }
.cal-cell-blank:hover { box-shadow: none; }
.cal-cell-today { box-shadow: 0 0 0 2px var(--steel-dark) inset; }
.cal-cell-selected { box-shadow: 0 0 0 2px var(--rust) inset; }
.cal-day-num { font-size: 12.5px; font-weight: 800; margin-bottom: 3px; }
.cal-pay-line { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pay-cash { color: #146428; }
.cal-pay-bank { color: #143c6e; }
.cal-pay-more { font-size: 10px; color: #777; font-style: italic; }

@media (max-width: 768px) {
    .cal-grid { grid-template-columns: repeat(7, minmax(38px, 1fr)); }
    .cal-cell { min-height: 60px; padding: 3px; }
    .cal-pay-line, .cal-pay-more { display: none; }
}
