/* ==========================================================================
   ASK Webtool-Vorlage – Stylesheet  ·  VORLAGE-VERSION 1.2.1
   Quelle der Wahrheit: docker-apps/_vorlage. Projektfarbe nur ueber --brand*,
   Eigenes in eine zweite Datei (<projekt>.css), nicht hier hinein.

   Gestaltung: ruhige Flaechen mit Tonschritt statt Schatten, eine Akzentfarbe,
   Schriftgroessen nur aus der Skala (--fs-*), Radien nur aus den Tokens.
   ========================================================================== */

:root {
  /* Flaechen und Schrift */
  --bg: #f6f7f9;
  --bg-accent: #eef0f4;
  --card: #ffffff;
  --card-2: #f9fafb;
  --ink: #121826;
  --ink-soft: #374151;
  --muted: #5d6676;
  --line: #e5e8ed;
  --line-strong: #d5dae2;
  --line-input: #8a94a3;
  --line-hover: #b9c0cb;

  /* Marke */
  --brand: #0d5bd4;
  --brand-soft: #ebf2fe;
  --brand-line: #c7dafb;
  --brand-ink: #0a4bb0;
  /* Volle Markenflaechen (Primaerknopf, Logo). Im Dunkelmodus dunkler als
     --brand, sonst reicht der Kontrast fuer weisse Schrift nicht. */
  --brand-fill: #0d5bd4;
  --brand-fill-hover: #0a4bb0;
  --on-brand: #fff;

  /* Zustaende */
  --ok: #1f9d55;   --ok-soft: #ecf8f0;   --ok-line: #bfe6cd;   --ok-ink: #1f7a43;   --ok-fill: #1a7f45;
  --warn: #d97706; --warn-soft: #fdf6e6; --warn-line: #f2dcac; --warn-ink: #8a5a00;
  --bad: #b3271e;  --bad-soft: #fdeceb;  --bad-line: #f2c2be;  --bad-ink: #b3271e;

  /* Tiefe: ruhende Flaechen fast ohne Schatten, nur Schwebendes hebt sich ab */
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lift: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-pop: 0 16px 40px -8px rgba(16, 24, 40, .22), 0 4px 12px -4px rgba(16, 24, 40, .08);
  --shadow-btn: 0 1px 2px rgba(16, 24, 40, .06);

  /* Formen */
  --radius-lg: 14px;
  --radius: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Schrift: Segoe UI Variable (Windows 11) mit optischen Groessen, sonst Segoe UI */
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-base: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 26px;

  /* Bewegung */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.23, 1, .32, 1);

  --topbar-h: 56px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0e13;
  --bg-accent: #161b23;
  --card: #11151c;
  --card-2: #161b23;
  --ink: #e9edf3;
  --ink-soft: #c5cdd9;
  --muted: #8e99ab;
  --line: #222a35;
  --line-strong: #2e3744;
  --line-input: #5a6578;
  --line-hover: #435064;

  --brand: #5b9bff;
  --brand-soft: #14223a;
  --brand-line: #2a4472;
  --brand-ink: #93bcff;
  --brand-fill: #2f6fe0;
  --brand-fill-hover: #255fc7;

  --ok: #33b56b;   --ok-soft: #0f2318;   --ok-line: #23492f;   --ok-ink: #5ed08e;   --ok-fill: #1f7a43;
  --warn: #e0930f; --warn-soft: #231b0c; --warn-line: #4a3814; --warn-ink: #e6b155;
  --bad: #e0655a;  --bad-soft: #281410;  --bad-line: #57281f;  --bad-ink: #ef8d83;

  --shadow: none;
  --shadow-lift: 0 6px 20px -4px rgba(0, 0, 0, .55);
  --shadow-pop: 0 18px 48px -8px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .03);
  --shadow-btn: none;
  color-scheme: dark;
}

/* --- Grundlagen --------------------------------------------------------- */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

/* Kein Tipp-Blitz auf dem Handy - die :active-Zustaende geben die Rueckmeldung.
   Bewusst KEIN scroll-behavior: smooth - sonst scrollt jeder Seitenwechsel animiert. */
html {
  -webkit-tap-highlight-color: transparent;
  scrollbar-gutter: stable;
  scrollbar-color: var(--line-strong) transparent;
}

