:root {
    color-scheme: light;
    font: 100%/1.5 system-ui, sans-serif;
    color: #15252b;
    background: #edf2f3;
    --accent: #095e51;
    --muted: #465e65;
    --line: #cddadd;
    --surface: #fff;
    --active: #dcf4ea;
    --space-xs: .25rem;
    --space-sm: .5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --control-height: 2.75rem;
    --radius: .5rem;
}

* { box-sizing: border-box; }
body, h1, h2, p, ul { margin: 0; }
a { color: var(--accent); text-underline-offset: .2em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: -.04em; line-height: 1.15; overflow-wrap: anywhere; }
h2 { font-size: 1.18rem; }
ul { padding-inline-start: var(--space-lg); }
.frame { max-width: 70rem; margin-inline: auto; padding-inline: var(--space-lg); }
main.frame { display: grid; align-content: start; gap: var(--space-lg); padding-block: var(--space-xl); }
.topbar { background: #142a32; color: white; }
.bar, .bar nav, .document-line, .pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}
.bar { min-height: 4.25rem; padding-block: var(--space-sm); }
.bar a { color: white; }
.brand { display: inline-flex; gap: var(--space-sm); align-items: center; text-decoration: none; font-weight: 720; }
.brand span {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
    background: #b7ead9;
    color: #142a32;
}
.page-heading { display: grid; gap: var(--space-xs); }
.page-heading p, .hint, .path, .project-card span { color: var(--muted); }
.breadcrumb { justify-self: start; margin-bottom: var(--space-xs); }
.panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: .75rem;
    background: var(--surface);
}
.panel { display: grid; gap: var(--space-md); padding: var(--space-lg); }

