/* ====== Premium Ledger - Refined Design System ====== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    --font-mono: "SimSun", "宋体", "STSong", "Songti SC", "Noto Serif CJK SC", serif;
    /* Premium Warm Palette */
    --primary: #E5A323;
    --primary-dark: #D4951A;
    --primary-deep: #C58815;
    --primary-light: #FFF9F0;
    --primary-glow: rgba(229,163,35,0.25);
    --income: #2D8A56;
    --income-light: #EDF7F1;
    --expense: #D9463E;
    --expense-light: #FDF0EE;
    --danger: #C0392B;

    /* Depth layers */
    --bg-base: #F5F5F7;
    --bg-raised: #FFFFFF;
    --bg-glass: rgba(255,255,255,0.72);
    --bg-input: #F2F2F7;

    /* Text */
    --text: #1D1D1F;
    --text-secondary: #86868B;
    --text-tertiary: #A1A1A6;
    --text-placeholder: #C7C7CC;

    /* Borders */
    --border: #E5E5EA;
    --border-light: #F2F2F7;

    /* Shadows - multi-layer for realism */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
    --shadow-xl: 0 16px 40px rgba(0,0,0,0.1), 0 6px 12px rgba(0,0,0,0.06);
    --shadow-glow: 0 0 0 4px var(--primary-glow);

    /* Radius */
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-2xl: 28px;

    /* Animation */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --nav-height: 64px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-base);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0));
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

/* =============================================
   BOTTOM NAVIGATION - Frosted Glass
   ============================================= */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: rgba(255,255,255,0.78);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(0,0,0,0.06);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.04);
}
.bottom-nav a {
    text-decoration: none; color: var(--text-tertiary);
    display: flex; flex-direction: column; align-items: center;
    gap: 3px; font-size: 11px; font-weight: 600;
    transition: all 0.25s var(--ease-out); padding: 8px 0;
    letter-spacing: 0;
    position: relative;
}
.bottom-nav a .nav-icon {
    font-size: 22px; line-height: 1;
    transition: transform 0.3s var(--ease-spring);
    filter: grayscale(0.4); opacity: 0.5;
    transition: all 0.3s var(--ease-out);
}
.bottom-nav a.active { color: var(--primary-dark); }
.bottom-nav a.active .nav-icon {
    transform: scale(1.12);
    filter: grayscale(0); opacity: 1;
}
.bottom-nav .nav-add-btn { position: relative; top: -20px; }
.bottom-nav .nav-add-btn .nav-icon {
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, #F0C860 0%, var(--primary) 40%, var(--primary-dark) 100%);
    color: white; display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 300;
    box-shadow: 0 8px 24px rgba(229,163,35,0.30);
    filter: grayscale(0); opacity: 1;
    transition: all 0.3s var(--ease-spring);
}
.bottom-nav .nav-add-btn:active .nav-icon {
    transform: scale(0.92);
    box-shadow: 0 6px 16px rgba(229,163,35,0.25);
}

/* =============================================
   PAGE CONTAINER
   ============================================= */
.page-container {
    max-width: 100%; margin: 0 auto;
    padding: 20px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    min-height: 100vh;
}

/* =============================================
   PAGE HEADER
   ============================================= */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 0 18px; gap: 12px;
}
.page-header h1 {
    font-size: 26px; font-weight: 800;
    color: var(--text); letter-spacing: -0.02em;
}

/* =============================================
   CARDS - Premium Layered
   ============================================= */
.card {
    background: var(--bg-raised);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: box-shadow 0.3s var(--ease-smooth), transform 0.3s var(--ease-smooth);
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.6);
}

/* =============================================
   HERO SUMMARY - Gradient Depth
   ============================================= */
.summary-hero {
    background: linear-gradient(160deg, #2C2C2E 0%, #3A3A3C 100%);
    border-radius: var(--radius-2xl);
    padding: 26px 24px 22px;
    margin-bottom: 18px; color: white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    position: relative; overflow: hidden;
}
/* Subtle inner glow */
.summary-hero::before {
    content: ''; position: absolute;
    top: -40%; left: -20%;
    width: 140%; height: 140%;
    background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.12) 0%, transparent 60%);
    pointer-events: none;
}
.summary-hero > * { position: relative; z-index: 1; }
.summary-hero .hero-month { font-size: 13px; opacity: 0.8; margin-bottom: 6px; font-weight: 500; letter-spacing: 0.02em; }
.summary-hero .hero-label { font-size: 13px; opacity: 0.75; font-weight: 500; }
.summary-hero .hero-amount {
    font-size: 40px; font-weight: 800; letter-spacing: -0.03em;
    margin-bottom: 4px; text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.summary-hero .hero-subtitle { font-size: 13px; opacity: 0.75; margin-top: 2px; }
.summary-hero .hero-row { display: flex; gap: 12px; margin-top: 16px; }
.summary-hero .hero-item {
    flex: 1;
    background: rgba(255,255,255,0.13);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--radius);
    padding: 14px 12px; text-align: center;
    border: 1px solid rgba(255,255,255,0.12);
    transition: background 0.2s;
}
.summary-hero .hero-item:active { background: rgba(255,255,255,0.2); }
.summary-hero .hero-item-val { font-size: 20px; font-weight: 700; }
.summary-hero .hero-item-label { font-size: 11px; opacity: 0.75; margin-top: 3px; letter-spacing: 0.02em; }

