/* 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; }

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 */
.sidenav {
    flex: 0 0 var(--sidenav-width);
    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 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    line-height: 1;
    color: var(--use-brand);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.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);
}

.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 {
    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; }

/* 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);
}

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

.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 .toolbar__search { max-width: 760px; }

.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; }

.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;
}

/* 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; }
}
