/*
 * MoniMark app design system.
 * Same tokens as www.monimark.eu (web/app/globals.css, web/DESIGN.md), the only place colors live.
 * Palette law: bordó = action and alarm, green = confirmed watch/safety, navy = ink and neutral states.
 * Structure: ruled registers, not cards. Calm: 4 type sizes, 2 weights, status = dot + word, no tints, no glyph tiles, almost no motion.
 */

/* ---------- Fonts (self-hosted, 400 and 600 only) ---------- */
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/fira-sans-latin-ext-400.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, 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.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+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-latin-ext-600.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, 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.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }


/* ---------- Tokens ---------- */
:root {
  --brand: #991f47;
  --brand-strong: #7d1839;
  --brand-tint: #f9eef2;
  --brand-tint-strong: #f3dfe6;
  --ink: #0b0146;
  --ink-soft: #5a5675;
  --ink-tint: #ecebf3;
  --safe-strong: #0f7a2b;
  --safe-deep: #0c6624;
  --safe-tint: #e8f4eb;
  --text: #474747;
  --paper: #ffffff;
  --mist: #f5f5f5;
  --line: #e4e2ec;
  --line-strong: #cfcbe0;
  --hover-row: #fafafc;

  /* four sizes, two weights (400 / 600) */
  --font: 'Fira Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --t-caption: 0.78125rem;  /* 12.5px: meta lines, table headers, hints */
  --t-body: 0.875rem;       /* 14px: text, tables, controls */
  --t-section: 1rem;        /* 16px: section headings, totals */
  --t-h1: 1.5rem;           /* 24px: page title */

  --r-control: 0.5rem;
  --r-panel: 0.875rem;
  --shadow-contact: 0 1px 2px rgb(11 1 70 / 0.12);
  --shadow-pop: 0 1px 2px rgb(11 1 70 / 0.08), 0 12px 32px -12px rgb(11 1 70 / 0.3);
  --shadow-panel: 0 1px 2px rgb(11 1 70 / 0.06), 0 24px 48px -24px rgb(11 1 70 / 0.28);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --rail: 15rem;
  --topbar: 3.5rem;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--ink-soft) var(--mist); scroll-padding-top: 5rem; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font-family: var(--font); font-size: var(--t-body); line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { color: var(--ink); margin: 0; text-wrap: balance; line-height: 1.25; font-weight: 600; font-size: var(--t-section); }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; }
strong, b { color: var(--ink); font-weight: 600; }
a { color: var(--brand); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
::selection { background: var(--brand); color: var(--paper); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, textarea { caret-color: var(--brand); }
table { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); }
.small { font-size: var(--t-body); }
.caption { font-size: var(--t-caption); }
.ink { color: var(--ink); }
.stack { display: grid; gap: 1rem; align-content: start; }
.stack-sm { display: grid; gap: 0.5rem; align-content: start; }
.stack-lg { display: grid; gap: 2rem; align-content: start; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.icon { width: 1.125rem; height: 1.125rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-xs { width: 0.875rem; height: 0.875rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.5rem; padding: 0.5rem 1rem; border-radius: var(--r-control);
  font-weight: 600; font-size: var(--t-body); line-height: 1.2; text-decoration: none; cursor: pointer;
  border: 0; white-space: nowrap; background: transparent; color: var(--ink);
  transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn-primary { background: var(--brand); color: var(--paper); }
.btn-quiet { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost { background: transparent; color: var(--ink); padding-inline: 0.75rem; }
.btn-safe { background: var(--safe-strong); color: var(--paper); }
.btn-danger { background: var(--paper); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand-tint-strong); }
.btn-sm { min-height: 2.125rem; padding: 0.375rem 0.75rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--brand-strong); }
  .btn-quiet:hover { box-shadow: inset 0 0 0 1px var(--ink-soft); }
  .btn-ghost:hover { background: var(--ink-tint); }
  .btn-safe:hover { background: var(--safe-deep); }
  .btn-danger:hover { background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
}
.spin { display: inline-block; width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: mm-spin 700ms linear infinite; flex: none; }
@keyframes mm-spin { to { transform: rotate(360deg); } }
/* submit: blocked at once (is-busy), spinner only when the request takes longer than 300 ms (is-loading) */
.btn.is-busy, .btn.is-loading { pointer-events: none; }
.btn.is-busy { opacity: 0.75; }
.link-arrow { display: inline-flex; align-items: center; gap: 0.375rem; color: var(--brand); font-weight: 600; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .link-arrow:hover { text-decoration: underline; } }
.link-plain { color: var(--ink); text-decoration: none; font-weight: 600; }
.link-plain:hover { color: var(--brand); text-decoration: underline; }
.link-quiet { color: var(--ink); text-decoration: none; }
.link-quiet:hover { text-decoration: underline; }
.ico-btn { width: 2.25rem; height: 2.25rem; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--ink-soft); border-radius: var(--r-control); cursor: pointer; text-decoration: none; transition: background-color 120ms ease, color 120ms ease; }
@media (hover: hover) and (pointer: fine) { .ico-btn:hover { background: var(--ink-tint); color: var(--ink); } .ico-btn.is-danger:hover { background: var(--brand-tint); color: var(--brand); } }

/* ---------- Forms ---------- */
.field { display: grid; gap: 0.375rem; min-width: 0; align-content: start; }
.field > label, .field .label { font-size: var(--t-body); font-weight: 600; color: var(--ink); }
.field .optional { font-weight: 400; color: var(--ink-soft); }
.hint { font-size: var(--t-caption); color: var(--ink-soft); line-height: 1.45; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]), .field select, .field textarea {
  width: 100%; min-height: 2.5rem; padding: 0.5rem 0.75rem; border-radius: var(--r-control);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field textarea, textarea.input { min-height: 7rem; resize: vertical; line-height: 1.5; }
.field select, select.input { appearance: none; padding-right: 2.25rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a5675' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.625rem center; background-size: 1.125rem; }
.field select[multiple], select.input[multiple] { background-image: none; padding-right: 0.75rem; min-height: 8rem; }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--ink-soft); opacity: 0.75; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-strong); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-tint); }
.input[disabled], .field input[disabled], .field select[disabled] { background: var(--mist); color: var(--ink-soft); }
.field.invalid .input, .field.invalid input, .field.invalid select, .field.invalid textarea, .input.is-invalid, .field.invalid input:focus { border-color: var(--brand); }
.field input[type=date] { height: 2.5rem; }
.err, .errorlist { font-size: var(--t-caption); color: var(--brand); display: flex; gap: 0.375rem; align-items: center; list-style: none; padding: 0; margin: 0; }
.form-grid { display: grid; gap: 1rem 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; padding-top: 1.25rem; border-top: 1px solid var(--line); margin-top: 0.5rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row3 { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
@media (width < 40rem) { .row2, .row3, .form-grid { grid-template-columns: 1fr; } }

/* segmented control: only for a real two- or three-way toggle */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--mist); border-radius: 0.625rem; box-shadow: inset 0 0 0 1px var(--line); flex-wrap: wrap; }
.seg label, .seg a { position: relative; cursor: pointer; text-decoration: none; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.seg span, .seg a {
  display: block; padding: 0.4rem 0.8rem; border-radius: 0.5rem; font-weight: 600; font-size: var(--t-body); color: var(--ink-soft);
  transition: background-color 120ms ease, color 120ms ease;
}
.seg input:checked + span, .seg a[aria-current] { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) { .seg label:hover span, .seg a:not([aria-current]):hover { color: var(--ink); } }

/* filter tabs: radios that look like the one tab style (underline) */
.rtabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.rtabs label { position: relative; cursor: pointer; flex: none; }
.rtabs input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.rtabs span { display: block; padding: 0.5rem 0.75rem; color: var(--ink-soft); white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; transition: color 120ms ease; }
.rtabs input:checked + span { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }
.rtabs input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) { .rtabs label:hover span { color: var(--ink); } }