/* =============================================
   QUICK CATEGORIES
   ============================================= */
.quick-cats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 10px; margin-bottom: 18px;
}
.quick-cat-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 8px; padding: 14px 4px;
    background: var(--bg-raised);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.25s var(--ease-spring);
    text-decoration: none; color: var(--text);
}
.quick-cat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.quick-cat-item:active { transform: scale(0.94) translateY(0); }
.quick-cat-item .qc-icon {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, #FFF8E1, #FFF3D6);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.quick-cat-item .qc-icon.expense-bg { background: linear-gradient(135deg, #FFEBEE, #FFCDD2); }
.quick-cat-item .qc-icon.income-bg { background: linear-gradient(135deg, #E8F5E9, #C8E6C9); }
.quick-cat-item .qc-label {
    font-size: 11px; color: var(--text-secondary);
    font-weight: 600; letter-spacing: 0.01em;
}

/* =============================================
   TRANSACTION LIST - Refined
   ============================================= */
.trans-date-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 4px 10px;
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}
.trans-date-header .date-badge {
    font-size: 12px; color: var(--text-secondary);
    font-weight: 500; margin-left: auto;
    background: var(--bg-base); padding: 3px 10px;
    border-radius: 20px;
}
.trans-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px; background: var(--bg-raised);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}
.trans-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateX(2px);
}
.trans-item:active { transform: scale(0.985); }
.trans-icon-wrap {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
    background: var(--bg-input);
}
.expense-icon { background: var(--expense-light); }
.income-icon { background: var(--income-light); }
.trans-icon-wrap.expense-icon { background: linear-gradient(135deg, #FFEBEE, #FFCDD2); }
.trans-icon-wrap.income-icon { background: linear-gradient(135deg, #E8F5E9, #C8E6C9); }
.trans-info { flex: 1; min-width: 0; }
.trans-info .trans-cat {
    font-size: 14px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.trans-info .trans-note {
    font-size: 12px; color: var(--text-tertiary); margin-top: 2px;
    display: flex; align-items: center; gap: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.trans-amount {
    font-size: 17px; font-weight: 700;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    min-width: 90px; text-align: right;
}
.trans-amount.expense { color: var(--text); }
.trans-amount.income { color: var(--income); }

/* =============================================
   AMOUNT DISPLAY - Premium Input Area
   ============================================= */
.amount-display {
    text-align: center;
    padding: 24px 0 22px;
    background: var(--bg-raised);
    border-radius: var(--radius-xl);
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
    border: 1.5px solid var(--border-light);
    transition: all 0.35s var(--ease-out);
    position: relative;
    overflow: hidden;
}
.amount-display::after {
    content: '';
    position: absolute; bottom: 0; left: 10%; right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    transition: all 0.35s var(--ease-out);
}
.amount-display.has-value {
    border-color: var(--primary);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(255,179,0,0.12);
}
.amount-display.has-value::after {
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    left: 25%; right: 25%;
}
.amount-display .currency {
    font-size: 30px; color: var(--text);
    font-weight: 700; margin-right: 3px;
    opacity: 0.8; transition: opacity 0.3s;
}
.amount-display.has-value .currency { opacity: 1; }
.amount-display .amount-value { font-family: var(--font-mono);
    font-size: 52px; font-weight: 800; color: var(--text);
    letter-spacing: -0.04em;
    transition: all 0.2s var(--ease-spring);
    display: inline-block;
}
.amount-display .amount-value.placeholder {
    color: var(--text-placeholder);
    font-size: 52px; font-weight: 600;
}
.amount-display .amount-flash {
    animation: amountPop 0.2s var(--ease-spring);
}
@keyframes amountPop {
    0% { transform: scale(1.15); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}
.amount-display .amount-note-hint {
    font-size: 14px; color: var(--text-secondary);
    margin-top: 8px; min-height: 22px;
    font-weight: 500; letter-spacing: 0.01em;
    transition: color 0.3s;
}
.amount-display.has-value .amount-note-hint {
    color: var(--primary-dark);
    font-weight: 600;
}

/* =============================================
   TYPE SWITCH - Pill Toggle
   ============================================= */
.type-switch {
    display: flex; justify-content: center;
    gap: 8px; margin-bottom: 18px;
    background: var(--bg-base);
    padding: 4px; border-radius: 28px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}
.type-switch-btn {
    flex: 1; padding: 12px 20px;
    border-radius: 24px; font-size: 14px;
    font-weight: 700; cursor: pointer; border: none;
    background: transparent; color: var(--text-secondary);
    transition: all 0.3s var(--ease-spring);
    letter-spacing: 0.01em;
    position: relative;
}
.type-switch-btn.active-expense {
    background: linear-gradient(135deg, var(--expense), #FF1744);
    color: white;
    box-shadow: 0 4px 12px rgba(255,82,82,0.3), 0 2px 4px rgba(255,82,82,0.15);
}
.type-switch-btn.active-income {
    background: linear-gradient(135deg, var(--income), #2E7D32);
    color: white;
    box-shadow: 0 4px 12px rgba(76,175,80,0.3), 0 2px 4px rgba(76,175,80,0.15);
}

/* =============================================
   NUMPAD - Tactile Premium Keys
   ============================================= */
.numpad {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px; margin-bottom: 18px;
    padding: 4px;
}
.numpad-key {
    aspect-ratio: 1.55; border-radius: var(--radius);
    font-size: 24px; font-weight: 700; border: none;
    background: var(--bg-raised);
    color: var(--text);
    cursor: pointer;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.04),
        0 4px 8px rgba(0,0,0,0.03),
        inset 0 1px 0 rgba(255,255,255,0.6);
    border: 1px solid var(--border-light);
    transition: all 0.15s var(--ease-smooth);
    display: flex; align-items: center; justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.02em;
    position: relative;
}
.numpad-key::after {
    content: '';
    position: absolute; inset: 0; border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255,255,255,0.5) 0%, transparent 40%);
    pointer-events: none;
}
.numpad-key:hover {
    box-shadow:
        0 4px 8px rgba(0,0,0,0.06),
        0 6px 12px rgba(0,0,0,0.04),
        inset 0 1px 0 rgba(255,255,255,0.6);
    transform: translateY(-1px);
}
.numpad-key:active, .numpad-key.pressed {
    background: linear-gradient(180deg, #FFF3D6, #FFE8B0);
    transform: scale(0.9);
    box-shadow:
        0 1px 2px rgba(0,0,0,0.06),
        inset 0 2px 4px rgba(0,0,0,0.06);
    border-color: var(--primary-light);
}
.numpad-key.key-del {
    font-size: 18px; color: var(--text-secondary);
    background: var(--bg-input);
}
.numpad-key.key-del:active { background: #FFEBEE; border-color: #FFCDD2; }
.numpad-key.key-done {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; font-size: 14px; font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow:
        0 4px 12px rgba(245,166,35,0.35),
        0 2px 6px rgba(245,166,35,0.2),
        inset 0 1px 0 rgba(255,255,255,0.2);
    border: none;
}
.numpad-key.key-done::after { display: none; }
.numpad-key.key-done:active {
    background: var(--primary-deep);
    transform: scale(0.9);
    box-shadow: 0 2px 6px rgba(255,179,0,0.35);
}
.numpad-key.key-dot { font-size: 32px; font-weight: 400; }

/* =============================================
   CATEGORY GRID - Polished
   ============================================= */
.cat-select-title {
    font-size: 13px; font-weight: 700; color: var(--text-secondary);
    margin-bottom: 10px; letter-spacing: 0.02em; text-transform: none;
}
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-grid-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 14px 4px;
    border-radius: var(--radius);
    background: var(--bg-raised);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.25s var(--ease-spring);
    box-shadow: var(--shadow-xs);
}
.cat-grid-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.cat-grid-item:active { transform: scale(0.94); }
.cat-grid-item.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, #FFF8E1, #FFF3D6);
    box-shadow: var(--shadow-sm), 0 0 0 3px rgba(245,166,35,0.1);
}
.cat-grid-item.selected .cat-grid-icon {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 10px rgba(245,166,35,0.25);
}
.cat-grid-icon {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--bg-input);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    transition: all 0.25s var(--ease-spring);
}
.cat-grid-label {
    font-size: 11px; color: var(--text-secondary);
    font-weight: 600; letter-spacing: 0.01em;
}

/* =============================================
   STATS - Number-forward
   ============================================= */
.stats-summary {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; margin-bottom: 18px;
}
.stats-summary .stat-card {
    background: var(--bg-raised);
    border-radius: var(--radius);
    padding: 18px 14px;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border-light);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stats-summary .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.stats-summary .stat-card-label {
    font-size: 11px; color: var(--text-secondary);
    margin-bottom: 6px; font-weight: 600; letter-spacing: 0.04em;
    text-transform: uppercase;
}
.stats-summary .stat-card-value { font-family: var(--font-mono);
    font-size: 24px; font-weight: 800; letter-spacing: -0.03em;
}
.stats-summary .stat-card-value.income { color: var(--income); }
.stats-summary .stat-card-value.expense { color: var(--expense); }

/* =============================================
   BUTTONS - Refined
   ============================================= */
.btn {
    padding: 11px 22px; border: none;
    border-radius: 24px; font-size: 14px; font-weight: 700;
    cursor: pointer; transition: all 0.25s var(--ease-spring);
    display: inline-flex; align-items: center; gap: 6px;
    letter-spacing: 0.01em; position: relative; overflow: hidden;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 14px rgba(245,166,35,0.35), 0 2px 4px rgba(245,166,35,0.15);
}
.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(245,166,35,0.4);
    transform: translateY(-1px);
}
.btn-primary:active {
    background: var(--primary-deep);
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(255,179,0,0.35);
}
.btn-outline {
    background: var(--bg-raised);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-sm { padding: 7px 15px; font-size: 12px; border-radius: 18px; }
.btn-danger {
    background: transparent; color: var(--danger);
    border: 1px solid rgba(229,57,53,0.3);
}
.btn-danger:hover { background: var(--expense-light); }
.btn-block {
    width: 100%; justify-content: center;
    padding: 15px; font-size: 16px; border-radius: 26px;
    box-shadow: 0 6px 20px rgba(245,166,35,0.35);
}

/* =============================================
   FORMS - Clean & Airy
   ============================================= */
.form-input {
    width: 100%; padding: 12px 15px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px; background: var(--bg-input);
    color: var(--text); transition: all 0.25s var(--ease-out);
    outline: none; letter-spacing: -0.01em;
}
.form-input:hover { border-color: var(--text-tertiary); }
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255,179,0,0.12);
    background: var(--bg-raised);
}
.form-input::placeholder { color: var(--text-placeholder); }
.form-row { display: flex; gap: 10px; margin-bottom: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 80px; }
.form-group label {
    display: block; font-size: 12px; color: var(--text-secondary);
    margin-bottom: 5px; font-weight: 700; letter-spacing: 0.02em;
}

/* =============================================
   FILTER BAR
   ============================================= */
.filter-bar {
    display: flex; gap: 6px; flex-wrap: wrap;
    align-items: center; padding: 12px;
}
.filter-bar .form-input {
    width: auto; min-width: 80px; flex: 1;
    font-size: 13px; padding: 9px 12px;
}

/* =============================================
   PAGINATION
   ============================================= */
.pagination { display: flex; justify-content: center; gap: 8px; padding: 20px 0; }
.page-btn {
    width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg-raised);
    font-size: 13px; font-weight: 700; color: var(--text-secondary);
    cursor: pointer; transition: all 0.2s var(--ease-spring);
    box-shadow: var(--shadow-xs);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary-dark); }
.page-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; border-color: transparent;
    box-shadow: 0 4px 10px rgba(255,179,0,0.35);
}

