:root {
    --canvas: #f3f1ec;
    --paper: #fbfaf7;
    --paper-strong: #ffffff;
    --ink: #171a21;
    --ink-soft: #626671;
    --line: #d5d2ca;
    --line-strong: #aaa8a2;
    --blue: #3156d8;
    --blue-dark: #2444b5;
    --blue-wash: #e7ebff;
    --coral: #d65745;
    --coral-wash: #f9e9e5;
    --positive: #17715c;
    --positive-wash: #e3f1ed;
    --radius: 8px;
    color-scheme: light;
    font-family: Arial, Helvetica, sans-serif;
}

html[data-theme="dark"] {
    --canvas: #12141a;
    --paper: #1a1d24;
    --paper-strong: #20242c;
    --ink: #f1f0ec;
    --ink-soft: #a9abb3;
    --line: #343842;
    --line-strong: #555a65;
    --blue: #7892ff;
    --blue-dark: #9aabff;
    --blue-wash: #242d55;
    --coral: #f0806f;
    --coral-wash: #442925;
    --positive: #67c5ad;
    --positive-wash: #203b35;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        --canvas: #12141a;
        --paper: #1a1d24;
        --paper-strong: #20242c;
        --ink: #f1f0ec;
        --ink-soft: #a9abb3;
        --line: #343842;
        --line-strong: #555a65;
        --blue: #7892ff;
        --blue-dark: #9aabff;
        --blue-wash: #242d55;
        --coral: #f0806f;
        --coral-wash: #442925;
        --positive: #67c5ad;
        --positive-wash: #203b35;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; }
button, input, select { font: inherit; }

.site-header {
    height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(24px, calc((100vw - 1160px) / 2));
    border-bottom: 1px solid var(--line);
    background: var(--canvas);
}

.brand {
    color: var(--ink);
    text-decoration: none;
    font-size: 18px;
    font-weight: 400;
    letter-spacing: -.04em;
}

.brand span { font-weight: 800; }
.brand i { color: var(--blue); font-style: normal; padding: 0 2px; }
.brand small { margin-left: 10px; color: var(--ink-soft); font-size: 12px; font-weight: 400; letter-spacing: 0; }

.theme-button {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    padding: 8px 0;
    cursor: pointer;
    font-size: 13px;
}

.page-shell { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 52px 0 90px; }

.hero {
    min-height: 570px;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    align-items: center;
    gap: 9vw;
    border-bottom: 1px solid var(--line);
}

.kicker, .eyebrow {
    margin: 0 0 18px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0;
    max-width: 650px;
    font-size: clamp(60px, 8.5vw, 118px);
    font-weight: 800;
    line-height: .84;
    letter-spacing: -.075em;
}

.hero-intro {
    max-width: 560px;
    margin: 36px 0 28px;
    color: var(--ink-soft);
    font-size: 19px;
    line-height: 1.55;
}

.hero-actions { display: flex; align-items: center; gap: 18px; }
.hero-actions span { color: var(--ink-soft); font-size: 13px; }

.ledger-preview { border-top: 3px solid var(--ink); font-variant-numeric: tabular-nums; }
.ledger-label, .ledger-row, .ledger-result { display: flex; justify-content: space-between; gap: 30px; }
.ledger-label { padding: 13px 0 22px; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.ledger-row { padding: 19px 0; border-top: 1px solid var(--line); font-size: 17px; }
.ledger-row span { display: flex; justify-content: space-between; flex: 1; }
.ledger-row small { color: var(--ink-soft); font-size: 13px; }
.ledger-result { margin-top: 18px; padding: 19px; background: var(--blue); color: #fff; font-size: 18px; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.feature-grid article { min-height: 245px; padding: 38px 36px 30px 0; border-right: 1px solid var(--line); }
.feature-grid article + article { padding-left: 36px; }
.feature-grid article:last-child { border-right: 0; }
.feature-grid article > span { color: var(--blue); font-size: 12px; font-weight: 700; }
.feature-grid h2 { margin: 48px 0 10px; font-size: 21px; letter-spacing: -.025em; }
.feature-grid p { margin: 0; max-width: 300px; color: var(--ink-soft); }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 10px 18px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { border-color: var(--line-strong); background: transparent; color: var(--ink); }
.button-secondary:hover { border-color: var(--ink); }

.narrow { width: min(720px, 100%); margin: 22px auto; }
.narrow h1, .event-header h1 { margin: 10px 0 16px; font-size: clamp(42px, 7vw, 74px); line-height: .95; letter-spacing: -.055em; }
.lead { margin: 0 0 38px; color: var(--ink-soft); font-size: 18px; }
.back-link { color: var(--ink-soft); text-decoration: none; font-size: 14px; }

.stacked-form { display: grid; gap: 21px; margin-top: 30px; }
.stacked-form.compact { margin-top: 18px; }
.stacked-form label, .expense-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--paper); color: var(--ink); padding: 10px 12px; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-wash); }
fieldset { margin: 0; padding: 0; border: 0; }

