/* ───────────────────────────────────────────────────────────────────────────
   LEDGER — minimal, native-feeling finance UI
   Design tokens
   ─────────────────────────────────────────────────────────────────────────── */

:root {
    --bg:            #F7F6F3;
    --surface:       #FFFFFF;
    --surface-muted: #EFEDE7;
    --border:        #E4E1D9;
    --border-strong: #D8D4C9;

    --ink:           #17181B;
    --ink-soft:      #6E7178;
    --ink-faint:     #7C7F85;

    --accent:        #1D4E89;   /* primary / saved */
    --accent-soft:   #E8EEF6;
    --income:        #2E7D5B;
    --income-soft:   #E5F1EB;
    --expense:       #B23A48;
    --expense-soft:  #F7E9EA;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;

    --shadow-sm: 0 1px 2px rgba(23,24,27,.04), 0 1px 1px rgba(23,24,27,.03);
    --shadow-md: 0 8px 24px rgba(23,24,27,.07);
    --shadow-card: 0 1px 0 rgba(23,24,27,.03), 0 2px 10px rgba(23,24,27,.045);

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;

    --nav-w: 232px;
    --tabbar-h: 64px;

    --tabbar-bg: rgba(255,255,255,.86);

    --chart-grid:  rgba(23,24,27,0.06);
    --chart-label: #6E7178;
    --chart-value: #17181B;
    --chart-empty: #7C7F85;
}

:root[data-theme="dark"] {
    --tabbar-bg:     rgba(25,27,30,.86);

    --chart-grid:  rgba(255,255,255,0.08);
    --chart-label: #9A9DA4;
    --chart-value: #F2F1ED;
    --chart-empty: #757880;

    --bg:            #101214;
    --surface:       #191B1E;
    --surface-muted: #222528;
    --border:        #2B2E32;
    --border-strong: #383B40;

    --ink:           #F2F1ED;
    --ink-soft:      #9A9DA4;
    --ink-faint:     #757880;

    --accent:        #5B93D1;
    --accent-soft:   #1C2A3B;
    --income:        #5FBE91;
    --income-soft:   #16281F;
    --expense:       #E27884;
    --expense-soft:  #2F1B1E;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,.4);
    --shadow-card: 0 1px 0 rgba(0,0,0,.2), 0 2px 10px rgba(0,0,0,.28);
}

body, .card, .tab-bar, input, select, .month-chip, .balance-card {
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    line-height: 1.45;
}

.hidden { display: none !important; }

/* Themed scrollbar — replaces the default white/system one everywhere,
   including the page and any internally-scrolling lists. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid var(--bg);
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
input, select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.tab-item:focus-visible { border-radius: var(--radius-sm); outline: none; }

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ─── APP SHELL ───────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 1.25rem calc(var(--tabbar-h) + 2rem);
    max-width: 1080px;
    margin: 0 auto;
    width: 100%;
}

/* ─── NAV: bottom tab bar (mobile) ↔ sidebar (desktop) ──────────────────── */
.tab-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--tabbar-h);
    display: flex;
    align-items: stretch;
    background: var(--tabbar-bg);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 40;
}

.tab-bar-brand, .tab-bar-footer { display: none; }

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    text-decoration: none;
    color: var(--ink-faint);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: color .15s ease;
}
.tab-icon { width: 22px; height: 22px; }
.tab-item.active { color: var(--accent); }
.tab-item:active { opacity: 0.6; }

/* ─── HEADER ──────────────────────────────────────────────────────────────── */
.app-header { margin-bottom: 1.5rem; }

.header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.2rem;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.month-caption {
    color: var(--ink-soft);
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

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

.month-chip {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.3rem 0.3rem 0.9rem;
    gap: 0.4rem;
}
.month-chip input {
    border: none;
    background: none;
    padding: 0.2rem 0;
    width: 76px;
    font-size: 0.82rem;
}
.month-chip input:focus { box-shadow: none; }
.chip-btn {
    background: var(--surface-muted);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink);
}
.chip-btn:hover { background: var(--border); }

