/* ==========================================================================
   WEALTH MANAGER — PROFESSIONAL FINANCE DESIGN SYSTEM
   Clean, institutional. Bloomberg / Robinhood / Vercel aesthetic.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap');

/* ── DESIGN TOKENS ─────────────────────────────────────────────────────── */
:root {
    /* Surface Hierarchy */
    --bg-page:         #0a0a0c;
    --bg-surface:      #0f0f12;
    --bg-card:         #141418;
    --bg-card-hover:   #1a1a20;
    --bg-elevated:     #1e1e26;
    --bg-header:       rgba(10, 10, 12, 0.96);

    /* Borders */
    --border-subtle:   #1e1e24;
    --border-default:  #2a2a33;
    --border-strong:   #3a3a46;

    /* Semantic Colors — restrained, not garish */
    --green:           #22c55e;
    --green-muted:     rgba(34, 197, 94, 0.10);
    --green-border:    rgba(34, 197, 94, 0.20);

    --red:             #f87171;
    --red-muted:       rgba(248, 113, 113, 0.10);
    --red-border:      rgba(248, 113, 113, 0.20);

    --blue:            #60a5fa;
    --blue-muted:      rgba(96, 165, 250, 0.10);
    --blue-border:     rgba(96, 165, 250, 0.20);

    --amber:           #fbbf24;
    --amber-muted:     rgba(251, 191, 36, 0.10);
    --amber-border:    rgba(251, 191, 36, 0.20);

    --teal:            #2dd4bf;
    --teal-muted:      rgba(45, 212, 191, 0.10);

    /* Text */
    --text-primary:    #f0f0f5;
    --text-secondary:  #8b8b9a;
    --text-tertiary:   #55555f;
    --text-inverse:    #0a0a0c;

    /* Typography */
    --font-sans:  'Inter', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:  'JetBrains Mono', 'Courier New', monospace;

    /* Radii */
    --r-xs:   4px;
    --r-sm:   6px;
    --r-md:   8px;
    --r-lg:   12px;
    --r-xl:   16px;

    /* Shadows */
    --shadow-sm:   0 1px 4px rgba(0,0,0,0.4);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:   0 12px 40px rgba(0,0,0,0.7);

    /* Timing */
    --ease:    all 0.15s ease;

    /* Aliases for legacy compatibility */
    --bg-surface:      var(--bg-surface);
    --border-color:    var(--border-default);
    --border-highlight:var(--border-strong);
    --success:         var(--green);
    --success-bg:      var(--green-muted);
    --danger:          var(--red);
    --danger-bg:       var(--red-muted);
    --warning:         var(--amber);
    --warning-bg:      var(--amber-muted);
    --info:            var(--teal);
    --info-bg:         var(--teal-muted);
    --text-main:       var(--text-primary);
    --text-muted:      var(--text-secondary);
    --text-dim:        var(--text-tertiary);
    --accent-blue:     var(--blue);
    --radius-sm:       var(--r-sm);
    --radius-md:       var(--r-md);
    --radius-lg:       var(--r-lg);
    --radius-full:     9999px;
    --shadow-card:     var(--shadow-md);
    --transition:      var(--ease);
    --font-mono:       'JetBrains Mono', monospace;
}

/* ── RESET ─────────────────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html { font-size: 14px; }

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ── LAYOUT ────────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────────────────────── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
}

.sidebar {
    width: 230px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 1.15rem 0.875rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--ease);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.375rem 0.5rem 1.1rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1.1rem;
}

.brand-flag {
    width: 32px;
    height: 32px;
    background: #1a0000;
    border: 1px solid rgba(220,38,38,0.3);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.brand-text h1 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-text span {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.575rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--r-md);
    font-size: 0.845rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--ease);
    border: 1px solid transparent;
    user-select: none;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
    border-color: var(--border-default);
    font-weight: 600;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.75;
    flex-shrink: 0;
}

.sidebar-footer {
    padding-top: 0.875rem;
    border-top: 1px solid var(--border-subtle);
}

.bs-today-badge {
    background: rgba(251,191,36,0.06);
    border: 1px solid rgba(251,191,36,0.15);
    padding: 0.5rem 0.7rem;
    border-radius: var(--r-md);
    font-size: 0.73rem;
    color: #d97706;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-mono);
}

/* ── MAIN CONTENT ──────────────────────────────────────────────────────── */
.main-content {
    margin-left: 230px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 230px);
}

