/* FLOW - mobile first, light and dark mode. The base tokens are the
   standard design "flow" (navy and light blue); other designs ("brands")
   override them per data-brand on <html>, chosen with 'theme' in
   config/config.php. Red is left to defects and status in every design. */

:root {
    --header: #0e2746;
    --header-text: #ffffff;
    /* title bars of the cards; in dark mode lifted off the dark card */
    --title-bg: var(--header);
    /* buttons on the title bar and main actions (.btn-primary): the bar lightened */
    --action-bg: color-mix(in srgb, var(--title-bg) 90%, #ffffff);
    --action-hover: color-mix(in srgb, var(--title-bg) 80%, #ffffff);
    --accent: #1d5d9b;
    --accent-strong: #154a7d;
    --on-accent: #ffffff;
    --link: #1d5d9b;
    --bg: #f2f5f9;
    --surface: #ffffff;
    --surface-2: #e9eef5;
    --text: #0f1b2d;
    --muted: #55657a;
    --border: #d3dbe6;
    --focus: #2f80c8;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --warn: #a16207;
    --warn-bg: #fef3c7;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --info-bg: #e0ecff;
    --info: #1e40af;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 1px 8px rgb(0 0 0 / 0.04);
    /* list rows: a mark on the left edge in two light tones of the header
       color; hover tints the row with the page background */
    --row-mark-base: var(--header);
    --row-mark: color-mix(in srgb, var(--row-mark-base) 60%, var(--surface));
    --row-mark-alt: color-mix(in srgb, var(--row-mark-base) 35%, var(--surface));
    --row-hover: var(--bg);
    --radius: 12px;
    --tap: 48px;
    --nav-h: 64px;
    /* space for the home indicator / gesture bar below the bottom navigation */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}

/* Firefox on Android reports the system navigation bar as bottom inset
   although the page ends above it while its toolbar is visible: the bottom
   navigation got an empty strip until the toolbar hid on scrolling. The
   page does not reach under the bar there, so the inset is dropped for
   Gecko. Firefox on iOS uses WebKit and keeps the inset. */
@supports (-moz-appearance: none) {
    :root { --safe-bottom: 0px; }
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --header: #0b1f3a;
        --title-bg: color-mix(in srgb, var(--header) 80%, var(--accent));
        --row-mark-base: color-mix(in srgb, var(--header) 40%, #ffffff);
        --accent: #51abda;
        --accent-strong: #7cc4ea;
        --on-accent: #0a1422;
        --link: #7cc4ea;
        --bg: #0a1422;
        --surface: #111f33;
        --surface-2: #1a2b44;
        --text: #eef3f9;
        --muted: #9fb0c6;
        --border: #263a57;
        --focus: #7cc4ea;
        --ok: #4ade80;
        --ok-bg: #12301d;
        --warn: #fbbf24;
        --warn-bg: #3a2c09;
        --bad: #f87171;
        --bad-bg: #3d1414;
        --info-bg: #172443;
        --info: #a5c0ff;
        --shadow: none;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --header: #0b1f3a;
    --title-bg: color-mix(in srgb, var(--header) 80%, var(--accent));
    --row-mark-base: color-mix(in srgb, var(--header) 40%, #ffffff);
    --accent: #51abda;
    --accent-strong: #7cc4ea;
    --on-accent: #0a1422;
    --link: #7cc4ea;
    --bg: #0a1422;
    --surface: #111f33;
    --surface-2: #1a2b44;
    --text: #eef3f9;
    --muted: #9fb0c6;
    --border: #263a57;
    --focus: #7cc4ea;
    --ok: #4ade80;
    --ok-bg: #12301d;
    --warn: #fbbf24;
    --warn-bg: #3a2c09;
    --bad: #f87171;
    --bad-bg: #3d1414;
    --info-bg: #172443;
    --info: #a5c0ff;
    --shadow: none;
    color-scheme: dark;
}

/* ---------- brand "wiehl" (white label): gray of the footer on feuerwehr-wiehl.de ---------- */

:root[data-brand="wiehl"] {
    --header: #434243;
    --accent: #434243;
    --accent-strong: #2b2a2b;
    --on-accent: #ffffff;
    --link: #434243;
    --bg: #f4f4f5;
    --surface: #ffffff;
    --surface-2: #f0f0f2;
    --text: #18181b;
    --muted: #5f5f68;
    --border: #d9d9de;
    --focus: #1d4ed8;
}

@media (prefers-color-scheme: dark) {
    :root[data-brand="wiehl"]:not([data-theme="light"]) {
        --header: #434243;
        --accent: #d9d9d9;
        --accent-strong: #ffffff;
        --on-accent: #18181b;
        --link: #e4e4e7;
        --bg: #101012;
        --surface: #1b1b1f;
        --surface-2: #26262b;
        --text: #f1f1f3;
        --muted: #a5a5ae;
        --border: #34343b;
        --focus: #7aa2ff;
    }
}

:root[data-brand="wiehl"][data-theme="dark"] {
    --header: #434243;
    --accent: #d9d9d9;
    --accent-strong: #ffffff;
    --on-accent: #18181b;
    --link: #e4e4e7;
    --bg: #101012;
    --surface: #1b1b1f;
    --surface-2: #26262b;
    --text: #f1f1f3;
    --muted: #a5a5ae;
    --border: #34343b;
    --focus: #7aa2ff;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.has-nav { padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); }

a { color: var(--link); text-underline-offset: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.1rem; }
h2 small { font-weight: normal; color: var(--muted); font-size: .85rem; }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

[hidden] { display: none !important; }

.icon {
    width: 1.25em; height: 1.25em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: -0.25em;
}

/* ---------- top bar ---------- */

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
    background: var(--header); color: var(--header-text);
    /* separates the bar from card titles of the same color scrolling below it */
    border-bottom: 1px solid rgb(255 255 255 / .35);
    box-shadow: 0 2px 6px rgb(0 0 0 / .2);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--header-text) !important; text-decoration: none; min-width: 0; }
.brand-logo { display: block; width: auto; height: 30px; flex: none; }
:root[data-brand="flow"] .brand-logo { height: 38px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-text strong { letter-spacing: .08em; }
.brand-text small { font-size: .72rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user {
    display: grid; place-items: center; width: var(--tap); height: var(--tap); margin-right: -8px;
    color: var(--header-text) !important; border-radius: 50%;
}

/* ---------- layout ----------
   One pattern for every page: only the page head (title, optional subline,
   status badge) sits on the background, all content is in cards. Every card
   starts with a title bar like the top bar (header color, light text);
   actions of the card go to the right of the title (.card-head). */

.container { max-width: 760px; margin: 0 auto; padding: 16px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head > div { min-width: 0; }
.page-title { font-size: 1.45rem; margin: 0; overflow-wrap: anywhere; }
.page-sub { margin: 4px 0 0; color: var(--muted); }
.page-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; flex: none; }

.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; margin: .25em 0; }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
/* card title: plain h2 as the first heading, or .card-head with actions;
   a bar across the top of the card, inside its 1px border */
.card > h2:first-of-type, .card-head {
    margin: -16px -16px 14px; padding: 12px 16px;
    background: var(--title-bg); color: var(--header-text);
    border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}
.card > h2:first-of-type, .card-head > h2 { font-size: 1.05rem; }
/* title additions: a short counter stays inline as <small>, longer text goes
   to its own line below the title as .card-sub */
.card > h2:first-of-type small, .card-head > h2 small { color: inherit; opacity: .8; }
.card-sub { display: block; margin-top: 2px; font-size: .85rem; font-weight: normal; opacity: .8; }
/* a card that is only its title bar (e.g. just an action) */
.card > h2:first-of-type:last-child, .card > .card-head:last-child { margin-bottom: -16px; border-radius: calc(var(--radius) - 1px); }
/* title left, actions right: the title wraps in its own column, the actions
   are segments of the bar, full height and flush with its edges, set off by
   a divider and a lighter tint. The bar is as high as its title. */
.card-head { display: flex; align-items: stretch; padding: 0; overflow: hidden; }
.card-head > h2 { flex: 1 1 auto; margin: 0; min-width: 0; padding: 12px 16px; color: inherit; }
.card-head > .btn, .card-head > form, .card-actions { flex: none; display: flex; margin: 0; }
/* text at the top, level with the first line of a wrapped title (same top
   padding and line height as the title, 1.05rem * 1.25) */
.card-head .btn {
    min-height: 0; margin: 0; padding: 12px 16px 0; align-items: flex-start; font-size: .9rem; line-height: 1.3125rem;
    border: 0; border-left: 1px solid rgb(255 255 255 / .25); border-radius: 0;
    background: var(--action-bg); color: var(--header-text) !important;
}
.card-head .btn:hover { background: var(--action-hover); }
.card-head .btn:focus-visible { outline-offset: -3px; }
.card-head .btn-warning { background: var(--warn-bg); color: var(--warn) !important; }
.card-head .btn-warning:hover { background: var(--warn-bg); filter: brightness(1.06); }

.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 0; }

.grid-2 { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- flash ---------- */

.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 12px; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: currentColor; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: currentColor; }
.flash-info { background: var(--info-bg); color: var(--info); border-color: currentColor; }

/* ---------- buttons ---------- */

/* three roles, one height (40px):
   - main action (.btn-primary): filled in the tone of the title bar buttons
   - everything else (.btn, .btn-secondary): outline in the text color
   - danger (.btn-danger): outline in red
   .btn-warning only for "Mangel melden", .btn-large only for finishing an
   inspection; .btn-small just has less padding at the sides */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 16px;
    border: 1px solid color-mix(in srgb, var(--text) 35%, transparent); border-radius: 10px;
    background: transparent; color: var(--text) !important;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn:where(:not(.btn-primary, .btn-warning)):hover { background: var(--row-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--action-bg); border-color: var(--action-bg); color: var(--header-text) !important; }
.btn-primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn-warning { background: var(--warn-bg); color: var(--warn) !important; border-color: currentColor; }
.btn-danger { color: var(--bad) !important; border-color: currentColor; }
.btn-small { padding: 8px 12px; }
.btn-large { min-height: 56px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.linklike {
    display: flex; align-items: center; gap: 12px; width: 100%;
    background: none; border: 0; padding: 12px 16px; font: inherit; color: var(--text); cursor: pointer; text-align: left;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
/* buttons of a form at the end of a card: a footer set off by a line, the
   main action (first in the markup) on the right */
.card > form:last-child > .actions:last-child, form.card > .actions:last-child,
.card > .actions:last-child {
    flex-direction: row-reverse; justify-content: flex-start;
    margin: 16px -16px -16px; padding: 12px 16px; border-top: 1px solid var(--border);
}

/* ---------- forms ---------- */

/* forms: small gray labels above lighter fields; text in the fields has the
   size of the page (15px, the iOS zoom on focus is turned off in app.js) */
.form label { display: block; margin: 0 0 12px; font-size: .85rem; color: var(--muted); }
.form label.btn { display: inline-flex; margin: 0; font-size: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"],
input[type="search"], input[type="date"], select, textarea {
    display: block; width: 100%; min-height: 40px; margin-top: 4px; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: normal; font-size: .9375rem;
}
textarea { min-height: 72px; resize: vertical; }
.form label.check, label.check {
    display: flex; align-items: center; gap: 10px; font-weight: normal; font-size: .9375rem; color: var(--text); min-height: 40px; margin: 0 0 4px;
}
label.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
label.check.small { min-height: 36px; font-size: .92rem; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.form legend { font-size: .85rem; font-weight: normal; color: var(--muted); }
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-top: 12px; }
.form-inline label { flex: 1 1 180px; margin-bottom: 0; }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 8px; }

.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.filter select, .filter input { margin: 0; flex: 1 1 160px; width: auto; }
.filter form { flex: 1 1 200px; margin: 0; }

/* ---------- lists ---------- */

/* lists: rows across the full card width, each with a 4px mark on its left
   edge (every second one lighter) and a 2px gap to the next, so the entries
   read as a list; the same for timeline, audit, results, items, sites */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { margin: 0 -16px; }
.list-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 12px 16px; min-height: 56px; color: inherit !important; text-decoration: none;
}
/* clickable rows: a faint arrow on the right, the same for every list */
a.list-item { position: relative; padding-right: 36px; }
a.list-item::after {
    content: ""; position: absolute; top: 50%; right: 12px; width: 18px; height: 18px; margin-top: -9px;
    background: currentColor; opacity: .3; pointer-events: none;
    -webkit-mask: var(--chevron) center / contain no-repeat; mask: var(--chevron) center / contain no-repeat;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E");
}
a.list-item:hover::after { opacity: .55; }
/* on the row, not the link, so the background does not cover the mark */
.list > li:has(> a.list-item:hover), .list > li:has(> a.list-item:active) { background: var(--row-hover); }
/* the text takes the space left by the side and wraps, the side never moves
   to a line of its own */
.list-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 0; gap: 2px; }
.list-main strong { overflow-wrap: anywhere; }
.list-main small { color: var(--muted); font-size: .85rem; }
.list-main > .badge { align-self: flex-start; margin-top: 4px; }
.list-side { display: flex; align-items: center; gap: 6px; flex: none; color: var(--muted); }
/* badges next to the title, in the first line of the row */
.list-side-top { align-self: flex-start; }
.list-item.inactive { opacity: .55; }

.list > li, .result, .item-list > li, .site-edit, .timeline li, .audit li { box-shadow: inset 4px 0 0 var(--row-mark); }
.list > li:nth-child(even), .result:nth-child(even), .item-list > li:nth-child(even),
.site-edit:nth-of-type(even), .timeline li:nth-child(even), .audit li:nth-child(even) { box-shadow: inset 4px 0 0 var(--row-mark-alt); }
.list > li + li, .result + .result, .item-list > li + li, .site-edit + .site-edit,
.timeline li + li, .audit li + li { margin-top: 2px; }

.assignment-edit { flex-basis: 100%; }
.assignment-edit summary { color: var(--muted); font-size: .9rem; cursor: pointer; }

/* form opened by an action in the title bar: shown when its link is followed
   (#id), or always with .is-open; "Abbrechen" links back to the card */
.reveal { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); scroll-margin-top: 72px; }
.card-head + .reveal { margin-top: 0; padding-top: 0; border-top: 0; }
.reveal:not(:target):not(.is-open) { display: none; }
.stock-form label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stock-form input[type="number"] { width: 6em; flex: none; margin-top: 0; text-align: right; }

.plain { padding-left: 1.2em; margin: 0; }

.chips { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.chips a { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); text-decoration: none; font-size: .9rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; margin: 0 0 12px; overflow-x: auto; }
.tabs a {
    padding: 10px 16px; border-radius: 999px; text-decoration: none; color: var(--text) !important;
    background: var(--surface); border: 1px solid var(--border); white-space: nowrap;
}
.tabs a[aria-current="page"] { background: var(--action-bg); border-color: var(--action-bg); color: var(--header-text) !important; }

.pager { display: flex; justify-content: space-between; gap: 8px; margin: 12px 0; }

/* ---------- badges, status ---------- */

.badge {
    display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600;
    background: var(--surface-2); color: var(--text); white-space: nowrap; border: 1px solid var(--border);
}
.urgency-low { background: var(--surface-2); }
.urgency-medium { background: var(--info-bg); color: var(--info); }
.urgency-high { background: var(--warn-bg); color: var(--warn); }
.urgency-critical { background: var(--bad); color: #fff; border-color: var(--bad); }
.dstatus-open { background: var(--bad-bg); color: var(--bad); }
.dstatus-in_progress { background: var(--warn-bg); color: var(--warn); }
.dstatus-resolved { background: var(--ok-bg); color: var(--ok); }
.dstatus-rejected { opacity: .8; }
.due-overdue { background: var(--bad-bg); color: var(--bad); }
.due-soon { background: var(--warn-bg); color: var(--warn); }
.due-ok { background: var(--ok-bg); color: var(--ok); }
.result-ok { background: var(--ok-bg); color: var(--ok); }
.result-defects { background: var(--bad-bg); color: var(--bad); }
/* colored badges: edge in the muted status color, like the stat tiles */
.urgency-medium, .urgency-high,
.dstatus-open, .dstatus-in_progress, .dstatus-resolved,
.due-overdue, .due-soon, .due-ok,
.result-ok, .result-defects { border-color: color-mix(in srgb, currentColor 35%, transparent); }

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.status .dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; }
.status-ready { color: var(--ok); }
.status-limited { color: var(--warn); }
.status-out_of_service { color: var(--bad); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.stat {
    display: flex; flex-direction: column; align-items: center; padding: 12px 6px;
    border-radius: var(--radius); text-decoration: none; box-shadow: var(--shadow);
    /* edge in the muted status color, so the tiles sit like the cards */
    border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
}
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .8rem; text-align: center; }
.stat-ready { background: var(--ok-bg); color: var(--ok) !important; }
.stat-limited { background: var(--warn-bg); color: var(--warn) !important; }
.stat-out_of_service { background: var(--bad-bg); color: var(--bad) !important; }

/* ---------- bottom navigation ---------- */

.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav > a, .navmenu > summary {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted) !important; text-decoration: none; font-size: .72rem; cursor: pointer;
    list-style: none; -webkit-tap-highlight-color: transparent; height: var(--nav-h);
}
.navmenu > summary::-webkit-details-marker { display: none; }
.bottomnav .icon { width: 24px; height: 24px; }
.bottomnav > a[aria-current="page"] { color: var(--accent) !important; font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
.navmenu[open] > summary { color: var(--accent) !important; }
.navmenu-panel {
    position: fixed; right: 8px; left: 8px; bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
    max-height: 70vh; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 8px 32px rgb(0 0 0 / .25); padding: 8px 0;
}
@media (min-width: 560px) { .navmenu-panel { left: auto; width: 320px; } }
.navmenu-panel a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text) !important; text-decoration: none; }
.navmenu-panel a:active, .linklike:active { background: var(--surface-2); }
.navmenu-head { margin: 8px 16px 2px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

@media (min-width: 900px) {
    .bottomnav { max-width: 760px; margin: 0 auto; border: 1px solid var(--border); border-bottom: 0; border-radius: 16px 16px 0 0; }
}

/* ---------- auth ---------- */

.auth { max-width: 420px; margin: 24px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 20px; }
.auth > h1 {
    font-size: 1.2rem; background: var(--title-bg); color: var(--header-text);
    margin: 0 -20px 16px; padding: 12px 20px;
}
.auth > h1:first-child { margin-top: -24px; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.auth-brand + h1 { margin-top: -20px; }
/* white logo on a panel in header color */
.auth-brand {
    margin: -24px -20px 20px; padding: 28px 24px 24px;
    background: var(--header); border-radius: var(--radius) var(--radius) 0 0;
}
.auth-brand img { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; }
/* wiehl: color logo, needs a white panel in light and dark mode */
:root[data-brand="wiehl"] .auth-brand { background: #ffffff; border-bottom: 1px solid var(--border); }

/* ---------- inspection ---------- */

.inspection-head {
    position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 10;
    background: var(--bg); padding: 8px 0; margin: -8px 0 8px;
}
.inspection-head .page-head { margin-bottom: 8px; }
.progress { display: flex; align-items: center; gap: 10px; }
.progress progress { flex: 1; height: 10px; border-radius: 99px; overflow: hidden; appearance: none; border: 0; background: var(--surface-2); }
.progress progress::-webkit-progress-bar { background: var(--surface-2); }
.progress progress::-webkit-progress-value { background: var(--ok); }
.progress progress::-moz-progress-bar { background: var(--ok); }
.progress-text { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.save-state { min-height: 1.2em; margin: 2px 0 0; font-size: .8rem; color: var(--muted); }
.save-state.is-error { color: var(--bad); font-weight: 600; }

/* one card per compartment, the check items are rows with a status stripe
   on the left edge of the card */
.check-group { padding-bottom: 0; overflow: hidden; }
.check-item {
    margin: 0 -16px; padding: 14px 16px 16px 12px;
    border-left: 4px solid var(--border);
}
.check-item + .check-item { border-top: 1px solid var(--border); }
.check-group > h2:first-of-type { margin-bottom: 0; }
.check-item.is-answered { border-left-color: var(--ok); }
.check-item.is-defect { border-left-color: var(--bad); }
.check-item legend { float: left; width: 100%; font-size: 1.02rem; margin-bottom: 8px; }
.check-item legend + * { clear: both; }
.qty, .optional { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.check-item input[type="text"], .check-item textarea { margin-top: 0; }

.toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; clear: both; }
.toggle label, .urgency label { position: relative; display: block; margin: 0; }
.toggle input, .urgency input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle span {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 56px; border-radius: 10px; border: 2px solid var(--border); font-weight: 700; background: var(--surface-2);
}
.toggle-good input:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.toggle-bad input:checked + span { background: var(--bad); border-color: var(--bad); color: #fff; }
.toggle input:focus-visible + span, .urgency input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.defect-panel { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.defect-panel label { display: block; font-weight: 600; margin-bottom: 10px; }
.urgency { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.urgency span {
    display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px;
    border-radius: 10px; border: 2px solid var(--border); font-size: .85rem; font-weight: 600; text-align: center;
}
.urgency .urgency-low input:checked + span { background: var(--surface-2); border-color: var(--text); }
.urgency .urgency-medium input:checked + span { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.urgency .urgency-high input:checked + span { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.urgency .urgency-critical input:checked + span { background: var(--bad); border-color: var(--bad); color: #fff; }
.urgency label.urgency-low, .urgency label.urgency-medium, .urgency label.urgency-high, .urgency label.urgency-critical {
    background: none; border: 0; padding: 0; color: inherit;
}

.photos { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.photo-thumb img { display: block; width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.photo-add { cursor: pointer; }
.photo-pending { opacity: .5; }

.result-list { list-style: none; padding: 0; margin: 0; }
.result-list .group-title { margin: 16px 0 6px; }
.result-list .group-title:first-child { margin-top: 4px; }
.result { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0 -16px; padding: 10px 16px; }
.result-value { font-weight: 700; color: var(--ok); justify-self: end; text-align: right; }
.result.is-defect .result-value { color: var(--bad); }
.result-comment, .result-defect, .result .photos { grid-column: 1 / -1; }
/* badges of the reported defect: right column, below the value; the comment
   then stays left of them */
.result-tags { grid-column: 2; grid-row: 2; display: flex; gap: 6px; justify-self: end; align-self: start; }
.result:has(.result-tags) .result-comment { grid-column: 1; grid-row: 2; }
.result-comment { color: var(--muted); font-size: .92rem; }

/* ---------- template editor ---------- */

.item-list { list-style: none; padding: 0; margin: 0 0 12px; counter-reset: item; }
.item-list > li { margin: 0 -16px; padding: 6px 16px; counter-increment: item; }
.item-list summary::before { content: counter(item) "."; flex: none; min-width: 1.8em; color: var(--muted); }
.item-list summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.item-title { display: flex; flex-direction: column; }
.item-title small { color: var(--muted); }
.item-list form { margin-top: 10px; }
.site-edit { margin: 0 -16px; padding: 8px 16px; }
.site-edit summary { cursor: pointer; min-height: 40px; }

/* ---------- timeline, audit ---------- */

.timeline, .audit { list-style: none; padding: 0; margin: 0 0 16px; }
.timeline li, .audit li { display: flex; flex-direction: column; gap: 2px; margin: 0 -16px; padding: 10px 16px; }
.timeline-meta, .audit-meta { font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.timeline-what { font-weight: 600; }
.timeline-comment { white-space: normal; }
.audit code { font-size: .78rem; background: var(--surface-2); padding: 0 6px; border-radius: 4px; }
.audit pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; background: var(--surface-2); padding: 8px; border-radius: 8px; margin: 4px 0; }
.audit details summary { cursor: pointer; font-size: .85rem; color: var(--muted); }

/* ---------- document ---------- */

.document { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.document-head { display: flex; flex-direction: column; gap: 12px; border-bottom: 2px solid var(--accent); padding-bottom: 12px; margin-bottom: 16px; }
/* white paper behind the logo, also in dark mode on screen */
.document-head img { width: 240px; height: auto; background: #fff; border-radius: 6px; padding: 6px; box-sizing: content-box; }
.document h1 { font-size: 1.35rem; }
.document h2 { margin-top: 24px; }
.document h3 { font-size: 1rem; margin-top: 18px; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; display: block; overflow-x: auto; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }

/* ---------- QR labels ---------- */

.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.label {
    margin: 0; padding: 10px; background: #fff; color: #000; border: 1px dashed #999; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; text-align: center; break-inside: avoid;
}
.label .qr { width: 100%; max-width: 140px; aspect-ratio: 1; }
.label .qr svg { width: 100%; height: auto; display: block; }
.label figcaption { display: flex; flex-direction: column; margin-top: 6px; line-height: 1.25; }
.label small { font-size: .72rem; color: #333; }
.label .label-brand { color: var(--accent); font-weight: 700; margin-top: 2px; }

/* ---------- print ---------- */

@media print {
    :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --border: #bbb; color-scheme: light; }
    body { background: #fff; padding: 0 !important; font-size: 11pt; }
    .topbar, .bottomnav, .no-print, .flash { display: none !important; }
    .container { max-width: none; padding: 0; }
    .document { border: 0; padding: 0; }
    .card > h2:first-of-type, .card-head, .auth > h1 { background: none; color: var(--text); border-bottom: 1px solid var(--border); }
    .labels-card { border: 0; padding: 0; box-shadow: none; background: none; }
    .labels { grid-template-columns: repeat(4, 1fr); gap: 4mm; }
    .label { border: 1px dashed #999; }
    a { color: #000; text-decoration: none; }
}
