/* ============================================================
   workbench — Kelziholz Backoffice, Design "Apple"
   ============================================================
   Anders als warm und web keine vollstaendige Kopie, sondern eine
   Schicht UEBER workbench.css (siehe `Design.basis` in models.py).
   basis.html laedt erst das klassische Stylesheet, dann diese Datei,
   dann mobil.css. Was hier nicht steht, sieht deshalb klassisch aus --
   eine neue Klasse in einem Modul ist nie ungestylt, sie traegt nur
   noch nicht den Apple-Look.

   Hier steht nur Optik, keine Struktur: Farben, Schrift, Radien,
   Materialien, Druck-Feedback. Das Markup bleibt fuer alle Designs
   gleich (Vorbild ist das Mockup "Bestellungen im Apple-Stil").

   Zwei Entscheidungen, die man beim Lesen sonst sucht:

   1. Die Farben sind die von www.kelziholz.de (wie workbench-web.css),
      die Formen die von Apple. --accent bleibt das zurueckgenommene Gruen,
      weil es im Haus auch "gut" heisst (.chip.good, .kpi.is-good). Das
      Schwarz des Shops steckt in --tint und faerbt alles Bedienbare:
      Hauptschaltflaeche, Links, Fokus, Statuskreise. Ausgewaehltes
      (Navigation, Listenzeile) traegt Sand -- --auswahl.

   2. Kein Monospace mehr fuer Zahlen. Die Systemschrift hat
      tabellarische Ziffern (font-variant-numeric: tabular-nums), damit
      fluchten Preiskolonnen genauso -- und sie sehen aus wie in Numbers.
   ============================================================ */

:root {
  /* Farbe -- das Schema von www.kelziholz.de (siehe workbench-web.css):
     Weiss, Schwarz, Sand als einziger Farbakzent. */
  --ground:      #F7F7F7;
  --surface:     #FFFFFF;
  --surface-2:   #F1F1F1;
  --sand:        #DDD0C0;
  --line:        rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.19);
  --ink:         #000000;
  --ink-2:       #3C3C3C;
  --ink-3:       #767676;
  --accent:      #4E7A5E;
  --accent-soft: #E7EFE9;
  --accent-ink:  #33553F;
  --warn:        #9A6B22;
  --warn-soft:   #F6EBD8;
  --crit:        #A83A2E;
  --crit-soft:   #F6E0DD;

  --tint:        #000000;
  --tint-ink:    #FFFFFF;
  --tint-soft:   rgba(221, 208, 192, 0.55);
  --auswahl:     #DDD0C0;
  --auswahl-ink: #000000;
  --seg-an:      #FFFFFF;
  --balken:      #8C7A63;
  --fill:        rgba(0, 0, 0, 0.055);
  --material:    rgba(247, 247, 247, 0.74);
  --bar:         rgba(255, 255, 255, 0.74);
  --scrim:       rgba(0, 0, 0, 0.32);
  --shadow:      0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --shadow-hoch: 0 2px 6px rgba(0, 0, 0, 0.08), 0 24px 60px rgba(0, 0, 0, 0.18);

  /* Typografie -- die Systemschrift bringt optische Groessen mit */
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --data: var(--ui);

  /* Raster */
  --r: 10px;
  --r-gross: 14px;

  /* Bewegung -- kritisch gedaempft, kein Ueberschwingen */
  --feder: cubic-bezier(0.32, 0.72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #0E0E0E;
    --surface:     #161616;
    --surface-2:   #1F1F1F;
    --sand:        #6A5F51;
    --line:        rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.2);
    --ink:         #FFFFFF;
    --ink-2:       #BDBDBD;
    --ink-3:       #9A9A9A;
    --accent:      #7FB093;
    --accent-soft: #1B2A20;
    --accent-ink:  #A5CDB4;
    --warn:        #D2A05A;
    --warn-soft:   #2E2417;
    --crit:        #DE7A6D;
    --crit-soft:   #33201D;
    --tint:        #FFFFFF;
    --tint-ink:    #000000;
    --tint-soft:   rgba(106, 95, 81, 0.5);
    --auswahl:     #6A5F51;
    --auswahl-ink: #FFFFFF;
    --seg-an:      #3E3E3E;
  --balken:      #BBA88F;
    --fill:        rgba(255, 255, 255, 0.09);
    --material:    rgba(22, 22, 22, 0.74);
    --bar:         rgba(22, 22, 22, 0.74);
    --scrim:       rgba(0, 0, 0, 0.5);
    --shadow:      0 0 0 0.5px rgba(255, 255, 255, 0.06);
    --shadow-hoch: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 24px 60px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground:      #0E0E0E;
  --surface:     #161616;
  --surface-2:   #1F1F1F;
  --sand:        #6A5F51;
  --line:        rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.2);
  --ink:         #FFFFFF;
  --ink-2:       #BDBDBD;
  --ink-3:       #9A9A9A;
  --accent:      #7FB093;
  --accent-soft: #1B2A20;
  --accent-ink:  #A5CDB4;
  --warn:        #D2A05A;
  --warn-soft:   #2E2417;
  --crit:        #DE7A6D;
  --crit-soft:   #33201D;
  --tint:        #FFFFFF;
  --tint-ink:    #000000;
  --tint-soft:   rgba(106, 95, 81, 0.5);
  --auswahl:     #6A5F51;
  --auswahl-ink: #FFFFFF;
  --seg-an:      #3E3E3E;
  --balken:      #BBA88F;
  --fill:        rgba(255, 255, 255, 0.09);
  --material:    rgba(22, 22, 22, 0.74);
  --bar:         rgba(22, 22, 22, 0.74);
  --scrim:       rgba(0, 0, 0, 0.5);
  --shadow:      0 0 0 0.5px rgba(255, 255, 255, 0.06);
  --shadow-hoch: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 24px 60px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Grundbausteine ---------- */

