/* ============================================
   سامانه مدیریت چک و اقساط - UI بهبود یافته
   ============================================ */

:root {
    --font: 'IRANYekan', Tahoma, sans-serif;
    --primary: #4c6ef5;
    --primary-dark: #364fc7;
    --success: #0ca678;
    --danger: #e03131;
    --warning: #f59f00;
    --mustard: #c9a227;
    --info: #15aabf;
    --radius: 14px;
    --shadow: 0 2px 12px rgba(0,0,0,.06);
    --shadow-hover: 0 8px 28px rgba(0,0,0,.12);
    --transition: .22s ease;
    --sidebar-w: 250px;
    --sidebar-collapsed: 72px;
}

/* ---- تم روشن: سایدبار هم روشن ---- */
[data-theme="light"] {
    --bg: #f4f6fb;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-sidebar: #475569;
    --text-sidebar-active: #4c6ef5;
    --border: #e2e8f0;
    --border-sidebar: #e2e8f0;
    --input-bg: #fff;
    --hover: #f1f5f9;
    --sidebar-hover: #f1f5f9;
    --sidebar-active-bg: rgba(76,110,245,.1);
    --modal-bg: rgba(15,23,42,.4);
    --topbar-bg: #ffffff;
}

/* ---- تم تاریک ---- */
[data-theme="dark"] {
    --bg: #0f1117;
    --bg-card: #1a1d2e;
    --bg-sidebar: #12141f;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #fff;
    --border: #2d3148;
    --border-sidebar: #2d3148;
    --input-bg: #1e2235;
    --hover: #22253a;
    --sidebar-hover: rgba(255,255,255,.06);
    --sidebar-active-bg: rgba(76,110,245,.2);
    --modal-bg: rgba(0,0,0,.65);
    --topbar-bg: #1a1d2e;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 15px;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    direction: rtl;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }

/* ---- Layout: اسکرول فقط روی محتوای اصلی ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    border-left: 1px solid var(--border-sidebar);
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span:not(.nav-icon),
.sidebar.collapsed .user-info,
.sidebar.collapsed .btn-logout span {
    display: none;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}
.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 18px 8px;
}
.sidebar.collapsed .sidebar-footer {
    justify-content: center;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px;
    border-bottom: 1px solid var(--border-sidebar);
    min-height: 64px;
    flex-shrink: 0;
}
.brand-icon { font-size: 1.6rem; flex-shrink: 0; }
.brand-text {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, #4c6ef5, #15aabf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    margin: 2px 10px;
    border-radius: 10px;
    color: var(--text-sidebar);
    transition: all var(--transition);
    border: none;
    white-space: nowrap;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-sidebar-active);
}
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--text-sidebar-active);
    font-weight: 700;
}
.nav-icon {
    font-size: 1.25rem;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-sidebar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: var(--text); font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .72rem; opacity: .75; }
.btn-logout {
    background: rgba(224,49,49,.12);
    color: var(--danger);
    border: none;
    border-radius: 10px;
    width: 36px; height: 36px;
    cursor: pointer;
    font-size: 1.05rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition);
}
.btn-logout:hover { background: rgba(224,49,49,.25); }

.main-content {
    flex: 1;
    margin-right: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    transition: margin-right var(--transition);
}
.sidebar.collapsed ~ .main-content,
body.sidebar-collapsed .main-content {
    margin-right: var(--sidebar-collapsed);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}
.btn-menu, .btn-collapse {
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 40px; height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.btn-menu:hover, .btn-collapse:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-menu { display: none; }

.page-title {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.topbar-actions { margin-right: auto; display: flex; gap: 8px; }
.btn-icon {
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 40px; height: 40px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
    color: var(--text);
}
.btn-icon:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* محتوای اصلی اسکرول می‌شود — نه کل صفحه */
.content-area {
    padding: 20px 24px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.content-area::-webkit-scrollbar { width: 8px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}
.card-title { font-size: 1.05rem; font-weight: 800; }

/* ---- Stats ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0; left: 0;
    height: 3px;
    background: var(--stat-color, var(--primary));
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}
.stat-icon { font-size: 1.6rem; margin-bottom: 4px; }
.stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--stat-color, var(--primary));
}
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 15px;
    border: none;
    border-radius: 10px;
    font-family: var(--font);
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; box-shadow: 0 4px 14px rgba(76,110,245,.35); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #099268; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c92a2a; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #e67700; color: #fff; }
.btn-secondary { background: var(--hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: .78rem; border-radius: 8px; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Quick filter chips ---- */
.quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.qf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 700;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    background: var(--hover);
    color: var(--text);
}
.qf:hover { transform: translateY(-1px); }
.qf.active { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.qf-all.active { border-color: var(--primary); color: var(--primary); background: rgba(76,110,245,.1); }
.qf-overdue { color: var(--danger); }
.qf-overdue.active { border-color: var(--danger); background: rgba(224,49,49,.12); }
.qf-today { color: #e8590c; }
.qf-today.active { border-color: #e8590c; background: rgba(232,89,12,.12); }
.qf-tomorrow { color: var(--mustard); }
.qf-tomorrow.active { border-color: var(--mustard); background: rgba(201,162,39,.15); }
.qf-week { color: var(--warning); }
.qf-week.active { border-color: var(--warning); background: rgba(245,159,0,.12); }
.qf-pending { color: var(--primary); }
.qf-pending.active { border-color: var(--primary); background: rgba(76,110,245,.1); }
.qf-paid { color: var(--success); }
.qf-paid.active { border-color: var(--success); background: rgba(12,166,120,.1); }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 700;
    font-size: .88rem;
}
.form-control {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font-family: var(--font);
    font-size: .92rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(76,110,245,.18);
}
.form-control:disabled, .form-control[readonly] {
    opacity: .75;
    background: var(--hover);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 72px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(224,49,49,.15);
}
.field-error {
    color: var(--danger);
    font-size: .8rem;
    margin-top: 4px;
    font-weight: 600;
}

/* ---- Tables ---- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
th, td {
    padding: 9px 11px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
th {
    background: var(--hover);
    font-weight: 800;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
tr:hover td { background: var(--hover); }

.row-paid td { opacity: .6; }
.row-near td { background: rgba(245,159,0,.07) !important; }
.row-today td { background: rgba(232,89,12,.1) !important; }
.row-tomorrow td { background: rgba(201,162,39,.1) !important; }
.row-urgent td { background: rgba(232,89,12,.12) !important; }
.row-overdue td { background: rgba(224,49,49,.14) !important; font-weight: 700; }

/* ---- Badges & Chips ---- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
}
.badge-success { background: rgba(12,166,120,.14); color: var(--success); }
.badge-danger { background: rgba(224,49,49,.14); color: var(--danger); }
.badge-warning { background: rgba(245,159,0,.14); color: var(--warning); }
.badge-info { background: rgba(21,170,191,.14); color: var(--info); }
.badge-primary { background: rgba(76,110,245,.14); color: var(--primary); }
.badge-mustard { background: rgba(201,162,39,.18); color: #9a7b1a; }
.badge-orange { background: rgba(232,89,12,.14); color: #e8590c; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .78rem;
    background: var(--hover);
    border: 1px solid var(--border);
    margin: 2px;
    white-space: nowrap;
}
.chip-near { background: rgba(245,159,0,.12); border-color: var(--warning); color: var(--warning); }
.chip-today { background: rgba(232,89,12,.12); border-color: #e8590c; color: #e8590c; }
.chip-tomorrow { background: rgba(201,162,39,.15); border-color: var(--mustard); color: #9a7b1a; }
.chip-urgent { background: rgba(224,49,49,.12); border-color: var(--danger); color: var(--danger); }
.chip-paid { background: rgba(12,166,120,.1); border-color: var(--success); color: var(--success); }
.chip-overdue { background: rgba(224,49,49,.14); border-color: var(--danger); color: var(--danger); font-weight: 700; }

.amt-paid { color: var(--success); font-weight: 700; }
.amt-fine { color: var(--danger); font-weight: 700; }
.amt-remain { color: var(--warning); font-weight: 700; }
.amt-base { color: var(--text); font-weight: 600; }

/* ---- Alerts ---- */
.alert {
    padding: 11px 15px;
    border-radius: 10px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    animation: slideDown .3s ease;
}
.alert-success { background: rgba(12,166,120,.1); color: var(--success); border: 1px solid rgba(12,166,120,.25); }
.alert-error { background: rgba(224,49,49,.1); color: var(--danger); border: 1px solid rgba(224,49,49,.25); }
.alert-warning { background: rgba(245,159,0,.1); color: var(--warning); border: 1px solid rgba(245,159,0,.25); }
.alert-info { background: rgba(76,110,245,.1); color: var(--primary); border: 1px solid rgba(76,110,245,.25); }
.alert-close {
    background: none; border: none; font-size: 1.25rem;
    cursor: pointer; color: inherit; opacity: .7;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Filters ---- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    align-items: flex-end;
}
.filters .form-group { margin-bottom: 0; flex: 1; min-width: 130px; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-bg);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .2s ease;
}
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.28);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn .22s ease;
}
.modal-lg { max-width: 700px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; }
.modal-close {
    background: none; border: none; font-size: 1.4rem;
    cursor: pointer; color: var(--text-muted); line-height: 1;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 18px; }