.check { display: flex; gap: 0.625rem; align-items: flex-start; cursor: pointer; }
.check input[type=checkbox], .check input[type=radio], input.mm-check {
  appearance: none; width: 1.125rem; height: 1.125rem; margin: 0.15rem 0 0; flex: none; border-radius: 0.3rem;
  border: 1.5px solid var(--line-strong); background: var(--paper); display: inline-grid; place-items: center; cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.check input[type=radio] { border-radius: 50%; }
.check input[type=checkbox]::after, input.mm-check::after { content: ""; width: 0.6rem; height: 0.32rem; border: 2px solid var(--paper); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); opacity: 0; }
.check input[type=radio]::after { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--paper); opacity: 0; }
.check input:checked, input.mm-check:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after, input.mm-check:checked::after { opacity: 1; }
.check input:disabled { opacity: 0.5; cursor: not-allowed; }
.switch { position: relative; display: inline-flex; gap: 0.75rem; align-items: center; cursor: pointer; }
.switch input { appearance: none; width: 2.25rem; height: 1.375rem; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; margin: 0; flex: none; transition: background-color 120ms ease; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 1rem; height: 1rem; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow-contact); transition: transform 120ms ease; }
.switch input:checked { background: var(--safe-strong); }
.switch input:checked::after { transform: translateX(0.875rem); }
.switch input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.drop {
  display: flex; align-items: center; gap: 1rem; padding: 0.75rem; border-radius: var(--r-control);
  border: 1px dashed var(--line-strong); background: var(--paper); cursor: pointer; transition: border-color 120ms ease;
}
.drop.over { border-color: var(--ink); }
.drop .thumb { width: 3rem; height: 3rem; border-radius: 0.375rem; background: var(--mist); display: grid; place-items: center; overflow: hidden; color: var(--ink-soft); flex: none; }
.drop .thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--paper); }
.drop b { color: var(--ink); display: block; font-size: var(--t-body); }
.drop small { color: var(--ink-soft); font-size: var(--t-caption); }
/* the mark's logo: upload with a crop box (components/logo_cropper.html, static/js/logo-cropper.js) */
.logo-cropper { display: grid; gap: 0.75rem; min-width: 0; }
.crop { display: grid; gap: 0.5rem; min-width: 0; }
.crop-frame { position: relative; justify-self: start; max-width: calc(100% - 1rem); margin: 0.5rem; line-height: 0; background: var(--mist); box-shadow: 0 0 0 1px var(--line); user-select: none; -webkit-user-select: none; }
.crop-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.crop-shade { position: absolute; box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--paper) 78%, transparent); }
.crop-frame img { display: block; max-width: 100%; height: auto; object-fit: contain; pointer-events: none; }
.crop-box { position: absolute; cursor: move; touch-action: none; box-shadow: 0 0 0 1px var(--ink), 0 0 0 2px var(--paper); }
.crop-box:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.crop-h { position: absolute; width: 0.75rem; height: 0.75rem; background: var(--paper); box-shadow: inset 0 0 0 1px var(--ink); touch-action: none; }
.crop-h::before { content: ""; position: absolute; inset: -0.5rem; }
.crop-h[data-h="nw"] { left: -0.375rem; top: -0.375rem; cursor: nwse-resize; }
.crop-h[data-h="ne"] { right: -0.375rem; top: -0.375rem; cursor: nesw-resize; }
.crop-h[data-h="sw"] { left: -0.375rem; bottom: -0.375rem; cursor: nesw-resize; }
.crop-h[data-h="se"] { right: -0.375rem; bottom: -0.375rem; cursor: nwse-resize; }
@media (pointer: coarse) { .crop-h { width: 1.125rem; height: 1.125rem; } .crop-h[data-h="nw"], .crop-h[data-h="sw"] { left: -0.5625rem; } .crop-h[data-h="ne"], .crop-h[data-h="se"] { right: -0.5625rem; } .crop-h[data-h="nw"], .crop-h[data-h="ne"] { top: -0.5625rem; } .crop-h[data-h="sw"], .crop-h[data-h="se"] { bottom: -0.5625rem; } }
.crop-bar { display: grid; gap: 0.25rem; max-width: 40rem; }
.crop-bar [data-crop-readout] { font-variant-numeric: tabular-nums; }

