/* Fonts (SIL OFL — licenses alongside in ../fonts) */
@font-face {
    font-family: "Saira Condensed";
    src: url("../fonts/SairaCondensed-Regular.6f84d0203fea.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Saira Condensed";
    src: url("../fonts/SairaCondensed-Medium.ce0eb0e6fd35.ttf") format("truetype");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "Saira Condensed";
    src: url("../fonts/SairaCondensed-SemiBold.85e9cc387433.ttf") format("truetype");
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: "Saira Condensed";
    src: url("../fonts/SairaCondensed-Bold.c019c2573e77.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "Jaro";
    src: url("../fonts/Jaro-Regular-VariableFont_opsz.ff9669c8108c.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Economica";
    src: url("../fonts/Economica-Regular.cf6c76be23e4.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Economica";
    src: url("../fonts/Economica-Italic.8d40caedd6e5.ttf") format("truetype");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "Economica";
    src: url("../fonts/Economica-Bold.1d72c18e8a33.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Economica";
    src: url("../fonts/Economica-BoldItalic.55c9edb637d6.ttf") format("truetype");
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "Geo";
    src: url("../fonts/Geo-Regular.566960c80213.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Geo";
    src: url("../fonts/Geo-Italic.6fbe402dac4d.ttf") format("truetype");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "BenchNine";
    src: url("../fonts/BenchNine-Light.0fea981f5ba8.ttf") format("truetype");
    font-weight: 300;
    font-display: swap;
}
@font-face {
    font-family: "BenchNine";
    src: url("../fonts/BenchNine-Regular.28942f8e8e2d.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "BenchNine";
    src: url("../fonts/BenchNine-Bold.57293446c964.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "Jockey One";
    src: url("../fonts/JockeyOne-Regular.d4c58485a8aa.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Aclonica";
    src: url("../fonts/Aclonica-Regular.543459e87802.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Englebert";
    src: url("../fonts/Englebert-Regular.f0340b336f8a.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

/* Themes.
   Colors: role-based palette per theme (primary, secondary, accent, neutrals,
   status, focus) emitted by base.html as --color-<role>, from core/themes.py.
   Rules below never use --color-* directly: they use --use-* tokens, which
   base.html maps to a role (USES in core/themes.py; editable in the theme editor).
   Hover/pressed shades are derived here with color-mix. */
:root,
[data-theme="comic"] {
    --font-body: "BenchNine", system-ui, sans-serif;
    --font-heading: "Jockey One", "BenchNine", system-ui, sans-serif;
}

[data-theme="pastry"] {
    --font-body: "Saira Condensed", system-ui, sans-serif;
    --font-heading: "Jaro", "Saira Condensed", system-ui, sans-serif;
}

[data-theme="amsterdam"] {
    --font-body: "Economica", system-ui, sans-serif;
    --font-heading: "Geo", "Economica", system-ui, sans-serif;
}

[data-theme="coral"] {
    --font-body: "Englebert", system-ui, sans-serif;
    --font-heading: "Aclonica", "Englebert", system-ui, sans-serif;
}

:root {
    --sidenav-width: 240px;
    --hover-shade: 12%;
    --pressed-shade: 24%;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
/* The dashboard's top menu stays on screen (sticky); anchors (#documents) land below it. */
html { scroll-padding-top: 4.5rem; }

body {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    color: var(--use-text);
    background: var(--use-page-bg);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--use-heading);
    font-weight: 400;
    margin: 0;
}

a { color: var(--use-link); }

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--use-focus-ring);
    outline-offset: 2px;
}

::placeholder { color: var(--use-placeholder); opacity: 1; }

.layout {
    display: flex;
    min-height: 100vh;
}

/* Side navigation */
/* Only the client area scrolls: the side nav stays put, the full viewport tall, with the theme picker at
   its foot (it scrolls within itself on a very short window). */
.sidenav {
    flex: 0 0 var(--sidenav-width);
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    align-self: flex-start;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--use-sidenav-bg);
    color: var(--use-sidenav-text);
    border-right: 1px solid var(--use-divider);
}

.sidenav__banner {
    padding: 1.25rem 1.5rem;
    border-bottom: 3px solid var(--use-sidenav-active);
}

.sidenav__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-size: 2.5rem;
    line-height: 1;
    color: var(--use-brand);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.sidenav__logo {
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
}

.sidenav__nav {
    flex: 1;
    padding: 1rem 0;
}

.sidenav__item {
    display: block;
    width: 100%;
    padding: 0.6rem 1.5rem;
    border: 0;
    border-left: 4px solid transparent;
    background: none;
    color: var(--use-sidenav-text);
    font: inherit;
    font-size: 1.125rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.sidenav__item:hover {
    background: color-mix(in oklch, var(--use-sidenav-active) 10%, transparent);
}

.sidenav__item:active {
    background: color-mix(in oklch, var(--use-sidenav-active) 20%, transparent);
}

.sidenav__item.is-active {
    border-left-color: var(--use-sidenav-active);
    background: color-mix(in oklch, var(--use-sidenav-active) 14%, transparent);
    color: var(--use-sidenav-active);
}

/* A submenu item (settings → accounts): indented and smaller under its parent. */
.sidenav__item--sub {
    padding: 0.4rem 1.5rem 0.4rem 2.75rem;
    font-size: 1rem;
}

.sidenav__theme {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--use-divider);
}

.sidenav__theme-label {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--use-sidenav-muted);
}

.sidenav__theme-select,
.sidenav__theme-apply {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
    cursor: pointer;
}

/* Client area */
.client {
    flex: 1;
    min-width: 0;
    padding: 2rem;
}

/* Panels & forms */
.panel {
    max-width: 360px;
    padding: 2rem;
    background: var(--use-panel-bg);
    border-top: 4px solid var(--use-panel-accent);
    box-shadow: 0 2px 8px color-mix(in oklch, var(--use-text) 12%, transparent);
}

.panel__title {
    font-size: 2rem;
    margin-bottom: 1.25rem;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form__field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form__label {
    font-weight: 600;
    letter-spacing: 0.03em;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="email"],
.form input[type="url"],
.form textarea,
.toolbar input[type="search"] {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    font: inherit;
    color: var(--use-text);
    background: var(--use-input-bg);
}

.form textarea { resize: vertical; }

.form__error {
    padding: 0.5rem 0.75rem;
    background: color-mix(in oklch, var(--use-msg-error) 10%, var(--use-panel-bg));
    border-left: 4px solid var(--use-msg-error);
}

.button {
    align-self: flex-start;
    padding: 0.5rem 1.5rem;
    border: 0;
    border-radius: 3px;
    background: var(--use-button-bg);
    color: var(--use-button-text);
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.button:hover {
    background: color-mix(in oklch, var(--use-button-bg), black var(--hover-shade));
}

.button:active {
    background: color-mix(in oklch, var(--use-button-bg), black var(--pressed-shade));
}

/* Dashboard top-level menu */
.topmenu {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 0.25rem;
    margin: -2rem -2rem 2rem;
    padding: 0 2rem;
    background: var(--use-topmenu-bg);
    border-bottom: 1px solid var(--use-topmenu-border);
}

.topmenu__item {
    padding: 0.85rem 1.25rem 0.7rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    color: var(--use-topmenu-text);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-decoration: none;
}

.topmenu__item:hover {
    color: var(--use-topmenu-active);
    background: color-mix(in oklch, var(--use-topmenu-active) 8%, transparent);
}

.topmenu__item:active {
    background: color-mix(in oklch, var(--use-topmenu-active) 16%, transparent);
}

.topmenu__item.is-active {
    color: var(--use-topmenu-active);
    border-bottom-color: var(--use-topmenu-active);
}

/* Secondary buttons */
.button--secondary {
    background: var(--use-button-secondary-bg);
    color: var(--use-button-secondary-text);
    box-shadow: inset 0 0 0 1px var(--use-button-secondary-text);
}

.button--secondary:hover {
    background: color-mix(in oklch, var(--use-button-secondary-text) 8%, var(--use-button-secondary-bg));
}

.button--secondary:active {
    background: color-mix(in oklch, var(--use-button-secondary-text) 16%, var(--use-button-secondary-bg));
}

.button--link,
.button--link:hover,
.button--link:active {
    background: none;
    color: var(--use-link);
    text-decoration: underline;
}

a.button { display: inline-block; text-decoration: none; }

/* Cancel links in a form's action row get an outline like the secondary button */
.form__actions a.button--link { box-shadow: inset 0 0 0 1px var(--use-link); }
.form__actions a.button--link:hover { background: color-mix(in oklch, var(--use-link) 8%, transparent); }
.form__actions a.button--link:active { background: color-mix(in oklch, var(--use-link) 16%, transparent); }

/* Flash messages: tinted surface with a status side bar */
.messages {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
}

.messages__item {
    --status: var(--use-msg-info);
    padding: 0.6rem 1rem;
    margin-bottom: 0.5rem;
    background: color-mix(in oklch, var(--status) 10%, var(--use-panel-bg));
    border-left: 4px solid var(--status);
}

.messages__item--success { --status: var(--use-msg-success); }
.messages__item--warning { --status: var(--use-msg-warning); }
.messages__item--error { --status: var(--use-msg-error); }

/* List toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.toolbar__search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 520px;
}

.toolbar__search input { flex: 1; }

.toolbar__search .button { align-self: auto; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--use-panel-bg);
    box-shadow: 0 2px 8px color-mix(in oklch, var(--use-text) 8%, transparent);
}

.table th,
.table td {
    padding: 0.6rem 1rem;
    text-align: left;
    border-bottom: 1px solid color-mix(in oklch, var(--use-divider) 45%, transparent);
}

.table th {
    background: var(--use-table-header-bg);
    color: var(--use-table-header-text);
    font-weight: 600;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--use-divider);
}

.table tbody tr:hover { background: var(--use-row-hover); }

.empty {
    padding: 2rem;
    background: var(--use-panel-bg);
    color: var(--use-text-muted);
    text-align: center;
}

.empty strong { color: var(--use-text); }

/* Wide forms */
.panel--wide { max-width: 760px; }

.form__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}

.form__field--full { grid-column: 1 / -1; }

.form__crawl {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.form__field--grow { flex: 1; }

.form__crawl .button { align-self: flex-end; }

.form__hint {
    margin: -0.5rem 0 0;
    font-size: 0.9375rem;
    color: var(--use-text-muted);
}

.form__notice {
    padding: 0.5rem 0.75rem;
    background: color-mix(in oklch, var(--use-msg-info) 10%, var(--use-panel-bg));
    border-left: 4px solid var(--use-msg-info);
}

.form__field.is-filled input,
.form__field.is-filled textarea {
    background: color-mix(in oklch, var(--use-fill-highlight) 14%, var(--use-input-bg));
    border-color: var(--use-fill-highlight);
}

.form__field-error {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--use-msg-error);
}

.form__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid color-mix(in oklch, var(--use-divider) 45%, transparent);
}

/* Section sub-menu (e.g. Payments: Search / New) */
.submenu {
    display: flex;
    gap: 0.25rem;
    margin: -1rem 0 1.5rem;
    border-bottom: 1px solid color-mix(in oklch, var(--use-divider) 45%, transparent);
}

.submenu__item {
    padding: 0.4rem 1rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--use-text-muted);
    font-weight: 600;
    letter-spacing: 0.03em;
    text-decoration: none;
}

.submenu__item:hover { color: var(--use-topmenu-active); }

.submenu__item.is-active {
    color: var(--use-topmenu-active);
    border-bottom-color: var(--use-topmenu-active);
}

.table tfoot th {
    background: var(--use-table-header-bg);
    color: var(--use-table-header-text);
    border-top: 1px solid var(--use-divider);
}

.apply-input {
    width: 8rem;
    padding: 0.3rem 0.45rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
    text-align: right;
}

.form select {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
}

.form input[type="date"],
.form input[type="number"]:not(.apply-input) {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
}

.filters__side {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filters__side .filters__count { padding-top: 0; }

.form__pair {
    display: flex;
    gap: 0.75rem;
}

.form__field--qty { flex: 0 0 6rem; }

.panel + .panel, .messages + .panel { margin-top: 1.25rem; }

.invoice-scope { margin-top: 0.5rem; }

.inline-amount {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.inline-amount input {
    width: 6rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
    text-align: right;
}

.charges .button--link { padding: 0.25rem 0.4rem; }

.charges + .form__hint,
.empty + .form__hint { margin: 0.6rem 0 0; }

.panel > .invoice__section:first-child { margin-top: 0; }

.is-inactive td { color: var(--use-text-muted); }

.toggle {
    min-width: 5.5rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--use-input-border);
    border-radius: 999px;
    background: var(--use-input-bg);
    color: var(--use-text-muted);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.toggle.is-on {
    border-color: var(--use-msg-success);
    background: color-mix(in oklch, var(--use-msg-success) 14%, var(--use-input-bg));
    color: var(--use-msg-success);
}

.row-actions { display: flex; gap: 0.5rem; align-items: center; white-space: nowrap; }

.form__check { flex-direction: row; align-items: center; gap: 0.5rem; }

.section-link { margin-left: 0.75rem; font-family: var(--font-body); font-size: 1rem; }

.standing-date { flex-direction: row; align-items: center; gap: 0.5rem; }

.standing-date input {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
}

.charge-total {
    padding: 0.5rem 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.button[disabled] { opacity: 0.5; cursor: not-allowed; }

.invoice__totals--form {
    align-self: flex-end;
    min-width: 260px;
    margin-left: auto;
}

/* Summary tiles */
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    padding: 0.75rem 1rem;
    background: var(--use-panel-bg);
    border-top: 3px solid var(--use-panel-accent);
    box-shadow: 0 2px 8px color-mix(in oklch, var(--use-text) 8%, transparent);
}

.stat__label {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--use-text-muted);
}

.stat__value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-variant-numeric: tabular-nums;
}

/* Filters, badges, numbers, pagination */
.filters select {
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
}

.filters { align-items: flex-start; }

.filters__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.filters__search { flex: 1 1 220px; min-width: 180px; }

.filters input[type="date"] {
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
}

.filters .button { align-self: auto; }

.daterange {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.daterange__step {
    padding: 0.35rem 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
}

.daterange__step--day { font-size: 0.95rem; }

.daterange__sep { color: var(--use-text-muted); }

.filters__count { padding-top: 0.5rem; white-space: nowrap; }

.filters__count { color: var(--use-text-muted); }

.badge {
    display: inline-block;
    padding: 0 0.4rem;
    border-radius: 2px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--use-badge);
    background: color-mix(in oklch, var(--use-badge) 14%, var(--use-panel-bg));
    vertical-align: 0.1em;
}

.badge--muted {
    color: var(--use-text-muted);
    background: color-mix(in oklch, var(--use-text-muted) 12%, var(--use-panel-bg));
}

.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.is-voided td { color: var(--use-text-muted); text-decoration: line-through; }

.is-voided td .badge { text-decoration: none; }

.pagination {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem 0;
    color: var(--use-text-muted);
}

/* Invoice detail */
.invoice { max-width: 980px; }

.invoice__header {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.invoice__meta { margin: 0.25rem 0; color: var(--use-text-muted); }

.invoice__totals {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.2rem 1.5rem;
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.invoice__totals dd { margin: 0; text-align: right; }

.invoice__totals .invoice__total {
    font-weight: 700;
    padding-top: 0.2rem;
    border-top: 1px solid color-mix(in oklch, var(--use-divider) 45%, transparent);
}

.invoice__section {
    margin: 1.5rem 0 0.6rem;
    font-size: 1.35rem;
}

/* RAD incidentals: the shared rate and markup above a rule, each kind (Claude calls, text messages) indented below. */
.rad-incidentals__rule {
    margin: 1rem 0 0;
    border: 0;
    border-top: 1px solid var(--use-divider);
}

.rad-incidentals__kind { margin-left: 1.75rem; }

.rad-incidentals__kind h3 {
    margin: 1rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--use-divider);  /* from the indent to the section's right edge, like the rule above */
}

.rad-incidentals__minimum { max-width: 16rem; }

/* Theme editor */
.editor { max-width: 1200px; }

.editor__header { margin-bottom: 1.25rem; }

.editor__header .form__hint { margin: 0; max-width: 75ch; }

.editor__group-title {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.5rem;
}

.editor__colors {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.editor__color {
    background: var(--use-panel-bg);
    box-shadow: 0 2px 8px color-mix(in oklch, var(--use-text) 10%, transparent);
}

.editor__swatch {
    height: 64px;
    display: flex;
    align-items: flex-end;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid color-mix(in oklch, black 12%, transparent);
}

.editor__swatch-label {
    padding: 0.1rem 0.5rem;
    background: white;
    color: #222;
    font-weight: 600;
    letter-spacing: 0.05em;
    border-radius: 2px;
}

.editor__color-meta {
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid color-mix(in oklch, var(--use-divider) 45%, transparent);
}

.editor__color-meta code { display: block; font-size: 0.9375rem; color: var(--use-text); }

.editor__color-meta p {
    margin: 0.2rem 0 0;
    font-size: 0.9375rem;
    color: var(--use-text-muted);
}

.editor__uses {
    list-style: none;
    margin: 0;
    padding: 0;
}

.editor__use {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid color-mix(in oklch, var(--use-divider) 30%, transparent);
    line-height: 1.2;
}

.editor__use:last-child { border-bottom: 0; }

.editor__use--empty { color: var(--use-text-muted); font-style: italic; }

.editor__use-group {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--use-text-muted);
}

.editor__use select {
    flex: 0 0 auto;
    max-width: 11rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--use-input-border);
    border-radius: 3px;
    background: var(--use-input-bg);
    color: var(--use-text);
    font: inherit;
}

.editor__changed {
    font-size: 0.8125rem;
    font-style: normal;
    font-weight: 600;
    padding: 0 0.35rem;
    border-radius: 2px;
    color: var(--use-badge);
    background: color-mix(in oklch, var(--use-badge) 14%, var(--use-panel-bg));
}

.editor__unsaved { font-weight: 600; color: var(--use-msg-warning); }

@media (max-width: 720px) {
    .form__grid { grid-template-columns: 1fr; }
    .form__crawl, .toolbar { flex-direction: column; align-items: stretch; }
}

.colligo-report__title { margin: 1rem 0 0.4rem; font-size: 1.05rem; }
.colligo-report__file { margin: 1rem 0; }
.colligo-report__file > summary { cursor: pointer; font-weight: 600; margin-bottom: 0.4rem; }
.colligo-report .table { margin-bottom: 0.5rem; }

.collapsible__summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 0.5rem; }
.collapsible__summary::-webkit-details-marker { display: none; }
.collapsible__summary::before {
    content: "▸"; display: inline-block; width: 1em; color: var(--use-text-muted);
    transition: transform 0.15s ease; transform-origin: 40% 50%;
}
.collapsible[open] > .collapsible__summary::before { transform: rotate(90deg); }
.collapsible__summary .invoice__section { margin: 0; }
.collapsible[open] > .collapsible__summary { margin-bottom: 0.6rem; }
.collapsible__summary:focus-visible { outline: 2px solid var(--use-focus-ring); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .collapsible__summary::before { transition: none; } }

/* Wide panels never let a table bleed past their border: tighten charge tables, scroll as a last resort. */
.panel--wide { overflow-x: auto; }
.charges .num, .charges .nowrap { white-space: nowrap; }
.charges td:last-child { white-space: nowrap; }

/* Pages with wide tables (New invoice): the panel grows with the viewport instead of squeezing them. */
.panel--fluid { max-width: 1280px; }

.invoice-toolbar { max-width: 760px; }

.apply-search { margin-bottom: 0.5rem; }

/* Payables sub-navigation (Expenses · Payees · Types · Accounts · Cost units). */
.subnav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--use-divider); }
.subnav__item { padding: 0.35rem 0; color: var(--use-text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav__item:hover { color: var(--use-text); }
.subnav__item.is-active { color: var(--use-link); border-bottom-color: var(--use-link); font-weight: 600; }
.filters__narrow { width: 9rem; }
.filters__tiny { width: 5.5rem; }
.expense-groups { margin: 0 0 1.25rem; }
.expense-groups__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; align-items: start; }
.expenses-table td { vertical-align: top; }
/* Created today: the id column a fifth wider than its content alone would make it. */
.created-today th:first-child { width: 9.5em; }
.form__field-inner { display: flex; flex-direction: column; gap: 0.35rem; }
.new-type-description { margin-top: 0.35rem; }
/* Amount and interest keep the form's columns; the USD -> CAD helper takes the next two
   (beside them when four columns fit, on its own row otherwise, full width in one column). */
#expense-form { container-type: inline-size; }
.amount-row { display: grid; grid-template-columns: subgrid; gap: inherit; align-items: start; }
.usd-helper { grid-column: span 2; min-width: 0; margin: 0; border: 1px dashed var(--use-divider); border-radius: 4px; padding: 0.35rem 0.8rem 0.6rem; }
@container (max-width: 31.24rem) { .usd-helper { grid-column: 1 / -1; } }
.usd-helper__row { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; }
.usd-helper__row input { width: 7rem; margin-left: 0.35rem; }
.usd-helper__source { margin: 0.6rem 0 0; }  /* below the boxes, not pulled up like other hints */
.receipt-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 1rem; }
.receipt-name input { flex: 1 1 22rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.reference-tables { margin-top: 1.5rem; }

/* "Create this payee/type" sits a little below its box. */
.form__field-inner + .form__check { margin-top: 0.5rem; }

/* CCA / T2125 reference tables: side by side when there's room, stacked otherwise. */
.reference-tables__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 1rem; align-items: start; }
.reference-tables__grid > *, .expense-groups__grid > * { min-width: 0; }
.reference-table th, .reference-table td { padding: 0.4rem 0.7rem; vertical-align: top; }
.reference-tables > .form__hint { margin: 0 0 0.6rem; }
.reference-table tr[data-pick-for] { cursor: pointer; }
.reference-table tr[data-pick-for]:hover td { background: color-mix(in oklch, var(--use-link) 8%, transparent); }

/* CCA class / T2125 line: a known code narrows the box, its description takes the rest of the width. */
.code-field__row { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.code-field__row input { flex: 1 1 auto; min-width: 0; width: 100%; }
.code-field.has-description .code-field__row input { flex: 0 0 5.5rem; width: 5.5rem; }
.code-field__description {
    flex: 1 1 0; min-width: 0; font-size: 0.875rem; line-height: 1.25; color: var(--use-text-muted);
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.code-field:not(.has-description) .code-field__description { display: none; }

/* Expense form fields flow into as many columns as the width allows. */
.expense-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }

/* Public promotional page at / (no sidenav): product cards with calls to action, Log in top right. */
.promo { display: flex; flex-direction: column; min-height: 100vh; }
.promo__bar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem clamp(1rem, 4vw, 3rem);
    background: var(--use-sidenav-bg);
    border-bottom: 3px solid var(--use-sidenav-active);
}
.promo__brand {
    display: flex; align-items: center; gap: 0.6rem;
    font-family: var(--font-heading); font-size: 2rem; line-height: 1;
    color: var(--use-brand); text-decoration: none;
}
.promo__logo { width: 2.5rem; height: 2.5rem; }
.promo__main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: clamp(2rem, 6vw, 4.5rem) clamp(1rem, 4vw, 3rem); }
.promo__hero { max-width: 44rem; margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.promo__title { font-size: clamp(2.25rem, 5vw, 3.5rem); line-height: 1.1; margin-bottom: 1rem; }
.promo__lead { margin: 0; font-size: 1.3rem; color: var(--use-text-muted); }
.promo__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 1.25rem; }
.promo__card {
    display: flex; flex-direction: column; gap: 0.75rem;
    padding: 1.5rem;
    background: var(--use-panel-bg);
    border-top: 4px solid var(--use-panel-accent);
    box-shadow: 0 2px 8px color-mix(in oklch, var(--use-text) 12%, transparent);
}
.promo__card p { margin: 0; }
.promo__name { font-size: 2rem; text-align: center; }
.promo__tagline { font-weight: 700; color: var(--use-heading); }
.promo__cta { margin-top: auto; align-self: flex-start; }
.promo__footer { padding: 1.25rem clamp(1rem, 4vw, 3rem); color: var(--use-text-muted); border-top: 1px solid var(--use-divider); }

/* Service type picker (search + dropdown + "new" dialog). */
.type-picker { display: flex; flex-direction: column; gap: 0.4rem; }
.type-picker__row { display: flex; gap: 0.5rem; align-items: stretch; }
.type-picker__search { flex: 1; min-width: 0; }
.type-picker__dialog {
    width: min(32rem, calc(100vw - 2rem));
    padding: 1.5rem;
    color: var(--use-text);
    background: var(--use-panel-bg);
    border: 0;
    border-top: 4px solid var(--use-panel-accent);
    box-shadow: 0 4px 24px color-mix(in oklch, var(--use-text) 25%, transparent);
}
.type-picker__dialog::backdrop { background: color-mix(in oklch, var(--use-text) 35%, transparent); }
.type-picker__dialog .form__grid { margin-top: 1rem; }
@media (max-width: 600px) {
    .type-picker__row { flex-direction: column; }
}

/* Review scanned expenses: the email or attachment beside the proposed expense. */
.scan-review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.scan-review__source { position: sticky; top: 4.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.scan-review__frame {
    width: 100%;
    height: calc(100vh - 14rem);
    min-height: 420px;
    border: 1px solid var(--use-divider);
    background: #fff;
}
.scan-review__tabs { flex-wrap: wrap; }
.subnav__item.is-disabled { opacity: 0.5; cursor: default; }
.scan-review__notes {
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--use-sidenav-active);
    background: color-mix(in oklch, var(--use-sidenav-active) 8%, transparent);
}
@media (max-width: 1100px) {
    .scan-review { grid-template-columns: 1fr; }
    .scan-review__source { position: static; }
}
.inline-form { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; }

/* Possible duplicates on the scanned-expense review page. */
.duplicates { margin: 0.75rem 0; }
.duplicates--exact, .duplicates:not(.duplicates--none) {
    padding: 0.6rem 0.75rem;
    border-left: 3px solid var(--use-msg-error);
    background: color-mix(in oklch, var(--use-msg-error) 8%, transparent);
}
.duplicates:not(.duplicates--exact):not(.duplicates--none) { border-left-color: var(--use-sidenav-active); background: color-mix(in oklch, var(--use-sidenav-active) 8%, transparent); }
.duplicates__title { margin: 0 0 0.4rem; font-size: 1.05rem; }
.duplicates__table { font-size: 0.85rem; display: block; overflow-x: auto; }

/* Documents kept with an expense (Edit expense). */
.expense-documents { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.expense-documents__frame { height: 70vh; }
.expense-documents__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.expense-documents__list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; }
.expense-documents__list .form__hint { margin: 0; }
.doc-mark { font-size: 0.85em; }

/* Expense type chart (cumulative spending) and its launcher beside each type in the list. */
.chart-link { margin-left: 0.35rem; text-decoration: none; font-size: 0.9em; opacity: 0.55; }
.chart-link:hover, .chart-link:focus-visible { opacity: 1; }
.type-chart__title { margin: 0 0 1rem; }
.type-chart { position: relative; margin: 0 0 1.5rem; padding: 0.75rem; background: var(--use-panel-bg); }
.type-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.type-chart [hidden] { display: none; }
.type-chart__grid { stroke: var(--use-divider); stroke-width: 1; }
.type-chart__axis { stroke: var(--use-text-muted); stroke-width: 1; }
.type-chart__tick { fill: var(--use-text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.type-chart__line { fill: none; stroke: var(--use-link); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.type-chart__bar { fill: var(--use-link); }
.type-chart__crosshair { stroke: var(--use-text-muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.type-chart__dot { fill: var(--use-link); stroke: var(--use-panel-bg); stroke-width: 2; pointer-events: none; }
.type-chart__hit { fill: transparent; cursor: crosshair; }
.type-chart__tooltip {
    position: absolute;
    margin: 0.75rem;
    padding: 0.4rem 0.6rem;
    pointer-events: none;
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--use-text);
    background: var(--use-page-bg);
    border: 1px solid var(--use-divider);
    box-shadow: 0 2px 8px color-mix(in oklch, var(--use-text) 12%, transparent);
}
.type-chart__tooltip-label { color: var(--use-text-muted); }
.type-chart__tooltip-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Highlighter marks, as if drawn on a paper statement: amber = suggested or not reconciled, green = matched */
:root { --highlight-amber: rgb(255 191 0 / 0.32); --highlight-green: rgb(70 200 90 / 0.28); }
.hl-amber, tr.hl-amber > td { background-color: var(--highlight-amber); }
.hl-green, tr.hl-green > td { background-color: var(--highlight-green); }
span.hl-amber, span.hl-green { padding: 0 0.25rem; border-radius: 2px; }
tr.is-target > td { box-shadow: inset 0 2px 0 var(--use-link), inset 0 -2px 0 var(--use-link); }

.button--small { padding: 0.2rem 0.75rem; font-size: 0.9rem; }
.button--green, .button--green:hover { background: rgb(46 160 67); color: #fff; }
.button--green:hover { background: rgb(36 135 55); }
.button--amber { background: rgb(240 170 0); color: #2a1d00; }
.button--amber:hover { background: rgb(215 150 0); }
.button--danger { background: rgb(190 40 40); color: #fff; }
.button--danger:hover { background: rgb(160 30 30); }

.stat__value--small { font-size: 1.1rem; }
.statement__title { margin-bottom: 0.5rem; }
.statement__status { margin: 0.5rem 0 1rem; }
.statement-unread { margin-bottom: 1.5rem; }
.statement-replacement { margin: 0 0 1.5rem; padding: 0.75rem 1rem; background: var(--highlight-amber); border-radius: 3px; }
.statement-lines td { vertical-align: top; }
.statement-lines form { margin: 0; }
.statement-manage { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-top: 2rem; }
.statement-manage__replace { display: flex; align-items: flex-end; gap: 1rem; max-width: 46rem; }
.statement-manage__delete summary { list-style: none; cursor: pointer; }
.statement-manage__delete summary::-webkit-details-marker { display: none; }
.statement-opener { margin-left: 0.25rem; text-decoration: none; }