/* =============================================
   MODAL - Bottom Sheet
   ============================================= */
.modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    z-index: 200; align-items: flex-end; justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--bg-raised);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%; max-width: 480px; height: 92vh; max-height: 92vh; top: 8vh;
    overflow-y: auto; padding: 24px 20px;
    animation: slideUp 0.35s var(--ease-spring);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-handle {
    width: 36px; height: 5px;
    background: var(--border);
    border-radius: 3px; margin: 0 auto 20px;
}

/* =============================================
   SETTINGS - iOS-style Groups
   ============================================= */
.settings-section {
    background: var(--bg-raised);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border-light);
    overflow: hidden;
}
.settings-section-title {
    font-size: 12px; font-weight: 700; color: var(--text-secondary);
    padding: 16px 18px 8px; letter-spacing: 0.04em;
    text-transform: uppercase;
}
.settings-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 18px; border-bottom: 1px solid var(--border-light);
    font-size: 15px; transition: background 0.15s;
}
.settings-item:hover { background: var(--bg-base); }
.settings-item:last-child { border-bottom: none; }
.settings-item .item-left { display: flex; align-items: center; gap: 12px; }
.settings-item .item-icon {
    width: 34px; height: 34px; border-radius: var(--radius-xs);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.settings-item .item-arrow { color: var(--text-placeholder); font-size: 16px; }
.add-row {
    display: flex; gap: 8px; padding: 14px 18px;
    align-items: center; border-bottom: 1px solid var(--border-light);
}
.add-row .form-input { flex: 1; font-size: 13px; padding: 9px 12px; }

/* =============================================
   RANK BARS
   ============================================= */
.rank-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 0; font-size: 14px;
}
.rank-num {
    width: 22px; text-align: center;
    font-weight: 800; color: var(--text-secondary); font-size: 13px;
}
.rank-bar-bg {
    flex: 1; height: 7px;
    background: var(--bg-base); border-radius: 4px;
    overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.rank-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 4px; transition: width 0.6s var(--ease-out);
}
.rank-amount {
    font-weight: 700; min-width: 70px; text-align: right;
    font-size: 13px; letter-spacing: -0.02em;
}
.rank-cnt { color: var(--text-secondary); font-size: 11px; min-width: 30px; }
/* Category rank expand */
.cat-rank-row {
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 6px;
    padding: 9px 8px;
    margin: 0 -8px;
}
.cat-rank-row:hover { background: var(--bg-base); }
.cat-rank-row.expanded { background: rgba(59,130,246,0.06); }
.rank-expand-arrow {
    font-size: 10px; color: var(--text-light);
    transition: transform 0.25s;
    margin-left: 4px;
}
.cat-rank-row.expanded .rank-expand-arrow {
    transform: rotate(90deg);
    color: var(--primary);
}
.cat-detail {
    margin: 2px 0 8px 22px;
    border-left: 2px solid var(--border);
    padding-left: 12px;
}
.cat-detail-list {
    display: flex; flex-direction: column; gap: 1px;
}
.cat-detail-row {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 0;
    font-size: 12px; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}
