/* Tageswerte – ein Stylesheet für alle Seiten, nur Dunkelmodus.
   Gliederung: 1 Tokens · 2 Base · 3 Layout · 4 Typo · 5 Formulare · 6 Buttons · 7 Komponenten · 8 Seiten · 9 Utilities · 10 Preferences
   Regeln: kein Inline-CSS (CSP style-src 'self'), Zustände über Attribute/Klassen, Bewegung nur transform/opacity. */

/* ===== 1  TOKENS ===== */
:root {
  color-scheme: dark;

  /* Flächen */
  --bg: #0e1419;
  --surface: #161f26;
  --surface-2: #1e2a33;
  --field: #0a1015;           /* Eingabefelder: dunkler als das Panel, wirken eingelassen */
  --today: #163a46;
  --qr-bg: #fff;              /* QR-Codes brauchen hellen Grund und Ruhezone */

  /* Rahmen */
  --line: #2b3843;            /* Trennlinien, dekorativ */
  --line-strong: #66798a;     /* Bedienelemente, mind. 3:1 */

  /* Text (alle Paare mind. AA) */
  --fg: #e8eef2;
  --muted: #9aa9b5;
  --subtle: #8797a4;

  /* Akzent und Status */
  --accent: #5cc3dc;
  --accent-hover: #7fd3e8;
  --accent-pressed: #4aafc8;
  --accent-fg: #06222b;
  --focus: var(--accent);
  --bad: #ff9a90;
  --bad-bg: #3a1d1e;
  --ok: #7bd69a;
  --warn: #f0c36a;

  /* Typo */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-val: ui-monospace, "Cascadia Mono", "SF Mono", "Roboto Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fw-medium: 500;
  --fw-semi: 600;
  --fw-bold: 700;
  --lh-tight: 1.2;
  --lh-base: 1.45;
  --lh-prose: 1.55;

  /* Abstände (4er-Raster) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Form */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;
  --control-h: 3rem;
  --tap: 44px;
  --ring: 3px;
  --shadow-pop: 0 6px 20px rgb(0 0 0 / .45);

  /* Layout, Bewegung, Ebenen */
  --w-main: 480px;
  --w-wide: 960px;
  --dur-fast: .12s;
  --dur: .18s;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --z-toast: 100;
}

/* ===== 2  BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
html {
  scrollbar-gutter: stable;              /* Scrollbalken erscheint/verschwindet nicht mehr als Layout-Sprung */
  interpolate-size: allow-keywords;      /* weiches Auf-/Zuklappen von <details> (progressiv) */
  background: var(--bg);                 /* kein heller Blitz beim Laden und Überscrollen */
  font-size: 100%;                       /* Browser-Textgröße respektieren */
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scrollbar-color: var(--line-strong) var(--bg);
}
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font-ui); font-size: var(--fs-md); line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  padding-top: max(var(--space-5), env(safe-area-inset-top, 0px));
  padding-bottom: max(var(--space-7), calc(var(--space-4) + env(safe-area-inset-bottom, 0px)));
  padding-left: max(var(--space-4), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-4), env(safe-area-inset-right, 0px));
  overflow-wrap: break-word;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button, a, summary, label, input, select { touch-action: manipulation; }
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-fg); }
::placeholder { color: var(--subtle); opacity: 1; }

/* ===== 3  LAYOUT ===== */
main { width: 100%; max-width: var(--w-wide); margin-inline: auto; display: flex; flex-direction: column; gap: var(--space-5); }
main.wide { max-width: var(--w-wide); }
main.narrow > :not(.top) { width: 100%; max-width: var(--w-main); margin-inline: auto; }   /* Kopfzeile über die volle Breite, Inhalt schmal: Titel und Navigation bleiben auf jeder Seite am selben Platz */

/* Kopfzeile mit Navigation */
.top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-1) var(--space-4); min-height: var(--tap); padding-bottom: var(--space-3); border-bottom: 1px solid var(--line); view-transition-name: top; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); min-height: var(--tap); min-width: 0; }
.nav a, .nav .linkbtn {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-3);
  border-radius: var(--r-md); color: var(--muted); font-size: var(--fs-sm); font-weight: var(--fw-medium); text-decoration: none;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
