:root {
    --bg: #f4efe6;
    --bg-accent: rgba(15, 118, 110, 0.14);
    --surface: rgba(255, 255, 255, 0.78);
    --surface-strong: #ffffff;
    --surface-soft: #f8fafc;
    --border: rgba(148, 163, 184, 0.26);
    --text: #162033;
    --muted: #667085;
    --brand: #0f766e;
    --brand-strong: #115e59;
    --accent: #f97316;
    --income: #10b981;
    --expense: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(249, 115, 22, 0.16), transparent 26%),
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.15), transparent 28%),
        linear-gradient(180deg, #fcfaf7 0%, var(--bg) 48%, #eef4f3 100%);
    transition: background-color 0.35s ease, color 0.35s ease;
}

body.dark {
    --bg: #08111f;
    --bg-accent: rgba(59, 130, 246, 0.2);
    --surface: rgba(15, 23, 42, 0.76);
    --surface-strong: rgba(15, 23, 42, 0.92);
    --surface-soft: rgba(30, 41, 59, 0.92);
    --border: rgba(148, 163, 184, 0.18);
    --text: #ecf3ff;
    --muted: #97a6ba;
    --brand: #2dd4bf;
    --brand-strong: #14b8a6;
    --accent: #fb923c;
    --income: #34d399;
    --expense: #f87171;
    --warning: #fbbf24;
    --shadow: 0 26px 60px rgba(2, 6, 23, 0.45);
    background:
        radial-gradient(circle at top left, rgba(251, 146, 60, 0.14), transparent 20%),
        radial-gradient(circle at top right, rgba(45, 212, 191, 0.14), transparent 24%),
        linear-gradient(180deg, #09111f 0%, #0c1729 46%, #0f1c30 100%);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
}

.page-shell {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    color: white;
    font-family: "Sora", sans-serif;
    font-weight: 700;
    letter-spacing: 0.08em;
    box-shadow: var(--shadow);
}

.brand-text p,
.brand-text h1 {
    margin: 0;
}

.kicker {
    color: var(--brand-strong);
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.brand-title {
    font-family: "Sora", sans-serif;
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.04em;
}

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

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.theme-toggle-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.theme-toggle-copy strong {
    font-size: 0.95rem;
}

.theme-toggle-copy span {
    font-size: 0.78rem;
    color: var(--muted);
}

#dark-mode-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 58px;
    height: 34px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
}

.toggle-thumb {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: white;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.16);
    transition: transform 0.3s ease, background-color 0.3s ease;
}

#dark-mode-toggle:checked + .toggle-track .toggle-thumb {
    transform: translateX(24px);
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 999px;
    font-weight: 700;
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    color: white;
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--text);
    color: var(--surface-strong);
}

.btn-ghost {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    gap: 20px;
    margin-bottom: 22px;
}

.hero-card {
    position: relative;
    overflow: hidden;
    padding: 28px;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: auto -40px -50px auto;
    width: 180px;
    height: 180px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(15, 118, 110, 0.24), transparent 70%);
    pointer-events: none;
}

.hero-card-accent {
    background:
        linear-gradient(145deg, rgba(15, 118, 110, 0.92), rgba(249, 115, 22, 0.92)),
        var(--surface);
    color: white;
}

.hero-card-accent .hero-note,
.hero-card-accent .hero-chip span,
.hero-card-accent .hero-label {
    color: rgba(255, 255, 255, 0.84);
}

.hero-card h2,
.hero-card p,
.hero-card h3 {
    margin: 0;
}

.hero-title {
    margin-top: 10px;
    font-family: "Sora", sans-serif;
    font-size: clamp(2rem, 4vw, 3.3rem);
    line-height: 1;
    letter-spacing: -0.06em;
}

.hero-note {
    max-width: 640px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.7;
}

.hero-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.46);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 0.92rem;
    font-weight: 700;
}

.hero-card-accent .hero-chip {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
}

.hero-spotlight {
    display: grid;
    gap: 18px;
    align-content: space-between;
    min-height: 100%;
}

.hero-label {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.spotlight-value {
    font-family: "Sora", sans-serif;
    font-size: clamp(2.4rem, 4vw, 3.2rem);
    line-height: 1;
    letter-spacing: -0.06em;
}

.spotlight-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.spotlight-stat {
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.spotlight-stat strong,
.spotlight-stat span {
    display: block;
}

.spotlight-stat span {
    font-size: 0.82rem;
    opacity: 0.82;
}

.spotlight-stat strong {
    margin-top: 6px;
    font-size: 1.1rem;
}

.budget-summary-section {
    margin-bottom: 22px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.section-heading h2,
.section-heading h3,
.section-heading p {
    margin: 0;
}

.section-heading h2,
.section-heading h3 {
    font-family: "Sora", sans-serif;
    font-size: 1.25rem;
    letter-spacing: -0.04em;
}

.section-heading p {
    color: var(--muted);
    margin-top: 6px;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--brand-strong);
    font-size: 0.85rem;
    font-weight: 800;
}

.budget-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
}

.budget-category {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 158px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--surface-strong) 0%, rgba(255, 255, 255, 0.76) 100%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.budget-category .category-name {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.budget-category .category-amount {
    font-family: "Sora", sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}

.budget-category .category-progress {
    color: var(--muted);
    font-weight: 700;
}

.budget-category.low {
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.12) 0%, rgba(255, 255, 255, 0.9) 100%);
}