.cat-detail-row:last-child { border-bottom: none; }
.cdr-date {
    font-variant-numeric: tabular-nums;
    color: var(--text-light); font-size: 11px;
    min-width: 72px; flex-shrink: 0;
}
.cdr-member {
    color: var(--primary); font-size: 11px;
    min-width: 56px; flex-shrink: 0;
}
.cdr-note {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 12px;
}
.cdr-amount {
    font-weight: 700; font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    font-size: 13px; flex-shrink: 0; min-width: 60px; text-align: right;
}
.cdr-amount.expense { color: var(--expense); }
.cdr-amount.income { color: var(--income); }


/* =============================================
   BOTTOM SHEET 鈥?鍗婂睆寮圭獥璁拌处
   ============================================= */
.sheet-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.35);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s var(--ease-smooth), visibility 0.3s;
}
.sheet-overlay.show {
    opacity: 1; visibility: visible;
}

.sheet {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 201;
    height: 100vh; max-height: 100vh; top: 0;
    background: rgba(255,255,255,0.98);
    border-radius: 0;
    transform: translateY(100%);
    transition: transform 0.38s var(--ease-spring);
    display: flex; flex-direction: column;
    box-shadow: 0 -12px 48px rgba(0,0,0,0.15);
    overflow: visible;
    max-width: 540px;
    left: 50%; right: auto;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
}
.sheet-overlay.show .sheet {
    transform: translateX(-50%) translateY(0);
}