@media (hover: hover) { .nav a:hover, .nav .linkbtn:hover { color: var(--fg); } }
.nav a:focus-visible, .nav .linkbtn:focus-visible { outline-offset: 0; }   /* Ring überlappt sonst den Nachbarn */
.nav a[aria-current="page"] { color: var(--fg); background: var(--surface); box-shadow: inset 0 -2px 0 var(--accent); }
.nav .who { min-width: 0; padding-left: var(--space-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--subtle); font-size: var(--fs-sm); }

/* Anmelde-/Einrichtungs-/Offline-Seiten: mittig, mit Marke */
body.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: flex-start; padding-bottom: max(var(--space-5), env(safe-area-inset-bottom, 0px)); }
body.auth main { max-width: var(--w-main); margin-block: max(var(--space-5), 10vh) auto; }   /* oben verankert: die Marke bleibt bei jedem Schritt und Hinweis am selben Platz */
.brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; }
.brand .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: var(--space-2); }
.brand h1 { font-size: 1.75rem; }

/* ===== 4  TYPO ===== */
h1 { margin: 0; font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: -0.01em; }
h2 { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-semi); line-height: var(--lh-tight); }
.sub { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: var(--lh-prose); }
.hint { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: var(--lh-prose); }
.hint.bad { color: var(--bad); }
.hint.ok { color: var(--ok); }
.hint:not(:empty) { animation: dc-hint var(--dur-fast) var(--ease-out); }
/* Leere Live-Regionen bleiben im DOM (Screenreader), belegen aber weder Platz noch Abstand. */
.hint:empty:not(.reserve) { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hint.reserve { min-height: calc(var(--fs-sm) * var(--lh-prose)); margin-bottom: calc(-1 * var(--space-3)); }     /* Startseite: die Liste darunter soll beim Tippen nicht springen */
.foot { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: var(--lh-prose); }
.mono { font-family: var(--font-val); }

/* ===== 5  FORMULARE ===== */
form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
form.stack { grid-template-columns: minmax(0, 1fr); }
label { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; color: var(--muted); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
label.check { flex-direction: row; align-items: center; align-self: start; justify-self: start; width: fit-content; gap: var(--space-3); min-height: var(--tap); color: var(--fg); font-size: var(--fs-md); cursor: pointer; }

input, select {    /* bewusst ohne :where – muss den Reset (font/color: inherit) in Abschnitt 2 überstimmen */
  width: 100%; min-width: 0; height: var(--control-h); padding: 0 var(--space-3);
  font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 400; color: var(--fg);
  background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input[type="checkbox"] { width: 1.375rem; height: 1.375rem; flex: none; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.search { max-width: 28rem; }   /* Suchfeld über der Benutzertabelle */
input[type="search"] { appearance: none; }
input.input-val { font-family: var(--font-val); font-size: 1.15rem; }
input[type="date"] { font-family: var(--font-val); font-size: 1.05rem; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="date"]::-webkit-calendar-picker-indicator { padding: var(--space-2); cursor: pointer; opacity: .85; }
.code-input { font-family: var(--font-val); font-size: var(--fs-2xl); text-align: center; letter-spacing: .3em; text-indent: .3em; }
select { appearance: none; padding-right: 2.5rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
option { background: var(--surface); color: var(--fg); }
input:-webkit-autofill { -webkit-text-fill-color: var(--fg); caret-color: var(--fg); box-shadow: 0 0 0 100px var(--field) inset; }
input:focus-visible, select:focus-visible { border-color: var(--accent); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.full { grid-column: 1 / -1; }

/* ===== 6  BUTTONS ===== */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-4);
  font-weight: var(--fw-semi); line-height: var(--lh-tight); text-align: center; text-decoration: none;
  background: var(--accent); color: var(--accent-fg); border: 1px solid transparent; border-radius: var(--r-md); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
@media (hover: hover) { .btn:hover:not(:disabled) { background: var(--accent-hover); } }
.btn:active:not(:disabled) { background: var(--accent-pressed); transform: scale(.985); }
.btn.secondary { background: transparent; color: var(--fg); border-color: var(--line-strong); }
@media (hover: hover) { .btn.secondary:hover:not(:disabled) { background: var(--surface-2); } }
.btn.secondary:active:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
@media (hover: hover) { .btn.danger:hover:not(:disabled) { background: var(--bad-bg); } }
.btn.danger:active:not(:disabled) { background: var(--bad-bg); }
.btn.danger.solid { background: var(--bad); color: #2a0b0b; }
.btn.small { min-height: 36px; padding: 0 var(--space-3); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
@media (pointer: coarse) { .btn.small { min-height: var(--tap); } }
.btn:disabled { background: var(--surface-2); color: var(--subtle); border-color: var(--line); cursor: default; transform: none; }
.btn.secondary:disabled, .btn.danger:disabled { background: transparent; }
.btn.busy { color: transparent; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 1.1em; height: 1.1em;
  border: 2px solid var(--accent-fg); border-right-color: transparent; border-radius: 50%; animation: dc-spin .7s linear infinite; }
.btn.secondary.busy::after { border-color: var(--accent); border-right-color: transparent; }
.btn.danger.busy::after { border-color: var(--bad); border-right-color: transparent; }
.btn.busy:disabled { opacity: .9; }

.linkbtn { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-2);
  background: none; border: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) { .linkbtn:hover { text-decoration-thickness: 2px; } }
.linkbtn:disabled { color: var(--subtle); cursor: default; }
form .linkbtn { justify-self: center; }

/* Reiter (Admin) */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); }
.tab { min-height: var(--tap); padding: 0 var(--space-4); margin-bottom: -1px; background: none; border: 0; border-bottom: 3px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0; color: var(--muted); font-weight: var(--fw-semi); cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
@media (hover: hover) { .tab:hover { color: var(--fg); } }

/* ===== 7  KOMPONENTEN ===== */
.panel { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel > p, .panel > .secret { margin: 0; }
.panel > .btn { align-self: stretch; }
.auth .panel { padding: var(--space-5); }
#newqr { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
#newqr > p { margin: 0; }

.notice { margin: 0; padding: var(--space-3) var(--space-4); background: var(--surface-2); border: 1px solid var(--line-strong);
  border-left: 4px solid var(--notice-c, var(--accent)); border-radius: var(--r-md); font-size: var(--fs-sm); line-height: var(--lh-prose); }
.notice.bad { --notice-c: var(--bad); background: var(--bad-bg); color: var(--bad); }
.notice.conn { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }

.qr { display: block; width: 264px; max-width: 100%; height: auto; aspect-ratio: 1; margin-inline: auto; padding: var(--space-3); background: var(--qr-bg); border-radius: var(--r-md); }
.secret { padding: var(--space-3); background: var(--field); border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: var(--font-val); font-size: var(--fs-md); text-align: center; overflow-wrap: anywhere; text-wrap: balance; user-select: all; }

.badges { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 var(--space-2); border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-semi); white-space: nowrap; }
.badge.info { color: var(--accent); border-color: var(--accent); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--bad); border-color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); z-index: var(--z-toast); max-width: min(90vw, 28rem);
  padding: var(--space-3) var(--space-4); background: var(--surface-2); color: var(--fg); border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  box-shadow: var(--shadow-pop); font-size: var(--fs-sm); text-align: center; overflow-wrap: anywhere; pointer-events: none;
  opacity: 0; transform: translate(-50%, 8px); transition: opacity var(--dur-fast) var(--ease-in), transform var(--dur-fast) var(--ease-in); }
.toast.on { opacity: 1; transform: translate(-50%, 0); transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.toast.bad { color: var(--bad); border-color: var(--bad); background: var(--bad-bg); }

/* Dialog (Bestätigung, Einladungslink) */
.dialog { width: min(26rem, calc(100vw - 2rem)); padding: var(--space-5); color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); }
.dialog::backdrop { background: rgb(0 0 0 / .6); }
.dialog h2 { margin-bottom: var(--space-2); }
.dialog p { margin: 0 0 var(--space-3); color: var(--muted); }
.dialog input { font-family: var(--font-val); font-size: var(--fs-sm); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-4); }
.dialog[open] { animation: dc-in var(--dur) var(--ease-out); }

/* Aktionsleiste in der Benutzertabelle: Hauptaktion + Menü */
.actions { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; gap: var(--space-2); }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: .4em; height: .4em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); }
.menu[open] > summary { background: var(--surface-2); }
.menu-list { position: absolute; top: calc(100% + var(--space-1)); right: 0; z-index: 20; display: flex; flex-direction: column; min-width: 14rem; padding: var(--space-1);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow-pop); animation: dc-in var(--dur-fast) var(--ease-out); }   /* überlagert statt zu schieben */
.menu.up .menu-list { top: auto; bottom: calc(100% + var(--space-1)); }
.menu-item { min-height: var(--tap); padding: 0 var(--space-3); background: none; border: 0; border-radius: var(--r-sm); color: var(--fg); text-align: left; cursor: pointer; }
@media (hover: hover) { .menu-item:hover { background: var(--surface); } }
.menu-item.danger { color: var(--bad); font-weight: var(--fw-semi); }
.menu-sep { width: 100%; margin: var(--space-1) 0; border: 0; border-top: 1px solid var(--line); }