.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
    from { opacity: 0; transform: scale(.94); }
    to { opacity: 1; transform: scale(1); }
}

/* ---- Jalali Date Picker ---- */
.jdp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.jdp-popup {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,.22);
    padding: 14px;
    width: 300px;
    border: 1px solid var(--border);
}
.jdp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 4px;
}
.jdp-title { font-weight: 800; font-size: .9rem; flex: 1; text-align: center; }
.jdp-nav {
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 30px; height: 30px;
    cursor: pointer;
    font-size: .95rem;
    color: var(--text);
    flex-shrink: 0;
}
.jdp-nav:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.jdp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: .72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 700;
}
.jdp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.jdp-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: .84rem;
    border: 2px solid transparent;
    transition: all .12s;
}
.jdp-day:hover { background: var(--primary); color: #fff; }
.jdp-day.selected { background: var(--primary); color: #fff; font-weight: 800; }
.jdp-day.today { border-color: var(--primary); font-weight: 800; }
.jdp-day.empty { cursor: default; visibility: hidden; }
.jdp-footer {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: center;
}

/* ---- Bank cards ---- */
.bank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.bank-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}
.bank-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.bank-card-header {
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.bank-logo {
    width: 44px; height: 44px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--hover);
}
.bank-logo-placeholder {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    font-weight: 800;
}
.bank-info { flex: 1; min-width: 0; }
.bank-name { font-weight: 800; font-size: 1rem; }
.bank-account { font-size: .76rem; color: var(--text-muted); }
.bank-stats {
    display: flex;
    gap: 10px;
    padding: 8px 14px;
    font-size: .78rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.bank-body { padding: 10px 14px; }
.checkbook-item {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.checkbook-item:last-child { border-bottom: none; }
.checkbook-name { font-weight: 700; font-size: .88rem; }
.checkbook-meta { font-size: .72rem; color: var(--text-muted); }
.check-chips { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 7px;
}
.swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform .12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-card); }

/* ---- Auth ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1a1d2e 0%, #2d3148 50%, #1a1d2e 100%);
    padding: 20px;
}
.auth-box {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
[data-theme="light"] .auth-box {
    --bg-card: #fff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --input-bg: #fff;
    --hover: #f1f5f9;
}
.auth-box h1 {
    text-align: center;
    margin-bottom: 6px;
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--primary), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: .88rem;
}

/* ---- Banners ---- */
.urgent-banner {
    background: linear-gradient(135deg, rgba(224,49,49,.1), rgba(232,89,12,.08));
    border: 1px solid rgba(224,49,49,.25);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.urgent-banner h3 {
    color: var(--danger);
    margin-bottom: 8px;
    font-size: .95rem;
}
.urgent-list { display: flex; flex-wrap: wrap; gap: 6px; }

.empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 2.6rem; margin-bottom: 10px; }

.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.report-item {
    background: var(--hover);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}
.report-item .val { font-size: 1.15rem; font-weight: 800; }
.report-item .lbl { font-size: .76rem; color: var(--text-muted); }

.logo-preview {
    width: 72px; height: 72px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-top: 8px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}
.sidebar-backdrop.show { display: block; }

/* ---- Date nav (lookup) ---- */
.date-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.date-nav .form-control { width: 150px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(100%);
        width: var(--sidebar-w) !important;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { width: var(--sidebar-w) !important; }
    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .nav-item span:not(.nav-icon),
    .sidebar.collapsed .user-info { display: flex; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 11px 18px; }
    .main-content { margin-right: 0 !important; }
    .btn-menu { display: flex; }
    .btn-collapse { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filters { flex-direction: column; }
    .filters .form-group { min-width: 100%; }
    .content-area { padding: 14px; }
}

/* ---- Flash Modal (center) ---- */
.flash-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn .2s ease;
}
.flash-modal {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px 32px;
    min-width: 280px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    border: 1px solid var(--border);
    animation: scaleIn .25s ease;
}
.flash-modal.alert-success { border-top: 4px solid var(--success); }
.flash-modal.alert-error { border-top: 4px solid var(--danger); }
.flash-modal-icon {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}
.flash-modal.alert-success .flash-modal-icon { color: var(--success); }
.flash-modal.alert-error .flash-modal-icon { color: var(--danger); }
.flash-modal-msg {
    font-size: 1rem;
    margin-bottom: 18px;
    color: var(--text);
    line-height: 1.6;
}
.flash-modal-btn { min-width: 100px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- App version ---- */
.app-version {
    display: block;
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 4px;
    opacity: .8;
}

/* ---- Nav icon SVG ---- */
.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}
.nav-icon svg { display: block; }
.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.brand-icon svg { display: block; }

/* ---- Bank drag ---- */
.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.bank-card { position: relative; transition: box-shadow .2s, transform .15s; }
.bank-card.dragging { opacity: .6; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.bank-card.drag-over { outline: 2px dashed var(--primary); }
.drag-handle {
    cursor: grab;
    padding: 4px 8px;
    color: var(--text-muted);
    font-size: 1.1rem;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.bank-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 12px;
    font-size: .82rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.bank-stats-grid span { color: var(--text-muted); }
.bank-stats-grid strong { color: var(--text); }

/* ---- Confirm modal override ---- */
.confirm-modal-btns { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }

/* ---- Manual accounts ---- */
.manual-unit-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--primary-bg, rgba(76,110,245,.12));
    color: var(--primary);
    font-size: .8rem;
}
.remain-positive { color: var(--danger); font-weight: 600; }
.remain-zero { color: var(--success); font-weight: 600; }

/* Flash modal solid background */
.flash-modal-overlay {
    background: rgba(0,0,0,.55) !important;
}
.flash-modal {
    background: var(--card-bg) !important;
    opacity: 1 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Image attachment */
.img-attach-preview {
    max-width: 120px;
    max-height: 80px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 6px;
    cursor: pointer;
    object-fit: cover;
}
.img-view-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
}
.img-view-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

/* Bank detail clickable */
.bank-card-clickable { cursor: pointer; }
.bank-card-clickable:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); }


