:root {
    --paper: #f3efe6;
    --card: #fffdf8;
    --ink: #1d2420;
    --muted: #5d6a62;
    --line: #e4d8c6;
    --green: #1f5c45;
    --green-dark: #143d2e;
    --moss: #e7f3ec;
    --clay: #9c4228;
    --clay-soft: #f8ebe3;
    --gold: #f4e7c8;
    --gold-ink: #6d4e12;
    --danger: #8d2f2f;
    --shadow: 0 16px 40px rgba(48, 36, 18, 0.06);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: Outfit, "Segoe UI", sans-serif;
    line-height: 1.45;
    background:
        radial-gradient(1000px 420px at 100% -10%, rgba(31, 92, 69, 0.1), transparent 50%),
        radial-gradient(800px 380px at -10% 0%, rgba(156, 66, 40, 0.07), transparent 46%),
        var(--paper);
}

h1, h2, h3,
.stat-value,
.entry-sum strong,
.money,
.login-card h1 {
    font-family: Fraunces, Georgia, serif;
    font-weight: 560;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 2.7rem);
    letter-spacing: -0.03em;
}

h2 {
    margin: 0 0 12px;
    font-size: 1.45rem;
}

h3 {
    margin: 0;
    overflow-wrap: anywhere;
}

p {
    overflow-wrap: anywhere;
}

a {
    color: var(--green-dark);
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

::selection {
    background: #cfe4d8;
}

.skip {
    position: absolute;
    left: 12px;
    top: -48px;
    z-index: 40;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
}

.skip:focus {
    top: 12px;
}

.wrap {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0 48px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(243, 239, 230, 0.92);
    border-bottom: 1px solid rgba(228, 216, 198, 0.95);
    backdrop-filter: blur(12px);
}

.topbar-inner {
    position: relative;
    width: min(1080px, calc(100% - 32px));
    min-height: 72px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--green);
    color: #f6f1e7;
}

.top-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.site-nav,
.account {
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-nav a,
.account a,
.nav-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.site-nav a[aria-current="page"] {
    background: var(--moss);
    color: var(--green-dark);
}

.site-nav a:hover,
.account a:hover,
.nav-toggle:hover {
    background: rgba(255, 253, 248, 0.8);
}

.badge {
    min-width: 1.3rem;
    height: 1.3rem;
    margin-left: 6px;
    padding: 0 5px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: var(--clay);
    color: white;
    font-family: Outfit, "Segoe UI", sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
}

.who {
    max-width: 160px;
    padding: 0 8px;
    overflow: hidden;
    color: var(--muted);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-toggle {
    display: none;
    margin-left: auto;
    border: 1px solid var(--line);
    background: var(--card);
}

.page-head {
    margin-bottom: 22px;
}

.lede {
    margin: 8px 0 0;
    color: var(--muted);
}

.stats {
    display: grid;
    grid-template-columns: 1.45fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.stat {
    display: block;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--card);
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow);
}

a.stat:hover {
    border-color: #c9b89a;
}

.stat-remaining {
    background: var(--green);
    border-color: transparent;
    color: #f6f1e7;
}

.stat-remaining.is-negative {
    background: var(--clay);
}

.stat-label {
    margin: 0;
    font-weight: 600;
    font-size: 0.92rem;
}

.stat-value {
    margin: 8px 0 0;
    font-size: clamp(1.8rem, 3vw, 2.35rem);
    letter-spacing: -0.03em;
}

.stat-remaining .stat-value {
    font-size: clamp(2.3rem, 5vw, 3.3rem);
}

.stat-note {
    margin: 8px 0 0;
    font-size: 0.88rem;
    opacity: 0.82;
}

.pending-note,
.banner {
    border-radius: 16px;
    background: var(--gold);
    color: var(--gold-ink);
}

.pending-note {
    margin: 0 0 18px;
    padding: 12px 14px;
    font-weight: 600;
}

.banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 0 0 22px;
    padding: 16px 18px;
}

.banner h2,
.banner p {
    margin: 0;
}

.banner h2 {
    margin-bottom: 4px;
    font-size: 1.35rem;
}

.columns,
.layout-split {
    display: grid;
    grid-template-columns: 1.35fr 0.85fr;
    gap: 22px;
    align-items: start;
}