/* Passwort anzeigen */
.field { position: relative; display: flex; }
.field input { padding-right: 5.5rem; }
.reveal { position: absolute; inset-block: 0; right: 0; min-width: 5rem; padding: 0 var(--space-3); background: none; border: 0; border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--accent); font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; }
@media (hover: hover) { .reveal:hover { color: var(--accent-hover); } }
.reveal:focus-visible { outline-offset: -3px; }

/* Wochen-Navigation und zuletzt benutzte Nummern */
.weeknav { display: flex; gap: var(--space-2); }
.weeknav .btn { flex: 1 1 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.chips .linkbtn { min-height: 36px; font-size: var(--fs-sm); }
.chips-label { color: var(--muted); font-size: var(--fs-sm); }
.chip { min-height: 36px; padding: 0 var(--space-3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  color: var(--fg); font-family: var(--font-val); font-size: var(--fs-sm); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
@media (hover: hover) { .chip:hover { background: var(--surface-2); border-color: var(--accent); } }
@media (pointer: coarse) { .chip { min-height: var(--tap); } }
kbd { padding: 1px 6px; background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-sm);
  color: var(--fg); font-family: var(--font-val); font-size: .9em; }

/* Platzhalter beim Laden */
.skel, #rows.loading .val.empty { display: inline-block; justify-self: start; align-self: center; width: 6ch; height: 1.1em; border-radius: var(--r-sm);
  background: var(--line); color: transparent; opacity: .6; animation: dc-pulse 1.2s ease-in-out infinite; }
td .skel { width: 8ch; }
.empty-cell { padding: var(--space-5); color: var(--muted); text-align: center; }

/* ===== 8  SEITEN ===== */
/* Werteliste */
#f { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); row-gap: var(--space-2); }
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.head, .row { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
.head { border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-semi); letter-spacing: .06em; text-transform: uppercase; }
.row { border-top: 1px solid var(--line); }
#rows > .row:first-child { border-top: 0; }
.row.today { background: var(--today); box-shadow: inset 3px 0 0 var(--accent); }   /* der heutige Tag, nicht der erste der Woche */
.date { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.date small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.val { font-family: var(--font-val); font-size: var(--fs-xl); font-weight: var(--fw-semi); line-height: var(--lh-tight); letter-spacing: .02em;
  font-variant-numeric: tabular-nums; font-variant-ligatures: none; overflow-wrap: anywhere; }
.val.empty { color: var(--muted); font-weight: 400; }
button.val { position: relative; justify-self: start; padding: var(--space-1) 10px; margin: calc(-1 * var(--space-1)) -10px;
  background: none; border: 0; border-radius: var(--r-sm); color: inherit; text-align: left; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
@media (hover: hover) { button.val:hover { background: var(--today); } }
button.val:active { background: var(--today); }
@media (pointer: coarse) { button.val { min-height: var(--tap); } }
button.val:focus-visible { outline-offset: -2px; }   /* .list schneidet mit overflow:hidden sonst den Fokusring ab */
button.val::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--ok); opacity: 0; pointer-events: none; }
button.val.copied { color: var(--ok); }
button.val.copied::after { animation: dc-flash .4s var(--ease-out); }
#rows { transition: opacity var(--dur) var(--ease); }
#rows:empty { min-height: 478px; }   /* 7 Zeilen: Hinweise darunter springen beim Laden nicht */
@media (max-width: 360px) { #rows:empty { min-height: 428px; } }
#rows.loading, tbody.loading { opacity: .45; transition-delay: .12s; }
tbody { transition: opacity var(--dur) var(--ease); }
.foot + details.foot { margin-top: calc(-1 * var(--space-3)); }
details.foot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
details.foot summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--tap); padding: 0 var(--space-4);
  color: var(--fg); font-weight: var(--fw-medium); cursor: pointer; list-style: none; transition: background-color var(--dur-fast) var(--ease); }
