:root {
    --bg: #f6f6f2;
    --card: rgba(255, 255, 255, 0.86);
    --text: #1f2937;
    --muted: #5b6473;
    --accent: #f97316;
    --accent-dark: #c2410c;
    --danger: #dc2626;
    --border: #e6e7ea;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 15% 0%, #fff7ed 0%, transparent 45%),
                radial-gradient(circle at 90% 80%, #dbeafe 0%, transparent 40%),
                var(--bg);
    min-height: 100vh;
}

.bg-shape {
    position: fixed;
    border-radius: 999px;
    filter: blur(40px);
    z-index: -1;
}

.bg-shape-1 {
    width: 250px;
    height: 250px;
    background: rgba(251, 146, 60, 0.18);
    top: -40px;
    right: 10%;
}

.bg-shape-2 {
    width: 300px;
    height: 300px;
    background: rgba(59, 130, 246, 0.16);
    left: -70px;
    bottom: -60px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    backdrop-filter: blur(8px);
    border-bottom: 3px solid var(--accent);
    background: linear-gradient(90deg, #1f2937 0%, #111827 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.brand {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    color: var(--accent);
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    text-shadow: 0 0 20px rgba(249, 115, 22, 0.5);
    background: rgba(249, 115, 22, 0.08);
    border: 2px solid var(--accent);
}

.brand:hover {
    background: rgba(249, 115, 22, 0.2);
    transform: translateY(-2px);
    text-shadow: 0 0 30px rgba(249, 115, 22, 0.8);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.4);
}

nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1.5px solid rgba(249, 115, 22, 0.4);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

nav a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.5);
}

nav a:active {
    transform: translateY(0);
}

.link-btn {
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    background: linear-gradient(135deg, var(--accent), #ea580c);
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.link-btn:hover {
    background: linear-gradient(135deg, #ea580c, var(--accent-dark));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.pill {
    background: linear-gradient(135deg, #111827, #1f2937);
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    border: 1.5px solid var(--accent);
    transition: all 0.3s ease;
}

.pill:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.inline-form {
    margin: 0;
    display: inline-block;
}

.nav-divider {
    width: 1px;
    height: 2rem;
    background: linear-gradient(180deg, transparent, var(--border), transparent);
    margin: 0 0.5rem;
}

.nav-main {
    position: relative;
}

.nav-tools {
    opacity: 0.9;
    font-size: 0.9rem;
}

.nav-tools:hover {
    opacity: 1;
}

.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
    animation: rise 0.45s ease;
}

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

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.hero div {
    flex: 1;
    min-width: 200px;
}

.hero-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

h1,
h2,
h3 {
    margin: 0 0 0.4rem 0;
}

.muted {
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 1rem;
}

.stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.analysis-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.analysis-chart {
    height: 320px;
    max-height: 320px;
    margin-top: 1rem;
}

.analysis-breakdown {
    margin-bottom: 1rem;
}

.analysis-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--accent);
}

.analysis-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 0 0 auto;
}

.analysis-form label {
    font-weight: 700;
    white-space: nowrap;
}

.analysis-form select {
    width: auto;
    min-width: 220px;
}

.analysis-detail {
    margin-bottom: 1rem;
}

.analysis-highlight {
    margin: 1rem 0 0;
    color: var(--accent-dark);
    font-size: 2.2rem;
    font-weight: 800;
}

.analysis-positive {
    color: #15803d;
    font-weight: 800;
}

.analysis-negative {
    color: var(--danger);
    font-weight: 800;
}

.analysis-detail .muted {
    max-width: 760px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
}

.auth-card,
.form-card {
    max-width: 540px;
    margin: 2rem auto;
}

.stat-card .amount {
    margin-top: 0.5rem;
    font-size: 1.8rem;
    font-weight: 800;
}

.btn-primary,
.btn-danger {
    border: none;
    border-radius: 10px;
    padding: 0.65rem 1rem;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #ea580c);
    text-decoration: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ea580c, var(--accent-dark));
}

.btn-danger {
    background: var(--danger);
}

.btn-secondary {
    background: #fff;
    border: 1.5px solid var(--accent-dark);
    color: #111827;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.card-action {
    margin-top: 1.2rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-start;
}

.card-action .btn-primary {
    width: auto;
}

.stack-form p {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

input,
select,
textarea {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem;
    font: inherit;
    width: 100%;
}

.table-wrap {
    overflow-x: auto;
}

.expense-list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.list-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.3rem 0.4rem 0.3rem 0.75rem;
    color: #fff;
    background: #1f2937;
    border: 1px solid rgba(249, 115, 22, 0.5);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.14);
}

.list-controls label {
    color: #fed7aa;
    font-size: 0.85rem;
    font-weight: 800;
    white-space: nowrap;
}

.list-controls select {
    width: auto;
    min-width: 190px;
    padding: 0.45rem 2rem 0.45rem 0.6rem;
    color: #111827;
    background: #fff;
    border: 0;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

.expense-list-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0.5rem;
}

.clean-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.clean-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    margin-top: 0.9rem;
    flex-wrap: wrap;
}

.pagination-links {
    display: flex;
    gap: 0.7rem;
}

.pagination a {
    color: var(--accent-dark);
    font-weight: 700;
}

.page-jump {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.4rem;
    width: max-content;
    max-width: 100%;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.page-jump .page-number-input {
    display: block;
    flex: 0 0 36px !important;
    width: 36px !important;
    min-width: 36px;
    max-width: 36px;
    height: 36px;
    padding: 0;
    text-align: center;
}

.page-jump .btn-secondary {
    padding: 0.45rem 0.75rem;
}

@media (max-width: 600px) {
    .expense-list-toolbar {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .expense-list-toolbar .list-controls {
        margin-left: auto;
    }

    .hero-actions {
        width: 100%;
    }

    .list-controls {
        flex: 1;
    }

    .list-controls select {
        min-width: 0;
        flex: 1;
    }
}

.month-filter {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.alerts {
    margin-bottom: 1rem;
}

.alert {
    background: #ecfeff;
    border: 1px solid #bae6fd;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
}

.budget-alert {
    margin-bottom: 1rem;
}

.budget-ok {
    border-left: 4px solid #16a34a;
}

.budget-warning {
    border-left: 4px solid #ca8a04;
}

.budget-danger {
    border-left: 4px solid #dc2626;
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 260px;
    max-height: 260px;
    overflow: hidden;
}

.chart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
}

@media (max-width: 900px) {
    .stats-grid,
    .content-grid,
    .analysis-grid {
        grid-template-columns: 1fr;
    }

    .analysis-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }
}

@media (max-width: 600px) {
    .analysis-selector,
    .analysis-form {
        align-items: stretch;
        flex-direction: column;
    }

    .analysis-form select,
    .analysis-form .btn-primary {
        width: 100%;
    }

    .analysis-stats {
        grid-template-columns: 1fr;
    }
}
