:root {
    --paper: #f0ede6;
    --paper-raised: #f8f6f1;
    --ink: #201d18;
    --ink-soft: #5c574c;
    --steel: #2f4f5e;
    --steel-dark: #1c333e;
    --steel-soft: #6f8c99;
    --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(--steel-dark);
    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: #24404d; 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;
    height: 160px;
    overflow-y: auto;
}

/* --- 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; }
}

/* --- صفحه‌ی ورود --- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--steel-dark);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--paper-raised);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.login-card .brand-name { font-weight: 800; font-size: 17px; text-align: center; margin-bottom: 2px; }
.login-card .brand-sub { font-size: 12px; color: var(--ink-soft); text-align: center; margin-bottom: 24px; }
.login-card .form-label { display: block; margin-bottom: 6px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 10px; margin-top: 8px; }
.login-error {
    background: var(--rust-soft);
    color: #8a4517;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
    margin-bottom: 16px;
}
