/* ============================================
   SCALIX — Mobile-First UI
   ============================================ */

:root {
    --bg-base: #0c1018;
    --bg-surface: rgba(255, 255, 255, 0.045);
    --bg-surface-hover: rgba(255, 255, 255, 0.075);
    --bg-elevated: rgba(255, 255, 255, 0.065);
    --border: rgba(255, 255, 255, 0.09);
    --border-hover: rgba(255, 255, 255, 0.16);

    --text-primary: #f1f5f9;
    --text-secondary: rgba(241, 245, 249, 0.62);
    --text-muted: rgba(241, 245, 249, 0.38);

    --accent: #6366f1;
    --accent-light: #a5b4fc;
    --accent-teal: #2dd4bf;
    --accent-teal-light: #5eead4;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-teal-glow: rgba(45, 212, 191, 0.35);

    --accent-subtle: rgba(99, 102, 241, 0.12);
    --accent-border: rgba(99, 102, 241, 0.28);
    --teal-subtle: rgba(45, 212, 191, 0.1);

    --cyan: #22d3ee;
    --pink: #f472b6;
    --green: #34d399;
    --red: #fb7185;
    --amber: #fbbf24;

    --gradient-1: linear-gradient(135deg, #6366f1 0%, #2dd4bf 100%);
    --gradient-2: linear-gradient(135deg, #818cf8 0%, #34d399 100%);
    --gradient-hero: linear-gradient(
        165deg,
        rgba(99, 102, 241, 0.2) 0%,
        rgba(45, 212, 191, 0.08) 45%,
        rgba(12, 16, 24, 0.4) 100%
    );

    --sheet-bg: #12161f;
    --toast-bg: #161b26;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;

    --header-h: 64px;
    --bottom-nav-h: calc(64px + env(safe-area-inset-bottom, 0px));
    --fab-size: 58px;

    --font: 'Outfit', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

body.sheet-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse 90% 60% at 50% -15%, rgba(99, 102, 241, 0.18) 0%, transparent 55%),
        radial-gradient(ellipse 70% 45% at 100% 80%, rgba(45, 212, 191, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 0% 60%, rgba(129, 140, 248, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.bg-grid { display: none; }

.app {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: var(--bottom-nav-h);
}

.mobile-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
    background: rgba(12, 16, 24, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: var(--gradient-1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.brand-icon svg { width: 18px; height: 18px; color: white; }

.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.header-month {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-logout {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(251, 113, 133, 0.1);
    border: 1px solid rgba(251, 113, 133, 0.22);
    border-radius: var(--radius-sm);
    color: var(--red);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}

.btn-refresh {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);
    color: var(--accent-light);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}

.btn-refresh svg,
.btn-logout svg {
    width: 18px;
    height: 18px;
}

.btn-refresh:active,
.btn-logout:active {
    transform: scale(0.92);
}

.btn-refresh.is-loading .refresh-icon {
    animation: spinRefresh 0.75s linear infinite;
}

@keyframes spinRefresh {
    to { transform: rotate(360deg); }
}

.refresh-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 200;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.refresh-bar.active {
    opacity: 1;
}

.refresh-bar.active::after {
    content: '';
    display: block;
    height: 100%;
    width: 35%;
    background: var(--gradient-1);
    border-radius: 0 2px 2px 0;
    animation: refreshBarSlide 1s ease-in-out infinite;
}

@keyframes refreshBarSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(380%); }
}

.pull-refresh {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 54px);
    left: 50%;
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(18, 22, 31, 0.95);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    pointer-events: none;
    transform: translate(-50%, -24px);
    transition: opacity 0.15s ease;
}

.pull-refresh.visible {
    opacity: 1;
}

.pull-refresh:not(.visible) {
    opacity: 0;
    visibility: hidden;
}

.pull-refresh-icon {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.pull-refresh.ready {
    color: var(--accent-teal-light);
    border-color: var(--accent-border);
}

.pull-refresh.ready .pull-refresh-icon {
    transform: rotate(180deg);
}

.header-month-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-teal-light);
    padding: 8px 12px;
    background: var(--teal-subtle);
    border: 1px solid rgba(45, 212, 191, 0.22);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 20px;
}

.month-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}

.month-btn:active:not(:disabled) { transform: scale(0.92); }

.month-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.month-btn svg { width: 20px; height: 20px; }

.month-picker-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-family: var(--font);
}

.hero-month {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.hero-month-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.month-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.month-banner {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-teal-light);
    padding: 10px 16px;
    margin-bottom: 14px;
    background: var(--teal-subtle);
    border: 1px solid rgba(45, 212, 191, 0.18);
    border-radius: var(--radius);
}

.card-badge {
    font-size: 0.68rem;
    padding: 4px 10px;
    background: var(--accent-subtle);
    color: var(--accent-light);
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.input-month {
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 44px;
    color-scheme: dark;
}

.input-month:focus { outline: none; border-color: var(--accent); }

.main { padding: 16px 16px 88px; }

.view { display: none; animation: slideUp 0.35s ease; }
.view.active { display: block; }

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

.hero-card {
    background: var(--gradient-hero);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    margin-bottom: 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hero-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.hero-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

.hero-amount {
    font-family: var(--mono);
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-change {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.stats-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -16px 20px;
    padding: 0 16px 4px;
}

.stats-scroll::-webkit-scrollbar { display: none; }

.stat-pill {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: 130px;
    background: linear-gradient(145deg, var(--bg-elevated), var(--bg-surface));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.stat-pill-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-pill-value {
    display: block;
    font-family: var(--mono);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-pill-value-sm { font-family: var(--font); font-size: 0.95rem; }

.stat-pill-sub {
    display: block;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.change-badge {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.72rem;
}

.change-badge.up { background: rgba(251, 113, 133, 0.15); color: var(--red); }
.change-badge.down { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.change-badge.neutral { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); }

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 { font-size: 0.95rem; font-weight: 600; }

.chart-wrap { position: relative; height: 200px; }
.chart-wrap-donut { height: 180px; }
.chart-wrap-bar { height: 260px; }

.category-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 5px 10px;
    background: var(--bg-elevated);
    border-radius: 20px;
}

.legend-dot { width: 7px; height: 7px; border-radius: 50%; }

.expense-list { display: flex; flex-direction: column; gap: 2px; }
.expense-list-full { gap: 4px; }

.expense-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid transparent;
    transition: background var(--transition);
    min-height: 0;
}

.expense-item:active {
    background: var(--bg-surface-hover);
    border-color: var(--border);
}

.expense-cat-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.expense-info {
    flex: 1;
    min-width: 0;
    line-height: 1.25;
}

.expense-title {
    font-weight: 600;
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-amount {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-primary);
    flex-shrink: 0;
    white-space: nowrap;
}

.expense-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.expense-item .btn-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
}

.expense-item .btn-icon svg {
    width: 14px;
    height: 14px;
}

.search-wrap { position: relative; margin-bottom: 12px; }

.search-wrap svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-search {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    min-height: 50px;
}

.input-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -16px 16px;
    padding: 0 16px 4px;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 10px 16px;
    min-height: 44px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.chip.active {
    background: var(--accent-subtle);
    border-color: var(--accent-border);
    color: var(--accent-light);
}

.category-breakdown { display: flex; flex-direction: column; gap: 14px; }

/* Partner balances */
.partner-card {
    border-color: rgba(99, 102, 241, 0.22);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.08) 0%, rgba(18, 22, 31, 0.6) 100%);
}

.partner-pool-summary {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: -4px 0 14px;
}

.partner-balance-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.partner-balance-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.partner-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    flex-shrink: 0;
}

.partner-balance-info {
    flex: 1;
    min-width: 0;
}

.partner-balance-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.partner-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.partner-balance-amt {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.partner-balance-amt.positive { color: var(--accent-teal-light); }
.partner-status-card {
    border-color: rgba(45, 212, 191, 0.35);
    background: linear-gradient(180deg, rgba(45, 212, 191, 0.1) 0%, rgba(18, 22, 31, 0.65) 100%);
}

.partner-balance-amt.negative {
    color: #fb7185;
    font-weight: 700;
}
.partner-balance-amt.settled { color: var(--text-muted); }

.partner-balance-amt.pending { color: var(--accent-teal-light); }
.partner-balance-amt.overdrawn { color: var(--red); }

.partner-balance-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.partner-balance-bar-wrap {
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.partner-balance-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.breakdown-item { display: flex; align-items: center; gap: 12px; }

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

.breakdown-info { flex: 1; min-width: 0; }
.breakdown-label { font-size: 0.88rem; font-weight: 500; }

.breakdown-bar-wrap {
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.breakdown-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.breakdown-amount {
    font-family: var(--mono);
    font-size: 0.88rem;
    font-weight: 600;
    flex-shrink: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 22px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    min-height: 48px;
}

.btn svg { width: 20px; height: 20px; }

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow), 0 0 24px var(--accent-teal-glow);
}

.btn-primary:active { transform: scale(0.98); }

.btn-glow { position: relative; overflow: hidden; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    min-height: 40px;
    padding: 8px 16px;
}

.btn-danger { background: linear-gradient(135deg, #fb7185 0%, #f43f5e 100%); color: white; }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; min-height: 36px; }
.btn-block { width: 100%; }

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:active { transform: scale(0.92); }
.btn-icon svg { width: 17px; height: 17px; }

.btn-icon.danger {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.08);
}

.fab {
    position: fixed;
    right: max(20px, calc(50% - 220px));
    bottom: calc(var(--bottom-nav-h) + 16px);
    z-index: 60;
    width: var(--fab-size);
    height: var(--fab-size);
    border: none;
    border-radius: 50%;
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 6px 28px var(--accent-glow), 0 2px 12px var(--accent-teal-glow), 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition);
}

.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(0.92); }

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 70;
    width: 100%;
    max-width: 480px;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: rgba(12, 16, 24, 0.94);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px 12px;
    min-height: 64px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color var(--transition);
    position: relative;
}

