:root {
    color-scheme: light;
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-muted: #eef4f8;
    --text: #142234;
    --muted: #647386;
    --line: #d8e1ea;
    --primary: #2368b8;
    --primary-dark: #184f8f;
    --cyan: #0d8aa4;
    --positive: #12745b;
    --negative: #b4233a;
    --danger: #b4233a;
    --shadow: 0 12px 32px rgba(20, 34, 52, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem clamp(1rem, 3vw, 2.5rem);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    color: var(--text);
    font-weight: 800;
    letter-spacing: 0;
}

nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.85rem;
    font-size: 0.95rem;
}

.nav-cta,
.pill {
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--primary-dark);
    padding: 0.35rem 0.7rem;
    font-weight: 700;
}

.user-label,
.muted,
.help-text,
.form-footer,
.event-card p,
.section-header p,
td span {
    color: var(--muted);
}

.page {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.page-heading,
.auth-layout,
.form-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.auth-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    align-items: center;
    min-height: calc(100vh - 9rem);
}

.form-shell {
    grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 1fr);
}

.form-shell.narrow {
    display: block;
    max-width: 560px;
    margin: 3rem auto 0;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 860px;
    margin-bottom: 0.55rem;
    font-size: clamp(2rem, 5vw, 4.5rem);
    line-height: 0.98;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0.4rem;
    font-size: 1.15rem;
    letter-spacing: 0;
}

.form-panel h1,
.form-panel h2,
.panel h2,
.event-card h2 {
    font-size: 1.2rem;
    line-height: 1.25;
}

.eyebrow {
    margin-bottom: 0.45rem;
    color: var(--cyan);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.panel,
.event-card,
.metric,
.empty-state {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel,
.empty-state {
    padding: 1.25rem;
}

.empty-state {
    max-width: 620px;
}

.event-grid,
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.event-card {
    display: flex;
    min-height: 260px;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
}

.event-card-header,
.section-header,
.actions,
.form-actions,
.inline-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.event-card-header,
.section-header {
    justify-content: space-between;
}

.actions,
.form-actions {
    flex-wrap: wrap;
}

.stat-list,
.metric-grid {
    margin: 0;
}

.stat-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.stat-list div {
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--surface-muted);
}

dt,
.metric span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

dd {
    margin: 0.15rem 0 0;
    font-size: 1.25rem;
    font-weight: 800;
}

.metric {
    min-height: 112px;
    padding: 1rem;
}

.metric strong {
    display: block;
    margin-top: 0.45rem;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.1;
}

.metric.accent {
    border-color: rgba(13, 138, 164, 0.35);
    background: #eefafe;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 1rem;
    margin-top: 1rem;
}

.notes-panel {
    margin-top: 1rem;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 660px;
}

th,
td {
    padding: 0.85rem 0.65rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
}

td span {
    display: block;
    font-size: 0.85rem;
}

.expense-list {
    display: grid;
    gap: 0.75rem;
}

.expense-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}

.expense-row:last-child,
tbody tr:last-child td {
    border-bottom: 0;
}

.expense-row span {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.button,
button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.65rem 0.95rem;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
}

.button:hover {
    text-decoration: none;
}

.primary {
    background: var(--primary);
    color: #ffffff;
}

.primary:hover {
    background: var(--primary-dark);
}

.secondary,
.compact {
    border-color: var(--line);
    background: #ffffff;
    color: var(--text);
}

.compact {
    min-height: 36px;
    padding: 0.45rem 0.75rem;
}

.danger {
    background: var(--danger);
    color: #ffffff;
}

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

.link-button {
    min-height: auto;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--primary);
}

.form-panel {
    display: grid;
    gap: 1rem;
}

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

.form-panel.wide .field:has(textarea),
.form-panel.wide .form-errors,
.form-panel.wide .form-actions {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 0.35rem;
}

label {
    font-weight: 800;
}

.control,
.form-panel input,
.form-panel select,
.form-panel textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    padding: 0.65rem 0.75rem;
}

textarea.control {
    min-height: 96px;
    resize: vertical;
}

.field-errors,
.form-errors {
    color: var(--danger);
    font-size: 0.9rem;
}

.field-errors ul,
.form-errors ul,
.help-text ul {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
}

.messages {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.message {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    padding: 0.75rem 1rem;
}

.message.success {
    border-color: rgba(18, 116, 91, 0.3);
    background: #eefbf6;
}

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

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

@media (max-width: 820px) {
    .site-header,
    .page-heading,
    .auth-layout,
    .form-shell,
    .split-layout {
        grid-template-columns: 1fr;
    }

    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    nav {
        justify-content: flex-start;
    }

    .page {
        width: min(100% - 1rem, 1180px);
        padding-top: 1rem;
    }

    h1 {
        font-size: 2.4rem;
    }

    .actions {
        width: 100%;
    }

    .actions .button,
    .page-heading > .button {
        width: 100%;
    }

    .form-panel.wide {
        grid-template-columns: 1fr;
    }
}