body {
  font: var(--fs-base)/1.55 var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

::selection { background: color-mix(in srgb, var(--brand) 24%, transparent); }

h1, h2, h3, h4 {
  margin: 0; font-family: var(--font-display); font-weight: 600;
  letter-spacing: -.012em; text-wrap: balance;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

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

/* Tippbare Bedienelemente: kein Doppeltipp-Zoom (keine 300-ms-Verzoegerung),
   langes Druecken markiert nicht die Beschriftung. */
button, a, .chip, [role="button"] { touch-action: manipulation; }
.btn, .icon-btn, .user-chip, .chip, .topnav a, .menu button, .tabs button {
  -webkit-user-select: none; user-select: none;
}

[hidden] { display: none !important; }

.noscript {
  margin: 24px auto; max-width: 640px; padding: 16px 20px;
  border: 1px solid var(--bad-line); background: var(--bad-soft); color: var(--bad-ink);
  border-radius: var(--radius);
}

[tabindex="-1"]:focus { outline: none; }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 200;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--brand-fill); color: #fff; font-weight: 600; text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

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

/* --- Ladeanzeige -------------------------------------------------------- */

.boot {
  min-height: 60vh;
  display: grid; place-content: center; justify-items: center; gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Schnelle Antworten sollen keinen Spinner aufblitzen lassen. */
.view > .boot { animation: fadeIn .12s var(--ease-out) .15s both; }

/* --- Kopfleiste --------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 22px;
  padding: 0 20px;
  /* Deckend, ohne Weichzeichner: backdrop-filter macht jede Neuzeichnung teuer. */
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); flex: none; white-space: nowrap;
}
.topbar .brand:hover { text-decoration: none; }

.brand-mark {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--brand-fill);
  /* Feiner Lichtrand oben: wirkt wie eine Flaeche, nicht wie ein Aufkleber. */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), var(--shadow-btn);
  display: grid; place-items: center;
  color: var(--on-brand); flex: none;
}
.brand-mark svg { width: 16px; height: 16px; stroke-width: 2; }

/* Firmenlogo. Im Dunkelmodus liegt es auf einer hellen Flaeche: die dunkelblaue
   Wortmarke waere auf dunklem Grund sonst nicht lesbar, und ein CSS-Filter wuerde
   die CI-Farben verfaelschen. */
.brand-logo {
  height: 26px; width: auto; display: block; flex: none;
  padding: 3px 6px; border-radius: var(--radius-xs); box-sizing: content-box;
}
:root[data-theme="dark"] .brand-logo { background: #fff; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 650; font-size: var(--fs-base); letter-spacing: -.015em;
  color: var(--ink);
}

.brand-sub {
  font-weight: 400; color: var(--muted); font-size: var(--fs-sm);
  padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--line);
}

.topnav { display: flex; gap: 2px; flex: 1; min-width: 0; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }

.topnav a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--fs-md); font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.topnav a:hover { background: var(--bg-accent); color: var(--ink); text-decoration: none; }
.topnav a:active { background: var(--bg-accent); }
.topnav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 6px; flex: none; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease), transform .12s var(--ease-out);
}
.icon-btn:hover { background: var(--bg-accent); color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 17px; height: 17px; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: background .16s var(--ease), transform .12s var(--ease-out);
}
.user-chip:hover, .user-chip[aria-expanded="true"] { background: var(--bg-accent); }
.user-chip:active { transform: scale(.97); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink);
  box-shadow: inset 0 0 0 1px var(--brand-line);
  display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: 700; flex: none;
  letter-spacing: .02em;
}