/* ── TOP HEADER ────────────────────────────────────────────────────────── */
.top-header {
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.mobile-nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 0.35rem 0.55rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.header-title h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.header-title p {
    font-size: 0.74rem;
    color: var(--text-tertiary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ── SELECTS ───────────────────────────────────────────────────────────── */
.select-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 0 0.7rem;
    height: 34px;
    border-radius: var(--r-sm);
    font-size: 0.8rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: var(--ease);
    font-family: var(--font-sans);
}

.select-pill:hover,
.select-pill:focus {
    border-color: var(--border-strong);
    background: var(--bg-card-hover);
}

/* ── UNIFIED BUTTON SYSTEM ─────────────────────────────────────────────── */
/*
  Finance app button philosophy:
  - Primary:   solid dark blue-grey fill. Not bright.
  - Secondary: ghost / outlined. Neutral.
  - Success:   subtle green. NOT neon.
  - Danger:    icon-only or text, not screaming red gradient.
  - All:       same height (34px default), consistent radius, no heavy shadows.
*/

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0 0.875rem;
    height: 34px;
    border-radius: var(--r-sm);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--ease);
    text-decoration: none;
    box-sizing: border-box;
    outline: none;
    user-select: none;
    letter-spacing: 0.01em;
}

.btn:active {
    opacity: 0.85;
    transform: translateY(0.5px);
}

.btn i, .btn svg {
    font-size: 0.78rem;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* Primary — dark indigo fill, professional */
.btn-primary {
    background: #252540;
    color: #c8c8f0;
    border-color: #363660;
}

.btn-primary:hover {
    background: #2e2e52;
    border-color: #4040a0;
    color: #e0e0ff;
}

/* Secondary — ghost neutral */
.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.04);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* Success — muted green, not loud */
.btn-success {
    background: var(--green-muted);
    color: #4ade80;
    border-color: var(--green-border);
}

.btn-success:hover {
    background: rgba(34,197,94,0.16);
    color: #86efac;
    border-color: rgba(34,197,94,0.35);
}

/* Danger — muted red */
.btn-danger {
    background: transparent;
    color: var(--text-tertiary);
    border: 1px solid var(--border-subtle);
}

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

/* Small variant */
.btn-sm {
    height: 30px;
    padding: 0 0.65rem;
    font-size: 0.77rem;
    border-radius: var(--r-xs);
}

.btn-sm i, .btn-sm svg {
    font-size: 0.72rem;
    width: 11px;
    height: 11px;
}

/* Account card action row */
.account-card-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.875rem;
    flex-wrap: wrap;
    width: 100%;
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.875rem;
}

.account-card-actions .btn-sm {
    flex: 1;
    min-width: 0;
    font-size: 0.72rem;
    gap: 0.3rem;
}

/* ── QUICK ACTIONS ─────────────────────────────────────────────────────── */
.quick-action-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.quick-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0 0.875rem;
    height: 34px;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ease);
    outline: none;
    font-family: var(--font-sans);
    user-select: none;
}

.quick-action-btn:hover {
    border-color: var(--border-strong);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
}

.quick-action-btn:active {
    opacity: 0.8;
}

/* ── CONTENT BODY ──────────────────────────────────────────────────────── */
.content-body {
    padding: 1.5rem;
    flex: 1;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── CARDS ─────────────────────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ── PREMIUM ACCOUNTS GRID ─────────────────────────────────────────────────────────────── */
.account-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.account-card {
    background: rgba(22, 27, 40, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--r-xl);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.account-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--card-color, #3b82f6);
    border-radius: var(--r-xl) 0 0 var(--r-xl);
    opacity: 0.9;
}

.account-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(30, 36, 51, 0.7);
}

.account-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-icon-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-icon-circle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}
.btn-icon-circle.primary:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}
.btn-icon-circle.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-icon-circle.success:hover {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--ease);
    position: relative;
}