/* ---------- Status (dot + word), badges, risk ---------- */
/* .chip is the status of a row: a 6px dot and a word. No pill, no fill, no icon. */
.chip { display: inline-flex; align-items: center; gap: 0.45rem; font-size: var(--t-body); font-weight: 400; color: var(--ink); white-space: nowrap; line-height: 1.3; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); flex: none; }
.chip .icon { display: none; }
.chip-alarm::before, .chip-warn::before { background: var(--brand); }
.chip-watch::before, .chip-ok::before { background: var(--safe-strong); }
.chip-wait::before, .chip-neutral::before, .chip-cart::before { background: var(--ink-soft); }
.chip-done, .chip-off { color: var(--ink-soft); }
.chip-done::before, .chip-off::before { background: var(--line-strong); }
/* regions and similar lists are plain text: "Česko, EU+" */
.tags { display: inline; }
.tag { display: inline; font: inherit; color: inherit; white-space: nowrap; }
.tag + .tag::before { content: ", "; white-space: normal; }
.count { min-width: 1.25rem; height: 1.25rem; padding: 0 0.375rem; border-radius: 999px; background: var(--brand); color: var(--paper); font-size: var(--t-caption); font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; line-height: 1; }
.count-neutral { background: var(--line); color: var(--ink); }
/* risk is a word: high in bordó, medium in ink, the rest ink-soft */
.risk { font-size: var(--t-body); font-weight: 400; white-space: nowrap; color: var(--ink-soft); }
.risk.r1 { color: var(--brand); font-weight: 600; }
.risk.r2 { color: var(--ink); }