details.foot summary::-webkit-details-marker { display: none; }
details.foot summary::after { content: ""; flex: none; width: .5em; height: .5em; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); transition: transform var(--dur) var(--ease); }
details.foot[open] summary::after { transform: rotate(225deg) translateY(-2px); }
@media (hover: hover) { details.foot summary:hover { background: var(--surface-2); } }
details.foot summary:focus-visible { outline-offset: -3px; }
.foot-body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-1) var(--space-4) var(--space-4); }
.foot-body p { margin: 0; }
details.foot::details-content { block-size: 0; overflow: clip; transition: block-size var(--dur) var(--ease), content-visibility var(--dur) allow-discrete; }
details.foot[open]::details-content { block-size: auto; }

/* Admin */
#pane-users, #pane-audit { display: flex; flex-direction: column; gap: var(--space-4); }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: var(--space-3); border-top: 1px solid var(--line); text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
th:first-child, td:first-child { padding-left: var(--space-4); }
th:last-child, td:last-child { padding-right: var(--space-4); }
thead th { border-top: 0; color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-semi); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
@media (hover: hover) { tbody tr:hover { background: color-mix(in srgb, var(--fg) 4%, transparent); } }
td small.sub { display: block; }
#pane-users .tablewrap { overflow: visible; }   /* sonst schneidet die Tabelle das aufgeklappte Menü ab */
tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-lg); }
tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r-lg); }
td.actions-cell { width: 1%; white-space: nowrap; }
td.actions-cell .actions { flex-wrap: nowrap; }
#log td:first-child, #users td:nth-child(3) { white-space: nowrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); align-items: end; }
.filters .btn { grid-column: 1 / -1; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); color: var(--muted); font-size: var(--fs-sm); }