/* ─── SETTINGS ────────────────────────────────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.9rem;
    align-items: end;
}
.form-group-action { display: flex; }

/* ─── BALANCE HERO CARD (signature element) ─────────────────────────────── */
.balance-card {
    margin-top: 1.25rem;
    background: linear-gradient(155deg, var(--accent) 0%, #163C69 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.5rem 1.35rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.balance-card::after {
    content: '';
    position: absolute;
    top: -60%; right: -20%;
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(255,255,255,.10) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
}
.balance-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: rgba(255,255,255,.72);
}
.balance-value {
    font-size: clamp(2.1rem, 5vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    margin: 0.15rem 0 1.1rem;
    cursor: pointer;
}
.balance-value.editing input {
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    border-radius: 10px;
    font-size: 1.6rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    width: 60%;
}

.balance-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.4rem;
    position: relative;
}
.balance-stat {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    color: rgba(255,255,255,.85);
}
.balance-stat b {
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    margin-left: 0.15rem;
}
.stat-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-income  { background: #6FE0A8; }
.dot-expense { background: #FF9C9C; }
.dot-saved   { background: #9FC6FF; }

/* ─── CONTENT SECTIONS / CARDS ───────────────────────────────────────────── */
.content-section { animation: fadeSlideIn .2s ease; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.25rem;
}
.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.9rem;
    letter-spacing: -0.005em;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
.charts-grid .card { margin-bottom: 0; }
canvas { width: 100%; height: 240px; display: block; }

/* ─── PERIOD CHART CONTROLS (week/month toggle + nav) ────────────────────── */
.period-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}
.period-chart-header .card-title { margin-bottom: 0; }
.period-toggle {
    display: flex;
    background: var(--surface-muted);
    border-radius: 999px;
    padding: 0.2rem;
    gap: 0.15rem;
}
.period-toggle-btn {
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.period-toggle-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

.period-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    margin-bottom: 0.6rem;
    touch-action: pan-y;
}
.period-nav-btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--ink);
    font-size: 1rem;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.period-nav-btn:hover { background: var(--border); }
.period-nav-btn:disabled { opacity: 0.35; cursor: default; }
.period-nav-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
    min-width: 110px;
    text-align: center;
}

/* ─── FORMS ───────────────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}
/* Fixed column count (not auto-fit) — showing/hiding the weekday, monthday,
   or bucket field never reshuffles how the other fields wrap, since the
   number of columns stays constant regardless of how many are visible. */
.inst-form-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) {
    .inst-form-grid { grid-template-columns: repeat(2, 1fr); }
}
.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.form-group input, .form-group select { width: 100%; }

.btn {
    border-radius: 999px;
    padding: 0.65rem 1.3rem;
    font-weight: 600;
    font-size: 0.85rem;
    transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #163C69; }
.btn-secondary { background: var(--surface-muted); color: var(--ink); }
.btn-secondary:hover { background: var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.78rem; }

.activity-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.activity-controls input {
    flex: 1;
    min-width: 180px;
}

/* ─── CATEGORY LIST ───────────────────────────────────────────────────────── */
.category-list { display: flex; flex-direction: column; gap: 0.65rem; }
.category-item {
    display: grid;
    grid-template-columns: minmax(0, 112px) 1fr auto;
    align-items: center;
    gap: 0.75rem;
}
.category-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.category-bar {
    height: 8px;
    background: var(--surface-muted);
    border-radius: 999px;
    overflow: hidden;
}
.category-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--expense), #D97A82);
    border-radius: 999px;
    transition: width .3s ease;
}
.category-amount {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    min-width: 64px;
    text-align: right;
}

