/*
 * Warehouse UI. Mobile first: the base rules are for phones, wider screens are added with min-width queries.
 * Breakpoints: 720px (tables become tables again, forms get columns), 1024px (permanent sidebar).
 * Style (from the ui-ux-pro-max design system): flat, data-dense dashboard. Surfaces are separated by borders,
 * not shadows; industrial slate with an emerald accent; Fira Sans with tabular figures.
 * Colours, spacing and radii are tokens below; the dark theme only redefines tokens.
 */

/* ---------- Fonts (self-hosted, SIL OFL: fonts/OFL.txt) ---------- */
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/fira-sans-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/fira-sans-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/fira-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/fira-sans-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/fira-sans-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/fira-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fira-sans-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fira-sans-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fira-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/fira-sans-cyrillic-700-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/fira-sans-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/fira-sans-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- Tokens ---------- */
:root {
    color-scheme: light dark;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --muted: #475569;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --control-border: #7c8aa0; /* 3:1 on surfaces (WCAG 1.4.11) */
    --accent: #047857;
    --accent-hover: #065f46;
    --accent-soft: #ecfdf5;
    --accent-text: #ffffff;
    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --warning: #92400e;
    --warning-soft: #fffbeb;
    --info: #1d4ed8;
    --info-soft: #eff6ff;
    /* The sidebar is dark slate in both themes. */
    --nav-bg: #0f172a;
    --nav-text: #cbd5e1;
    --nav-muted: #94a3b8;
    --nav-hover: #1e293b;
    --nav-active: #1e293b;
    --nav-accent: #34d399;
    --shadow-sm: 0 0 0 transparent;
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .12);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, .25);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --control-h: 2.75rem;
    --sidebar-w: 248px;
    --appbar-h: 3.5rem;
    --ease: cubic-bezier(.2, 0, 0, 1);
    --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Dark theme: follows the system unless the user picked a theme in the sidebar (html[data-theme], see app.js). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1120;
        --surface: #131c2e;
        --surface-2: #18233a;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --border: #243049;
        --border-strong: #334155;
        --control-border: #6b7a90;
        --accent: #34d399;
        --accent-hover: #6ee7b7;
        --accent-soft: #0d2e25;
        --accent-text: #052e1f;
        --danger: #f87171;
        --danger-soft: #3b1518;
        --success: #4ade80;
        --success-soft: #0f2a1a;
        --warning: #fbbf24;
        --warning-soft: #2e2208;
        --info: #93c5fd;
        --info-soft: #14233f;
        --nav-bg: #070c18;
        --nav-hover: #131c2e;
        --nav-active: #18233a;
        --shadow-sm: 0 0 0 transparent;
        --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #131c2e;
    --surface-2: #18233a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #243049;
    --border-strong: #334155;
    --control-border: #6b7a90;
    --accent: #34d399;
    --accent-hover: #6ee7b7;
    --accent-soft: #0d2e25;
    --accent-text: #052e1f;
    --danger: #f87171;
    --danger-soft: #3b1518;
    --success: #4ade80;
    --success-soft: #0f2a1a;
    --warning: #fbbf24;
    --warning-soft: #2e2208;
    --info: #93c5fd;
    --info-soft: #14233f;
    --nav-bg: #070c18;
    --nav-hover: #131c2e;
    --nav-active: #18233a;
    --shadow-sm: 0 0 0 transparent;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
    font-family: var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1 { font-size: 1.375rem; line-height: 1.25; margin: 0 0 var(--space-4); font-weight: 600; letter-spacing: -.005em; }
h2 { font-size: 1.0625rem; line-height: 1.3; margin: var(--space-5) 0 var(--space-3); font-weight: 600; }
p { margin: 0 0 var(--space-3); }
small { font-size: .8125rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
.icon { width: 1.125rem; height: 1.125rem; flex: none; }
button .icon, .button .icon { width: 1rem; height: 1rem; margin-inline-start: -.125rem; }
a, button, .button, select, summary, label.checkbox { cursor: pointer; }

.muted { color: var(--muted); }
.error { color: var(--danger); font-size: .875rem; font-weight: 400; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--space-2); top: -4rem; z-index: 100; padding: var(--space-2) var(--space-3); background: var(--surface); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--space-2); box-shadow: var(--shadow-md); }