body {
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--tint);
}

:focus-visible {
  outline: 3px solid var(--tint-soft);
  outline-offset: 1px;
  box-shadow: 0 0 0 1px var(--tint);
  border-radius: 6px;
}

.mono { font-family: var(--ui); font-variant-numeric: tabular-nums; }

/* Ueberschriften: enge Sperrung, je groesser desto enger */
h1 { font-family: var(--display); font-weight: 700; letter-spacing: -0.022em; line-height: 1.12; }
h2 { font-weight: 600; letter-spacing: -0.01em; }

/* Apple setzt Rubriken nicht in Versalien */
.eyebrow { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500; }

a { color: inherit; }
.main a:not([class]) { color: var(--tint); text-decoration: none; }
.main a:not([class]):hover { text-decoration: underline; }

.screen-head p { color: var(--ink-3); }

.back { color: var(--tint); font-size: 14px; }
.back:hover { color: var(--tint); opacity: 0.8; }

.dot { background: var(--ink-3); opacity: 0.5; }

/* ---------- Geruest: Materialien statt Flaechen ----------
   `.app > .rail` statt `.rail`: mobil.css setzt den Hintergrund der
   Leiste bei gleicher Spezifitaet und wird spaeter geladen. */

.app > .rail {
  background: var(--material);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border-right: 0.5px solid var(--line);
}
.rail-brand { border-bottom: 0; }
.marke { color: var(--tint); }
.rail-brand:hover .marke { color: var(--tint); opacity: 0.8; }

.rail-nav { padding: 6px 10px; }
.rail-nav a,
.rail-nav button {
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--ink);
}
.rail-nav a:hover,
.rail-nav button:hover { background: var(--fill); }
.rail-nav a[aria-current="page"],
.rail-nav button[aria-current="page"] { background: var(--auswahl); color: var(--auswahl-ink); font-weight: 600; }
.rail-nav .glyph { color: var(--tint); opacity: 1; }
.rail-nav .count { font-family: var(--ui); font-variant-numeric: tabular-nums; }
.rail-sep { background: var(--line); margin: 8px 12px; }