/* ─── TRANSACTIONS ────────────────────────────────────────────────────────── */
.transaction-list { display: flex; flex-direction: column; gap: 0.5rem; }
.tx-date-header {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink-faint);
    text-transform: uppercase;
    margin: 0.9rem 0 0.35rem;
}
.tx-date-header:first-child { margin-top: 0.1rem; }
.transaction-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    animation: fadeSlideIn .2s ease;
}
.tx-icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.tx-icon.expense { background: var(--expense-soft); }
.tx-icon.income  { background: var(--income-soft); }
.tx-icon.save    { background: var(--accent-soft); }
.tx-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.tx-category { font-weight: 600; font-size: 0.88rem; color: var(--ink); }
.tx-meta { font-size: 0.74rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount { font-weight: 700; font-size: 0.88rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.tx-amount.expense { color: var(--expense); }
.tx-amount.income  { color: var(--income); }
.tx-amount.save    { color: var(--accent); }
.btn-delete {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-faint);
    font-size: 0.8rem;
    flex-shrink: 0;
}
.btn-delete:hover { background: var(--expense-soft); color: var(--expense); }

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--ink-faint);
}
.empty-icon { font-size: 1.6rem; margin-bottom: 0.4rem; }

/* ─── ACTION MENU ("⋮" dropdown used instead of stacked buttons) ─────────── */
.action-menu { position: relative; flex-shrink: 0; margin-left: auto; }
.action-menu-btn {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-faint);
    font-size: 1.1rem;
    line-height: 1;
}
.action-menu-btn:hover { background: var(--surface-muted); color: var(--ink); }
.action-menu-list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 0.3rem;
    min-width: 150px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.action-menu-item {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
}
.action-menu-item:hover { background: var(--surface-muted); }
.action-menu-item.danger { color: var(--expense); }
.action-menu-item.danger:hover { background: var(--expense-soft); }

/* ─── SETTINGS: collapsible sections ─────────────────────────────────────── */
.settings-collapsible summary.card-title {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
}
.settings-collapsible summary.card-title::-webkit-details-marker { display: none; }
.settings-collapsible summary.card-title::after {
    content: '›';
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--ink-faint);
    transform: rotate(90deg);
    transition: transform .15s ease;
}
.settings-collapsible[open] summary.card-title::after { transform: rotate(-90deg); }
.settings-collapsible[open] summary.card-title { margin-bottom: 0; }

/* ─── SETTINGS: switch row / toggle ──────────────────────────────────────── */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.switch-title { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.switch-caption { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.15rem; }

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 27px;
    flex-shrink: 0;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    transition: background .18s ease;
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 23px; height: 23px;
    left: 2px; top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .18s ease;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(19px); }

.money-amt { font-variant-numeric: tabular-nums; }
.money-rial {
    display: inline-flex;
    align-items: baseline;
    gap: 0.15em;
}
.rial-symbol {
    font-size: 0.9em;
    font-weight: 600;
}

.installment-list { display: flex; flex-direction: column; gap: 0.5rem; }
.installment-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    flex-wrap: nowrap;
}
.installment-item .tx-details { flex: 1 1 auto; min-width: 0; }
.installment-item .tx-category { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.installment-item .tx-amount { margin-right: 0.25rem; }

.category-manager-list { display: flex; flex-direction: column; gap: 0.5rem; }
.category-manager-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}
.category-manager-name { flex: 1; font-weight: 600; font-size: 0.85rem; color: var(--ink); }
.category-manager-name.is-hidden { color: var(--ink-faint); text-decoration: line-through; }
.category-manager-emoji { font-size: 1.1rem; flex-shrink: 0; width: 22px; text-align: center; }

