:root {
  --teal: #00BCBC;
  --teal-dark: #009A9A;
  --ink: #1A202C;
  --muted: #6B7280;
  --line: #E3E8EF;
  --bg: #F2F4F7;
  --white: #FFFFFF;
  --ok: #16A34A;
  --warn: #D97706;
  --err: #DC2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lift: 0 12px 34px rgba(16, 24, 40, .18);
  --tap: 44px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "DejaVu Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
input, select, button { font: inherit; }

/* ---------- Anmeldung ---------- */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
}
.login .card {
  width: 100%; max-width: 400px; background: var(--white); border-radius: 14px;
  padding: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.login h1 { font-size: 19px; margin: 18px 0 12px; font-weight: 600; }
.login label { font-size: 12.5px; color: var(--muted); margin: 14px 0 6px; }
input, select {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--white); color: var(--ink); width: 100%; min-height: var(--tap);
}
input:focus, select:focus { outline: 2px solid rgba(0, 188, 188, .35); outline-offset: 1px; border-color: var(--teal); }
button.primary {
  margin-top: 20px; padding: 13px 16px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--teal); color: #fff; font-weight: 600; min-height: var(--tap);
}
button.primary:hover { background: var(--teal-dark); }
button.primary:disabled { opacity: .6; cursor: default; }
.hint { font-size: 12.5px; color: var(--err); min-height: 16px; margin: 10px 0 0; }
.hint.muted { color: var(--muted); }