.topbar,
.tabbar {
  background: var(--bar);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}
.topbar { border-bottom: 0.5px solid var(--line); }
.tabbar { border-top: 0.5px solid var(--line); }
.tabbar a[aria-current="page"],
.tabbar button[aria-current="page"] { color: var(--tint); border-top-color: transparent; }

/* ---------- Karten: gruppierte Flaechen wie in den Einstellungen ---------- */

.card {
  border: 0;
  border-radius: var(--r-gross);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { border-bottom: 0.5px solid var(--line); padding: 12px 16px; }
.card-head h2 { font-size: 15px; }
.card-body { padding: 14px 16px; }

/* Kennzahlen: der Zustand steckt in der Zahl, nicht in einem Randstreifen */
.kpi {
  border: 0;
  border-radius: var(--r-gross);
  box-shadow: var(--shadow);
  padding: 13px 15px;
}
.kpi .n {
  font-family: var(--display);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.02em;
}
.kpi .l { color: var(--ink-3); font-size: 12px; }
.kpi.is-crit .n { color: var(--crit); }
.kpi.is-warn .n { color: var(--warn); }
.kpi.is-good .n { color: var(--accent); }

.list-row {
  border-top: 0.5px solid var(--line);
  border-left: 0;
  position: relative;
}
.list-row:hover { background: var(--surface-2); }
.list-row.is-crit::before,
.list-row.is-warn::before,
.list-row.is-good::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
}
.list-row.is-crit::before { background: var(--crit); }
.list-row.is-warn::before { background: var(--warn); }
.list-row.is-good::before { background: var(--accent); }

.note { background: var(--fill); color: var(--ink-2); border-radius: var(--r); }
:root[data-theme="dark"] .note,
:root[data-theme="light"] .note { background: var(--fill); color: var(--ink-2); }

/* ---------- Chips ---------- */

.chip {
  border: 0;
  background: var(--fill);
  color: var(--ink-2);
  font-size: 11.5px;
  letter-spacing: 0;
  padding: 2px 9px;
}
.chip.plain { background: transparent; box-shadow: inset 0 0 0 0.5px var(--line-strong); }

/* ---------- Segment-Regler ---------- */

.seg {
  background: var(--fill);
  border-radius: 9px;
  padding: 2px;
  gap: 0;
}
.seg a {
  border-radius: 7px;
  padding: 5px 12px;
  font-weight: 500;
  color: var(--ink);
  transition: background 200ms var(--feder), box-shadow 200ms var(--feder);
}
.seg a.on {
  background: var(--seg-an);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--line);
  font-weight: 600;
}
.seg a .n { font-family: var(--ui); font-variant-numeric: tabular-nums; }
.seg a.on .n { color: var(--tint); }

/* Reiter der Artikel-Detailseite werden ebenfalls ein Segment-Regler */
.reiter {
  display: inline-flex;
  max-width: 100%;
  gap: 0;
  padding: 2px;
  border-bottom: 0;
  border-radius: 9px;
  background: var(--fill);
}
.reiter a {
  top: 0;
  border: 0;
  border-radius: 7px;
  padding: 5px 14px;
  font-weight: 500;
  color: var(--ink);
}
.reiter a.on {
  background: var(--seg-an);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--line);
  font-weight: 600;
}

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

table, .bl-tabelle { font-variant-numeric: tabular-nums; }
thead th,
.bl-tabelle thead th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  border-bottom: 0.5px solid var(--line);
}
tbody td,
.bl-tabelle td { border-bottom: 0.5px solid var(--line); }
td.num, th.num { font-family: var(--ui); }
.bl-tabelle .bl-name:hover,
.bl-karte .bl-name:hover { color: var(--tint); text-decoration: none; }
.bl-tabelle tr.bl-tr.is-dringend td:first-child { box-shadow: inset 3px 0 0 var(--crit); }