.sheet-handle {
    width: 36px; height: 5px;
    background: var(--border);
    border-radius: 3px;
    margin: 10px auto;
    flex-shrink: 0;
}

.sheet-body {
    overflow-y: auto;
    padding: 0 16px 12px;
    flex: 0 1 auto;
    max-height: 40vh;
    -webkit-overflow-scrolling: touch;
}

/* Sheet amount display */
.sheet-amount {
    text-align: center;
    padding: 4px 0 8px;
    flex-shrink: 0;
}
.sheet-amount-val {
    font-size: 36px; font-weight: 800;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
    color: var(--text);
}
.sheet-amount-val.placeholder {
    color: var(--text-placeholder);
    font-weight: 500;
}
.sheet-amount-hint {
    font-size: 11px; color: var(--text-tertiary);
    margin-top: 4px;
}

/* Sheet type switch */
.sheet-type-switch {
    display: flex; gap: 8px;
    margin-bottom: 16px;
}
.sheet-type-btn {
    flex: 1; padding: 10px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-raised);
    font-size: 14px; font-weight: 600;
    cursor: pointer; text-align: center;
    transition: all 0.2s var(--ease-smooth);
}
.sheet-type-btn.active-expense {
    background: var(--expense-light);
    border-color: var(--expense);
    color: var(--expense);
}
.sheet-type-btn.active-income {
    background: var(--income-light);
    border-color: var(--income);
    color: var(--income);
}

/* Sheet category grid */
.sheet-cat-grid {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 10px; margin-bottom: 16px;
}
.sheet-cat-item {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    padding: 10px 4px;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}
.sheet-cat-item:hover {
    background: var(--bg-input);
}
.sheet-cat-item.selected {
    background: var(--primary-light);
    border-color: var(--primary);
}
.sheet-cat-icon {
    font-size: 24px; line-height: 1;
}
.sheet-cat-name {
    font-size: 10px; color: var(--text-secondary);
    white-space: nowrap;
}

/* Sheet member segmented control */
.sheet-member-bar {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}
.sheet-member-label {
    font-size: 11px; color: var(--text-tertiary);
    flex-shrink: 0;
}
.sheet-member-seg {
    display: flex; flex: 1; gap: 4px;
}
.sheet-member-btn {
    flex: 1; padding: 6px 8px;
    border-radius: 8px; border: none;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex; align-items: center;
    justify-content: center; gap: 4px;
}
.sheet-member-btn.selected {
    background: var(--bg-raised);
    color: var(--text);
    box-shadow: var(--shadow-xs);
}
.sheet-member-avatar {
    width: 18px; height: 18px; border-radius: 50%;
    object-fit: cover;
}

/* Sheet numpad */
.sheet-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.sheet-numpad-key {
    padding: 16px 0;
    font-size: 22px; font-weight: 600;
    font-family: var(--font-mono);
    border: none; border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.sheet-numpad-key:active {
    background: var(--border);
    transform: scale(0.95);
}
.sheet-numpad-key.key-del {
    font-size: 18px;
    color: var(--text-secondary);
}
.sheet-numpad-key.key-dot {
    font-size: 28px;
}

/* Sheet submit */
.sheet-submit {
    width: 100%; padding: 14px;
    font-size: 16px; font-weight: 700;
    border: none; border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}
.sheet-submit:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}
.sheet-submit:disabled {
    opacity: 0.4; cursor: not-allowed;
}

/* Sheet date / note row */
.sheet-extra-row {
    display: flex; gap: 8px;
    margin-bottom: 12px;
}
.sheet-extra-row .form-input {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-raised);
}

/* =============================================
   TOAST
   ============================================= */
.toast {
    position: fixed; top: 50px; left: 50%; transform: translateX(-50%);
    padding: 12px 28px; border-radius: 24px; color: white;
    font-size: 14px; font-weight: 700; z-index: 300;
    opacity: 0; transition: all 0.3s var(--ease-spring);
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    letter-spacing: 0.01em;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
.toast.success { background: rgba(76,175,80,0.92); }
.toast.error { background: rgba(229,57,53,0.92); }

/* =============================================
   MEMBER BUTTONS
   ============================================= */
.member-toggle { display: flex; gap: 8px; }
.member-btn {
    flex: 1; padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px; font-weight: 700;
    background: var(--bg-raised); cursor: pointer;
    transition: all 0.25s var(--ease-spring);
    text-align: center; letter-spacing: 0.01em;
}
.member-btn:hover { border-color: var(--primary-light); }
.member-btn.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, #FFF8E1, #FFF3D6);
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(245,166,35,0.15);
}

/* Member Avatar inside buttons */
.member-avatar-img {
    width: 28px; height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto 4px;
    border: 2px solid var(--border-light);
    transition: border-color 0.25s var(--ease-spring);
}
.member-btn {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; padding: 8px 10px;
}
.member-btn.selected .member-avatar-img {
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(245,166,35,0.2);
}

/* Hero member avatar */
.hero-member-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
    margin-bottom: 6px;
    display: block; margin-left: auto; margin-right: auto;
}
.hero-item { display: flex; flex-direction: column; align-items: center; }