.glass-card:hover {
    border-color: var(--border-default);
    background: var(--bg-card-hover);
}

/* Net Worth hero card */
.stat-card-networth {
    background: #0d0d18;
    border: 1px solid #1e1e35;
}

/* ── STAT COMPONENTS ───────────────────────────────────────────────────── */
.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.stat-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.stat-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-sub {
    font-size: 0.74rem;
    color: var(--text-tertiary);
    margin-top: 0.3rem;
}

/* ── SECTION HEADERS ───────────────────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0 0.875rem;
}

.section-header:first-child {
    margin-top: 0;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

/* ── LEDGER VIEW (TRANSACTIONS) ────────────────────────────────────────── */
.tx-date-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--r-md);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.tx-date-header {
    background: var(--bg-card-hover);
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.tx-date-header .date-text {
    font-weight: 700;
    color: var(--text-secondary);
}

.tx-date-header .date-total {
    font-family: var(--font-mono);
    font-weight: 600;
}

.tx-ledger-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.tx-ledger-item:last-child {
    border-bottom: none;
}

.tx-ledger-item:hover {
    background: var(--bg-card-hover);
}

.tx-ledger-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    flex-shrink: 0;
}

.tx-ledger-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tx-ledger-note {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-ledger-sub {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.1rem;
}

.tx-ledger-amount {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    padding-left: 1rem;
}

/* ── TABLES ────────────────────────────────────────────────────────────── */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.84rem;
}

.custom-table th {
    background: var(--bg-surface);
    padding: 0.7rem 1rem;
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border-subtle);
}

.custom-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.custom-table tbody tr:last-child td {
    border-bottom: none;
}

.custom-table tbody tr:hover {
    background: rgba(255,255,255,0.018);
}

/* ── BADGES ────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: var(--r-xs);
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-income   { background: var(--green-muted); color: var(--green); border: 1px solid var(--green-border); }
.badge-expense  { background: var(--red-muted);   color: var(--red);   border: 1px solid var(--red-border); }
.badge-transfer { background: var(--blue-muted);  color: var(--blue);  border: 1px solid var(--blue-border); }
.badge-warning  { background: var(--amber-muted); color: var(--amber); border: 1px solid var(--amber-border); }

/* ── KHATA LEDGER ──────────────────────────────────────────────────────── */
.khata-receivable { border-top: 2px solid var(--green); }
.khata-payable    { border-top: 2px solid var(--red); }

/* ── PROGRESS BAR ──────────────────────────────────────────────────────── */
.progress-bar-bg {
    background: rgba(255,255,255,0.06);
    height: 4px;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 0.65rem;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

/* ── FORMS ─────────────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-group label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-control {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 0.55rem 0.8rem;
    border-radius: var(--r-sm);
    font-size: 0.84rem;
    font-family: var(--font-sans);
    outline: none;
    transition: var(--ease);
    width: 100%;
}

.form-control:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px rgba(96,165,250,0.08);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

select.form-control option {
    background: var(--bg-surface);
}

/* ── MODALS ────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(6px) scale(0.98);
    transition: transform 0.18s ease, opacity 0.18s ease;
    margin: auto;
}

.modal-overlay.active .modal-card {
    transform: translateY(0) scale(1);
}

.modal-card form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.15rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    transition: var(--ease);
}

.close-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: var(--bg-surface);
    flex-shrink: 0;
}

/* Large modal variant (transaction wizard etc.) */
.modal-card.modal-lg {
    max-width: 860px;
    max-height: 88vh;
}

/* ── CHART BOX ─────────────────────────────────────────────────────────── */
.chart-box {
    position: relative;
    height: 220px;
    width: 100%;
}

/* ── MOBILE BOTTOM NAV ─────────────────────────────────────────────────── */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.12rem;
    color: var(--text-tertiary);
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--ease);
}

.mobile-nav-item.active { color: var(--text-primary); }
.mobile-nav-item svg { width: 18px; height: 18px; }

/* ── WIZARD STEPPER ────────────────────────────────────────────────────── */
.wiz-step-badge {
    padding: 0.3rem 0.65rem;
    border-radius: var(--r-sm);
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-tertiary);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-subtle);
    transition: var(--ease);
}

