:root {
    --bg: #f5efe3;
    --surface: rgba(255, 251, 245, 0.92);
    --surface-strong: #fffdf8;
    --ink: #1f2522;
    --muted: #64716b;
    --accent: #0b6e4f;
    --accent-soft: #dff2ea;
    --warm: #c46a2f;
    --border: rgba(31, 37, 34, 0.12);
    --shadow: 0 18px 50px rgba(65, 44, 19, 0.12);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(196, 106, 47, 0.22), transparent 32%),
        radial-gradient(circle at bottom right, rgba(11, 110, 79, 0.18), transparent 30%),
        linear-gradient(180deg, #f8f2e6 0%, #f4ebdd 48%, #f6efe4 100%);
    min-height: 100vh;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    width: min(100%, 1080px);
    margin: 0 auto;
    padding: 1rem 1rem 2.5rem;
}

.topbar {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem 0 1rem;
}

.topbar h1,
.panel h2,
.auth-card h2 {
    font-family: Georgia, "Times New Roman", serif;
    margin: 0;
    letter-spacing: -0.02em;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--warm);
    font-size: 0.82rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.topbar-actions,
.form-actions,
.filter-actions,
.entry-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.tab {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid transparent;
    text-decoration: none;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tab.active {
    background: var(--surface-strong);
    border-color: rgba(11, 110, 79, 0.18);
    box-shadow: var(--shadow);
}

.tab:hover {
    transform: translateY(-1px);
}

.tab-icon {
    width: 1.1rem;
    height: 1.1rem;
    display: inline-flex;
}

.tab-icon svg,
.hero-icon svg {
    width: 100%;
    height: 100%;
}

.page-content {
    display: grid;
    gap: 1rem;
}

.panel,
.auth-card,
.summary-card,
.entry-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
}

.panel,
.auth-card {
    padding: 1.15rem;
}

.panel-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.panel-header p,
.auth-card p,
.muted-text,
.summary-label {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.report-filters-grid {
    align-items: end;
}

.summary-card {
    padding: 1rem;
}

.summary-card strong {
    display: block;
    margin-top: 0.55rem;
    font-size: 1.55rem;
}

.summary-card.accent {
    background: linear-gradient(135deg, rgba(11, 110, 79, 0.15), rgba(196, 106, 47, 0.1));
}

.auth-card {
    width: min(100%, 720px);
    margin: 10vh auto 0;
}

.auth-hero {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.hero-icon {
    width: 3.3rem;
    height: 3.3rem;
    padding: 0.8rem;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(11, 110, 79, 0.16), rgba(196, 106, 47, 0.2));
}

.stack-form,
.compact-form,
.category-list,
.entry-list {
    display: grid;
    gap: 1rem;
}

.form-grid,
.filters-grid,
.receipt-uploader,
.split-panel,
.report-grid,
.report-metrics-grid,
.insight-grid {
    display: grid;
    gap: 1rem;
}

.field {
    display: grid;
    gap: 0.4rem;
}

.field span {
    font-weight: 600;
}

.date-warning {
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    background: rgba(196, 106, 47, 0.14);
    border: 1px solid rgba(196, 106, 47, 0.2);
    color: #7f451c;
    font-size: 0.92rem;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(31, 37, 34, 0.14);
    background: rgba(255, 255, 255, 0.74);
    color: var(--ink);
}

.field textarea {
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 3px solid rgba(11, 110, 79, 0.16);
    border-color: rgba(11, 110, 79, 0.38);
}

.field-wide {
    grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.ghost-button,
.inline-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 46px;
    padding: 0.85rem 1.1rem;
    border-radius: 999px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
}

.primary-button {
    background: var(--accent);
    color: #fff;
}

.secondary-button {
    background: var(--warm);
    color: #fff;
}

.ghost-button,
.inline-link {
    background: rgba(255, 255, 255, 0.65);
    color: var(--ink);
    border-color: rgba(31, 37, 34, 0.12);
}

.role-chip,
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.92rem;
}

.role-admin {
    background: rgba(11, 110, 79, 0.15);
    color: var(--accent);
}