/* ===== 9  UTILITIES ===== */
[hidden] { display: none !important; }   /* einzige !important-Regel: sonst schlägt display:grid/flex das Attribut */
.offscreen { position: fixed; left: -9999px; top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.enter { animation: dc-in var(--dur) var(--ease-out); }
@keyframes dc-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes dc-hint { from { opacity: 0; transform: translateY(-3px); } }
@keyframes dc-spin { to { transform: rotate(1turn); } }
@keyframes dc-pulse { 50% { opacity: .3; } }
@keyframes dc-flash { from { opacity: .3; } to { opacity: 0; } }

/* ===== 10  RESPONSIVE UND VORLIEBEN ===== */
@media (min-width: 600px) { .panel { padding: var(--space-5); } }
@media (min-width: 900px) {
  .filters { grid-template-columns: 1.2fr 1fr 1fr 1fr auto auto; }
  .filters .btn { grid-column: auto; }
}
@media (max-width: 600px) {
  .top { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; }
  .nav .who { margin-left: auto; }
}
@media (max-width: 560px) {
  #create { grid-template-columns: minmax(0, 1fr); }
  .filters .btn { flex: 1 1 100%; }
}
@media (min-width: 561px) { #create .btn { justify-self: start; } }
@media (max-width: 360px) {
  body { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .head, .row { grid-template-columns: 1fr 1.15fr 1.15fr; gap: var(--space-1); padding-inline: 10px; }
  .date { font-size: .9rem; }
  .date small { font-size: .7rem; }
  .val { font-size: var(--fs-md); overflow-wrap: normal; white-space: nowrap; }
  button.val { padding-inline: 6px; margin-inline: -6px; }
  .nav .who { display: none; }
}
/* Admin-Tabellen als Karten auf dem Handy */
@media (max-width: 720px) {
  .tablewrap { overflow: visible; background: none; border: 0; }
  table, tbody, tr, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody { display: flex; flex-direction: column; gap: var(--space-3); }
  tr { padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
  td, th:first-child, td:first-child, td:last-child { padding: 3px 0; border: 0; }
  td[data-label] { display: flex; align-items: baseline; gap: var(--space-3); }
  td[data-label]::before { content: attr(data-label); flex: 0 0 9.5em; color: var(--muted); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; }
  td:empty { display: none; }
  td.actions-cell { width: auto; margin-top: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--line); white-space: normal; }
  td.actions-cell .actions { flex-wrap: wrap; justify-content: flex-start; }
  #log td:first-child, #users td:nth-child(3) { white-space: normal; }
}
@media (max-height: 500px) { body.auth { padding-bottom: var(--space-4); } }

/* Seitenwechsel: Kopfzeile bleibt stehen (view-transition-name: top), der Rest blendet kurz über */
@view-transition { navigation: auto; }
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: .14s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
    transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn { border: 1px solid ButtonText; }
  .row.today { outline: 2px solid Highlight; outline-offset: -2px; }
  .badge { border-color: CanvasText; }
}