.wiz-step-badge.active {
    color: var(--blue);
    background: var(--blue-muted);
    border-color: var(--blue-border);
}

.wiz-step-badge.completed {
    color: var(--green);
    background: var(--green-muted);
    border-color: var(--green-border);
}

.wiz-step-pane { display: none !important; }
.wiz-step-pane.active { display: block !important; }

/* ── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar-backdrop.active { display: block; }
    .main-content { margin-left: 0; width: 100%; padding-bottom: 62px; }
    .mobile-nav-toggle { display: block; }
    .mobile-bottom-nav { display: flex; }
}

@media (max-width: 640px) {
    .top-header {
        padding: 0 1rem;
        height: auto;
        min-height: 56px;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .header-actions { flex-wrap: wrap; justify-content: flex-start; }
    .content-body { padding: 1rem; }
    .stat-value { font-size: 1.35rem; }
    .table-container { overflow-x: auto; }
}

/* ── LAYOUT PATTERNS ────────────────────────────────────────────────────── */

/* ─ Page Toolbar (sticky filter / action bar above content) ─ */
.page-toolbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    margin-bottom: 1.25rem;
}

.page-toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-toolbar .toolbar-spacer {
    flex: 1;
    min-width: 0.5rem;
}

/* ─ Page Section Title Bar (title + right-side action) ─ */
.page-section-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1.25rem;
}

.page-section-bar h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.page-section-bar p {
    font-size: 0.74rem;
    color: var(--text-tertiary);
    margin-top: 0.15rem;
}

/* ─ Dashboard 2-Column Layout ─ */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto auto;
    gap: 1.25rem;
    align-items: start;
}

.dashboard-main   { grid-column: 1; }
.dashboard-aside  { grid-column: 2; grid-row: 1 / span 4; }

/* ─ KPI Strip ─ */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.875rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: var(--ease);
}

.kpi-card:hover { border-color: var(--border-default); }

.kpi-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.kpi-label i { font-size: 0.7rem; }

.kpi-value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    line-height: 1.1;
    color: var(--text-primary);
}

.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-value.accent   { color: var(--blue); }

.kpi-sub {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 0.1rem;
}

/* ─ Balance Sheet Aside Panel ─ */
.balance-sheet-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    overflow: hidden;
    position: sticky;
    top: calc(52px + 1.5rem);
}

.bsp-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bsp-header h4 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

.bsp-body {
    padding: 0.5rem 0;
    max-height: 70vh;
    overflow-y: auto;
}

.bsp-group-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
    padding: 0.5rem 1rem 0.25rem;
    margin-top: 0.375rem;
}

.bsp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 1rem;
    gap: 0.5rem;
    transition: var(--ease);
}

.bsp-row:hover { background: rgba(255,255,255,0.025); }

.bsp-acc-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.bsp-acc-balance {
    font-size: 0.78rem;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.bsp-acc-balance.neg { color: var(--red); }

.bsp-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0.5rem 0;
}

.bsp-total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.bsp-total-row span {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.bsp-total-row strong {
    font-size: 0.88rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
}

/* ─ Account Category Tab Bar ─ */
.category-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.category-tab-bar::-webkit-scrollbar { display: none; }

.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.875rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-tertiary);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: var(--ease);
    font-family: var(--font-sans);
    margin-bottom: -1px;
}

.cat-tab:hover { color: var(--text-primary); }

.cat-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--blue);
}

/* ─ Account Group Section ─ */
.acc-group-section { margin-bottom: 1.5rem; }

.acc-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.acc-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.acc-group-total {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-secondary);
}

.acc-group-total.neg { color: var(--red); }

/* ─ Account Cards Grid ─ */
.acc-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.875rem;
}

/* ─ Account Card ─ */
.acc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    padding: 1.1rem;
    position: relative;
    overflow: hidden;
    transition: var(--ease);
}

.acc-card:hover {
    border-color: var(--border-default);
    background: var(--bg-card-hover);
}

.acc-card-accent {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--blue);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.acc-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.acc-card-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.acc-card-institution {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-top: 0.15rem;
}

