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

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --primary:       #5a67d8;
    --primary-dark:  #434db5;
    --primary-light: #7f8ff4;
    --accent:        #9f7aea;

    --gradient-primary: linear-gradient(135deg, #5a67d8 0%, #9f7aea 100%);
    --gradient-success: linear-gradient(135deg, #38a169 0%, #276749 100%);
    --gradient-danger:  linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    --gradient-warning: linear-gradient(135deg, #dd6b20 0%, #c05621 100%);

    --bg-color:     #f7f8fc;
    --surface:      #ffffff;
    --card-bg:      #ffffff;
    --card-border:  #e8eaf0;
    --input-bg:     #f0f2f8;
    --border-color: #dde1ec;

    --text-primary:   #1a1d2e;
    --text-secondary: #6b7494;
    --text-muted:     #9ba3c2;

    --success: #2f9e58;
    --danger:  #e53e3e;
    --warning: #dd6b20;

    --radius-xs:   6px;
    --radius-sm:   10px;
    --radius-md:   14px;
    --radius-lg:   20px;
    --radius-xl:   28px;
    --radius-pill: 9999px;

    --shadow-xs: 0 1px 3px rgba(26,29,46,0.06);
    --shadow-sm: 0 2px 8px rgba(26,29,46,0.07);
    --shadow-md: 0 6px 20px rgba(26,29,46,0.09);
    --shadow-lg: 0 16px 40px rgba(90,103,216,0.12);

    --ease-out:    0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Dark Mode ──────────────────────────────────────────────── */
body.dark-mode {
    --bg-color:     #0f1117;
    --surface:      #1a1e2e;
    --card-bg:      #1a1e2e;
    --card-border:  #262b40;
    --input-bg:     #212638;
    --border-color: #2c3252;

    --text-primary:   #eef0f8;
    --text-secondary: #8892b0;
    --text-muted:     #4a5280;

    --shadow-xs: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: #0b0e1a;
    color: var(--text-primary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ── App Shell ──────────────────────────────────────────────── */
@media (min-width: 480px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 24px;
    }
    .app-shell {
        width: 412px;
        height: 840px;
        background-color: var(--bg-color);
        border-radius: 44px;
        border: 10px solid #181c30;
        box-shadow:
            0 30px 60px -12px rgba(0,0,0,0.7),
            0 0 0 1px rgba(255,255,255,0.04),
            inset 0 1px 0 rgba(255,255,255,0.06);
        overflow: hidden;
        position: relative;
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 479px) {
    body { overflow: hidden; }
    .app-shell {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        background-color: var(--bg-color);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
    }
}

#app-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.app-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 104px;
    position: relative;
}
.app-container::-webkit-scrollbar { width: 0; }

/* ── Typography ─────────────────────────────────────────────── */
.logo-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}
.logo-text .word-pocket { color: var(--text-primary); }
.logo-text .word-safe   { color: var(--primary); }

.logo-text-lg {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}
.logo-text-lg .word-pocket { color: var(--text-primary); }
.logo-text-lg .word-safe   { color: var(--primary); }

h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

h2 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 14px;
    color: var(--text-primary);
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-xs);
    margin-bottom: 12px;
    transition: box-shadow var(--ease-out);
}
.card:active { box-shadow: var(--shadow-sm); }

/* ── Header ─────────────────────────────────────────────────── */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 16px;
}

.logo-badge {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
}
.logo-badge img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    box-shadow: var(--shadow-sm);
}

/* ── Icon button ────────────────────────────────────────────── */
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ease-out);
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn svg { width: 17px; height: 17px; stroke-width: 2.2; }

/* ── User pill ──────────────────────────────────────────────── */
.user-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-pill);
    padding: 5px 12px 5px 6px;
    cursor: pointer;
    transition: all var(--ease-out);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
}
.user-pill:hover { border-color: var(--primary); }
.user-pill-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

/* ── Budget Gauge ───────────────────────────────────────────── */
.budget-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0 8px;
}

.gauge-circle {
    width: 152px;
    height: 152px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 0%, var(--accent) 0%, var(--border-color) 0% 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.9s ease;
    box-shadow: 0 8px 24px rgba(90,103,216,0.2);
    position: relative;
}
.gauge-circle::after {
    content: '';
    position: absolute;
    inset: 13px;
    background: var(--card-bg);
    border-radius: 50%;
    z-index: 1;
}
.gauge-content { position: relative; z-index: 2; text-align: center; }
.gauge-amount {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}
.gauge-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 1px;
}
.budget-stats {
    display: flex;
    width: 100%;
    justify-content: space-around;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}
.budget-stat-item { text-align: center; }
.budget-stat-val {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.budget-stat-lbl {
    font-size: 0.67rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* ── Quick chips ────────────────────────────────────────────── */
.quick-log-wrapper { display: flex; flex-direction: column; gap: 10px; }
.quick-log-input-group { display: flex; gap: 8px; position: relative; }
.quick-amount-input {
    flex: 1;
    font-size: 1.15rem;
    font-weight: 700;
    padding: 13px 14px;
    border-radius: var(--radius-md);
    background-color: var(--input-bg);
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    transition: all var(--ease-out);
}
.quick-amount-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(90,103,216,0.1);
}
.quick-chips-scroll { display: flex; gap: 7px; overflow-x: auto; padding: 3px 0 8px; scrollbar-width: none; }
.quick-chips-scroll::-webkit-scrollbar { display: none; }
.quick-chip {
    flex-shrink: 0;
    padding: 8px 14px;
    background: var(--input-bg);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--ease-out);
}
.quick-chip:active { transform: scale(0.95); background: rgba(90,103,216,0.1); border-color: var(--primary); color: var(--primary); }
.quick-chip.selected { background: var(--primary); color: white; border-color: var(--primary); font-weight: 700; }