.budget-category.exceeded {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.12) 0%, rgba(255, 255, 255, 0.92) 100%);
}

.budget-bar {
    width: 100%;
}

.budget-bar-background {
    overflow: hidden;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
}

.budget-bar-foreground {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
    gap: 20px;
    align-items: stretch;
    grid-template-areas:
        "income budget"
        "transactions budget-chart";
}

.panel {
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: 100%;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.panel-income-overview {
    grid-area: income;
}

.panel-budget-manager {
    grid-area: budget;
}

.panel-transactions {
    grid-area: transactions;
}

.panel-budget-chart {
    grid-area: budget-chart;
}

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

.panel-header h2,
.panel-header h3,
.panel-header p,
.panel-caption {
    margin: 0;
}

.panel-header h2,
.panel-header h3 {
    font-family: "Sora", sans-serif;
    font-size: 1.25rem;
    letter-spacing: -0.04em;
}

.panel-caption {
    margin-top: 6px;
    color: var(--muted);
}

.filter-controls {
    display: grid;
    gap: 14px;
}

.form-control,
.form-grid input,
.form-grid select,
.modal-form input,
.modal-form select,
#filter-form input,
#filter-form select {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.form-control:focus,
.form-grid input:focus,
.form-grid select:focus,
.modal-form input:focus,
.modal-form select:focus,
#filter-form input:focus,
#filter-form select:focus {
    border-color: rgba(15, 118, 110, 0.55);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.transaction-list {
    display: grid;
    gap: 12px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
    max-height: 680px;
    overflow: auto;
}

.transaction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: var(--surface-strong);
    border: 1px solid var(--border);
}

.transaction-main {
    min-width: 0;
}

.transaction-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.transaction-title {
    font-weight: 800;
    color: var(--text);
}

.transaction-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
}

.transaction-badge.income {
    color: var(--income);
    background: rgba(16, 185, 129, 0.12);
}

.transaction-badge.expense {
    color: var(--expense);
    background: rgba(239, 68, 68, 0.12);
}

.transaction-date,
.transaction-category {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

.text-button {
    padding: 0;
    background: transparent;
    color: var(--expense);
    font-weight: 800;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 180px;
    padding: 24px;
    border-radius: var(--radius-md);
    background: rgba(148, 163, 184, 0.08);
    color: var(--muted);
    text-align: center;
}

.form-grid {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.radio-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    font-weight: 700;
}

.radio-pill input {
    accent-color: var(--brand);
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--surface-strong);
    border: 1px solid var(--border);
}

.metric-card h4,
.metric-card p {
    margin: 0;
}

.metric-card h4 {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
}

.metric-card p {
    margin-top: 8px;
    font-family: "Sora", sans-serif;
    font-size: 1.35rem;
    letter-spacing: -0.04em;
}

.metric-card.income p {
    color: var(--income);
}

.metric-card.expense p {
    color: var(--expense);
}

.metric-card.balance p {
    color: var(--brand-strong);
}

.chart-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 240px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid var(--border);
}

.panel-income-overview .chart-wrap {
    min-height: 320px;
}

.panel-budget-chart .chart-wrap {
    min-height: 320px;
}

.panel canvas {
    width: 100% !important;
}

#filter-modal,
#modal {
    display: flex;
    position: fixed;
    inset: 0;
    padding: 24px;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(10px);
    z-index: 50;
}

#filter-modal.hidden,
#modal.hidden,
#budget-warning.hidden {
    display: none;
}

.modal-card {
    width: min(100%, 520px);
    padding: 24px;
    border-radius: var(--radius-xl);
    background: var(--surface-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.modal-card h3,
.modal-card p {
    margin: 0;
}

.modal-card p {
    color: var(--muted);
    margin-top: 8px;
}

.modal-form,
#filter-form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.inline-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

#budget-warning {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, #dc2626 0%, #fb923c 100%);
    color: white;
    box-shadow: var(--shadow);
    transform: translateY(24px);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 60;
}

#budget-warning.show {
    opacity: 1;
    transform: translateY(0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1024px) {
    .hero-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-areas:
            "income"
            "budget"
            "transactions"
            "budget-chart";
    }
}

@media (max-width: 760px) {
    .page-shell {
        width: min(100% - 20px, 100%);
        padding-top: 20px;
    }

    .app-header,
    .section-heading,
    .panel-header,
    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .brand-wrap {
        align-items: flex-start;
    }

    .theme-toggle {
        justify-content: space-between;
    }

    .hero-card,
    .panel,
    .modal-card {
        padding: 20px;
    }

    .inline-grid,
    .spotlight-grid,
    .metrics-row {
        grid-template-columns: 1fr;
    }

    .transaction-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    #budget-warning {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
}