/* Transaction list member avatar */
.trans-member-avatar {
    width: 16px; height: 16px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
}
.trans-note {
    font-size: 12px; color: var(--text-tertiary); margin-top: 2px;
    display: flex; align-items: center; gap: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Settings member avatar */
.settings-member-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-light);
    flex-shrink: 0;
}

/* =============================================
   CHART BOXES
   ============================================= */
.chart-box {
    background: var(--bg-raised);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border-light);
    margin-bottom: 14px;
}
.chart-box h3 {
    font-size: 13px; font-weight: 700; margin-bottom: 14px;
    color: var(--text-secondary); letter-spacing: 0.02em;
    text-transform: none;
}
.chart-box canvas { max-height: 250px; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.chart-box.full-width { grid-column: 1 / -1; }

/* =============================================
   DATE FILTER & LEGACY SUPPORT
   ============================================= */
.date-filter {
    display: flex; gap: 6px; align-items: center;
    font-size: 13px; color: var(--text-secondary);
}
.date-filter .form-input { width: auto; min-width: 100px; font-size: 13px; padding: 7px 12px; }

.summary-cards {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 14px;
}
.summary-cards .card { text-align: center; padding: 16px; }
.summary-cards .card-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }
.summary-cards .card-value { font-size: 22px; font-weight: 800; }
.card-income .card-value { color: var(--income); }
.card-expense .card-value { color: var(--expense); }
.card-balance .card-value { color: var(--primary-dark); }
.top-nav { display: none; }

/* =============================================
   REPORT TABLE
   ============================================= */
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th {
    background: var(--bg-input); padding: 11px 10px; text-align: left;
    font-weight: 700; color: var(--text-secondary);
    border-bottom: 2px solid var(--border); font-size: 11px;
    letter-spacing: 0.03em; text-transform: uppercase;
}
.report-table td { padding: 11px 10px; border-bottom: 1px solid var(--border-light); }
.report-table .inc { color: var(--income); font-weight: 700; }
.report-table .exp { color: var(--expense); font-weight: 700; }
.report-table tr:hover { background: var(--bg-base); }

/* =============================================
   MISC
   ============================================= */
.hint {
    font-size: 12px; color: var(--text-secondary);
    margin-top: 5px; line-height: 1.6;
}
.hint code {
    background: var(--bg-input); padding: 2px 8px;
    border-radius: 5px; font-size: 11px; font-weight: 600;
}
.ledger-select {
    padding: 7px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-xs); font-size: 12px;
    background: var(--bg-raised); cursor: pointer;
    color: var(--text); font-weight: 600;
}

/* =============================================
   RESPONSIVE
   ============================================= */



/* =============================================
   LEDGER SELECT 鈥?涓嬫媺閫夊崟
   ============================================= */

/* =============================================
   HOME HEADER 鈥?椴ㄩ奔璁拌处鏆栭噾瀹瑰櫒
   ============================================= */
.home-header {
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 16px;
    margin-bottom: 16px;
}
.home-header > * { position: relative; z-index: 1; }

.home-header .ledger-select-wrap {
    margin-bottom: 12px;
}

.ledger-select-wrap {
    margin-bottom: 14px;
}
/* Import button */
.btn-import {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: var(--bg-base); border: 1px solid var(--border);
    font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; flex-shrink: 0;
}
.btn-import:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-import:disabled { opacity: 0.5; cursor: not-allowed; }

.ledger-select-home {
    width: 100%; padding: 10px 36px 10px 14px;
    font-size: 14px; font-weight: 600;
    color: var(--text);
    background: var(--bg-raised);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    appearance: none; -webkit-appearance: none;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.25s var(--ease-spring), box-shadow 0.25s;
    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
}
.ledger-select-home:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255,179,0,0.15);
}

/* =============================================
   SEGMENTED CONTROL 鈥?iOS 鍒嗘鎺т欢
   ============================================= */
.segmented-control {
    display: flex; position: relative;
    background: var(--bg-input);
    border-radius: 12px; padding: 3px;
    margin-bottom: 14px;
    user-select: none;
}
.segmented-btn:disabled {
    opacity: 0.35; cursor: not-allowed; pointer-events: none;
}
.segmented-btn {
    flex: 1; padding: 9px 0;
    font-size: 13px; font-weight: 600;
    text-align: center; cursor: pointer;
    border: none; background: transparent;
    color: var(--text-tertiary);
    position: relative; z-index: 1;
    transition: color 0.25s var(--ease-smooth);
    border-radius: 10px;
}
.segmented-btn.active {
    color: var(--text);
}
.segmented-avatar-btn {
    padding: 5px 0;
}
.segmented-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: block; margin: 0 auto;
}
.segmented-avatar-btn.active .segmented-avatar {
    box-shadow: 0 0 0 2px var(--bg-raised), 0 1px 3px rgba(0,0,0,0.12);
}
.segmented-indicator {
    position: absolute; top: 3px; left: 0;
    height: calc(100% - 6px);
    width: calc(100% / 3);
    background: var(--bg-raised);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.35s var(--ease-spring);
    z-index: 0;
}

/* =============================================
   DASHBOARD BOARD 鈥?绮捐嚧鍗＄墖椋?
   ============================================= */
.dashboard-board {
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
    overflow: hidden;
}