/* Bank logo small in lists */
.bank-logo-sm {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    object-fit: cover;
    vertical-align: middle;
    margin-left: 6px;
    border: 1px solid var(--border);
}
.bank-logo-sm-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 6px;
}

/* Theme sun/moon */
#btnTheme .icon-sun { display: none; }
#btnTheme .icon-moon { display: block; }
html[data-theme="dark"] #btnTheme .icon-sun { display: block; }
html[data-theme="dark"] #btnTheme .icon-moon { display: none; }

/* Collapse arrows: open=right, closed=left (RTL sidebar) */
.btn-collapse .icon-collapse-open { display: block; }
.btn-collapse .icon-collapse-closed { display: none; }
html.sidebar-collapsed .btn-collapse .icon-collapse-open,
body.sidebar-collapsed .btn-collapse .icon-collapse-open { display: none; }
html.sidebar-collapsed .btn-collapse .icon-collapse-closed,
body.sidebar-collapsed .btn-collapse .icon-collapse-closed { display: block; }

/* Flash solid - force opaque card bg */
.flash-modal-overlay {
    background: rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: none !important;
}
.flash-modal {
    background: var(--bg) !important;
    opacity: 1 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 12px 40px rgba(0,0,0,.3) !important;
}
html[data-theme="dark"] .flash-modal {
    background: #1e2230 !important;
}
html[data-theme="light"] .flash-modal,
:root:not([data-theme="dark"]) .flash-modal {
    background: #ffffff !important;
}

/* Modal solid too */
.modal {
    background: var(--card-bg) !important;
    backdrop-filter: none !important;
}
html[data-theme="dark"] .modal {
    background: #1e2230 !important;
}
html[data-theme="light"] .modal,
:root:not([data-theme="dark"]) .modal {
    background: #ffffff !important;
}

/* Image viewer with download */
.img-view-overlay {
    flex-direction: column;
    gap: 12px;
}
.img-view-overlay .img-view-actions {
    display: flex;
    gap: 10px;
}
.img-view-overlay .img-view-actions a,
.img-view-overlay .img-view-actions button {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    font-size: .9rem;
}