.project-layout {
    --project-rail: 14rem;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    grid-template-columns: var(--project-rail) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
}
.project-layout[data-menu-collapsed] { --project-rail: 4.25rem; }
.project-layout > .topbar { grid-area: 1 / 2; }
.project-layout > main { grid-area: 2 / 2; }
.project-layout .frame { width: 100%; max-width: none; min-width: 0; }
.project-main { display: grid; min-width: 0; gap: var(--space-lg); }
.project-sidebar {
    grid-area: 1 / 1 / -1 / 2;
    position: sticky;
    inset-block-start: 0;
    align-self: start;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-inline-end: 1px solid var(--line);
    background: var(--surface);
}
.project-menu { display: grid; gap: var(--space-xs); }
.project-menu a, .project-menu-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-height: var(--control-height);
    padding: var(--space-sm);
    border-radius: var(--radius);
    color: #274148;
    text-decoration: none;
    font-weight: 600;
}
.project-menu-toggle { justify-self: end; justify-content: center; width: var(--control-height); background: transparent; }
.project-menu-toggle[hidden] { display: none; }
.project-menu a:hover, .project-menu-toggle:hover { background: #edf2f3; filter: none; }
.project-menu a[aria-current], .project-subnav a[aria-current=page] { color: var(--accent); background: var(--active); }
.project-icon { width: 1.25rem; height: 1.25rem; flex: none; }
.project-layout[data-menu-collapsed] .project-menu a { justify-content: center; }
.project-layout[data-menu-collapsed] .project-menu-toggle { justify-self: center; }
.project-layout[data-menu-collapsed] .project-menu-label { display: none; }
.project-subnav { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.project-subnav a {
    display: flex;
    align-items: center;
    min-height: var(--control-height);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
    font-weight: 600;
}
.project-subnav a:hover { border-color: var(--accent); }
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: var(--space-md); margin: 0; }
.dashboard-stats > div { padding: var(--space-md); border-radius: var(--radius); background: #edf2f3; }
.dashboard-stats dt { color: var(--muted); }
.dashboard-stats dd { margin: 0; font-size: 1.5rem; font-weight: 700; }
.panel-action { justify-self: start; }
.tax-topics { display: grid; gap: var(--space-sm); }

.narrow { width: min(100%, 30rem); margin-inline: auto; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: var(--space-lg); }
.project-card { gap: var(--space-xs); text-decoration: none; overflow-wrap: anywhere; }
.project-card:hover { border-color: var(--accent); }
.project-card strong { font-size: 1.15rem; }
.fields, .stack { display: flex; gap: var(--space-md); }
.fields { align-items: end; flex-wrap: wrap; }
.fields label { flex: 1 1 11rem; }
.stack { flex-direction: column; align-items: stretch; }
.stack > button { align-self: start; }
label { display: grid; gap: var(--space-xs); font-size: .9rem; font-weight: 600; min-width: 0; }
.checkbox { display: flex; align-items: baseline; gap: var(--space-sm); overflow-wrap: anywhere; }
.checkbox input { flex: none; margin: 0; accent-color: var(--accent); }
input, select, button, textarea { font: inherit; }
input:not([type=checkbox]), select, textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: var(--control-height);
    padding: var(--space-sm);
    border-radius: var(--radius);
    border: 1px solid #879da1;
    color: inherit;
    background: var(--surface);
}
select {
    appearance: none;
    padding-inline-end: var(--space-xl);
    background: linear-gradient(45deg, transparent 50%, #36555c 50%) right .85rem center / .35rem .35rem no-repeat,
        linear-gradient(135deg, #36555c 50%, transparent 50%) right .5rem center / .35rem .35rem no-repeat, var(--surface);
}
button {
    min-height: var(--control-height);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: white;
    background: var(--accent);
    font-weight: 650;
    cursor: pointer;
}
button:hover { filter: brightness(.9); }
button:disabled { opacity: .6; cursor: wait; }
button.subtle { background: var(--surface); color: var(--accent); border-color: var(--line); }
:focus-visible { outline: 3px solid #228aab; outline-offset: 3px; }

.hint, .path { font-size: .9rem; }
.path, .document-line > a { overflow-wrap: anywhere; }
.document-line > a { font-weight: 650; }
.record-list, .document { display: grid; gap: var(--space-md); }
.record-list > * + * { border-top: 1px solid var(--line); padding-block-start: var(--space-md); }
.status { padding: var(--space-xs) var(--space-sm); border-radius: var(--radius); font-size: .875rem; color: #744200; background: #fff0d6; }
.status.archived, .notice { color: #0c5844; background: var(--active); }
.notice, .errors, .results { border-radius: var(--radius); padding: var(--space-sm) var(--space-md); }
.errors, .results { padding-inline-start: var(--space-xl); }
.errors { color: #8a2424; background: #ffe6e6; }
.results { background: #edf5f5; overflow-wrap: anywhere; }
summary { color: var(--accent); cursor: pointer; }
details > summary + * { margin-block-start: var(--space-md); }

.category-list li + li, .category-list ul { margin-block-start: var(--space-xs); }
.category-catalog { border-top: 1px solid var(--line); padding-block-start: var(--space-md); }
.category-catalog > summary { font-weight: 650; }
.template-set { min-width: 0; margin: 0; padding: 0; border: 0; }
.template-set legend { padding: 0; margin-block-end: var(--space-sm); font-weight: 650; }
.template-group { padding: var(--space-sm) var(--space-md); border: 1px solid var(--line); border-radius: var(--radius); }
.template-group + .template-group { margin-block-start: var(--space-sm); }
.template-group summary { color: inherit; font-weight: 600; }
.template-options, .template-options ul { display: grid; gap: var(--space-sm); }
.template-options ul { padding-inline-start: var(--space-lg); list-style: none; }
.template-description { display: block; font-weight: 400; }
.booking-action {
    display: inline-flex;
    align-items: center;
    min-height: var(--control-height);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    color: white;
    background: var(--accent);
    text-decoration: none;
    font-weight: 650;
}
.booking-action:hover { filter: brightness(.9); }
.booking-register { margin-block-end: 4.5rem; }
.booking-month { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.booking-month > summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, auto);
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    list-style: none;
    color: inherit;
}
.booking-month > summary::-webkit-details-marker { display: none; }
.booking-month > summary::before {
    content: '';
    width: .45rem;
    height: .45rem;
    border: solid var(--accent);
    border-width: 0 2px 2px 0;
    transform: rotate(-45deg);
}
.booking-month[open] > summary::before { transform: rotate(45deg); }
.booking-month[open] > summary { border-bottom: 1px solid var(--line); }
.booking-month-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.booking-month > .booking-table-wrap { margin-block-start: 0; border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.booking-month-empty { margin: 0; padding: var(--space-md); }
.booking-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-md); font-variant-numeric: tabular-nums; }
.booking-total { display: grid; overflow-wrap: anywhere; }
.booking-total-label { color: var(--muted); font-size: .875rem; }
.booking-year-totals {
    position: fixed;
    z-index: 2;
    inset-inline: var(--project-rail, 0) 0;
    inset-block-end: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
    padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 -3px 14px rgb(20 42 50 / 8%);
}
.booking-year-totals .booking-totals { min-width: min(100%, 22rem); }
.booking-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.booking-table { width: 100%; min-width: 46rem; border-collapse: collapse; font-size: .9rem; }
.booking-table-account { min-width: 35rem; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: var(--space-md); }
.booking-table th, .booking-table td { padding: var(--space-sm); border-bottom: 1px solid var(--line); vertical-align: middle; }
.booking-table th { background: #edf2f3; text-align: left; }
.booking-table th[scope=colgroup], .booking-table th[class^=amount-] { text-align: center; }
.booking-table th.amount-income { background: #dcf4ea; color: #0c5844; }
.booking-table th.amount-expense { background: #f7e8e4; color: #783526; }
.booking-table th + th, .booking-table td + td { border-inline-start: 1px solid var(--line); }
.booking-table td:nth-child(2) { min-width: 11rem; overflow-wrap: anywhere; }
.booking-table tbody tr:last-child td { border-bottom: 0; }
.booking-table tbody tr { cursor: pointer; }
.booking-table tbody tr:hover, .booking-table tbody tr:focus-within { background: #edf5f5; }
.booking-table .booking-row-open { background: #fff7ec; }
.booking-table .booking-row-open:hover, .booking-table .booking-row-open:focus-within { background: #ffefd7; }
.booking-table .booking-row-open td:first-child { box-shadow: inset 3px 0 #b0641c; }
.booking-open-items { margin-block: var(--space-xs); padding-inline-start: var(--space-md); }
.booking-date, .booking-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.booking-amount { min-width: 5.75rem; text-align: right; }
.booking-amount.amount-income { color: #0c5844; }
.booking-amount.amount-expense { color: #783526; }
.booking-dialog {
    width: min(42rem, calc(100% - var(--space-xl)));
    max-height: calc(100dvh - var(--space-xl));
    padding: var(--space-lg);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: .75rem;
    color: inherit;
    background: var(--surface);
}
.booking-dialog::backdrop { background: rgb(20 42 50 / 55%); }
.booking-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: var(--space-md); }
.booking-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-md); }
.booking-dialog [aria-invalid=true] { border-color: #a43030; }
.booking-attachment { display: grid; gap: var(--space-sm); }
.booking-attachment > button { justify-self: start; }
.attachment-drop {
    gap: var(--space-sm);
    padding: var(--space-md);
    border: 1px dashed #879da1;
    border-radius: var(--radius);
    background: #edf5f5;
    cursor: pointer;
}
.attachment-drop:hover, .attachment-drop:focus-within, .attachment-drop.attachment-dragover {
    border-color: var(--accent);
    background: var(--active);
}
.attachment-drop input[type=file] { cursor: pointer; }
.qr svg { display: block; width: min(100%, 13rem); height: auto; }
.codes { columns: 2; column-gap: var(--space-lg); padding-inline-start: var(--space-md); }

@media (max-width: 44rem) {
    .frame { padding-inline: var(--space-md); }
    main.frame { padding-block: var(--space-lg); }
    .project-layout:not([data-menu-collapsed]) { --project-rail: 0rem; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
    .project-layout:not([data-menu-collapsed]) > .topbar { grid-area: 1 / 1; }
    .project-layout:not([data-menu-collapsed]) > main { grid-area: 3 / 1; }
    .project-layout:not([data-menu-collapsed]) > .project-sidebar {
        grid-area: 2 / 1;
        position: static;
        height: auto;
        overflow: visible;
        border-inline-end: 0;
        border-block-end: 1px solid var(--line);
    }
    .project-main { gap: var(--space-md); }
    .project-layout:not([data-menu-collapsed]) .project-menu { display: flex; flex-wrap: wrap; }
    .panel { padding: var(--space-md); }
    .booking-register { margin-block-end: 7rem; }
    .booking-month > summary { column-gap: var(--space-sm); row-gap: var(--space-sm); }
    .booking-month summary .booking-totals { grid-column: 2 / -1; }
    .booking-year-totals { display: grid; gap: var(--space-xs); padding-inline: var(--space-sm); }
    .booking-year-totals .booking-totals, .booking-month .booking-totals { gap: var(--space-sm); }
}