.columns {
    grid-template-columns: 1fr 1fr;
    margin-top: 8px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.section-head h2 {
    margin: 0;
}

.section-head a {
    font-weight: 700;
    text-decoration: none;
}

.wrap > section,
.stack > section,
.wrap > .card {
    margin-top: 26px;
}

.page-head + .stats,
.page-head + .layout-split,
.page-head + .card {
    margin-top: 0;
}

.card,
.entry,
.row-card,
.person,
.login-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.card,
.login-card {
    padding: 18px;
}

.narrow {
    max-width: 520px;
}

.side-forms {
    position: sticky;
    top: 88px;
    display: grid;
    gap: 14px;
}

.stack-form,
.field {
    display: grid;
    gap: 8px;
}

.stack-form {
    gap: 14px;
}

.field span,
.choices-wrap legend {
    font-weight: 600;
}

.hint,
.fine,
.meta,
.note {
    margin: 0;
    color: var(--muted);
}

.field .hint {
    font-weight: 400;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea,
.input-inline {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.form-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 0.9fr;
    gap: 12px;
}

.choices-wrap {
    margin: 0;
    padding: 0;
    border: 0;
}

.checks {
    display: grid;
    gap: 8px;
}

.checks label {
    display: flex;
    gap: 8px;
    align-items: center;
    font-weight: 500;
}

.choices {
    display: grid;
    gap: 8px;
}

.choice {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
    cursor: pointer;
}

.choice:has(input:checked) {
    border-color: var(--green);
    background: var(--moss);
}

.choice strong,
.choice small {
    display: block;
}

.choice small {
    color: var(--muted);
    font-weight: 400;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--green);
    color: #f6f1e7;
}

.btn-primary:hover {
    background: var(--green-dark);
}

.btn-ghost {
    border-color: var(--line);
    background: transparent;
    color: var(--ink);
}

.btn-ghost:hover {
    background: white;
}

.btn-danger {
    border-color: #e4c2c2;
    background: white;
    color: var(--danger);
}

.btn-danger:hover {
    background: #f8e6e6;
}

.btn-small {
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.92rem;
}

.btn-block {
    width: 100%;
}

.entry,
.row-card,
.person {
    padding: 14px 16px;
}

.entry + .entry,
.row-card + .row-card,
.person + .person {
    margin-top: 10px;
}

.entry {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entry-top,
.row-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 16px;
    align-items: center;
}

.entry-top {
    align-items: start;
}

.entry-sum {
    text-align: right;
}

.entry-sum strong,
.money {
    font-size: 1.3rem;
    white-space: nowrap;
}

.entry .note,
.entry .admin-note,
.entry .handover,
.entry .thumbs,
.entry .entry-actions,
.span-row,
.row-card > form,
.row-card > details,
.person > form,
.person > .hint {
    grid-column: 1 / -1;
}

.admin-note {
    margin: 0;
    color: var(--danger);
}

.handover {
    margin: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    margin-top: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eee7dc;
    color: var(--muted);
    font-family: Outfit, "Segoe UI", sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
}

.pill-wait {
    background: var(--gold);
    color: var(--gold-ink);
}

.pill-owed {
    background: var(--clay-soft);
    color: var(--clay);
}

.pill-ok {
    background: var(--moss);
    color: var(--green-dark);
}

.pill-no {
    background: #f8e6e6;
    color: var(--danger);
}

.thumbs,
.preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.thumb {
    display: block;
    width: 96px;
    height: 96px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.thumb img,
.preview-item img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 12px;
}

.preview-item {
    width: 96px;
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 0.75rem;
}

.preview-item img {
    border: 1px solid var(--line);
}

.doc-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--moss);
    color: var(--green-dark);
    font-weight: 700;
    text-decoration: none;
}

.entry-actions,
.inline-form,
.reject-form,
.person-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: end;
    min-width: 0;
}

.person-row .btn,
.inline-form .btn,
.reject-form .btn,
.entry-actions .btn {
    width: 100%;
}

.reject-form {
    flex: 1 1 240px;
}

.input-inline {
    flex: 1 1 180px;
    width: auto;
    min-height: 44px;
}

.person-body {
    display: grid;
    gap: 14px;
    min-width: 0;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

details.person > :not(summary) {
    margin-top: 0;
}

.person-body > .meta,
.person-body > .hint {
    margin: 0;
}

details.person {
    display: block;
}

details.person > summary {
    cursor: pointer;
    font-family: Fraunces, Georgia, serif;
    font-size: 1.15rem;
    font-weight: 560;
    list-style: none;
}

details.person > summary::-webkit-details-marker {
    display: none;
}

details.person > summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    color: var(--muted);
    font-family: Outfit, "Segoe UI", sans-serif;
}

details.person[open] > summary::before {
    content: "▾";
}

details.person > summary {
    min-width: 0;
}

details.quiet {
    margin-top: 4px;
}

details.quiet summary {
    width: fit-content;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
}

.empty {
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.55);
    color: var(--muted);
}

.is-inactive {
    opacity: 0.72;
}

.flashes {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.flash {
    margin: 0;
    padding: 12px 14px;
    border-radius: 14px;
    font-weight: 600;
}

.flash-ok {
    background: var(--moss);
    color: var(--green-dark);
}

.flash-error {
    background: #f8e6e6;
    color: var(--danger);
}

.site-footer {
    padding: 4px 16px 28px;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
}

.login-wrap .flashes,
.login-card {
    width: min(440px, 100%);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.eyebrow {
    margin: 0;
    color: var(--green);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.login-card h1 {
    font-size: 2.5rem;
}

@media (max-width: 900px) {
    .stats,
    .layout-split,
    .columns,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .side-forms {
        position: static;
        order: -1;
    }

    .banner {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (min-width: 721px) {
    .person-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .person-row .btn,
    .entry-actions .btn,
    .reject-form .btn {
        width: auto;
    }

    .entry-actions,
    .reject-form {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .reject-form input,
    .entry-actions input {
        flex: 1 1 10rem;
        width: auto;
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .wrap,
    .topbar-inner {
        width: min(1080px, calc(100% - 20px));
    }

    .entry-top,
    .row-card {
        grid-template-columns: minmax(0, 1fr);
    }

    .entry-sum {
        text-align: left;
    }

    .money {
        white-space: normal;
    }
}

@media (max-width: 860px) {
    .nav-toggle {
        display: inline-flex;
    }

    .top-links {
        display: none;
        position: absolute;
        top: calc(100% + 1px);
        left: 0;
        right: 0;
        margin-left: 0;
        padding: 8px 16px 16px;
        flex-direction: column;
        align-items: stretch;
        border-bottom: 1px solid var(--line);
        background: #fffdf8;
    }

    body.nav-open .top-links {
        display: flex;
    }

    .site-nav,
    .account {
        flex-direction: column;
        align-items: stretch;
    }

    .who {
        max-width: none;
        padding: 8px 12px 0;
    }
}

@media print {
    .topbar,
    .entry-actions,
    .side-forms,
    .nav-toggle,
    .site-footer,
    form {
        display: none !important;
    }

    body {
        background: white;
    }

    .stat-remaining {
        color: black;
        background: white;
        border: 1px solid #ccc;
    }
}