/* ---------- Marke ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; letter-spacing: .3px; }
.brand b { font-weight: 700; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--teal), #0E7C7C);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55);
}

/* ---------- Appbar: Telefon und Tablet ---------- */
.appbar {
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 30;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--white); border-bottom: 1px solid var(--line);
}
.appbar-title { font-size: 15px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.burger {
  width: var(--tap); height: var(--tap); flex: none; border: 0; background: none; padding: 0;
  display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  cursor: pointer; border-radius: 10px;
}
.burger:active { background: #F1F4F8; }
.burger span { display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .18s ease, opacity .18s ease; }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Grundgerüst: mobil zuerst (Schublade) ---------- */
.shell { display: block; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
  width: 84%; max-width: 310px;
  background: var(--white); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-103%);
  transition: transform .22s ease;
  box-shadow: var(--shadow-lift);
  overflow-y: auto;
  visibility: hidden;
}
.sidebar.open { transform: translateX(0); visibility: visible; }
.sidebar .brand { padding: 0 6px 4px; }

.sidebar nav { margin-top: 20px; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px;
  color: var(--muted); font-size: 15px; min-height: var(--tap);
}
.sidebar nav a:active { background: #F1F4F8; color: var(--ink); }
.sidebar nav a.active { background: rgba(0, 188, 188, .12); color: var(--teal-dark); font-weight: 600; }
.sidebar nav .ico { width: 18px; text-align: center; opacity: .85; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 6px 0; }
.sidebar-foot .user { font-size: 13px; color: var(--muted); line-height: 1.5; }
.sidebar-foot .user b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
button.link {
  background: none; border: 0; padding: 12px 0 0; color: var(--muted); font-size: 13.5px;
  cursor: pointer; text-align: left; min-height: var(--tap);
}
button.link:hover { color: var(--teal-dark); }

.backdrop {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(16, 24, 40, .45);
  opacity: 0; transition: opacity .2s ease;
}
.backdrop.show { opacity: 1; }

main { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--white); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 15px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.top-actions select { width: auto; padding: 8px 10px; font-size: 13px; min-height: 38px; border-radius: 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.status-dot.stale { background: var(--warn); box-shadow: 0 0 0 3px rgba(217, 119, 6, .15); }
.view { padding: 14px 14px calc(28px + env(safe-area-inset-bottom)); }

/* ---------- Kacheln ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--white); border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow); }
.kpi .label { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi .value.err { color: var(--err); }
.kpi .value.ok { color: var(--ok); }

/* ---------- Flächen ---------- */
.panel { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.panel-head .sub { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.empty { padding: 26px 16px; color: var(--muted); font-size: 14px; text-align: center; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:active { background: #F7FAFA; }
td.num { font-variant-numeric: tabular-nums; }
.row-link { cursor: pointer; }

/* ---------- Marken ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: rgba(22, 163, 74, .1); color: var(--ok); }
.badge.warn { background: rgba(217, 119, 6, .12); color: var(--warn); }
.badge.err { background: rgba(220, 38, 38, .1); color: var(--err); }
.badge.muted { background: #F1F4F8; color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Detail ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.kv { display: grid; grid-template-columns: 1fr; gap: 0; padding: 4px 16px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; margin-top: 12px; }
.kv dd { margin: 2px 0 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.pills { display: flex; flex-wrap: wrap; gap: 7px; padding: 14px 16px; }
.pill { padding: 6px 11px; border-radius: 999px; font-size: 12.5px; background: #F1F4F8; color: var(--muted); }
.pill.ok { background: rgba(22, 163, 74, .1); color: var(--ok); }
.pill.err { background: rgba(220, 38, 38, .1); color: var(--err); }
.muted { color: var(--muted); }
.btn-ghost {
  border: 1px solid var(--line); background: var(--white); color: var(--ink); border-radius: 9px;
  padding: 10px 14px; font-size: 13.5px; cursor: pointer; min-height: var(--tap);
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-dark); }
.back-link {
  display: inline-flex; align-items: center; gap: 8px; color: #017878; font-size: 14px; font-weight: 600;
  padding: 10px 14px; margin: 0 0 12px; border-radius: 9px; min-height: var(--tap);
  background: #F4FBFB; border: 1.5px solid rgba(0, 188, 188, .45);
}
.back-link:hover { background: rgba(0, 188, 188, .12); border-color: var(--teal); }
.back-link:active { background: rgba(0, 188, 188, .18); }

/* ---------- Tablet ---------- */
@media (min-width: 700px) {
  .appbar { padding: calc(10px + env(safe-area-inset-top)) 18px 10px; }
  .appbar-title { font-size: 16px; }
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .view { padding: 18px 20px 32px; }
  .topbar { padding: 12px 20px; }
  .topbar h2 { font-size: 16px; }
  .sidebar { width: 320px; }
  .kv { grid-template-columns: 170px 1fr; gap: 10px 16px; padding: 16px; align-items: baseline; }
  .kv dt { margin-top: 0; }
  .kv dd { margin: 0; }
  .grid-2 { grid-template-columns: 1.25fr 1fr; }
}

/* ---------- Schreibtisch: feste Seitenleiste ---------- */
@media (min-width: 1025px) {
  .shell { display: grid; grid-template-columns: 244px 1fr; }
  .appbar { display: none; }
  .sidebar {
    position: sticky; top: 0; transform: none; visibility: visible;
    width: auto; max-width: none; height: 100dvh; box-shadow: none; z-index: 1; padding: 22px 16px;
  }
  .backdrop { display: none !important; }
  .topbar { padding: 18px 28px; }
  .topbar h2 { font-size: 17px; }
  .view { padding: 24px 28px 40px; }
  .kpi { padding: 16px 18px; }
  .kpi .value { font-size: 26px; }
  th, td { padding: 12px 18px; }
  tbody tr:hover { background: #FAFCFC; }
  .sidebar nav a:hover { background: #F5F8F8; color: var(--ink); }
}

/* ---------- Telefon: eine Leiste, Menü in der Schublade ---------- */
.drawer-lang { display: none; margin-bottom: 14px; }
.drawer-lang label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

@media (max-width: 699px) {
  .topbar { display: none; }
  .drawer-lang { display: block; }
  .panel table thead { display: none; }
  .panel table, .panel tbody, .panel tr, .panel td { display: block; width: 100%; }
  .panel tbody tr { padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
  .panel tbody tr:last-child { border-bottom: 0; }
  .panel td {
    border: 0; padding: 6px 16px; display: flex; align-items: baseline;
    justify-content: space-between; gap: 14px; text-align: right;
  }
  .panel td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none;
  }
  .panel td:empty { display: none; }
  .panel td .btn-ghost, .panel td .btn-ack { width: 100%; }
  .panel td.action { padding-top: 10px; }
  .panel td.action::before { content: ""; }
  .badge { font-size: 12px; padding: 5px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .backdrop, .burger span { transition: none; }
}

/* ==========================================================================
   Bedienelemente deutlich erkennbar
   ========================================================================== */

/* Fokus: sichtbar für Tastatur, nicht für Maus */
:focus-visible {
  outline: 3px solid rgba(0, 188, 188, .45);
  outline-offset: 2px;
  border-radius: 8px;
}

/* --- Schaltflächen --- */
button.primary {
  background: var(--teal);
  box-shadow: 0 2px 0 #018585, 0 6px 14px rgba(0, 188, 188, .28);
  font-size: 15px;
  letter-spacing: .2px;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
button.primary:hover { background: var(--teal-dark); box-shadow: 0 2px 0 #017575, 0 8px 18px rgba(0, 188, 188, .32); }
button.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #016B6B, 0 2px 6px rgba(0, 188, 188, .25); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #F4FBFB;
  border: 1.5px solid rgba(0, 188, 188, .55);
  color: #017878;
  font-weight: 600;
  padding: 10px 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.btn-ghost:hover { background: rgba(0, 188, 188, .12); border-color: var(--teal); color: #016B6B; }
.btn-ghost:active { transform: translateY(1px); background: rgba(0, 188, 188, .18); }

/* Quittieren: klare Hauptaktion in der Zeile */
.btn-ack {
  background: var(--teal); border: 0; color: #fff; font-weight: 600;
  padding: 10px 16px; border-radius: 9px; min-height: var(--tap); cursor: pointer;
  box-shadow: 0 2px 0 #018585, 0 4px 10px rgba(0, 188, 188, .25);
}
.btn-ack:hover { background: var(--teal-dark); }
.btn-ack:active { transform: translateY(2px); box-shadow: 0 1px 0 #016B6B; }
.btn-ack:disabled { opacity: .55; box-shadow: none; cursor: default; }

/* --- Navigation: aktiver Punkt mit Balken und Fläche --- */
.sidebar nav a {
  position: relative;
  font-weight: 500;
  border: 1px solid transparent;
}
.sidebar nav a.active {
  background: rgba(0, 188, 188, .14);
  border-color: rgba(0, 188, 188, .35);
  color: #016B6B;
  font-weight: 700;
}
.sidebar nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--teal);
}
.sidebar nav a.active .ico { opacity: 1; }
.sidebar nav .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: #EEF4F5; color: #4B5563; font-size: 13px;
}
.sidebar nav a:hover .ico { background: rgba(0, 188, 188, .16); color: var(--teal-dark); }
.sidebar nav a.active .ico { background: var(--teal); color: #fff; }

/* --- Burger als sichtbare Schaltfläche --- */
.burger {
  background: #F1F6F6;
  border: 1px solid var(--line);
}
.burger:active { background: #E4EFEF; }

/* --- Auswahlfeld: als Bedienelement erkennbar --- */
.top-actions select, .drawer-lang select {
  border: 1.5px solid var(--line);
  background-color: #FBFDFD;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  cursor: pointer;
}
.top-actions select:hover, .drawer-lang select:hover { border-color: rgba(0, 188, 188, .5); }

/* --- Anklickbare Zeilen: Hervorhebung + Pfeil --- */
.panel tbody tr.row-link { position: relative; transition: background .12s ease; }
.panel tbody tr.row-link:hover { background: rgba(0, 188, 188, .07); }
.panel tbody tr.row-link:hover td { color: #016B6B; }
.panel tbody tr.row-link:active { background: rgba(0, 188, 188, .14); }
td.chev { width: 40px; padding-left: 0; text-align: right; color: var(--teal); font-size: 18px; font-weight: 700; }
th.chev, td.chev { width: 44px; }
tr.row-link td.chev::after { content: "›"; }

/* --- Kleine Rückmeldung beim Antippen --- */
a, button, .row-link { touch-action: manipulation; }

/* ==========================================================================
   Formulare (Rezepte, Ausrollung)
   ========================================================================== */
.form-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px 16px; padding: 16px;
}
.form-grid label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid textarea {
  width: 100%; font-family: ui-monospace, "DejaVu Sans Mono", monospace; font-size: 13px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #FBFDFD;
  color: var(--ink); resize: vertical; min-height: 84px;
}
.form-grid textarea:focus { outline: 2px solid rgba(0, 188, 188, .35); border-color: var(--teal); }
.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.form-actions .primary { margin-top: 0; min-width: 160px; }
.form-actions .hint { margin: 0; }

.check-list { display: flex; flex-direction: column; gap: 4px; }
label.check {
  display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #FBFDFD;
  min-height: var(--tap); cursor: pointer; font-weight: 400;
}
label.check:hover { border-color: rgba(0, 188, 188, .5); background: #F4FBFB; }
label.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--teal); }

@media (min-width: 700px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