/* ---------- App shell ---------- */
.appbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--space-2);
    height: calc(var(--appbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--space-2) 0;
    background: var(--nav-bg); color: #fff;
}
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: 1.0625rem; letter-spacing: .01em; color: inherit; }
.brand:hover { color: inherit; text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 2rem; height: 2rem; flex: none; border-radius: var(--radius);
    background: #059669; color: #fff;
}
.brand-mark .icon { width: 1.125rem; height: 1.125rem; }
.menu-toggle {
    display: none; place-items: center; width: var(--control-h); height: var(--control-h);
    padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: inherit;
}
.js .menu-toggle { display: inline-grid; }
.menu-toggle:hover { background: var(--nav-hover); color: inherit; }
.menu-toggle .icon { width: 1.375rem; height: 1.375rem; margin: 0; }

.sidebar { display: flex; flex-direction: column; min-width: 0; background: var(--nav-bg); color: var(--nav-text); }
.sidebar .brand { color: #fff; }
.sidebar-head { display: none; padding: var(--space-4) var(--space-4) var(--space-3); }
.sidebar-nav { flex: 1; padding: var(--space-2) var(--space-3); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--nav-hover) transparent; }
.nav-group + .nav-group { margin-top: var(--space-3); }
.nav-group-title { margin: 0; padding: var(--space-2) var(--space-3) var(--space-1); font-size: .6875rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--nav-muted); }
.nav-link {
    position: relative; display: flex; align-items: center; gap: var(--space-3); min-height: 2.5rem; padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm); color: var(--nav-text); font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link .icon { color: var(--nav-muted); transition: color .15s var(--ease); }
.nav-link:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
.nav-link:hover .icon { color: #fff; }
.nav-link.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav-link.active .icon { color: var(--nav-accent); }
.nav-link.active::before { content: ""; position: absolute; left: calc(-1 * var(--space-3)); top: 50%; width: 3px; height: 1.25rem; margin-top: -.625rem; border-radius: 0 3px 3px 0; background: var(--nav-accent); }
.sidebar :focus-visible { outline-color: var(--nav-accent); }
.sidebar-foot { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); border-top: 1px solid var(--nav-hover); }
.user-chip { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.avatar {
    display: inline-grid; place-items: center; width: 2rem; height: 2rem; flex: none; border-radius: 50%;
    background: #065f46; color: #d1fae5; font-weight: 600; font-size: .875rem;
}
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: #fff; }
.sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.sidebar-prefs { display: grid; grid-template-columns: 1fr; gap: var(--space-2); }
.js .sidebar-prefs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sidebar-user .user-chip { flex: 1 1 auto; }
.sidebar-user form { flex: none; }
.sidebar .button-quiet { color: var(--nav-muted); }
.sidebar .button-quiet:hover { background: var(--nav-hover); color: #fff; }
.logout { gap: var(--space-1); }
.sidebar-prefs select {
    min-height: 2.25rem; padding: .25rem 1.6rem .25rem .6rem; font-size: .8125rem;
    background-color: var(--nav-hover); border-color: #334155; color: var(--nav-text);
    background-position: calc(100% - .8rem) 50%, calc(100% - .5rem) 50%;
}
.sidebar-prefs select:hover:not(:disabled) { border-color: var(--nav-muted); }
.sidebar-prefs select, .guest-bar select {
    background-image: linear-gradient(45deg, transparent 50%, var(--nav-muted) 50%), linear-gradient(135deg, var(--nav-muted) 50%, transparent 50%);
}
.locale-form { margin: 0; }
.theme-switch { display: none; }
.js .theme-switch { display: block; }

/* Without JS the menu is a plain block under the app bar; with JS it slides in from the left. */
.js .with-sidebar .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(18rem, 86vw);
    transform: translateX(-100%); transition: transform .22s var(--ease), visibility 0s .22s; box-shadow: var(--shadow-lg); visibility: hidden;
}
.js .with-sidebar .sidebar-head { display: block; }
.js .nav-open .sidebar { transform: none; visibility: visible; transition: transform .22s var(--ease); }
.backdrop { display: none; }
.js .nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(2, 6, 23, .55); }
.js .nav-open { overflow: hidden; }