.role-viewer,
.pill {
    background: rgba(196, 106, 47, 0.12);
    color: #7f451c;
}

.flash {
    padding: 0.9rem 1rem;
    border-radius: 18px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(11, 110, 79, 0.12);
    border-color: rgba(11, 110, 79, 0.18);
}

.flash-error {
    background: rgba(180, 51, 36, 0.1);
    border-color: rgba(180, 51, 36, 0.18);
}

.entry-card {
    padding: 1rem;
}

.entry-main,
.entry-meta,
.checkbox-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.entry-date,
.entry-notes {
    margin: 0;
}

.entry-main h3 {
    margin: 0.15rem 0 0;
}

.entry-amount {
    font-size: 1.2rem;
}

.entry-meta,
.entry-actions,
.entry-notes {
    margin-top: 0.9rem;
}

.receipt-preview-card {
    display: grid;
    gap: 0.75rem;
    align-content: start;
    padding: 1rem;
    border-radius: 20px;
    border: 1px dashed rgba(31, 37, 34, 0.16);
    background: rgba(255, 255, 255, 0.48);
}

.receipt-preview-image,
.receipt-preview-empty {
    width: 100%;
    min-height: 220px;
    border-radius: 18px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.8);
}

.receipt-preview-empty {
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px dashed rgba(31, 37, 34, 0.1);
}

.analysis-box,
.empty-state {
    padding: 1rem;
    border-radius: 18px;
    background: rgba(11, 110, 79, 0.08);
}

.analysis-progress {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(11, 110, 79, 0.14);
    background: linear-gradient(135deg, rgba(11, 110, 79, 0.1), rgba(196, 106, 47, 0.08));
}

.is-hidden {
    display: none !important;
}

.analysis-progress p {
    margin: 0.2rem 0 0;
    color: var(--muted);
}

.analysis-progress-spinner {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
    border: 3px solid rgba(11, 110, 79, 0.16);
    border-top-color: var(--accent);
    flex: 0 0 auto;
    animation: spin 900ms linear infinite;
}

.bar-list {
    display: grid;
    gap: 0.95rem;
}

.bar-row {
    display: grid;
    gap: 0.4rem;
}

.bar-row-header {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.bar-track {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: rgba(11, 110, 79, 0.1);
    overflow: hidden;
}

.warm-track {
    background: rgba(196, 106, 47, 0.12);
}

.bar-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(11, 110, 79, 0.72), rgba(11, 110, 79, 1));
}

.warm-fill {
    background: linear-gradient(90deg, rgba(196, 106, 47, 0.68), rgba(196, 106, 47, 1));
}

.bar-caption {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
}

.timeline-chart {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(52px, 1fr);
    gap: 0.65rem;
    align-items: end;
    min-height: 260px;
    overflow-x: auto;
    padding-bottom: 0.35rem;
}

.timeline-column {
    display: grid;
    gap: 0.55rem;
    align-items: end;
    min-width: 52px;
}

.timeline-value,
.timeline-label {
    font-size: 0.82rem;
    text-align: center;
}

.timeline-value {
    color: var(--muted);
}

.timeline-bar {
    display: block;
    width: 100%;
    min-height: 10%;
    border-radius: 18px 18px 8px 8px;
    background: linear-gradient(180deg, rgba(196, 106, 47, 0.74), rgba(11, 110, 79, 0.92));
}

.insight-card {
    padding: 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid rgba(31, 37, 34, 0.08);
}

.insight-label,
.insight-card strong {
    display: block;
}

.insight-label {
    margin-bottom: 0.4rem;
    color: var(--muted);
}

.insight-card p {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.category-list {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.category-item {
    padding: 0.65rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.56);
}

.auth-note {
    margin-top: 1rem;
    font-size: 0.95rem;
}

@media (min-width: 720px) {
    .app-shell {
        padding: 1.25rem 1.25rem 3rem;
    }

    .tabs {
        display: flex;
        flex-wrap: wrap;
        justify-content: start;
    }

    .filters-grid,
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-grid,
    .split-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-metrics-grid,
    .insight-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .receipt-uploader,
    .report-filters-grid {
        grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
    }
}