/* ---------- App shell ---------- */
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; border-radius: var(--r-control); font-weight: 600; text-decoration: none; }
.skip:focus { top: 1rem; }
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100dvh; }
.rail-col { background: var(--mist); border-right: 1px solid var(--line); min-width: 0; }
.rail { display: flex; flex-direction: column; padding: 1.25rem 0.75rem 1rem max(0.75rem, env(safe-area-inset-left, 0px)); position: sticky; top: 0; height: 100dvh; overflow-y: auto; scrollbar-width: thin; }
.logo { display: block; }
.logo img { display: block; height: 2.25rem; width: auto; }
.rail .logo { padding: 0 0.5rem 1.5rem; }
.nav { display: grid; gap: 1px; }
.nav-label { font-size: var(--t-caption); font-weight: 600; color: var(--ink-soft); padding: 1.25rem 0.625rem 0.375rem; }
.nav a {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.625rem; border-radius: var(--r-control);
  color: var(--ink); text-decoration: none; font-weight: 400; font-size: var(--t-body);
  transition: background-color 120ms ease;
}
.nav a .icon { color: var(--ink-soft); }
.nav a .count { margin-left: auto; }
.nav a[aria-current="page"] { background: var(--ink-tint); font-weight: 600; }
.nav a[aria-current="page"] .icon { color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .nav a:not([aria-current="page"]):hover { background: var(--hover-row); } }
.rail-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 1rem 0.5rem 0; display: grid; gap: 0.75rem; }
.who { display: flex; gap: 0.625rem; align-items: center; text-decoration: none; color: inherit; min-width: 0; }
.who > span:last-child { min-width: 0; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-weight: 600; font-size: var(--t-caption); flex: none; text-transform: uppercase; }
.who b { display: block; color: var(--ink); font-size: var(--t-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { display: block; color: var(--ink-soft); font-size: var(--t-caption); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.impersonate { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 0.625rem max(16px, env(safe-area-inset-right, 0px)) 0.625rem max(16px, env(safe-area-inset-left, 0px)); background: var(--ink); color: var(--paper); font-size: var(--t-body); }
.impersonate b { color: var(--paper); }
.impersonate .btn { min-height: 2rem; }

.topbar { display: none; }
.main { min-width: 0; width: 100%; max-width: 82rem; padding: 2rem 2.5rem 5rem; }
.main:focus { outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { font-size: var(--t-h1); letter-spacing: -0.01em; }
.page-head p { margin-top: 0.375rem; max-width: 44rem; color: var(--ink-soft); }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.crumb { font-size: var(--t-body); margin-bottom: 0.75rem; display: inline-flex; gap: 0.375rem; align-items: center; color: var(--ink-soft); text-decoration: none; }
.crumb .icon { transform: rotate(180deg); }
.crumb:hover { color: var(--ink); }
.section { padding: 1.25rem 0 2rem; border-top: 1px solid var(--line); display: grid; gap: 1rem; }
.section:first-of-type { border-top-color: var(--ink); }
.section > h2, .section-title { font-size: var(--t-section); display: flex; gap: 0.75rem; align-items: center; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 2.5rem; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.sticky-side { position: sticky; top: 1.5rem; }

/* ---------- Toolbar, search, filters ---------- */
.toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.75rem; }
.toolbar .grow { flex: 1 1 14rem; }
.search { position: relative; flex: 1 1 14rem; max-width: 24rem; }
.search .icon { position: absolute; left: 0.75rem; top: 50%; translate: 0 -50%; color: var(--ink-soft); pointer-events: none; }
.search .input, .search input { padding-left: 2.5rem; }
.toolbar select.input, .toolbar .input { width: auto; min-width: 10rem; }

/* ---------- Register (ruled table) ---------- */
.reg-wrap { border-top: 1px solid var(--ink); overflow-x: auto; }
.reg { width: 100%; border-collapse: collapse; }
.reg th { text-align: left; font-size: var(--t-caption); font-weight: 400; color: var(--ink-soft); padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.reg th.r, .reg td.r { text-align: right; }
.reg td { padding: 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
.reg tr.mark, .reg tr.is-link, .reg tr[data-href] { transition: background-color 120ms ease; }
.reg tr.is-link, .reg tr[data-href], .reg tr.mark[data-expand] { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .reg tr.mark:hover, .reg tr.is-link:hover, .reg tr[data-href]:hover { background: var(--hover-row); } }
.reg tr.mark[aria-expanded="true"] { background: var(--hover-row); }
.reg tr.is-muted td { color: var(--ink-soft); }
.reg tr[data-href]:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 0; }
.tm { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
/* a logo thumbnail only when the mark has an image; word marks are just their name */
.tm-thumb { width: 2rem; height: 2rem; border-radius: 0.25rem; object-fit: contain; flex: none; background: var(--paper); }
.tm-name { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; text-decoration: none; }
a.tm-name:hover { color: var(--brand); text-decoration: underline; }
.tm-meta { font-size: var(--t-caption); color: var(--ink-soft); }
.tm-meta a { color: inherit; }
.td-finding { white-space: nowrap; }
.td-finding a { font-weight: 600; text-decoration: none; }
.td-finding a:hover { text-decoration: underline; }
.caret { color: var(--ink-soft); transition: transform 120ms ease; }
tr[aria-expanded="true"] .caret { transform: rotate(180deg); }
.reg-empty { padding: 2rem 0.75rem; display: grid; gap: 0.75rem; justify-items: start; border-bottom: 1px solid var(--line); }

/* expanding rows (staff tables): grid 0fr -> 1fr, short */
.expand { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 150ms var(--ease-out); }
.expand > .expand-in { overflow: hidden; min-height: 0; opacity: 0; transition: opacity 120ms ease; }
.expand.open { grid-template-rows: 1fr; }
.expand.open > .expand-in { opacity: 1; }
.reg td.detail-cell { padding: 0; border-bottom: 0; }
.reg tr.detail.open td.detail-cell { border-bottom: 1px solid var(--line); }
.detail-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

/* key / value: values in regular ink, not bold */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1.25rem; margin: 0; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.kv dd small { display: block; color: var(--ink-soft); font-size: var(--t-caption); }
.ruled-list { border-top: 1px solid var(--ink); }
.ruled-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 1.25rem; align-items: center; padding: 0.75rem 0.25rem; border-bottom: 1px solid var(--line); }
.ruled-row b { color: var(--ink); display: block; }
.ruled-row small { color: var(--ink-soft); font-size: var(--t-caption); display: block; }

/* staff forms with a list of regions (TMview search, rules) */
.newform { padding: 1.25rem 0.75rem 1.5rem; display: grid; gap: 1.25rem; }
.regionlist { border-top: 1px solid var(--line); }
.regionlist label { display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem; align-items: start; padding: 0.625rem 0.25rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.regionlist .rname { color: var(--ink); display: block; }
.regionlist .rdesc { color: var(--ink-soft); font-size: var(--t-caption); display: block; line-height: 1.4; }
.regionlist .rprice { color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nf-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1rem; border-top: 1px solid var(--line); }
.total b { font-size: var(--t-section); color: var(--ink); font-variant-numeric: tabular-nums; }
.total small { display: block; color: var(--ink-soft); font-size: var(--t-caption); }

/* payment block (QR + details) */
.pay { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2rem; align-items: start; }
.qr { width: 10rem; display: grid; gap: 0.5rem; justify-items: center; }
.qr img { width: 10rem; height: 10rem; image-rendering: pixelated; background: var(--paper); }
.qr small { font-size: var(--t-caption); color: var(--ink-soft); text-align: center; }
.paylist { margin: 0; display: grid; }
.paylist > div { display: grid; grid-template-columns: 9rem minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--line); min-height: 2.75rem; }
.paylist > div:first-child { border-top: 1px solid var(--line); }
.paylist dt { color: var(--ink-soft); }
.paylist dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.copy { font-size: var(--t-caption); font-weight: 600; color: var(--brand); background: transparent; border: 0; cursor: pointer; padding: 0.375rem 0.5rem; border-radius: 0.375rem; transition: background-color 120ms ease; }
@media (hover: hover) and (pointer: fine) { .copy:hover { background: var(--brand-tint); } }

/* summary column (flat, ruled) */
.summary { position: sticky; top: 1.5rem; border-top: 1px solid var(--ink); padding-top: 1.25rem; display: grid; gap: 1rem; }
.summary h2 { font-size: var(--t-section); }
.sum-lines { display: grid; gap: 0.5rem; }
.sum-lines > div { display: flex; justify-content: space-between; gap: 1rem; }
.sum-lines .disc { color: var(--safe-strong); }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.sum-total b { font-size: var(--t-section); color: var(--ink); font-variant-numeric: tabular-nums; }

/* items (checkout, order detail) */
.items { border-top: 1px solid var(--line); }
.item { display: flex; gap: 0.875rem; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.item > div { flex: 1 1 auto; min-width: 0; }
.item .price { color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Finding (comparison) ---------- */
.cmp { width: 100%; border-collapse: collapse; border-top: 1px solid var(--ink); }
.cmp th, .cmp td { padding: 0.75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cmp thead th { font-size: var(--t-caption); color: var(--ink-soft); font-weight: 400; }
.cmp tbody th { color: var(--ink-soft); font-weight: 400; width: 9rem; }
.cmp td { color: var(--ink); overflow-wrap: anywhere; }
.cmp .bigmark { font-size: var(--t-section); font-weight: 600; display: block; }
.cmp .logo-cell img { max-width: 8rem; max-height: 6rem; object-fit: contain; display: block; }
.decide { display: grid; gap: 0.75rem; }
.decide h2 { font-size: var(--t-section); }
.decided { display: grid; gap: 0.375rem; }
.decided small { display: block; color: var(--text); }
.undo { font-size: var(--t-caption); color: var(--ink); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* ---------- Data tables (admin, dense) ---------- */
.tbl-wrap { border-top: 1px solid var(--ink); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-body); }
.tbl th { text-align: left; font-size: var(--t-caption); font-weight: 400; color: var(--ink-soft); padding: 0.55rem 0.625rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--paper); }
.tbl td { padding: 0.6rem 0.625rem; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text); }
.tbl td b, .tbl td strong, .tbl td .strong { color: var(--ink); font-weight: 600; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl tr { transition: background-color 120ms ease; }
@media (hover: hover) and (pointer: fine) { .tbl tbody tr:hover { background: var(--hover-row); } }
.tbl .actions { display: flex; gap: 0.25rem; justify-content: flex-end; white-space: nowrap; }
.tbl img.thumb { width: 2rem; height: 2rem; object-fit: contain; border-radius: 0.25rem; background: var(--paper); }

/* pagination */
.pager { display: flex; gap: 0.25rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding-top: 1rem; }
.pager-links { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.pager a, .pager span.cur { min-width: 2.125rem; height: 2.125rem; padding: 0 0.625rem; display: inline-grid; place-items: center; border-radius: var(--r-control); text-decoration: none; color: var(--ink); font-variant-numeric: tabular-nums; transition: background-color 120ms ease; }
.pager span.cur { background: var(--ink-tint); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .pager a:hover { background: var(--hover-row); } }

/* tabs: the one tab style (underline) */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 0.625rem 0.75rem; color: var(--ink-soft); text-decoration: none; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; transition: color 120ms ease; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }
@media (hover: hover) and (pointer: fine) { .tabs a:not([aria-current]):hover { color: var(--ink); } }

/* notices */
.notice { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; padding: 0.75rem 1rem; border-radius: var(--r-control); background: var(--mist); color: var(--ink); align-items: start; }
.notice .icon { margin-top: 0.1rem; }
.notice-ok { background: var(--safe-tint); color: var(--safe-deep); }
.notice-alarm { background: var(--brand-tint); color: var(--brand-strong); }
.notice b { color: inherit; }

/* empty states: one sentence and, when there is one, the next action */
.empty { padding: 2rem 0; display: grid; justify-items: start; gap: 0.75rem; border-bottom: 1px solid var(--line); }
.empty > .icon { display: none; }
.empty h2, .empty h3 { font-size: var(--t-body); font-weight: 400; color: var(--ink); }
.empty p { max-width: 36rem; color: var(--ink-soft); }
.quiet-line { padding: 0.875rem 0.75rem; color: var(--ink-soft); border-bottom: 1px solid var(--line); }

/* loading: static placeholders, no shimmer */
.skel { display: block; height: 1rem; border-radius: 0.25rem; background: var(--mist); }
.progress { height: 4px; border-radius: 2px; background: var(--ink-tint); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ink); border-radius: 2px; }
.progress.is-done > i { background: var(--safe-strong); }

/* htmx: swaps fade in 120 ms; a region that waits longer than 300 ms dims (mm.js adds .is-pending) */
.htmx-indicator { opacity: 0; transition: opacity 120ms ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-added { opacity: 0; }
.htmx-settling .htmx-added, .htmx-added.htmx-settling { opacity: 1; transition: opacity 120ms ease; }
.is-pending { opacity: 0.6; transition: opacity 120ms ease; pointer-events: none; }
[aria-busy="true"] { cursor: progress; }

/* document panel (paper lying on the page: report sheets, previews) */
.paper { padding: 2rem; border-radius: var(--r-panel); background: var(--paper); box-shadow: var(--shadow-panel); }

/* ---------- Dialog (fades, no scale) ---------- */
dialog.dlg { border: 0; padding: 0; border-radius: var(--r-panel); box-shadow: var(--shadow-pop); width: min(30rem, calc(100vw - 2rem)); color: var(--text); background: var(--paper); opacity: 0; transition: opacity 150ms ease, overlay 150ms allow-discrete, display 150ms allow-discrete; }
dialog.dlg[open] { opacity: 1; }
@starting-style { dialog.dlg[open] { opacity: 0; } }
dialog.dlg::backdrop { background: rgb(11 1 70 / 0.35); }
.dlg-body { padding: 1.5rem; display: grid; gap: 0.75rem; }
.dlg-body h2 { font-size: var(--t-section); }
.dlg-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; padding: 1rem 1.5rem; border-top: 1px solid var(--line); }

/* ---------- Toast (150 ms fade) ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); translate: -50% 0; z-index: 90; display: grid; gap: 0.5rem; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 2rem); }
.toast {
  display: flex; gap: 0.625rem; align-items: center; max-width: 28rem;
  padding: 0.625rem 1rem; border-radius: var(--r-control); background: var(--paper); color: var(--ink); box-shadow: var(--shadow-pop);
  font-size: var(--t-body); pointer-events: auto; opacity: 0; transition: opacity 150ms ease;
}
.toast.show { opacity: 1; }
.toast .icon { color: var(--safe-strong); }
.toast.is-error .icon { color: var(--brand); }

/* ---------- Mobile sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-columns: minmax(0, 20rem) 1fr; visibility: hidden; transition: visibility 0s 180ms; }
.sheet.open { visibility: visible; transition: visibility 0s; }
.sheet-panel { background: var(--mist); padding: calc(1rem + env(safe-area-inset-top, 0px)) 1rem 1rem max(1rem, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 1rem; transform: translateX(-100%); transition: transform 180ms var(--ease-out); box-shadow: var(--shadow-panel); overflow-y: auto; }
.sheet.open .sheet-panel { transform: none; }
.sheet-scrim { background: rgb(11 1 70 / 0.35); opacity: 0; transition: opacity 180ms ease; border: 0; }
.sheet.open .sheet-scrim { opacity: 1; }

/* ---------- Auth layout (one centred column) ---------- */
.auth { min-height: 100dvh; display: grid; }
.auth-form { display: grid; align-content: center; justify-items: center; padding: 3rem max(16px, env(safe-area-inset-right, 0px)) max(3rem, 12dvh) max(16px, env(safe-area-inset-left, 0px)); }
.auth-form > div { width: 100%; max-width: 24rem; display: grid; gap: 1.25rem; }
.auth-form .logo img { height: 2.25rem; }
.auth-form h1 { font-size: var(--t-h1); letter-spacing: -0.01em; margin-top: 1rem; }
.pwrules { list-style: none; margin: 0.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem 1rem; font-size: var(--t-caption); color: var(--ink-soft); }
.pwrules li { display: inline-flex; gap: 0.3rem; align-items: center; transition: color 120ms ease; }
.pwrules li .icon { width: 0.875rem; height: 0.875rem; stroke-width: 2.25; opacity: 0.35; }
.pwrules li.ok { color: var(--safe-strong); }
.pwrules li.ok .icon { opacity: 1; }
.pw { position: relative; }
.pw input { padding-right: 5.5rem !important; }
.pw button { position: absolute; right: 0.375rem; top: 50%; translate: 0 -50%; border: 0; background: transparent; color: var(--ink); font-size: var(--t-caption); font-weight: 600; padding: 0.375rem 0.5rem; border-radius: 0.375rem; cursor: pointer; }
.or { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.75rem; align-items: center; color: var(--ink-soft); font-size: var(--t-caption); }
.or::before, .or::after { content: ""; height: 1px; background: var(--line); }
.btn-google { gap: 0.625rem; }
.btn-google svg { width: 1.125rem; height: 1.125rem; }

/* error pages */
.errpage { min-height: 100dvh; display: grid; place-items: center; padding: 3rem max(16px, env(safe-area-inset-right, 0px)) 3rem max(16px, env(safe-area-inset-left, 0px)); }
.errpage > div { max-width: 32rem; display: grid; gap: 1rem; }
.errpage .code { font-size: var(--t-body); font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; }
.errpage h1 { font-size: var(--t-h1); letter-spacing: -0.01em; }

/* rich text (blog editor previews, legal texts) */
.prose { max-width: 44rem; line-height: 1.65; }
.prose > * + * { margin-top: 0.875rem; }
.prose h2 { font-size: var(--t-section); margin-top: 2rem; }
.prose h3 { font-size: var(--t-body); margin-top: 1.5rem; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose img { border-radius: var(--r-control); }

/* ---------- Responsive ---------- */
@media (width < 75rem) {
  .split { grid-template-columns: minmax(0, 1fr) 18rem; gap: 2rem; }
}
@media (width < 62rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail-col { display: none; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 40;
    align-items: center; justify-content: space-between; gap: 1rem; min-height: var(--topbar);
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  }
  .topbar .logo img { height: 1.875rem; }
  .topbar-actions { display: flex; gap: 0.25rem; align-items: center; }
  .main { padding: 1.5rem max(16px, env(safe-area-inset-right, 0px)) 4rem max(16px, env(safe-area-inset-left, 0px)); }
  .split, .split-wide { grid-template-columns: minmax(0, 1fr); }
  .summary, .sticky-side { position: static; }
}
@media (width < 48rem) {
  /* registers become ruled stacked rows */
  .reg.stack-m thead { display: none; }
  .reg.stack-m, .reg.stack-m tbody { display: block; }
  .reg.stack-m tr.mark { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "tm st" "rg rg" "ck fd"; gap: 0.25rem 0.75rem; padding: 0.75rem 0.25rem; border-bottom: 1px solid var(--line); }
  .reg.stack-m tr.mark td { padding: 0; border: 0; }
  .reg.stack-m td.c-tm { grid-area: tm; }
  .reg.stack-m td.c-st { grid-area: st; justify-self: end; }
  .reg.stack-m td.c-rg { grid-area: rg; }
  .reg.stack-m td.c-ck { grid-area: ck; font-size: var(--t-caption); color: var(--ink-soft); }
  .reg.stack-m td.c-ck:empty { display: none; }
  .reg.stack-m td.c-fd { grid-area: fd; justify-self: end; font-size: var(--t-caption); }
  .reg.stack-m td.c-hide { display: none; }
  .reg.stack-m td[data-label]::before { content: attr(data-label) " "; color: var(--ink-soft); }
  .reg.stack-m tr.detail { display: block; }
  .reg.stack-m tr.detail > td { display: block; }
  .reg-wrap:has(.stack-m) { overflow-x: visible; }
  .newform { padding-inline: 0; }
  .item { flex-wrap: wrap; }
  .item .price { order: 3; flex-basis: 100%; }
  .pay { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .qr { justify-self: center; }
  .paylist > div { grid-template-columns: minmax(0, 1fr) auto; gap: 0.125rem 0.75rem; }
  .paylist dt { grid-column: 1 / -1; }
  .cmp tbody th { width: 6rem; }
  .ruled-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ruled-row .hide-m, .hide-m { display: none; }
  .paper { padding: 1.25rem; }
  .kv { grid-template-columns: minmax(0, 7rem) minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .expand, .expand > .expand-in { transition: none; }
  .sheet-panel { transform: none; transition: none; }
  .sheet-scrim, .toast, dialog.dlg, .htmx-settling .htmx-added, .is-pending { transition: none; }
  .caret, .switch input::after { transition: none; }
  .spin { animation-duration: 1.6s; }
}

/* ---------- Shared fixes ---------- */
/* .sr labels in <th> are absolutely positioned and would escape the scroll box (mobile overflow) */
.tbl-wrap, .reg-wrap { position: relative; }
.toolbar .search .input, .toolbar .search input { width: 100%; min-width: 0; }
.empty .btn .icon { width: 1rem; height: 1rem; color: currentColor; }
.tbl td.detail-cell { padding: 0; border-bottom: 0; }
.tbl tr.detail.open td.detail-cell { border-bottom: 1px solid var(--line); }
.tbl tr[data-expand], .tbl tr[data-href] { cursor: pointer; }
/* labels sharing a row with a link (login "Heslo" + "Zapomenuté heslo?") look like every other label */
.field .row-between > label { font-size: var(--t-body); font-weight: 600; color: var(--ink); }
/* wide admin tables scroll sideways on phones: show that more columns are there */
.tbl-wrap {
  background:
    linear-gradient(to right, var(--paper) 30%, rgb(255 255 255 / 0)) left / 2rem 100% no-repeat local,
    linear-gradient(to left, var(--paper) 30%, rgb(255 255 255 / 0)) right / 2rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgb(11 1 70 / 0.14), transparent) left / 0.75rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgb(11 1 70 / 0.14), transparent) right / 0.75rem 100% no-repeat scroll;
}
.tbl-wrap .tbl th { background: transparent; }

/* ---------- Popovers: date picker (datepicker.js) and rich select (richselect.js) ---------- */
/* one floating surface: paper, hairline border, pop shadow, 120 ms opacity fade, no scale */
.pop { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-pop); color: var(--text); opacity: 0; transition: opacity 120ms ease; z-index: 70; }
.pop.is-open { opacity: 1; }
.dp, .rs { position: relative; min-width: 0; }
.dp { display: flex; align-items: stretch; }
.dp .dp-text { flex: 1 1 auto; min-width: 0; padding-right: 2.5rem; font-variant-numeric: tabular-nums; }
.dp-btn { position: absolute; right: 0.25rem; top: 50%; translate: 0 -50%; width: 2rem; height: 2rem; display: grid; place-items: center; border: 0; border-radius: 0.375rem; background: transparent; color: var(--ink-soft); cursor: pointer; transition: background-color 120ms ease, color 120ms ease; }
.dp-btn[aria-expanded="true"] { color: var(--ink); background: var(--ink-tint); }
@media (hover: hover) and (pointer: fine) { .dp-btn:hover { background: var(--ink-tint); color: var(--ink); } }
.dp-pop { position: absolute; top: calc(100% + 0.375rem); left: 0; width: 18.75rem; padding: 0.75rem; }
.dp-pop.is-right { left: auto; right: 0; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 0.25rem; margin-bottom: 0.5rem; }
.dp-title { display: flex; gap: 0.25rem; min-width: 0; }
.dp-title select { appearance: none; border: 0; background: transparent; color: var(--ink); font-weight: 600; font-size: var(--t-body); padding: 0.375rem 0.375rem; border-radius: 0.375rem; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .dp-title select:hover { background: var(--hover-row); } }
.dp-title select:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }
.dp-nav[disabled] { opacity: 0.35; cursor: default; }
.dp-wd, .dp-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.dp-wd span { text-align: center; font-size: var(--t-caption); color: var(--ink-soft); padding: 0.25rem 0; }
.dp-day { height: 2.375rem; border: 0; background: transparent; color: var(--ink); font-size: var(--t-body); font-variant-numeric: tabular-nums; border-radius: 0.375rem; cursor: pointer; padding: 0; transition: background-color 120ms ease; }
.dp-day.is-out { color: var(--ink-soft); }
.dp-day.in-range { background: var(--mist); border-radius: 0; }
.dp-day.is-today { box-shadow: inset 0 0 0 1px var(--line-strong); }
.dp-day.is-edge { box-shadow: inset 0 0 0 1px var(--ink); }
.dp-day.is-sel { background: var(--ink); color: var(--paper); font-weight: 600; box-shadow: none; }
.dp-day[aria-disabled="true"] { color: var(--line-strong); cursor: not-allowed; text-decoration: line-through; text-decoration-color: var(--line); }
.dp-day:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; position: relative; z-index: 1; }
@media (hover: hover) and (pointer: fine) { .dp-day:not(.is-sel):not([aria-disabled="true"]):hover { background: var(--ink-tint); } }
.dp-foot { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.dp-scrim { position: fixed; inset: 0; z-index: 69; background: rgb(11 1 70 / 0.35); opacity: 0; transition: opacity 120ms ease; }
.dp-scrim.is-open { opacity: 1; }
/* phones: the calendar is a full-width panel at the bottom */
.dp-pop.is-sheet { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; border-radius: var(--r-panel) var(--r-panel) 0 0; border-bottom: 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px)); }
.dp-pop.is-sheet .dp-day { height: 2.75rem; }

.rs-native { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; pointer-events: none; }
.rs-btn { width: 100%; min-height: 2.5rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.625rem 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--paper); color: var(--ink); text-align: left; cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease; }
.rs-btn .rs-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-btn .icon { color: var(--ink-soft); }
@media (hover: hover) and (pointer: fine) { .rs-btn:hover { border-color: var(--line-strong); } }
.rs-btn:focus-visible, .rs-btn[aria-expanded="true"] { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-tint); }
.field.invalid .rs-btn { border-color: var(--brand); }
.rs-pop { position: absolute; top: calc(100% + 0.375rem); left: 0; min-width: 100%; width: min(28rem, calc(100vw - 2rem)); max-height: min(22rem, 60vh); display: flex; flex-direction: column; padding: 0.375rem; }
.rs-pop.is-up { top: auto; bottom: calc(100% + 0.375rem); }
.rs-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 0; list-style: none; }
.rs-list:focus { outline: none; }
.rs-list [role=option] { display: grid; gap: 0.125rem; padding: 0.5rem 0.625rem; border-radius: var(--r-control); cursor: pointer; }
.rs-list [role=option].is-active { background: var(--ink-tint); }
.rs-list:focus-visible [role=option].is-active { box-shadow: inset 0 0 0 2px var(--brand); }
.rs-list [role=option][aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
/* search on top of a long list (more than 5 options) */
.rs-search { flex: none; width: 100%; min-height: 2.5rem; margin-bottom: 0.375rem; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--paper); color: var(--ink); }
.rs-search::placeholder { color: var(--ink-soft); opacity: 0.75; }
.rs-search:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-tint); }
.rs-note { flex: none; margin: 0; padding: 0.375rem 0.625rem 0.25rem; font-size: var(--t-caption); color: var(--ink-soft); }
/* toolbars sized the native select by itself; the replacement keeps that */
.toolbar > .rs { flex: 0 1 auto; min-width: 10rem; }
.rs-pop.is-plain .rs-name { font-weight: 400; }
.rs-row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.rs-name { font-weight: 600; color: var(--ink); }
[aria-selected="true"] > .rs-row .rs-name::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); margin-left: 0.5rem; vertical-align: 0.15em; }
.rs-meta { color: var(--ink); white-space: nowrap; }
.rs-desc { font-size: var(--t-caption); color: var(--ink-soft); line-height: 1.45; }
@media (prefers-reduced-motion: reduce) {
  .pop, .dp-scrim, .dp-day, .dp-btn, .rs-btn { transition: none; }
}