/* ── Roommate bubbles ───────────────────────────────────────── */
.roommate-bubbles-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.roommate-bubbles-container { display: flex; gap: 12px; overflow-x: auto; padding: 3px 0 6px; scrollbar-width: none; }
.roommate-bubbles-container::-webkit-scrollbar { display: none; }
.roommate-bubble { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; flex-shrink: 0; }
.roommate-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--ease-spring);
    position: relative;
    overflow: hidden;
}
.roommate-bubble.selected .roommate-avatar {
    border-color: var(--primary);
    background: var(--gradient-primary);
    color: white;
    transform: scale(1.08);
    box-shadow: 0 0 0 3px rgba(90,103,216,0.18);
}
.roommate-avatar-check {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 15px;
    height: 15px;
    background: var(--success);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 7px;
    border: 2px solid var(--card-bg);
}
.roommate-bubble.selected .roommate-avatar-check { display: flex; }
.roommate-name {
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--text-muted);
    max-width: 58px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.roommate-bubble.selected .roommate-name { color: var(--primary); font-weight: 700; }

/* ── Savings Goal Widget ────────────────────────────────────── */
.goal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.goal-title { font-weight: 700; font-size: 0.9rem; }
.goal-values { font-weight: 700; font-size: 0.85rem; color: var(--primary); }
.goal-progress-track { width: 100%; height: 7px; background: var(--input-bg); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: 6px; }
.goal-progress-bar { height: 100%; background: var(--gradient-primary); border-radius: var(--radius-pill); width: 0%; transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1); }
.goal-meta { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--ease-out);
    width: 100%;
    letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.97); opacity: 0.92; }
.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(90,103,216,0.28);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(90,103,216,0.38); }
.btn-secondary {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}
.btn-danger {
    background: var(--gradient-danger);
    color: white;
    box-shadow: 0 4px 14px rgba(229,62,62,0.25);
}

/* ── Form elements ──────────────────────────────────────────── */
.input-group { margin-bottom: 14px; }
.input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
input, select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background-color: var(--input-bg);
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all var(--ease-out);
    appearance: none;
    -webkit-appearance: none;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(90,103,216,0.12);
}
input::placeholder { color: var(--text-muted); font-weight: 400; }

/* ── Lists ──────────────────────────────────────────────────── */
.transaction-list, .friend-list { list-style: none; }
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.list-item:last-child { border-bottom: none; }
.amount-positive { color: var(--success); font-weight: 700; }
.amount-negative { color: var(--danger);  font-weight: 700; }

/* ── Bottom Nav ─────────────────────────────────────────────── */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 8px 4px 26px;
    z-index: 100;
}
.nav-item {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--ease-out);
    letter-spacing: 0.02em;
}
.nav-item.active { color: var(--primary); }
.nav-item svg { stroke-width: 2px; width: 22px; height: 22px; stroke: var(--text-muted); transition: stroke var(--ease-out); }
.nav-item.active svg { stroke: var(--primary); }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 22, 0.55);
    z-index: 200;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn var(--ease-out) ease-out;
}
.modal-content {
    background: var(--card-bg);
    width: 100%;
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    padding: 28px 20px 20px;
    position: absolute;
    bottom: 0;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -4px 30px rgba(0,0,0,0.12);
    max-height: 82%;
    overflow-y: auto;
}
.modal-content::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-pill);
    margin: -14px auto 18px auto;
}

/* ── Reports ────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.stat-item {
    background: var(--input-bg);
    padding: 11px 8px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border-color);
}
.stat-label { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 0.92rem; font-weight: 700; }
.stat-value.text-success { color: var(--success); }
.stat-value.text-danger  { color: var(--danger); }

.bar-chart-container { height: 150px; display: flex; gap: 14px; justify-content: center; align-items: flex-end; padding-top: 8px; }
.bar-group { display: flex; flex-direction: column; align-items: center; width: 42px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; border-radius: var(--radius-xs) var(--radius-xs) 0 0; min-height: 4px; transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
.bar-label { margin-top: 7px; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); }

.chart-donut-wrapper { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 10px; }
.donut-chart { width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(var(--border-color) 0% 100%); position: relative; flex-shrink: 0; }
.donut-chart::after { content: ''; position: absolute; inset: 24px; background: var(--card-bg); border-radius: 50%; }
.donut-legend { font-size: 0.72rem; display: flex; flex-direction: column; gap: 7px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-weight: 500; color: var(--text-secondary); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── Views ──────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: viewFadeIn 0.22s ease-out; }

/* ── FAB ────────────────────────────────────────────────────── */
.fab {
    position: absolute;
    bottom: 88px;
    right: 18px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 6px 20px rgba(90,103,216,0.35);
    border: none;
    cursor: pointer;
    z-index: 90;
    transition: transform var(--ease-spring), box-shadow var(--ease-out);
}
.fab:active { transform: scale(0.88); box-shadow: 0 3px 10px rgba(90,103,216,0.3); }

/* ── Misc ───────────────────────────────────────────────────── */
.stat-label-sm { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }

/* ── Splash Screen ──────────────────────────────────────────── */
.splash-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 30px 20px;
    text-align: center;
    gap: 20px;
    background-color: var(--bg-color);
}
.splash-logo {
    width: 80px;
    height: 80px;
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    animation: pulse 1.8s infinite ease-in-out;
}
.splash-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: 10px;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes viewFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp   { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes spin      { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse     { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.05); opacity: 0.85; } }
