:root {
    color-scheme: dark;
    --canvas: #151817;
    --surface: #202521;
    --surface-raised: #292f29;
    --line: #424b42;
    --ink: #f2f2e7;
    --muted: #bcc5b7;
    --accent: #f3c17f;
    --accent-ink: #222017;
    --focus: #ffdbab;
    --gutter: clamp(14px, 4vw, 36px);
    font: 15px/1.55 system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
}

a { color: var(--accent); text-underline-offset: .2em; }
button { font: inherit; cursor: pointer; }
p { margin: 0 0 1rem; color: var(--muted); }
h1, h2 { margin: 0; line-height: 1.12; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.18rem, 2.5vw, 1.45rem); letter-spacing: -.02em; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

.wrap {
    width: min(100% - var(--gutter) * 2, 1120px);
    margin-inline: auto;
    min-width: 0;
}

.skip-link {
    position: absolute;
    top: 12px;
    left: var(--gutter);
    z-index: 2;
    padding: 10px 14px;
    color: var(--accent-ink);
    background: var(--focus);
    transform: translateY(-180%);
}

.skip-link:focus { transform: none; }

.masthead {
    border-bottom: 1px solid var(--line);
    background: #1b1f1b;
}

.masthead-inner {
    display: flex;
    align-items: center;
    min-height: 64px;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: .4em;
    min-height: 44px;
    color: var(--ink);
    font-size: clamp(.76rem, 2.5vw, .96rem);
    font-weight: 600;
    letter-spacing: .1em;
    text-decoration: none;
    white-space: nowrap;
}

.wordmark strong { color: var(--accent); font-weight: 800; }

.content { padding-block: clamp(24px, 5vw, 55px) 56px; }
.content > :last-child { margin-bottom: 0; }

.landing {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 14px;
}

.landing-intro {
    display: grid;
    container-type: inline-size;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    align-items: center;
    gap: clamp(12px, 3vw, 30px);
    padding: clamp(16px, 4vw, 38px);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    background: radial-gradient(ellipse at 15% 45%, #434737 0, transparent 67%), var(--surface);
}

.landing-emblem { display: block; width: 100%; height: auto; max-width: 260px; }
.landing-intro h1 { font-size: clamp(1.5rem, 7cqi, 3rem); overflow-wrap: anywhere; }

.landing-access {
    display: grid;
    align-content: center;
    justify-items: start;
}

.landing .landing-access { margin: 0; }
.landing-access .notice { margin: 0; }
.account-name { overflow-wrap: anywhere; }

.masthead-nav, .masthead-account {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2.5vw, 22px);
    min-width: 0;
}

.masthead-nav { margin-inline: clamp(10px, 4vw, 38px) auto; }
.masthead-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    text-decoration: none;
}

.masthead-nav a[aria-current="page"] { border-color: var(--accent); color: var(--ink); }
.masthead-nav a:hover { color: var(--accent); }
.masthead-account { margin-left: auto; }
.masthead-account .account-name {
    margin: 0;
    max-width: min(22vw, 15rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-title { margin: 0 0 20px; }

.balances {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
    margin: 0 0 14px;
}

.balance {
    min-width: 0;
    padding: clamp(12px, 3vw, 24px);
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
}

.balance dt, .details-grid dt { color: var(--muted); }
.balance dd {
    margin: 3px 0 0;
    font-size: clamp(1.2rem, 4vw, 2.2rem);
    font-weight: 740;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.balance-due { border-color: #897648; }
.balance-due dd, .due { color: var(--accent); }

.report-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    margin-bottom: 12px;
}

.panel .report-heading h2 { margin: 0; }

.segments { display: flex; flex-wrap: wrap; gap: 6px; }
.segments a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    text-decoration: none;
}

.segments a:hover { border-color: var(--muted); }
.segments a[aria-current="page"] {
    border-color: #897648;
    background: #443a29;
    color: var(--accent);
    font-weight: 700;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border: 1px solid var(--line);
    border-radius: 4px;
}

.table-scroll table {
    width: 100%;
    min-width: 40rem;
    border-collapse: collapse;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.table-scroll .ledger-table { min-width: 50rem; }
thead, tfoot { background: var(--surface-raised); }
thead { font-size: .86rem; }
tbody, tfoot, tr + tr { border-top: 1px solid var(--line); }
th, td { padding: 9px 12px; overflow-wrap: anywhere; }
td:has(time), .money { white-space: nowrap; }
.money { text-align: right; }
.report-table thead tr:first-child th[scope="colgroup"] { text-align: center; }
.report-table thead tr:last-child th { text-align: right; white-space: nowrap; }
.report-table :is(th, td) + :is(th, td) { border-left: 1px solid var(--line); }
.table-scroll tbody tr:nth-child(even) { background: #181c19; }
tfoot { font-weight: 740; }
.note { margin: 10px 0 0; font-size: .88rem; }

.operator-tools, .form-grid, .details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.record-form { display: grid; justify-items: start; gap: 10px; }
.form-grid { width: 100%; }
.field { display: grid; gap: 5px; min-width: 0; width: 100%; font-weight: 650; }

.control {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #141815;
    color: var(--ink);
    font: inherit;
    font-weight: 400;
}

.check-field {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    cursor: pointer;
}

.check-field input { width: 18px; height: 18px; accent-color: var(--accent); }
.details-grid { margin: 0; }
.details-grid > div { min-width: 0; padding: 9px 0; border-top: 1px solid var(--line); }
.details-grid dd { margin: 3px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.back-link, .entry-link { display: inline-flex; align-items: center; min-height: 44px; }
.entry-link { white-space: nowrap; }
.pagination { margin-top: 14px; }
.status-tag {
    display: inline-block;
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--muted);
    background: #141815;
    font-size: .84rem;
    white-space: nowrap;
}
.status-due { border-color: #897648; color: var(--accent); background: #443a29; }

.panel {
    min-width: 0;
    margin-block: 0 14px;
    padding: clamp(13px, 3.5vw, 27px);
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
}

.panel h2 { margin-bottom: 10px; }
.panel > :last-child { margin-bottom: 0; }

.notice {
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 4px;
    overflow-wrap: anywhere;
}

.notice-error { border-color: #8d5148; background: #432d28; color: #ffd1c6; }
.notice-success { border-color: #65805b; background: #303d29; color: #d9f0c6; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    max-width: 100%;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: none;
    text-align: center;
}

.button-primary { background: var(--accent); color: var(--accent-ink); }
.button-primary:hover { background: #ffdaaa; }
.button-secondary { border-color: var(--line); background: var(--surface-raised); color: var(--ink); }
.button-secondary:hover { border-color: var(--muted); }

@media (max-width: 810px) {
    .landing { grid-template-columns: minmax(0, 1fr); }
    .landing-intro { grid-template-columns: minmax(0, .8fr) minmax(0, 1.5fr); }
    .landing-emblem { max-width: 180px; }
    .operator-tools { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 590px) {
    .masthead-inner { min-height: 54px; }
    .landing-intro { grid-template-columns: minmax(62px, .65fr) minmax(0, 1.6fr); }
    .landing-intro h1 { font-size: clamp(1.25rem, 6vw, 2.2rem); }
    .masthead-inner { flex-wrap: wrap; }
    .masthead-nav { order: 1; width: 100%; margin: 0; gap: 18px; }
    .masthead-account .account-name { max-width: min(32vw, 12rem); }
    .form-grid, .details-grid { grid-template-columns: minmax(0, 1fr); }
}