.bottom-nav-item svg { width: 24px; height: 24px; transition: transform var(--transition); }
.bottom-nav-item.active { color: var(--accent-teal-light); }
.bottom-nav-item.active svg { transform: scale(1.08); }

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--gradient-1);
    border-radius: 0 0 4px 4px;
}

.sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    visibility: hidden;
}

.sheet-overlay.open { pointer-events: auto; visibility: visible; }

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity var(--transition);
}

.sheet-overlay.open .sheet-backdrop { opacity: 1; }

.sheet {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 480px;
    max-height: 92dvh;
    background: var(--sheet-bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sheet-overlay.open .sheet { transform: translateX(-50%) translateY(0); }

.sheet-sm { max-height: auto; }

.sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 8px;
    flex-shrink: 0;
}

.sheet-header h3 { font-size: 1.15rem; font-weight: 700; }

.sheet-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
}

.sheet-close svg { width: 18px; height: 18px; }

.sheet-body {
    padding: 8px 20px max(24px, env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.sheet-actions {
    padding: 8px 20px max(24px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.delete-msg { padding: 0 20px 8px; color: var(--text-secondary); font-size: 0.9rem; }

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.optional { font-weight: 400; color: var(--text-muted); }

.input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-height: 50px;
}

.input-lg { font-size: 1.05rem; }

.input-amount {
    font-family: var(--mono);
    font-size: 1.5rem !important;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.textarea { resize: none; min-height: 72px; }

.input-prefix { position: relative; }

.input-prefix span {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 1.25rem;
    font-weight: 500;
}

.input-prefix-lg .input { padding-left: 42px; }

.type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    min-height: 88px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.type-option:active { transform: scale(0.97); }

.type-option.selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent-light);
    box-shadow: 0 0 0 1px var(--accent-border);
}

.type-option .type-emoji { font-size: 1.75rem; }

.person-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.person-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 8px;
    min-height: 48px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.person-option:active { transform: scale(0.96); }

.person-option.selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent-light);
    box-shadow: 0 0 0 1px var(--accent-border);
}