.bl-karte {
  border: 0;
  border-top: 0;
  border-radius: var(--r-gross);
  box-shadow: var(--shadow);
  position: relative;
}
.bl-karte.is-warn > summary,
.bl-karte.is-good > summary,
.bl-karte.is-crit > summary { box-shadow: inset 0 3px 0 var(--status, transparent); }
.bl-karte.is-warn { --status: var(--warn); }
.bl-karte.is-good { --status: var(--accent); }
.bl-karte.is-crit { --status: var(--crit); }
.bl-karte .bl-sum { font-family: var(--ui); font-variant-numeric: tabular-nums; }

/* ---------- Eingaben ---------- */

input, select, textarea {
  border: 0.5px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  transition: box-shadow 150ms ease, border-color 150ms ease;
}
input:hover, select:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--tint);
  box-shadow: 0 0 0 3px var(--tint-soft);
}
input[type="checkbox"], input[type="radio"] { box-shadow: none; }
input.mono, .grid-2 input.mono { font-family: var(--ui); }
.field > label { font-weight: 500; color: var(--ink-3); }

.searchform input { border-radius: 9px; background: var(--fill); border-color: transparent; }

/* ---------- Schaltflaechen: Pillen, Feedback schon beim Druecken ---------- */

.btn {
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
  font-weight: 500;
  padding: 10px 18px;
  transition: transform 100ms ease-out, filter 150ms ease, background 150ms ease;
}
.btn:hover { background: var(--sand); }
.btn:active { transform: scale(0.97); }
.btn.primary,
:root[data-theme="dark"] .btn.primary,
:root[data-theme="light"] .btn.primary {
  background: var(--tint);
  color: var(--tint-ink);
}
.btn.primary:hover { background: var(--tint); opacity: 0.85; }
.btn.crit { background: var(--crit-soft); color: var(--crit); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--fill); }
.btn.sm { padding: 6px 14px; }

.icon-btn {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  transition: background 150ms ease, transform 100ms ease-out;
}
.icon-btn:hover { background: var(--fill); }
.icon-btn:active { transform: scale(0.94); }

.stepper button {
  border: 0;
  border-radius: var(--r);
  background: var(--fill);
  color: var(--ink);
  font-weight: 500;
  transition: transform 100ms ease-out, background 150ms ease;
}
.stepper button:active { transform: scale(0.97); }

.rail-nav a:active,
.list-row:active,
.seg a:active { transform: scale(0.98); }

/* ---------- Modale Blaetter: abdunkeln, Blatt nach vorn ---------- */

.form-overlay {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.form-overlay .modal-panel {
  border-radius: var(--r-gross);
  box-shadow: var(--shadow-hoch);
  animation: apple-blatt 320ms var(--feder);
}
@keyframes apple-blatt {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

/* ---------- Groessen ab Desktop ---------- */

@media (min-width: 900px) {
  h1 { font-size: 28px; }
}

/* ---------- Barrierefreiheit ---------- */

@media (prefers-reduced-motion: reduce) {
  .btn:active, .icon-btn:active, .stepper button:active,
  .rail-nav a:active, .list-row:active, .seg a:active { transform: none; }
  .form-overlay .modal-panel { animation: none; }
}

/* Ohne Transparenz werden die Materialien massiv */
@media (prefers-reduced-transparency: reduce) {
  .app > .rail, .topbar, .tabbar, .form-overlay {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .app > .rail, .topbar, .tabbar { background: var(--surface); }
}

@media (prefers-contrast: more) and (prefers-color-scheme: light) {
  :root {
    --line: rgba(0, 0, 0, 0.3);
    --line-strong: rgba(0, 0, 0, 0.5);
    --ink-3: #48484A;
  }
  .card, .kpi, .bl-karte { box-shadow: 0 0 0 1px var(--line-strong); }
}