.mode-choice { display: grid; gap: 10px; }
.mode-choice legend { margin-bottom: 9px; font-size: 13px; font-weight: 700; }
.choice-card { display: grid !important; grid-template-columns: 22px 1fr !important; align-items: start; gap: 13px !important; padding: 18px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); cursor: pointer; }
.choice-card.selected { border: 2px solid var(--blue); padding: 17px; background: var(--blue-wash); }
.choice-card input { width: auto; min-height: 0; margin-top: 3px; accent-color: var(--blue); }
.choice-card span { display: grid; gap: 5px; }
.choice-card strong { font-size: 16px; }
.choice-card small { margin-left: 7px; color: var(--blue); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.choice-card em { color: var(--ink-soft); font-size: 14px; font-style: normal; font-weight: 400; }

.event-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 32px; padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.event-header h1 { margin-bottom: 0; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.span-2 { grid-column: span 2; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.section-heading p { margin: 3px 0 0; color: var(--ink-soft); font-size: 13px; }

.expense-form { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 13px; margin: 26px 0 14px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.receipt-upload { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; margin-top: 22px; }
.receipt-upload label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.receipt-row form { margin: 0; }
.status-success { color: var(--positive); font-weight: 700; }
.status-error { color: var(--coral); font-weight: 700; }
.expense-form .participant-checks, .expense-form .button { grid-column: 1 / -1; }
.participant-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.participant-checks legend { width: 100%; font-size: 13px; font-weight: 700; }
.participant-checks label { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; font-weight: 400; }
.participant-checks input { width: auto; min-height: 0; accent-color: var(--blue); }

.item-list { margin-top: 18px; border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.list-row div { display: grid; }
.list-row small { color: var(--ink-soft); }
.empty-state { margin-top: 18px; padding: 28px 14px; border: 1px dashed var(--line-strong); color: var(--ink-soft); text-align: center; }
.people-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.person-chip { padding: 6px 9px; border: 1px solid var(--line); border-radius: 3px; font-size: 13px; }
.inline-form { display: flex; gap: 8px; }
.accent-card { border-top: 3px solid var(--blue); }
.big-amount { font-size: 26px; font-variant-numeric: tabular-nums; }
.notice { color: var(--ink-soft); font-size: 12px; }

.balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; margin: 20px 0; background: var(--line); border: 1px solid var(--line); }
.balance-tile { display: grid; min-height: 122px; padding: 15px; background: var(--paper-strong); }
.balance-tile strong { margin-top: auto; font-size: 23px; font-variant-numeric: tabular-nums; }
.balance-tile small { color: var(--ink-soft); }
.balance-tile.is-positive { background: var(--positive-wash); color: var(--positive); }
.balance-tile.is-negative { background: var(--coral-wash); color: var(--coral); }
.positive { color: var(--positive); }
.negative { color: var(--coral); }

.auth-card { width: min(460px, 100%); margin: 8vh auto; padding: 32px; border-top: 3px solid var(--blue); background: var(--paper); }
.alert { padding: 12px; border-left: 3px solid var(--coral); background: var(--coral-wash); color: var(--coral); }
.error-panel { padding: 35px 0; }
.error-panel pre { overflow: auto; white-space: pre-wrap; font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-bottom: 18px; background: var(--line); border: 1px solid var(--line); }
.stat-card { display: grid; min-height: 140px; padding: 20px; background: var(--paper); }
.stat-card span { color: var(--ink-soft); }
.stat-card strong { margin-top: auto; font-size: 38px; }

@media (max-width: 760px) {
    .site-header { height: 58px; padding: 0 18px; }
    .theme-button span { display: none; }
    .page-shell { width: min(100% - 28px, 1160px); padding: 30px 0 65px; }
    .hero { min-height: auto; grid-template-columns: 1fr; gap: 60px; padding: 50px 0 55px; }
    .hero h1 { font-size: clamp(57px, 19vw, 86px); }
    .hero-intro { margin-top: 28px; font-size: 17px; }
    .hero-actions { align-items: start; flex-direction: column; }
    .ledger-row span { display: grid; }
    .feature-grid, .stats-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .feature-grid article, .feature-grid article + article { min-height: auto; padding: 30px 0; border-right: 0; border-bottom: 1px solid var(--line); }
    .feature-grid h2 { margin-top: 25px; }
    .span-2 { grid-column: auto; }
    .event-header { align-items: start; flex-direction: column; }
    .event-header .button { width: 100%; }
    .expense-form { grid-template-columns: 1fr; }
    .receipt-upload { grid-template-columns: 1fr; }
    .inline-form { flex-direction: column; }
    .card { padding: 18px; }
}