/* ─── DATE PICKER (popup calendar) ───────────────────────────────────────── */
.date-picker-input { cursor: pointer; background: var(--surface); }
.date-picker-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 0.85rem;
    width: 268px;
    z-index: 200;
    animation: fadeSlideIn .15s ease;
}
.date-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.7rem;
}
.date-picker-title { font-weight: 700; font-size: 0.88rem; color: var(--ink); }
.date-picker-nav {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--ink);
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
}
.date-picker-nav:hover { background: var(--border); }
.date-picker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 0.3rem;
}
.date-picker-weekdays span {
    text-align: center;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ink-faint);
}
.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.date-picker-cell {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.date-picker-cell:not(.empty):hover { background: var(--surface-muted); }
.date-picker-cell.today { color: var(--accent); font-weight: 700; }
.date-picker-cell.selected { background: var(--accent); color: #fff; font-weight: 700; }
.date-picker-today-btn {
    width: 100%;
    margin-top: 0.7rem;
    padding: 0.45rem;
    text-align: center;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
}
.date-picker-today-btn:hover { background: var(--border); }

/* ─── SAVINGS ─────────────────────────────────────────────────────────────── */
.savings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.savings-card {
    background: var(--surface-muted);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    text-align: center;
}
.savings-card.savings-total {
    background: var(--accent-soft);
}
.savings-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.4rem;
}
.savings-amount {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}
.savings-card.savings-total .savings-amount { color: var(--accent); }

/* ─── TOAST ───────────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: calc(var(--tabbar-h) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    background: #1C1B19;
    color: #FFFFFF;
    padding: 0.7rem 1.1rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    z-index: 100;
    animation: fadeSlideIn .18s ease;
    max-width: min(90vw, 360px);
    text-align: center;
}

/* ─── ANIMATIONS ──────────────────────────────────────────────────────────── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── RESPONSIVE: MOBILE / TABLET (compact, scroll-minimized layout) ────── */
@media (max-width: 859px) {
    .app-main {
        padding: 1rem 1rem calc(var(--tabbar-h) + 1.25rem);
    }
    .app-header { margin-bottom: 1rem; }
    .header-title { font-size: 1.25rem; }
    .month-caption { font-size: 0.78rem; }

    .balance-card {
        margin-top: 0.9rem;
        padding: 1.1rem 1.2rem 1rem;
        border-radius: var(--radius-md);
    }
    .balance-value { font-size: 2rem; margin: 0.1rem 0 0.8rem; }
    .balance-stats { gap: 0.4rem 1rem; }
    .balance-stat { font-size: 0.74rem; }

    .card { padding: 1rem; margin-bottom: 0.9rem; border-radius: var(--radius-sm); }
    .card-title { font-size: 0.85rem; margin-bottom: 0.7rem; }

    .charts-grid { gap: 0.9rem; margin-bottom: 0.9rem; }
    canvas { height: 160px; }

    .category-list {
        gap: 0.5rem;
        max-height: 42vh;
        overflow-y: auto;
        padding-right: 2px;
    }
    .transaction-list {
        gap: 0.4rem;
        max-height: 48vh;
        overflow-y: auto;
        padding-right: 2px;
    }
    .transaction-item { padding: 0.55rem 0.6rem; }

    .savings-amount { font-size: 1.15rem; }
    .savings-card { padding: 0.85rem; }

    .form-grid { gap: 0.6rem; }
}

@media (max-width: 380px) {
    .balance-value { font-size: 1.7rem; }
    .header-title { font-size: 1.1rem; }
    canvas { height: 140px; }
}

/* ─── RESPONSIVE: DESKTOP (sidebar layout) ───────────────────────────────── */
@media (min-width: 860px) {
    .tab-bar {
        position: static;
        flex-direction: column;
        align-items: stretch;
        width: var(--nav-w);
        height: 100vh;
        height: 100dvh;
        position: sticky;
        top: 0;
        background: var(--surface);
        border-top: none;
        border-right: 1px solid var(--border);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        padding: 1.5rem 1rem;
        gap: 0.25rem;
    }
    .tab-bar-brand {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0 0.5rem;
        margin-bottom: 1.5rem;
    }
    .brand-mark {
        width: 32px; height: 32px;
        border-radius: 9px;
        background: var(--accent);
        color: #fff;
        display: flex; align-items: center; justify-content: center;
        font-weight: 700;
        font-size: 0.95rem;
    }
    .brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }

    .tab-item {
        flex: none;
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.7rem;
        padding: 0.65rem 0.75rem;
        border-radius: var(--radius-sm);
        font-size: 0.88rem;
    }
    .tab-item:hover { background: var(--surface-muted); }
    .tab-item.active { background: var(--accent-soft); color: var(--accent); }
    .tab-icon { width: 19px; height: 19px; }

    .tab-item-settings { margin-top: auto; }

    .tab-bar-footer {
        display: none;
    }

    .app-main { padding: 2.25rem 2.5rem; }
    .header-title { font-size: 1.7rem; }
    .balance-value { font-size: 2.5rem; }
}

@media (min-width: 1180px) {
    .app-main { padding: 2.5rem 3rem; }
}
