:root {
    --app-bg: #111621;
    --app-surface: rgba(30, 41, 59, 0.4);
    --app-surface-solid: #1a2332;
    --app-surface-hover: rgba(30, 41, 59, 0.6);
    --app-border: rgba(51, 65, 85, 0.5);
    --app-border-light: rgba(51, 65, 85, 0.3);
    --app-text: #f1f5f9;
    --app-text-secondary: #94a3b8;
    --app-text-muted: #64748b;
    --app-primary: #195de6;
    --app-primary-10: rgba(25, 93, 230, 0.1);
    --app-primary-20: rgba(25, 93, 230, 0.2);
    --app-primary-40: rgba(25, 93, 230, 0.4);
    --app-danger: #ef4444;
    --app-success: #10b981;
    --app-success-bg: rgba(16, 185, 129, 0.1);
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--app-bg);
    color: var(--app-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    min-height: 100dvh;
}

h1:focus { outline: none; }

/* ?? App Shell ??????????????????????????????? */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* ?? Header ?????????????????????????????????? */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(17, 22, 33, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--app-primary-10);
    border: 1px solid var(--app-primary-20);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-greeting {
    display: block;
    font-size: 12px;
    color: var(--app-text-secondary);
    font-weight: 500;
}

.header-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--app-text);
}

.notification-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--app-text-secondary);
    cursor: pointer;
    transition: background 0.2s;
}
.notification-btn:hover { background: rgba(30, 41, 59, 0.8); }

/* ?? Main Content ???????????????????????????? */
.app-main {
    flex: 1;
    padding: 0 24px 120px;
}

@media (min-width: 640px) {
    .app-main { max-width: 480px; margin: 0 auto; width: 100%; }
}

/* ?? FAB ????????????????????????????????????? */
.fab {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--app-primary);
    color: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 20px rgba(25, 93, 230, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
    cursor: pointer;
    transition: transform 0.15s;
}
.fab:active { transform: scale(0.95); }
.fab .mud-icon-root { font-size: 28px; }

/* ?? Bottom Nav ?????????????????????????????? */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(17, 22, 33, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(30, 41, 59, 0.5);
    padding: 12px 24px 28px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--app-text-muted);
    transition: color 0.2s;
    flex: 1;
    -webkit-tap-highlight-color: transparent;
}
.nav-item .nav-label { font-size: 10px; font-weight: 500; }
.nav-item.active { color: var(--app-primary); }
.nav-item.active .nav-label { font-weight: 700; }
.nav-item:hover { color: var(--app-primary); }

/* ?? Dashboard: Total Spending ??????????????? */
.total-spending {
    padding: 32px 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.total-spending-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--app-text-secondary);
    margin-bottom: 8px;
}
.total-spending-amount {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 16px;
}
.month-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--app-primary-20);
    color: var(--app-primary);
    border-radius: 9999px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.month-pill:active { background: rgba(25, 93, 230, 0.3); }
.month-pill .mud-icon-root { font-size: 18px; }

/* ?? Spending Trends Card ???????????????????? */
.trends-card {
    background: var(--app-surface);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--app-border);
    margin-bottom: 32px;
}
.trends-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.trends-title { font-size: 14px; font-weight: 700; }
.trends-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    color: var(--app-success);
    background: var(--app-success-bg);
    padding: 2px 8px;
    border-radius: 9999px;
}
.trends-badge .mud-icon-root { font-size: 12px; }
.chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 128px;
    gap: 8px;
    padding: 0 4px;
}
.chart-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 8px;
}
.chart-bar-bg {
    width: 100%;
    background: var(--app-primary-10);
    border-radius: 4px 4px 0 0;
    position: relative;
    height: 96px;
    overflow: hidden;
}
.chart-bar-bg.current {
    background: var(--app-primary-20);
    border: 1px solid var(--app-primary-20);
}
.chart-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--app-primary-40);
    border-radius: 4px 4px 0 0;
    transition: height 0.3s;
}
.chart-bar-bg.current .chart-bar-fill { background: var(--app-primary); }
.chart-label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--app-text-muted);
}
.chart-label.current { color: var(--app-primary); font-weight: 700; }

/* ?? Section Header ?????????????????????????? */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title { font-size: 18px; font-weight: 700; margin: 0; }
.section-action {
    font-size: 14px;
    font-weight: 600;
    color: var(--app-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

/* ?? Category Cards ?????????????????????????? */
.categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.category-card {
    background: var(--app-surface);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--app-border);
}
.category-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: white;
}
.category-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--app-text-secondary);
    margin-bottom: 4px;
}
.category-amount { font-size: 18px; font-weight: 700; }

/* ?? Transaction Items ??????????????????????? */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.transaction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--app-surface);
    border-radius: 8px;
    border: 1px solid var(--app-border-light);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}
.transaction-item:hover { background: var(--app-surface-hover); }
.transaction-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(51, 65, 85, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--app-text-secondary);
    flex-shrink: 0;
}
.transaction-icon .mud-icon-root { font-size: 20px; }
.transaction-info { min-width: 0; }
.transaction-name {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.transaction-category {
    font-size: 10px;
    color: var(--app-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}
.transaction-amount { font-size: 14px; font-weight: 700; white-space: nowrap; margin-left: 12px; }
.transaction-amount.expense { color: var(--app-danger); }
.transaction-amount.income { color: var(--app-success); }

/* ?? Page Sections ??????????????????????????? */
.page-section { margin-top: 32px; }

/* ?? Detail Page ????????????????????????????? */
.detail-card {
    background: var(--app-surface);
    border-radius: 16px;
    border: 1px solid var(--app-border);
    padding: 24px;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--app-border-light);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 12px; color: var(--app-text-secondary); font-weight: 500; }
.detail-value { font-size: 14px; font-weight: 600; }

/* ?? Settings ???????????????????????????????? */
.settings-card {
    background: var(--app-surface);
    border-radius: 12px;
    border: 1px solid var(--app-border);
    padding: 20px;
    margin-bottom: 16px;
}
.settings-card-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--app-text);
}
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--app-border-light);
    color: var(--app-text);
}
.settings-item:last-child { border-bottom: none; }
.settings-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.settings-item-label { font-size: 14px; font-weight: 500; }
.settings-item-value { font-size: 14px; color: var(--app-text-secondary); }

/* ?? Empty / Placeholder State ??????????????? */
.placeholder-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 64px 24px;
}
.placeholder-section .mud-icon-root { font-size: 48px; color: var(--app-text-muted); margin-bottom: 16px; }
.placeholder-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.placeholder-text { font-size: 14px; color: var(--app-text-secondary); }

/* ?? Date Group Header ??????????????????????? */
.date-group-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    margin-top: 24px;
}
.date-group-header:first-child { margin-top: 0; }

/* ?? Back Link ??????????????????????????????? */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--app-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 24px;
}
.back-link:hover { text-decoration: underline; }

/* ── Delete Button ─────────────────────────── */
.delete-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--app-text-muted);
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.delete-btn:hover { color: var(--app-danger); }

/* When a transaction card has a sibling delete button, reserve space */
.has-delete > .transaction-item {
    padding-right: 44px;
}

/* ── Refresh Button ────────────────────────── */
.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--app-primary-10);
    color: var(--app-primary);
    border: 1px solid var(--app-primary-20);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
}
.refresh-btn:hover {
    background: var(--app-primary-20);
}
.refresh-btn:active {
    transform: scale(0.95);
}

/* ── Blazor Error UI ───────────────────────── */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred."; }