/* 涓夊垪鎬绘暟 */
.db-totals-single {
    max-width: 260px; margin: 0 auto;
}
.db-totals {
    display: flex; flex-direction: column;
    padding: 16px 12px;
    gap: 0;
}
.db-col {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 8px;
    border-bottom: 0.5px solid rgba(60,60,67,0.08);
}
.db-col:last-child { border-bottom: none; }
.db-col::after { display: none; }
.db-col-expense::after { background: var(--expense); }
.db-col-income::after { background: var(--income); }
.db-col-balance::after { background: var(--primary); }

.db-label {
    font-size: 15px; font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
    display: flex; align-items: center;
    gap: 6px;
}
.db-icon { font-size: 18px; line-height: 1; }
.db-value {
    font-size: 22px; font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    text-align: right;
}

/* 鎴愬憳鏄庣粏鍖哄煙 */
.db-members {
    border-top: 0.5px solid rgba(60,60,67,0.08);
    padding: 12px 12px 14px;
    background: #FAFAFB;
}
.db-members-title {
    font-size: 10px; color: var(--text-tertiary);
    letter-spacing: 0.06em; margin-bottom: 8px;
    padding: 0 2px;
}

/* 鎴愬憳鍗＄墖 */
.db-member-card {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-base);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-left: 3px solid var(--accent, var(--primary));
    transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
}
.db-member-card:last-child { margin-bottom: 0; }
.db-member-card:active { transform: scale(0.98); }