.user-chip .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; min-width: 0; }
.user-chip .who b {
  font-size: var(--fs-sm); font-weight: 600;
  max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip .who span { font-size: var(--fs-xs); color: var(--muted); }

/* --- Menue -------------------------------------------------------------- */

.menu {
  /* fixed, nicht absolute: das Menue haengt an <body>; absolute wuerde ab
     Dokumentanfang zaehlen und auf einer gescrollten Seite verrutschen. */
  position: fixed;
  top: calc(var(--topbar-h) - 6px); right: 20px; z-index: 40;
  min-width: 210px;
  max-width: min(320px, calc(100vw - 26px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: 5px;
  animation: popIn .14s var(--ease-out);
  transform-origin: top center;
}

.menu button {
  width: 100%; text-align: left;
  font: inherit; font-size: var(--fs-md);
  padding: 7px 10px;
  border: 0; background: none; color: var(--ink);
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.menu button svg { width: 16px; height: 16px; color: var(--muted); }
.menu button:hover, .menu button:focus-visible { background: var(--bg-accent); outline: none; }
.menu button:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.menu button:disabled { opacity: .5; cursor: not-allowed; }
.menu button.danger, .menu button.danger svg { color: var(--bad); }
.menu button.danger:hover { background: var(--bad-soft); }
.menu button kbd {
  margin-left: auto; font: var(--fs-xs) var(--mono); color: var(--muted);
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--card-2);
}
.menu-trenner { height: 1px; background: var(--line); margin: 5px -5px; }
.menu-stufen { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 10px; font-size: var(--fs-md); }
.menu-stufen-text { flex: 1; }
.menu-stufen-wert { min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; }
.menu-stufen-knopf {
  width: 28px; height: 28px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-xs); background: var(--card);
  color: var(--ink); cursor: pointer;
}
.menu-stufen-knopf svg { width: 14px; height: 14px; }
.menu .menu-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin: 0 -5px 5px;
  padding-left: 15px;
  overflow-wrap: anywhere;
}
.menu .menu-head b { display: block; font-size: var(--fs-md); }
.menu .menu-head span { font-size: var(--fs-xs); color: var(--muted); }

@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* --- Seitengeruest ------------------------------------------------------ */

.view {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  animation: viewIn .22s var(--ease-out);
}
.view.wide { max-width: 1320px; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 24px;
}
.page-head h1 { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -.022em; line-height: 1.2; }
.page-head .sub { margin: 6px 0 0; color: var(--muted); font-size: var(--fs-md); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-label {
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 28px 0 12px;
}
.section-label:first-child { margin-top: 0; }

/* --- Karten ------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: var(--fs-lg); letter-spacing: -.015em; }
.card > h2 { margin-bottom: 14px; }
.card.tight { padding: 0; overflow: hidden; }
.card.tight > h2 { padding: 15px 20px; border-bottom: 1px solid var(--line); margin: 0; }
.card.tight > .card-body { padding: 18px 20px; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h1, .card-head h2 { margin-bottom: 0; }
.card-head .sub { margin: 3px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.card-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Kennzahlen --------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat .k { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.stat .v {
  font-family: var(--font-display);
  font-size: var(--fs-2xl); font-weight: 650; line-height: 1.15; margin-top: 6px; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat .v small { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.stat.accent .v { color: var(--brand); }
.stat.ok .v { color: var(--ok-ink); }
.stat.warn .v { color: var(--warn-ink); }

/* --- Pillen und Kennzeichnungen ----------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--bg-accent);
  color: var(--ink-soft);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.6;
  white-space: nowrap;
}
.pill.brand { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--brand-line); }
.pill.ok    { color: var(--ok-ink);    background: var(--ok-soft);    border-color: var(--ok-line); }
.pill.warn  { color: var(--warn-ink);  background: var(--warn-soft);  border-color: var(--warn-line); }
.pill.bad   { color: var(--bad-ink);   background: var(--bad-soft);   border-color: var(--bad-line); }
/* Kleiner Punkt vor dem Text, wenn eine Pille einen Zustand meldet. */
.pill.punkt::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* --- Schaltflaechen ----------------------------------------------------- */

.btn {
  font: inherit; font-size: var(--fs-md); font-weight: 600; line-height: 1.3;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease), box-shadow .16s var(--ease), transform .12s var(--ease-out);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
/* Grundgroesse fuer alle Symbole aus icon(). Bewusst nur eine Klasse, damit
   jede kontextbezogene Regel (.btn svg, .icon-btn svg, ...) weiter gewinnt. */
.ico { width: 16px; height: 16px; flex: none; vertical-align: -0.15em; }
.btn svg { width: 16px; height: 16px; flex: none; margin-left: -2px; }

.btn-primary {
  background: var(--brand-fill); color: var(--on-brand);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--shadow-btn);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-fill-hover); }

.btn-ghost {
  background: var(--card); border-color: var(--line-strong); color: var(--ink);
  box-shadow: var(--shadow-btn);
}
.btn-ghost:hover:not(:disabled) { background: var(--card-2); border-color: var(--line-hover); }

.btn-subtle { background: var(--bg-accent); color: var(--ink-soft); }
.btn-subtle:hover:not(:disabled) { background: var(--line); color: var(--ink); }

.btn-ok { background: var(--ok-fill); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--shadow-btn); }
.btn-ok:hover:not(:disabled) { filter: brightness(.94); }

.btn-danger { background: var(--card); border-color: var(--bad-line); color: var(--bad); box-shadow: var(--shadow-btn); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }

.btn-sm { font-size: var(--fs-sm); padding: 5px 10px; border-radius: var(--radius-xs); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; padding-top: 10px; padding-bottom: 10px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Formularfelder ----------------------------------------------------- */

.field { display: block; margin-bottom: 16px; }
/* Feldbeschriftungen werden am haeufigsten gelesen: normale Schreibung. */
.field > label,
.field-label {
  display: block;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft);
  margin-bottom: 6px;
}
.hint { font-size: var(--fs-sm); color: var(--muted); margin: 0 0 14px; }
.field .hint { font-size: var(--fs-xs); margin: 6px 0 0; }

input[type="text"], input[type="password"], input[type="email"], input[type="search"],
input[type="date"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%;
  font: inherit; font-size: var(--fs-md);
  color: var(--ink);
  padding: 8px 11px;
  line-height: 1.45;
  border: 1px solid var(--line-input);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-btn);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) {
  border-color: var(--muted);
}
/* background-color, nicht background: die Kurzform wuerde den Pfeil im select kacheln. */
input:disabled, select:disabled, textarea:disabled { background-color: var(--card-2); color: var(--muted); cursor: not-allowed; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
::placeholder { color: var(--muted); opacity: 1; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  /* Sichtbarer Ring: unter ~45 % lag er unter 3:1 zum Untergrund. */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 45%, transparent);
}
input.invalid, textarea.invalid { border-color: var(--bad); background: var(--bad-soft); }

input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-fill); width: 16px; height: 16px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%235d6676' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 30px;
}
/* Der Pfeil steckt als data:-URL im Hintergrund, dort greift var() nicht. */
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238e99ab' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }

.check {
  display: flex; align-items: center; gap: 9px;
  font-size: var(--fs-md); cursor: pointer; user-select: none;
}
.check input { cursor: pointer; }
fieldset.field { border: 0; padding: 0; min-width: 0; }
fieldset.field .check { margin: 6px 0; flex-wrap: wrap; }
table.data tr.gruppe th { padding-top: 18px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Scrollbare Auswahlliste, z. B. fuer Freischaltbedingungen. */
.picker-box {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--card); max-height: 190px; overflow-y: auto; padding: 4px;
}
.picker-row { padding: 7px 9px; border-radius: var(--radius-xs); transition: background .13s var(--ease); }
.picker-row:hover { background: var(--bg-accent); }
.picker-row:has(input:checked) { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

/* --- Werkzeugleiste ----------------------------------------------------- */

.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.toolbar .grow { flex: 1; min-width: 180px; }

.chip {
  font: inherit; font-size: var(--fs-sm); font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.chip:hover { border-color: var(--line-hover); color: var(--ink); }
.chip.active { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

/* --- Fortschritt -------------------------------------------------------- */

.progress { height: 6px; background: var(--bg-accent); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.progress .fill { height: 100%; background: var(--brand-fill); border-radius: 999px; transition: width .3s var(--ease-out); }
.progress .fill.done { background: var(--ok); }
.progress-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--fs-sm); color: var(--muted); }
.progress-line b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* --- Tabellen ----------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.data th, table.data td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
/* Tabellen in Karten schliessen buendig mit dem Kartentext ab (nicht in .tight - dort fehlt der Innenabstand). */
.card:not(.tight) table.data th:first-child, .card:not(.tight) table.data td:first-child { padding-left: 0; }
.card:not(.tight) table.data th:last-child, .card:not(.tight) table.data td:last-child { padding-right: 0; }
table.data th {
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  white-space: nowrap;
  padding-top: 8px; padding-bottom: 8px;
}
table.data tbody tr { transition: background .13s var(--ease); }
table.data tbody tr:hover { background: var(--card-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-soft); }
table.data td.right { text-align: right; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data .mono { font-family: var(--mono); font-size: var(--fs-sm); }
/* Lange Mailadressen, Pfade, URLs: duerfen umbrechen statt die Tabelle zu sprengen. */
table.data td.umbruch { overflow-wrap: anywhere; min-width: 12ch; }
/* Eingaben in Tabellenzeilen nicht bis zur Unlesbarkeit schrumpfen lassen. */
table.data td > input[type="text"], table.data td > select { min-width: 140px; padding-top: 6px; padding-bottom: 6px; }

/* --- Registerkarten ----------------------------------------------------- */

.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs button {
  font: inherit; font-size: var(--fs-md); font-weight: 500;
  padding: 9px 12px;
  margin-bottom: -1px;
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.tabs button svg { width: 16px; height: 16px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active, .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.tabs .zahl {
  font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 0 7px; border-radius: 999px; background: var(--bg-accent); color: var(--muted);
}

/* --- Leerzustaende ------------------------------------------------------ */

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
/* In einer Karte ohne zweiten Rahmen. */
.card .empty { border: 0; padding: 32px 16px; background: transparent; }
.empty .glyph {
  width: 44px; height: 44px; margin: 0 auto 14px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand-line);
  display: grid; place-items: center;
  color: var(--brand);
}
.empty .glyph svg { width: 20px; height: 20px; }
.empty h3 { font-size: var(--fs-base); color: var(--ink); margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; font-size: var(--fs-md); max-width: 42ch; }

/* --- Anmeldung ---------------------------------------------------------- */

.auth-wrap {
  min-height: 100vh;
  min-height: 100svh;
  display: grid; place-items: center;
  padding: 32px 20px;
  background: var(--bg);
}
.auth-theme { position: fixed; top: 16px; right: 16px; }

.auth-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 32px 32px 28px;
  animation: viewIn .28s var(--ease-out);
}
.auth-card .auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-card .auth-brand .brand-mark { width: 36px; height: 36px; border-radius: var(--radius-md); }
.auth-card .auth-brand .brand-mark svg { width: 20px; height: 20px; }
.auth-card .auth-brand .brand-logo { height: 38px; }
.auth-card .auth-brand b { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.015em; }
.auth-card .auth-brand div > span { display: block; font-size: var(--fs-sm); color: var(--muted); font-weight: 400; }
.auth-card h1 { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); font-size: var(--fs-md); margin: 0 0 22px; }
.auth-foot {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--muted); text-align: center;
}

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  margin-bottom: 16px;
  border: 1px solid transparent;
  animation: shakeIn .2s var(--ease-out);
}
.alert.bad  { background: var(--bad-soft);   border-color: var(--bad-line);   color: var(--bad-ink); }
.alert.warn { background: var(--warn-soft);  border-color: var(--warn-line);  color: var(--warn-ink); }
.alert.ok   { background: var(--ok-soft);    border-color: var(--ok-line);    color: var(--ok-ink); }
.alert.info { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }

@keyframes shakeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* --- Dialoge ------------------------------------------------------------ */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  /* Bewusst ohne backdrop-filter: der Weichzeichner macht Hover in Dialogen
     spuerbar traege (siehe Onboarding, 24.09.2026). */
  background: rgba(10, 14, 22, .5);
  display: grid; place-items: center;
  padding: 24px;
  animation: fadeIn .16s var(--ease-out);
}
/* Seite hinter dem Dialog scrollt nicht mit. */
body:has(.modal-backdrop) { overflow: hidden; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 480px;
  max-height: 88vh;
  max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: modalIn .2s var(--ease-out);
  overflow: hidden;
}
.modal.wide { max-width: 760px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal > header {
  padding: 18px 16px 4px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal > header h2 { font-size: var(--fs-lg); letter-spacing: -.015em; }
.modal-body { padding: 12px 22px 20px; overflow-y: auto; overscroll-behavior: contain; overflow-wrap: anywhere; }
.modal-body > p:first-child { margin-top: 0; }
.modal > footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--card-2);
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}

/* --- Meldungen ---------------------------------------------------------- */

.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-md);
  animation: toastIn .22s var(--ease-out);
  pointer-events: auto;
}
.toast.leaving { animation: toastOut .15s var(--ease-out) forwards; pointer-events: none; }
.toast .toast-text { min-width: 0; flex: 1; word-break: break-word; }
.toast-aktion {
  font: inherit; font-size: var(--fs-sm); font-weight: 600; flex: none;
  padding: 2px 10px; margin: -1px -4px -1px 0; min-height: 26px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-xs);
  background: var(--card); color: var(--brand); cursor: pointer;
}
.toast-aktion:hover { background: var(--card-2); }
/* Symbol der Meldung: traegt die Farbe, an der ersten Textzeile ausgerichtet. */
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--brand); }
.toast.ok svg   { color: var(--ok); }
.toast.bad svg  { color: var(--bad); }
.toast.warn svg { color: var(--warn); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }

/* --- Kleinteile --------------------------------------------------------- */

.mono { font-family: var(--mono); }