.guest-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); max-width: 1240px; margin: 0 auto; padding: var(--space-3) var(--space-4); color: #fff; }
.guest-bar select { background-color: var(--nav-hover); border-color: #334155; color: var(--nav-text); min-height: 2.25rem; font-size: .875rem; }
/* Signed out: a flat slate band behind the sign-in card. */
body.guest { background: linear-gradient(var(--nav-bg) 0 16rem, var(--bg) 16rem); }

main { width: 100%; max-width: 1360px; margin: 0 auto; padding: var(--space-4) var(--space-4) var(--space-6); }

@media (min-width: 1024px) {
    .with-sidebar { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
    .appbar { display: none; }
    .with-sidebar .sidebar, .js .with-sidebar .sidebar {
        position: sticky; top: 0; height: 100vh; width: auto; transform: none; visibility: visible;
        box-shadow: none; transition: none;
    }
    .with-sidebar .sidebar-head { display: block; }
    .backdrop, .js .nav-open .backdrop { display: none; }
    main { padding: var(--space-5) var(--space-6) 3rem; }
    h1 { font-size: 1.5rem; }
    html { font-size: 15px; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.page-head h1 { margin: 0; }
.page-head > .actions, .page-head > .button { flex: none; }
.page-subtitle { margin: var(--space-1) 0 0; color: var(--muted); }
/* "Back" sits above the title as a small link with an arrow, where the eye starts, not at the far right. */
.page-head .back-link {
    order: -1; flex-basis: 100%; display: inline-flex; align-items: center; gap: var(--space-1);
    min-height: 2.75rem; margin: calc(-1 * var(--space-3)) 0 calc(-1 * var(--space-2)); width: max-content; color: var(--muted); font-size: .9375rem;
}
.page-head .back-link::before { content: "←" / ""; }
.page-head .back-link:hover { color: var(--accent); }

/* ---------- Cards and lists ---------- */
.card {
    display: grid; gap: var(--space-4); max-width: 760px; padding: var(--space-4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.card.wide { max-width: none; }
.card.narrow { max-width: 420px; margin: var(--space-5) auto; padding: var(--space-5); box-shadow: var(--shadow-lg); border-color: transparent; }
@media (min-width: 720px) { .card.narrow { margin-top: 3rem; padding: var(--space-6); } }
.card.narrow h1 { text-align: center; }
.card.narrow form { display: grid; gap: var(--space-4); }
.card.narrow button.primary { width: 100%; }
@media (min-width: 720px) { .card { padding: var(--space-5); } }

.details-list { grid-template-columns: 1fr; gap: var(--space-1) var(--space-5); }
.details-list dt { color: var(--muted); font-size: .875rem; }
.details-list dd { margin: 0 0 var(--space-2); overflow-wrap: anywhere; }
@media (min-width: 720px) {
    .details-list { grid-template-columns: minmax(10rem, max-content) 1fr; row-gap: var(--space-3); }
    .details-list dd { margin: 0; }
}

/* Directories hub: one row per directory, icon, name, a short description. */
.hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: var(--space-3); max-width: 1100px; }
.hub-item {
    display: flex; align-items: center; gap: var(--space-3); min-height: 4.5rem; padding: var(--space-3) var(--space-4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text);
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.hub-item:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.hub-icon { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); }
.hub-icon .icon { width: 1.25rem; height: 1.25rem; }
.hub-text { display: grid; gap: .125rem; flex: 1; min-width: 0; }
.hub-text strong { font-weight: 600; font-size: 1rem; }
.hub-text span { color: var(--muted); font-size: .875rem; line-height: 1.35; }
.hub-chevron { color: var(--muted); transition: transform .15s var(--ease), color .15s var(--ease); }
.hub-item:hover .hub-chevron { color: var(--accent); transform: translateX(2px); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.tile {
    display: grid; gap: var(--space-1); align-content: start; min-height: 4rem; padding: var(--space-4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
    transition: border-color .15s var(--ease);
}
a.tile:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }

/* ---------- Home dashboard ---------- */
.actions.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); width: 100%; }
.quick-actions .button { white-space: normal; text-align: center; font-size: .875rem; }
@media (min-width: 720px) {
    .actions.quick-actions { display: flex; flex-wrap: wrap; width: auto; }
    .quick-actions .button { font-size: inherit; }
}
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
@media (min-width: 1024px) { .kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
.kpi {
    position: relative; display: grid; align-content: start; gap: var(--space-1); padding: var(--space-4) calc(var(--space-4) + 2.5rem) var(--space-4) var(--space-4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text);
    transition: border-color .15s var(--ease);
}
.kpi-icon {
    position: absolute; top: var(--space-3); right: var(--space-3); display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem;
    border-radius: var(--radius); background: var(--accent-soft); color: var(--accent);
}
.kpi-alert .kpi-icon { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
a.kpi:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.kpi-label { color: var(--muted); font-size: .8125rem; font-weight: 500; }
.kpi-value { font-size: 1.875rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-note { color: var(--muted); font-size: .8125rem; }
.kpi-alert { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-soft); }
.kpi-alert .kpi-value, .kpi-alert .kpi-label { color: var(--danger); }

.widgets { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--space-4); }
@media (min-width: 900px) { .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.widget {
    display: flex; flex-direction: column; min-width: 0; padding: var(--space-4);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.widget-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.widget-head h2 { flex: 1; margin: 0; font-size: 1rem; }
/* Drag handle: drag with a mouse or finger, or focus it and use the arrow keys (see app.js). */
.widget-handle {
    display: none; min-width: 2rem; min-height: 2rem; margin: calc(-1 * var(--space-1)) calc(-1 * var(--space-2)) calc(-1 * var(--space-1)) 0;
    padding: 0; border: 0; background: none; color: var(--muted); cursor: grab; touch-action: none;
}
.js .widget-handle { display: inline-grid; place-items: center; }
.widget-handle:hover { background: var(--surface-2); color: var(--text); }
.widget-handle .icon { width: 1.125rem; height: 1.125rem; margin: 0; }
@media (pointer: coarse) { .widget-handle { min-width: 2.75rem; min-height: 2.75rem; } }
.widget.dragging { position: relative; z-index: 10; border-color: var(--accent); box-shadow: var(--shadow-lg); opacity: .96; cursor: grabbing; }
.widget.dragging .widget-handle { cursor: grabbing; }
.widget.moved { animation: widget-moved .6s var(--ease); }
@keyframes widget-moved { from { border-color: var(--accent); } }
body.dragging-widget { user-select: none; cursor: grabbing; }
.widget-head a { font-size: .875rem; white-space: nowrap; }
.widget-empty, .widget-note { margin: var(--space-2) 0 0; color: var(--muted); font-size: .875rem; }
.widget-list { margin: 0; padding: 0; list-style: none; }
.widget-list > li + li { border-top: 1px solid var(--border); }
.widget-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; color: var(--text); }
a.widget-row { margin: 0 calc(-1 * var(--space-2)); padding-inline: var(--space-2); border-radius: var(--radius-sm); }
a.widget-row:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.widget-main { display: grid; gap: .125rem; min-width: 0; flex: 1; overflow-wrap: anywhere; }
.widget-sub { color: var(--muted); font-size: .8125rem; }
.meter { display: block; height: 6px; margin-top: var(--space-1); border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* Bar chart: one column per day, the count above the bar, the day of month below. */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; gap: 3px; height: 10rem; margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.bars > li { height: 100%; min-width: 0; }
/* Each day is a link to its tasks. */
.bar { display: grid; grid-template-rows: auto 1fr auto; height: 100%; padding: 0 1px; border-radius: var(--radius-sm); text-align: center; color: inherit; }
.bar:hover, .bar:focus-visible { background: var(--accent-soft); text-decoration: none; }
.bar-value { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1em; }
.bar-fill { align-self: end; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); transition: background .15s var(--ease); }
.bar:hover .bar-fill { background: var(--accent-hover); }
.bar-label { padding-top: var(--space-1); font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* A form bar above a list (e.g. inventory from warehouse stock). */
.toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3);
    padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.toolbar-field { flex: 1 1 16rem; font-size: .8125rem; color: var(--muted); }
.toolbar-field select { font-size: 1rem; }
@media (min-width: 720px) { .toolbar-field { max-width: 28rem; } }
.toolbar > button { flex: 1 1 auto; }
@media (min-width: 720px) { .toolbar > button { flex: 0 0 auto; } }

td.diff-minus { color: var(--danger); }
td.diff-plus { color: var(--success); }

.danger-zone { margin-top: var(--space-5); max-width: 760px; border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.details { white-space: pre-wrap; font-size: .8125rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); overflow-x: auto; }
.history { margin-top: var(--space-5); }
.history ul { margin: var(--space-2) 0; padding-left: 1.25rem; color: var(--muted); }
.history-totals { margin-bottom: var(--space-4); }

/* ---------- Forms ---------- */
label { display: grid; gap: var(--space-1); align-content: start; font-weight: 500; font-size: .9375rem; }
label.checkbox { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-h); font-weight: 400; }
fieldset { display: grid; gap: var(--space-3); min-width: 0; margin: 0; padding: var(--space-3) var(--space-4) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
legend { padding: 0 var(--space-2); font-size: .8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
@media (min-width: 720px) {
    .row { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .row > label.checkbox { align-self: start; margin-top: 1.6rem; }
}

input, select, textarea, button, .button { font: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
    width: 100%; min-height: var(--control-h); padding: var(--space-2) var(--space-3);
    border: 1px solid var(--control-border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { min-height: 5rem; resize: vertical; }
select {
    appearance: none; padding-right: 2.25rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 1.05rem) 50%, calc(100% - .75rem) 50%; background-size: .3rem .3rem; background-repeat: no-repeat;
}
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--muted); }
/* Focus: the accent border plus a 1px accent ring (2px solid in total) and a soft halo. */
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); flex: none; }
label:has(> .error) input, label:has(> .error) select, label:has(> .error) textarea, [aria-invalid="true"] { border-color: var(--danger); }

/* ---------- Buttons ---------- */
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--control-h); padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    font-weight: 500; line-height: 1.2; cursor: pointer; white-space: nowrap;
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}
button:active:not(:disabled), .button:active { transform: translateY(1px); }
button:hover, .button:hover { background: var(--surface-2); border-color: var(--control-border); color: var(--text); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
button.danger:hover { background: var(--danger-soft); }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 400; }
button.link:hover { background: none; text-decoration: underline; }
.button-quiet { min-height: 2.25rem; padding: var(--space-1) var(--space-3); border-color: transparent; background: transparent; color: var(--muted); }
.button-quiet:hover { color: var(--text); }
button:disabled { opacity: .55; cursor: not-allowed; }
/* Icon buttons (remove a line) keep a full touch target even though they look like a link. */
button.link[data-remove-line] {
    display: inline-grid; place-items: center; min-width: var(--control-h); min-height: var(--control-h);
    border-radius: var(--radius-sm); color: var(--muted);
}
button.link[data-remove-line] .icon { width: 1.125rem; height: 1.125rem; margin: 0; }
button.link[data-remove-line]:hover { background: var(--danger-soft); color: var(--danger); text-decoration: none; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
form.inline { display: inline; margin: 0; }
.document-actions { margin-top: var(--space-4); }

/* Phones: the save buttons of a long form stay at the bottom of the screen. */
@media (max-width: 719.98px) {
    form.card > .actions {
        position: sticky; bottom: 0; z-index: 5; margin: 0 calc(-1 * var(--space-4)) calc(-1 * var(--space-4));
        padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
        background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
    form.card > .actions > button, form.card > .actions > .button { flex: 1 1 auto; }
    .search > button[type=submit] { flex: 1 1 auto; }
}

/* ---------- Search and filters ---------- */
.search { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); max-width: 560px; margin-bottom: var(--space-4); }
.search input[type=search], .search > input:not([type=hidden]):not([type=checkbox]) { flex: 1 1 14rem; width: auto; }
.search .checkbox { white-space: nowrap; }
.filters-form {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none;
    padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.filters-form > input[type=search], .filters-form > button, .filters-form > .checkbox { grid-column: 1 / -1; }
.filters-form > label { font-size: .8125rem; color: var(--muted); font-weight: 500; }
/* Phones: filters beyond the search field fold behind a "Filters (n)" button (added by app.js). */
.filters-toggle { display: none; }
@media (max-width: 719.98px) {
    .filters-form.collapsible > .filters-toggle { display: inline-flex; grid-column: auto; }
    .filters-form.collapsible > button[type=submit] { grid-column: auto; }
    .filters-form.collapsible:not(.filters-open) > :is(select, input[type=date], input[type=number], label, .checkbox) { display: none; }
    .filters-toggle[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
}
.filters-count {
    display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .35rem;
    border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 700;
}
@media (min-width: 720px) {
    .filters-form { display: flex; flex-wrap: wrap; }
    .filters-form > * { flex: 0 1 auto; width: auto; }
    .filters-form > input[type=search] { flex: 1 1 16rem; }
    .filters-form > select { width: auto; max-width: 16rem; }
    .filters-form > label { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
    .filters-form > label input { width: auto; }
    .search.filters-form > input[type=date] { flex: 0 0 11rem; width: 11rem; }
}
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.filters a { display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text); background: var(--surface); font-size: .875rem; transition: border-color .15s var(--ease), background .15s var(--ease); }
.filters a:hover { border-color: var(--border-strong); text-decoration: none; }
.filters a.active { border-color: var(--accent); background: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ---------- Material picker ---------- */
.picker-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin: var(--space-1) 0 0; padding: var(--space-1);
    list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; font-weight: 400;
}
.picker-list li { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.picker-list li.active, .picker-list li:hover { background: var(--accent-soft); }
.picker-list li.picker-note { cursor: default; font-size: .875rem; }
.picker-list li.picker-note:hover { background: none; }
.picker-list li { flex-wrap: wrap; row-gap: 0; }
.picker-list li > span { flex: 1 1 12rem; }
.picker-list li > small { margin-left: auto; }
.picker-list small.out-of-stock { color: var(--danger); }

/* Searchable select: a text field over a hidden <select data-search> (app.js) */
.combo { position: relative; }
.combo input { width: 100%; }
.combo select[hidden] { display: none; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); font-size: .9375rem; font-variant-numeric: tabular-nums; }
th, td { padding: .625rem var(--space-3); text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
thead th a:hover { color: var(--text); text-decoration: none; }
thead th a { color: inherit; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
tfoot th, tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.negative td { color: var(--danger); }
td .actions { gap: var(--space-1) var(--space-2); margin: 0; min-width: 9rem; }
td .actions button, td .actions .button { min-height: 2rem; padding: var(--space-1) var(--space-3); font-size: .8125rem; }
table.journal td:nth-child(2) { white-space: nowrap; }
table.journal td:first-child { min-width: 6rem; }
@media (min-width: 720px) {
    table.journal { font-size: .875rem; }
    table.journal th, table.journal td { padding: var(--space-2) .4rem; }
    /* "Changed" is secondary; actions stack so the table fits next to the sidebar. */
    table.journal td:nth-last-child(2) { min-width: 6.5rem; color: var(--muted); font-size: .8125rem; }
    table.journal td .actions { flex-direction: column; align-items: stretch; min-width: 0; }
    table.journal td .actions form { display: block; }
    table.journal td .actions form, table.journal td .actions button { width: 100%; }
    table.journal td .actions button { white-space: normal; text-align: center; }
}

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); -webkit-overflow-scrolling: touch; }
.table-scroll > table { border: 0; }

/* Phones: list tables become cards, one per row; the first cell is the title, the others are label/value pairs. */
@media (max-width: 719.98px) {
    .table-scroll.has-stack { overflow: visible; background: none; border: 0; border-radius: 0; box-shadow: none; }
    table.stack, table.stack tbody, table.stack tr, table.stack td, table.stack tfoot { display: block; }
    table.stack { background: none; border: 0; }
    table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    table.stack tbody tr { display: flex; flex-direction: column; }
    table.stack tr {
        position: relative; margin-bottom: var(--space-3); padding: var(--space-3) var(--space-4);
        background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    }
    table.stack tbody tr:hover td { background: none; }
    table.stack td, table.stack tfoot th {
        display: flow-root; padding: var(--space-1) 0; border: 0; background: none; text-align: right; font-weight: 400;
    }
    table.stack td::before, table.stack tfoot th::before {
        content: attr(data-label); float: left; max-width: 50%; margin-right: var(--space-4);
        color: var(--muted); font-size: .8125rem; font-weight: 400; text-align: left;
    }
    table.stack .card-title { order: -2; padding-bottom: var(--space-1); text-align: left; font-weight: 600; font-size: 1rem; }
    /* The main text of a row (e.g. the task name) goes right under the title, without a label. */
    table.stack td.card-sub { order: -1; padding: 0 0 var(--space-2); margin-bottom: var(--space-1); border-bottom: 1px solid var(--border); text-align: left; font-weight: 500; }
    table.stack td.card-sub::before { content: none; }
    table.stack .card-title::before, table.stack td:not([data-label])::before, table.stack tfoot th:not([data-label])::before { content: none; }
    table.stack td:empty, table.stack tfoot th:empty, table.stack td[data-label="#"] { display: none; }
    table.stack td:last-child:has(> .document-actions, > form) { text-align: left; }
    table.stack .document-actions { margin-top: var(--space-2); }
    table.stack tfoot tr { background: var(--surface-2); }
    table.stack tfoot .card-title { font-size: .9375rem; }

    /* Document and task lines: every cell holds a field, so labels go above the fields. */
    table.lines.stack tr { padding-right: 3rem; }
    table.lines.stack td { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; gap: var(--space-1); text-align: left; padding: var(--space-1) 0; font-weight: 400; font-size: inherit; }
    table.lines.stack td::before { max-width: none; }
    table.lines.stack td:first-child { min-width: 0; padding-bottom: var(--space-1); }
    table.lines.stack td.num input { text-align: left; }
    table.lines.stack td:has([data-remove-line]) { position: absolute; top: var(--space-2); right: var(--space-2); padding: 0; }
    table.lines.stack td:has([data-remove-line])::before { content: none; }
    table.lines.stack [data-remove-line] { width: 2.5rem; height: 2.5rem; color: var(--muted); }
    table.lines.stack td[data-net]:not(:empty), table.lines.stack td[data-gross]:not(:empty) { display: flex; justify-content: space-between; }
}

table.lines { border: 0; background: none; }
table.lines thead th { background: none; }
table.lines td { vertical-align: top; }
table.lines td:first-child { position: relative; }
table.lines input { width: 100%; }
table.lines td.num input { text-align: right; }
table.lines tbody tr:hover td { background: none; }
.table-scroll:has(> table.lines) { border: 0; box-shadow: none; background: none; overflow: visible; }
@media (min-width: 720px) {
    table.lines td:first-child { min-width: 260px; }
    table.lines td.num input { min-width: 6rem; }
}

/* Materials report: one column per movement with the quantity and, under it, the amount; fits without
   sideways scrolling. Phones get a card per material with the movements in two columns. */
table.report-movements th.num { min-width: 5.5rem; white-space: normal; vertical-align: bottom; line-height: 1.25; }
table.report-movements td.num { white-space: nowrap; }
table.report-movements td:first-child { min-width: 9rem; }
.report-qty { display: block; font-weight: 500; }
.report-amount { display: block; margin-top: .125rem; color: var(--muted); font-size: .8125rem; }
.report-warehouse { display: block; margin-top: .125rem; color: var(--muted); font-size: .8125rem; }
table.report-movements .report-closing { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
table.report-movements .report-closing .report-qty { font-weight: 700; }
table.report-movements tfoot .report-amount { margin: 0; color: var(--text); font-size: inherit; font-weight: 600; }
/* Tablets (no sidebar, but still a table): tighter cells so seven columns fit from 720px. */
@media (min-width: 720px) and (max-width: 1023.98px) {
    table.report-movements { font-size: .875rem; }
    table.report-movements th, table.report-movements td { padding: var(--space-2) .4rem; }
    table.report-movements th.num { min-width: 0; }
    table.report-movements td:first-child { min-width: 7rem; }
}
@media (max-width: 719.98px) {
    table.report-movements.stack tbody tr, table.report-movements.stack tfoot tr {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4);
    }
    table.report-movements.stack .card-title { grid-column: 1 / -1; order: 0; }
    table.report-movements.stack td.num { display: block; padding: 0; text-align: left; white-space: normal; }
    table.report-movements.stack td.num::before { float: none; display: block; max-width: none; margin: 0 0 .125rem; font-size: .75rem; line-height: 1.3; }
    table.report-movements.stack td.num.report-closing { margin: 0 calc(-1 * var(--space-2)); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
}

/* Stock across warehouses: a material row with its totals, then a row per warehouse that holds it.
   On phones a material and its warehouses share one card. */
table.stock-groups tbody + tbody { border-top: 2px solid var(--border-strong); }
table.stock-groups tr.stock-material td { background: var(--surface-2); font-weight: 600; }
table.stock-groups tr.stock-warehouse td { font-size: .875rem; }
table.stock-groups tr.stock-warehouse td:first-child { padding-left: var(--space-6); }
@media (min-width: 720px) {
    table.stock-groups td.num, table.stock-groups th.num { white-space: nowrap; }
    table.stock-groups tr.stock-warehouse td { padding-top: var(--space-2); padding-bottom: var(--space-2); }
}
@media (max-width: 719.98px) {
    table.stock-groups.stack tbody {
        margin-bottom: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--border);
        border-radius: var(--radius-lg); background: var(--surface);
    }
    table.stock-groups.stack tbody tr { margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: none; }
    table.stock-groups.stack tr.stock-material td { background: none; }
    table.stock-groups.stack tr.stock-warehouse { margin-top: var(--space-2); padding-top: var(--space-2); padding-left: var(--space-3); border-top: 1px dashed var(--border); }
    table.stock-groups.stack tr.stock-warehouse td:first-child { padding-left: 0; }
    table.stock-groups.stack tr.stock-warehouse .card-title { font-size: .9375rem; }
}

/* Tabs: a segmented control. */
.tabs {
    display: flex; gap: 2px; width: max-content; max-width: 100%; margin: 0 0 var(--space-4); padding: 3px;
    background: color-mix(in srgb, var(--border) 70%, var(--bg)); border-radius: var(--radius); overflow-x: auto;
}
.tabs a {
    display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0 var(--space-4); border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 500; text-decoration: none; white-space: nowrap; transition: background .15s var(--ease), color .15s var(--ease);
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }

/* ---------- Feedback ---------- */
.flash {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid transparent; border-left-width: 4px;
}
.flash-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); border-left-color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); border-left-color: var(--danger); }
.flash-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); border-left-color: var(--info); }
.flash a { color: inherit; font-weight: 600; text-decoration: underline; }

.badge {
    display: inline-flex; align-items: center; gap: var(--space-1); padding: .125rem .55rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border-strong); }
.badge-locked { background: var(--danger-soft); color: var(--danger); }

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); }
.pagination a { display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0 var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
@media (min-width: 720px) { .pagination { justify-content: flex-start; } }

/* Task card: write-off status above the form. */
.task-status { margin-bottom: var(--space-4); }
.task-status .flash { display: block; }
.task-status .flash ul { margin: var(--space-2) 0 0; padding-left: 1.2rem; }
.task-status .flash p { margin: var(--space-2) 0 0; }

/* ---------- Touch and motion ---------- */
@media (pointer: fine) and (min-width: 1024px) {
    :root { --control-h: 2.375rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Print ---------- */
@media print {
    :root, :root[data-theme] { color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --text: #000; --muted: #444; --border: #bbb; --border-strong: #888; }
    .appbar, .sidebar, .backdrop, .skip-link, .actions, .document-actions, .search, .filters, .pagination, .menu-toggle { display: none !important; }
    .with-sidebar { display: block; }
    main { max-width: none; padding: 0; }
    .card, .table-scroll, .tile { box-shadow: none; }
    a { color: inherit; }
    table.stack, table.stack thead, table.stack tbody, table.stack tr, table.stack td { all: revert; }
}