.db-member-info {
    display: flex; align-items: center; gap: 8px;
    min-width: 0; flex-shrink: 0;
}
.db-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}
.db-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.db-avatar-placeholder {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.db-member-name {
    font-size: 13px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 鎴愬憳鏁板€?鈥?涓夊垪缃戞牸瀵归綈涓婃柟 */
.db-member-vals {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 4px; text-align: center;
    flex-shrink: 0; min-width: 180px;
}
.db-val {
    font-size: 13px; font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
    white-space: nowrap;
}

.expense-color { color: var(--expense); }
.income-color { color: var(--income); }


/* 房贷看板：金额大，缩小字号 */
.dashboard-board.mortgage .db-value {
    font-size: 20px; font-weight: 800;
    letter-spacing: -0.03em;
    font-family: var(--font-mono);
}
.dashboard-board.mortgage .db-label { font-size: 10px; margin-bottom: 2px; gap: 2px; }
.dashboard-board.mortgage .db-totals { padding: 14px 4px 10px; gap: 2px; }
@media (max-width: 400px) {
    .dashboard-board.mortgage .db-value { font-size: 12px; }
    .dashboard-board.mortgage .db-totals { padding: 12px 2px 8px; }
}



/* ============================================
   MONOSPACED AMOUNTS 鈥?all financial numbers
   ============================================ */
.trans-amount, .tl-amount, .stat-card-value, .amount-value, .db-val, .rank-amount,
.db-value, .amount-display .amount-value, .stats-summary .stat-card-value {
    font-family: var(--font-mono) !important;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   LIST ITEMS 鈥?thin separators, more space
   ============================================ */
.trans-item {
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0;
}
.trans-item:last-child { border-bottom: none; }
.trans-date-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 4px 10px;
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}
/* =============================================
   TIMELINE WATERFALL 鈥?鏃堕棿绾跨€戝竷娴?
   ============================================= */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.timeline-empty {
    text-align: center; color: var(--text-light);
    padding: 40px 0; font-size: 14px;
}

/* Date Group */
.tl-group { margin-bottom: 4px; }
.tl-date-header {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 14px 4px 8px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 4px;
}
.tl-date-text {
    font-size: 15px; font-weight: 700;
    color: var(--text);
}
.tl-date-sum {
    font-size: 11px; color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

/* Timeline Item */
.tl-item {
    position: relative; overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--border-light);
    margin-bottom: 2px;
}
.tl-item-inner {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--bg-raised);
    position: relative; z-index: 2;
    transition: transform 0.25s var(--ease-spring);
    border-radius: var(--radius-sm);
    will-change: transform;
}
.tl-actions {
    position: absolute; right: 0; top: 0; bottom: 0;
    display: flex; align-items: stretch;
    z-index: 1;
}
.tl-action-btn {
    width: 70px; border: none; cursor: pointer;
    font-size: 13px; font-weight: 600; color: #fff;
    display: flex; align-items: center; justify-content: center;
    transition: filter 0.2s;
}
.tl-action-btn:active { filter: brightness(0.9); }
.tl-edit-btn { background: var(--primary); }
.tl-del-btn { background: var(--expense); }

.tl-icon-wrap {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
    background: var(--bg-base);
}
.tl-info { flex: 1; min-width: 0; }
.tl-cat {
    font-size: 14px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-note {
    font-size: 12px; color: var(--text-light); margin-top: 2px;
    display: flex; align-items: center; gap: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-avatar {
    width: 16px; height: 16px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    border: 1px solid var(--border-light);
}
.tl-amount {
    font-size: 17px; font-weight: 700;
    white-space: nowrap; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}

/* =============================================
   RESPONSIVE SYSTEM — Multi-breakpoint
   ============================================= */

/* ≤400px — Small phones (iPhone SE, etc.) */
@media (max-width: 400px) {
    .page-container { padding: 12px 10px 0; }
    .page-header h1 { font-size: 22px; }
    .db-value { font-size: 18px; }
    .db-totals { padding: 12px 6px; }
    .db-label { font-size: 14px; }
    .db-col { padding: 10px 6px; }
    .tl-item-inner { padding: 10px 12px; gap: 8px; }
    .tl-amount { font-size: 15px; }
    .tl-cat { font-size: 13px; }
    .sheet-amount-val { font-size: 30px; }
    .sheet-numpad-key { font-size: 20px; padding: 14px 0; }
    .sheet-cat-grid { gap: 6px; }
    .segmented-btn { font-size: 12px; padding: 7px 0; }
    .segmented-avatar { width: 24px; height: 24px; }
    .chart-row { grid-template-columns: 1fr; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .form-input { font-size: 14px; padding: 10px 12px; }
    .filter-bar { gap: 4px; }
    .filter-bar .form-input { min-width: 60px; font-size: 12px; padding: 7px 8px; }
    .btn-sm { padding: 6px 12px; font-size: 11px; }
    .modal-content { max-width: 100%; padding: 18px 14px; }
}

/* 401-480px — Standard phones (iPhone 12-17 Pro, most Androids) */
@media (min-width: 401px) and (max-width: 480px) {
    .page-container { padding: 18px 14px 0; }
    .db-value { font-size: 20px; }
}

/* 481-600px — Large phones */
@media (min-width: 481px) and (max-width: 600px) {
    .db-value { font-size: 24px; }
    .tl-amount { font-size: 18px; }
    .sheet-numpad-key { font-size: 24px; padding: 18px 0; }
    .sheet-amount-val { font-size: 38px; }
}

/* 601-768px — Foldables unfolded portrait, small tablets */
@media (min-width: 601px) and (max-width: 768px) {
    .page-container { padding: 24px 20px 0; }
    .page-header h1 { font-size: 28px; }
    .db-value { font-size: 26px; }
    .db-totals { padding: 22px 12px 16px; }
    .db-label { font-size: 16px; }
    .tl-item-inner { padding: 14px 18px; gap: 14px; }
    .tl-amount { font-size: 19px; }
    .tl-cat { font-size: 15px; }
    .tl-icon-wrap { width: 40px; height: 40px; font-size: 20px; }
    .sheet-amount-val { font-size: 42px; }
    .sheet-numpad-key { font-size: 26px; padding: 20px 0; }
    .sheet-numpad { gap: 10px; }
    .segmented-btn { font-size: 14px; padding: 11px 0; }
    .segmented-avatar { width: 32px; height: 32px; }
    .chart-row { grid-template-columns: 1fr 1fr; }
    .summary-cards { gap: 12px; }
    .ledger-select-home { font-size: 15px; padding: 12px 40px 12px 16px; }
    .bottom-nav a { font-size: 12px; }
    .bottom-nav a .nav-icon { width: 26px; height: 26px; }
    .bottom-nav .nav-add-btn .nav-icon { width: 56px; height: 56px; font-size: 30px; }
}

/* 769-1024px — Foldables unfolded landscape, tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .page-container { max-width: 720px; padding: 28px 24px 0; margin: 0 auto; }
    .page-header h1 { font-size: 30px; }
    .db-value { font-size: 28px; }
    .db-totals { padding: 24px 16px 18px; }
    .db-label { font-size: 17px; }
    .tl-item-inner { padding: 16px 20px; gap: 16px; }
    .tl-amount { font-size: 20px; }
    .tl-cat { font-size: 16px; }
    .tl-icon-wrap { width: 44px; height: 44px; font-size: 22px; }
    .sheet-amount-val { font-size: 46px; }
    .sheet-numpad-key { font-size: 28px; padding: 22px 0; }
    .sheet-numpad { gap: 12px; }
    .sheet-cat-grid { gap: 14px; }
    .segmented-btn { font-size: 15px; padding: 12px 0; }
    .segmented-avatar { width: 36px; height: 36px; }
    .home-header { padding: 20px; }
}

/* >1024px — Large tablets */
@media (min-width: 1025px) {
    .page-container { max-width: 800px; padding: 32px 28px 0; margin: 0 auto; }
    .page-header h1 { font-size: 32px; }
    .db-value { font-size: 30px; }
    .db-totals { padding: 26px 20px 20px; }
    .db-label { font-size: 18px; }
    .tl-item-inner { padding: 18px 22px; gap: 18px; }
    .tl-amount { font-size: 22px; }
    .tl-cat { font-size: 17px; }
    .tl-icon-wrap { width: 48px; height: 48px; font-size: 24px; }
    .sheet-amount-val { font-size: 48px; }
    .sheet-numpad-key { font-size: 30px; padding: 24px 0; }
    .sheet-numpad { gap: 14px; }
    .sheet-cat-grid { gap: 16px; }
    .segmented-btn { font-size: 16px; padding: 14px 0; }
    .segmented-avatar { width: 38px; height: 38px; }
    .home-header { padding: 24px; }
    .bottom-nav a { font-size: 13px; }
    .bottom-nav a .nav-icon { width: 28px; height: 28px; }
    .bottom-nav .nav-add-btn .nav-icon { width: 60px; height: 60px; font-size: 32px; }
}

/* Touch target minimum (iOS HIG 44px) */
@media (pointer: coarse) {
    .segmented-btn { min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .sheet-numpad-key { min-height: 48px; }
    .tl-action-btn { min-width: 60px; }
    .btn { min-height: 44px; }
    .page-btn { width: 44px; height: 44px; }
    select.ledger-select-home { min-height: 44px; }
}