.acc-card-type-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.15rem 0.4rem;
    border-radius: var(--r-xs);
    background: rgba(255,255,255,0.06);
    color: var(--text-tertiary);
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
    flex-shrink: 0;
}

.acc-card-balance {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    margin: 0.5rem 0 0.25rem;
    font-variant-numeric: tabular-nums;
}

.acc-card-balance.neg { color: var(--red); }

.acc-card-meta {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* ─ Transactions Filter Bar ─ */
.tx-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    margin-bottom: 1rem;
}

.tx-filter-bar .filter-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* ─ Pagination Bar ─ */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    margin-top: 0.875rem;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.pagination-info {
    font-size: 0.76rem;
    color: var(--text-tertiary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-indicator {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 0.4rem;
}

/* ─ Quick Actions Strip (Dashboard) ─ */
.qa-strip {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

/* ─ Recent Tx Panel on Dashboard ─ */
.recent-tx-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.recent-tx-section .rx-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recent-tx-section .rx-header h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

/* ─ Responsive Dashboard ─ */
@media (max-width: 1100px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .dashboard-aside { grid-column: 1; grid-row: auto; }
    .balance-sheet-panel { position: static; max-height: 320px; }
    .kpi-strip { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .kpi-strip { grid-template-columns: 1fr 1fr; }
    .acc-cards-grid { grid-template-columns: 1fr; }
    .tx-filter-bar { gap: 0.5rem; }
}

/* ── COMPREHENSIVE MOBILE RESPONSIVENESS (PHONES & TABLETS) ─────────────── */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .content-body {
        padding: 0.65rem 0.65rem 2rem 0.65rem !important;
    }

    .top-header {
        padding: 0.5rem 0.75rem !important;
        min-height: 52px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }

    .card-grid, .kpi-strip {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .glass-card {
        padding: 0.875rem !important;
        border-radius: var(--radius-md, 12px) !important;
    }

    .stat-value {
        font-size: 1.25rem !important;
    }

    .tx-filter-bar {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
        padding: 0.65rem !important;
    }

    .tx-filter-bar input,
    .tx-filter-bar select,
    .tx-filter-bar button {
        width: 100% !important;
        height: 38px !important;
        font-size: 0.85rem !important;
    }

    .month-nav-bar {
        width: 100% !important;
        justify-content: space-between !important;
        padding: 0.35rem 0.5rem !important;
    }

    .tx-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.4rem !important;
        padding: 0.75rem !important;
    }

    .tx-item-right {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-top: 1px dashed var(--border-color, rgba(255,255,255,0.1));
        padding-top: 0.4rem !important;
        margin-top: 0.2rem !important;
    }

    .modal-overlay {
        padding: 0.5rem !important;
        align-items: flex-end !important;
    }

    .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 85vh !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-top-left-radius: 18px !important;
        border-top-right-radius: 18px !important;
        padding: 1.1rem !important;
    }

    .modal-card input,
    .modal-card select,
    .modal-card button {
        min-height: 44px !important;
    }

    .mobile-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        background: rgba(15, 23, 42, 0.95) !important;
        backdrop-filter: blur(16px) !important;
        -webkit-backdrop-filter: blur(16px) !important;
        border-top: 1px solid var(--border-color, rgba(255,255,255,0.1)) !important;
        z-index: 9990 !important;
        justify-content: space-around !important;
        align-items: center !important;
    }

    .mobile-nav-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.68rem !important;
        color: var(--text-tertiary, #94a3b8) !important;
        text-decoration: none !important;
        gap: 2px !important;
        flex: 1 !important;
    }

    .mobile-nav-item.active {
        color: var(--primary, #3b82f6) !important;
        font-weight: 700 !important;
    }

    .table-container {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: var(--radius-md, 8px);
    }

    .custom-table {
        width: 100% !important;
        min-width: 520px !important;
    }

    .dashboard-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .dashboard-main, .dashboard-aside {
        width: 100% !important;
    }

    .recent-tx-section {
        width: 100% !important;
        overflow: hidden !important;
    }

    .bsp-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
    }

    .bsp-acc-name {
        max-width: 180px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
}