.key-reveal {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--mono); font-size: var(--fs-lg); letter-spacing: .02em;
  padding: 10px 10px 10px 14px;
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  word-break: break-all;
  margin-bottom: 14px;
}
.key-reveal .btn { font-family: var(--font); letter-spacing: 0; flex: none; }

.divider { height: 1px; background: var(--line); margin: 22px 0; border: 0; }

.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }

kbd {
  font: var(--fs-xs) var(--mono); color: var(--ink-soft);
  padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 4px; background: var(--card);
}

.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 6px; border-radius: 50%;
  background: var(--bg-accent); color: var(--muted); font-size: var(--fs-xs); font-weight: 700;
  font-style: italic; font-family: Georgia, 'Times New Roman', serif;
  cursor: help; vertical-align: middle; flex: none; user-select: none; position: relative;
}
.info-icon::after { content: ''; position: absolute; inset: -6px; }
.info-icon:hover, .info-icon:focus-visible { background: var(--brand-soft); color: var(--brand); }
.info-icon:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* Kurze Bestaetigung an der geaenderten Stelle statt eines Toasts je Feld. */
tr.gespeichert td { background: var(--ok-soft); transition: background .3s var(--ease); }
tr.gespeichert td:first-child { box-shadow: inset 3px 0 0 var(--ok); }

/* Hinweis "neue Version, bitte neu laden" (siehe api.js) */
.versions-hinweis {
  position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 12px; max-width: min(720px, calc(100vw - 32px));
  padding: 10px 12px 10px 16px; border-radius: var(--radius-md); font-size: var(--fs-md); font-weight: 600;
  background: var(--warn-soft); color: var(--warn-ink); border: 1px solid var(--warn-line); box-shadow: var(--shadow-pop);
}
.versions-hinweis svg { width: 18px; height: 18px; flex: none; }

/* --- Anpassung an kleine Bildschirme ------------------------------------ */

@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand-name, .brand-sub, .user-chip .who { display: none; }
  .user-chip { padding: 4px; }
  /* Scrollt seitlich; der weiche Rand rechts zeigt, dass es weitergeht. */
  .topnav { overflow-x: auto; mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .topnav a { padding: 6px 10px; }
  .view { padding: 22px 14px 60px; }
  .card { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: var(--fs-xl); }
  .menu { right: 12px; }
}

/* --- Ruhige Darstellung, wenn gewuenscht -------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  /* Ein stehender Spinner sieht nach Absturz aus. */
  .spinner { animation: spin 1.2s linear infinite !important; }
}

/* ======================================================================== *
 * Bedienung mit dem Finger (Handy und Tablet)                              *
 * ======================================================================== *
 * Bewusst als EIN Block ganz am Ende, damit er gegen die Regeln oben gewinnt.
 * `pointer: coarse` trifft Finger unabhaengig von der Breite (iPad quer),
 * `max-width: 700px` faengt Geraete ab, die sich nicht als Fingergeraet melden.
 */
@media (pointer: coarse), (max-width: 700px) {
  /* Unter 16px zoomt Safari auf dem iPhone beim Antippen in die Seite. */
  input[type="text"], input[type="password"], input[type="email"],
  input[type="date"], input[type="number"], input[type="tel"],
  input[type="search"], select, textarea {
    font-size: 16px;
  }
  /* WCAG 2.5.8: Ankreuzfelder nicht in Browservorgabe (13px). */
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .check { min-height: 44px; }

  /* min-height statt height: umbrechende Beschriftungen duerfen wachsen. */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .chip { min-height: 36px; display: inline-flex; align-items: center; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .user-chip { min-width: 44px; min-height: 44px; justify-content: center; }
  .topnav a { min-height: 44px; display: inline-flex; align-items: center; }
  .menu button { min-height: 44px; }
  .menu-stufen-knopf { width: 44px; height: 44px; }
  .toast-aktion { min-height: 44px; }
  .tabs button { min-height: 44px; }
}

/* Hover-Faerbung nur bei echter Maus - auf Touch bliebe sie nach dem Tippen stehen. */
@media (hover: none) {
  .btn-primary:hover:not(:disabled) { background: var(--brand-fill); }
  .btn-ghost:hover:not(:disabled) { background: var(--card); border-color: var(--line-strong); }
  .btn-subtle:hover:not(:disabled) { background: var(--bg-accent); color: var(--ink-soft); }
  .icon-btn:hover, .user-chip:hover { background: transparent; color: var(--muted); }
  .chip:hover { border-color: var(--line-strong); color: var(--ink-soft); }
  table.data tbody tr:hover { background: transparent; }
}