.person-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 6px;
    flex-shrink: 0;
}

.person-option.with-avatar {
    justify-content: flex-start;
    padding-left: 12px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.cat-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 4px;
    min-height: 72px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.cat-option:active { transform: scale(0.96); }

.cat-option.selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent-light);
    box-shadow: 0 0 0 1px var(--accent-border);
}

.cat-option .cat-emoji { font-size: 1.4rem; }

input[type="date"], input[type="month"] { color-scheme: dark; }

.toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    width: calc(100% - 32px);
    max-width: 448px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 14px 18px;
    background: var(--toast-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.3s ease;
    text-align: center;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

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

.empty-state { text-align: center; padding: 32px 16px; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state .btn { margin-top: 16px; }
.hidden { display: none !important; }

/* PWA install prompt */
.install-banner {
    position: fixed;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 400;
    width: calc(100% - 24px);
    max-width: 456px;
    bottom: calc(var(--bottom-nav-h) + 8px);
    background: var(--sheet-bg);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-lg);
    padding: 14px 14px 14px 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(99, 102, 241, 0.15);
    transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
}

.install-banner.install-banner-visible {
    transform: translateX(-50%) translateY(0);
}

.login-page .install-banner {
    bottom: max(16px, env(safe-area-inset-bottom));
}

.install-banner-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-icon {
    border-radius: 12px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.install-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-text strong {
    font-size: 0.92rem;
    color: var(--text-primary);
}

.install-text span {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.install-btn {
    flex-shrink: 0;
    min-height: 38px !important;
    padding: 8px 16px !important;
}

.install-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
}

body.install-prompt-open .fab {
    bottom: calc(var(--bottom-nav-h) + 88px);
}

body.install-prompt-open .toast-container {
    bottom: calc(var(--bottom-nav-h) + 88px);
}

.install-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.install-modal {
    width: 100%;
    max-width: 480px;
    background: var(--sheet-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 12px 24px max(28px, env(safe-area-inset-bottom));
    text-align: center;
    animation: slideUpModal 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.install-modal-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    margin: 0 auto 16px;
}

.install-modal-icon {
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.install-modal h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.install-modal > p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.install-steps {
    list-style: none;
    text-align: left;
    margin-bottom: 20px;
}

.install-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.install-steps li:last-child {
    border-bottom: none;
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent-light);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-icon {
    width: 18px;
    height: 18px;
    margin-left: auto;
    color: var(--accent-teal-light);
    flex-shrink: 0;
}

@media (min-width: 520px) {
    body { background: #080a10; }
    .app {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        box-shadow: 0 0 80px rgba(0, 0, 0, 0.5);
    }
    .bottom-nav {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    .fab { right: calc(50% - 220px); }
}

@media (min-width: 768px) {
    .hero-amount { font-size: 3.25rem; }
}
