/* SCM-Planspiel – Design-System (angelehnt an die Apple Human Interface Guidelines) */
:root {
  /* Flächen & Text */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .08);
  --fill-hover: rgba(120, 120, 128, .18);
  --ink: #1d1d1f;
  --ink-2: #424245;
  --muted: #6e6e73;
  --muted-2: #86868b;
  --line: rgba(0, 0, 0, .08);
  --line-2: #d2d2d7;
  /* Systemfarben */
  --blue: #0071e3;
  --blue-ink: #0066cc;
  --green: #34c759;
  --green-ink: #248a3d;
  --orange: #ff9500;
  --orange-ink: #c93400;
  --red: #ff3b30;
  --red-ink: #d70015;
  --purple: #af52de;
  --brand: var(--blue);
  /* Kompatibilität mit bestehenden Komponenten */
  --brand-soft: #e8f1fd;
  --ok: var(--green-ink);
  --ok-soft: #e9f8ee;
  --warn: var(--orange-ink);
  --warn-soft: #fff4e5;
  --bad: var(--red-ink);
  --bad-soft: #ffeceb;
  --surface-2: #fafafc;
  --accent: var(--orange);
  /* Form & Bewegung */
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 1px rgba(0, 0, 0, .02);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-hover: 0 8px 28px rgba(0, 0, 0, .08);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .06);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Inter Variable', 'Segoe UI Variable Text', 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --ease: cubic-bezier(.25, .1, .25, 1);
  --spring: cubic-bezier(.32, .72, 0, 1);
  --gutter: clamp(16px, 2.6vw, 48px);
  --gap: clamp(12px, 1.2vw, 20px);
  --bar-h: 52px;
  color-scheme: light;
}

/* Grundschrift wächst moderat mit dem Bildschirm (stabil bei Windows-Skalierung 100–200 %) */
html { font-size: clamp(14.5px, 10.5px + .32vw, 17px); -webkit-text-size-adjust: 100%; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.47;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.12; font-weight: 600; }
h1 { font-size: clamp(1.75rem, 1.2rem + 1.3vw, 2.5rem); letter-spacing: -.028em; font-weight: 700; }
h2 { font-size: 1.35rem; letter-spacing: -.022em; }
h3 { font-size: 1.06rem; letter-spacing: -.016em; }
p { margin: 0; }
a { color: var(--blue-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--muted); }
small { font-size: .82rem; letter-spacing: -.006em; }
.mono { font-family: var(--mono); }
.num, .value, table.data td { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.show-sm { display: none; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
::selection { background: rgba(0, 113, 227, .2); }
:focus-visible { outline: 3px solid rgba(0, 113, 227, .45); outline-offset: 2px; }

/* ---------- Titelleiste (durchscheinend wie in macOS) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--bar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 var(--gutter);
  background: rgba(251, 251, 253, .78);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid rgba(0, 0, 0, .12);
  color: var(--ink);
}
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1rem; color: var(--ink); text-decoration: none; letter-spacing: -.018em; white-space: nowrap; }
.topbar .logo svg { width: 26px; height: 26px; }
.topbar .chip { background: transparent; border: 0; padding: 0; color: var(--muted); font-weight: 500; }
.topbar #topInfo { gap: 0 !important; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.topbar #topInfo > * + *::before { content: '·'; margin: 0 9px; color: var(--muted-2); }
.topbar .team-swatch { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Layout ---------- */
.wrap { width: 100%; margin: 0; padding: clamp(18px, 2.2vw, 36px) var(--gutter) 48px; }
.wrap.narrow { max-width: 560px; margin: 0 auto; }
.grid { display: grid; gap: var(--gap); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 25vw, 440px); gap: var(--gap); align-items: start; }
@media (max-width: 1100px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }

.card { --pad: clamp(16px, 1.5vw, 24px); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--pad); }
.card > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card > header h2, .card > header h3 { flex: 1; }
.card > header small { color: var(--muted); }
.card.flat { box-shadow: none; }
.card.pad-0 { padding: 0; overflow: hidden; }
.reveal { animation: reveal .6s var(--spring) both; animation-delay: calc(var(--i, 0) * 50ms); }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Bedienelemente ---------- */
.btn {
  appearance: none; border: 0; background: var(--fill); color: var(--ink); font: inherit; font-size: .94rem; font-weight: 500;
  letter-spacing: -.01em; padding: 8px 15px; border-radius: 10px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 1.25; white-space: nowrap;
  transition: background .2s var(--ease), transform .12s var(--ease), opacity .2s, color .2s;
}
.btn:hover { background: var(--fill-hover); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .4; cursor: default; transform: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #0077ed; }
.btn.ok { background: var(--green-ink); color: #fff; }
.btn.danger { color: var(--red-ink); }
.btn.danger:hover { background: rgba(255, 59, 48, .12); }
.btn.ghost { background: transparent; color: var(--blue-ink); }
.btn.ghost:hover { background: var(--fill-2); }
.btn.dark { background: var(--fill); color: var(--ink); }
.btn.sm { padding: 5px 11px; font-size: .84rem; border-radius: 8px; }
.btn.lg { padding: 13px 22px; font-size: 1.03rem; border-radius: 12px; font-weight: 600; }
.btn.block { width: 100%; }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .88rem; color: var(--ink-2); }
label.field small { font-weight: 400; color: var(--muted); }
.input, select.input, textarea.input {
  font: inherit; font-size: 1rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; width: 100%; transition: border-color .2s, box-shadow .2s; letter-spacing: -.01em;
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, .18); }
.input[disabled] { background: var(--fill-2); color: var(--muted); }
.input.code { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .3em; text-transform: uppercase; text-align: center; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .94rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

/* ---------- Status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--fill-2);
  font-size: .82rem; font-weight: 500; white-space: nowrap; color: var(--ink-2);
}
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill.lobby { background: rgba(88, 86, 214, .12); color: #3634a3; }
.pill.running { background: rgba(52, 199, 89, .14); color: var(--green-ink); }
.pill.paused { background: rgba(255, 149, 0, .14); color: var(--orange-ink); }
.pill.finished { background: var(--fill); color: var(--ink-2); }
.pill.open { background: rgba(0, 113, 227, .1); color: var(--blue-ink); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted-2); flex: none; }
.status-dot.on { background: var(--green); }
.status-dot.off { background: #c7c7cc; }
.team-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.banner { border-radius: 14px; padding: 13px 16px; display: flex; gap: 12px; align-items: flex-start; font-size: .95rem; background: var(--surface); box-shadow: var(--shadow); color: var(--ink-2); }
.banner b { color: var(--ink); font-weight: 600; }
.banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.banner.info svg { color: var(--blue); }
.banner.warn svg { color: var(--orange); }
.banner.bad { background: #fff2f1; box-shadow: none; }
.banner.bad svg { color: var(--red); }
.banner.ok { background: #effaf2; box-shadow: none; color: #1e5631; }
.banner.ok svg { color: var(--green-ink); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th, table.data td { padding: 10px 12px; border-bottom: .5px solid var(--line); text-align: right; white-space: nowrap; }
table.data th { font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--surface); position: sticky; top: 0; z-index: 1; letter-spacing: -.004em; }
table.data th:first-child, table.data td:first-child, table.data .left { text-align: left; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fafafc; }
table.data td.bad { color: var(--red-ink); font-weight: 600; }
table.data tr.current td { background: #f2f7ff; }
table.data td.order { font-weight: 600; color: var(--blue-ink); }

/* ---------- Segmente & Reiter ---------- */
.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 0; }
.seg button { appearance: none; border: 0; background: none; font: inherit; font-size: .84rem; font-weight: 500; padding: 5px 14px; border-radius: 7px; cursor: pointer; color: var(--ink); transition: background .2s, box-shadow .2s; }
.seg button.active { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); font-weight: 600; }
.tabs { display: flex; gap: 2px; margin-bottom: var(--gap); overflow-x: auto; background: var(--fill); border-radius: 10px; padding: 2px; width: max-content; max-width: 100%; }
.tabs button {
  appearance: none; border: 0; background: none; font: inherit; font-size: .9rem; font-weight: 500; color: var(--ink);
  padding: 6px 14px; cursor: pointer; border-radius: 8px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center;
}
.tabs button.active { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }
.tabs .count { color: var(--muted); font-size: .8rem; font-weight: 500; }

/* ---------- Mitteilungen & Fenster ---------- */
#toasts { position: fixed; right: var(--gutter); top: calc(var(--bar-h) + 12px); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast {
  background: rgba(255, 255, 255, .86); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  color: var(--ink); padding: 12px 16px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .06);
  font-size: .92rem; font-weight: 500; animation: toast-in .5s var(--spring); display: flex; gap: 10px; align-items: flex-start;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex: none; margin-top: 7px; }
.toast.ok::before { background: var(--green); }
.toast.bad::before { background: var(--red); }
.toast.msg::before { background: var(--blue); }
@keyframes toast-in { from { transform: translateY(-10px) scale(.98); opacity: 0; } }

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 90; display: grid; place-items: center; padding: 20px; animation: fade .25s ease-out; }
.modal {
  background: #fff; border-radius: 22px; box-shadow: var(--shadow-lg); width: min(500px, 100%); padding: 26px;
  max-height: calc(100dvh - 40px); overflow: auto; animation: pop .45s var(--spring);
}
.modal h2 { margin-bottom: 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-back.closing { animation: fade-out .2s forwards; }
.modal-back.closing .modal { animation: pop-out .2s forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.98); } }

/* Detailblatt einer Kennzahl */
.modal-back.sheet .modal { width: min(920px, 100%); padding: 0; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 22px 24px 6px; position: sticky; top: 0; background: #fff; z-index: 2; }
.sheet-ic { display: none; }
.sheet-head h2 { margin: 0; font-size: 1.6rem; letter-spacing: -.026em; color: var(--ink); }
.sheet-head small { display: block; margin-top: 2px; font-size: .9rem; }
.sheet-head .btn { margin-left: auto; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: var(--fill); color: var(--muted); font-size: .9rem; }
.sheet-body { padding: 14px 24px 26px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 0; margin-bottom: 18px; border-top: .5px solid var(--line); border-bottom: .5px solid var(--line); }
.stat { padding: 12px 14px 12px 0; }
.stat + .stat { padding-left: 14px; border-left: .5px solid var(--line); }
.stat span { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat b { display: block; font-size: 1.5rem; font-weight: 600; letter-spacing: -.024em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat b small { font-size: .8rem; font-weight: 500; }
.sheet .chart-box { height: clamp(240px, 38vh, 380px); }
.sheet .explain { margin-top: 16px; color: var(--muted); font-size: .94rem; }

/* ---------- Lieferkette (Szene) ---------- */
.scene-box { container-type: inline-size; }
.scene {
  --bld-w: clamp(52px, 11cqw, 136px); --bld-h: calc(var(--bld-w) * .833); --road-h: clamp(18px, 2.4cqw, 30px); --top: clamp(14px, 2cqw, 26px);
  position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding-top: var(--top); isolation: isolate;
}
.scene .road {
  position: absolute; left: calc(var(--pad, 0px) * -1); right: calc(var(--pad, 0px) * -1); top: calc(var(--top) + var(--bld-h)); height: var(--road-h); z-index: 0;
  background: #e8e8ed; border-top: 1px solid #d9d9de; border-bottom: 1px solid #d9d9de;
}
.scene .road i { position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: repeating-linear-gradient(90deg, #fff 0 18px, transparent 18px 36px); }
.station { display: flex; flex-direction: column; align-items: center; min-width: 0; position: relative; z-index: 1; }
.bld { width: var(--bld-w); height: var(--bld-h); position: relative; transform-origin: 50% 100%; transition: transform .5s var(--spring); }
.bld-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.road-gap { height: var(--road-h); }
.lbl { margin-top: 10px; text-align: center; display: flex; flex-direction: column; gap: 1px; max-width: 100%; padding: 0 4px; }
.lbl b { font-size: .92rem; font-weight: 600; hyphens: manual; overflow-wrap: break-word; line-height: 1.2; letter-spacing: -.014em; }
.lbl small { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station.me .bld { transform: scale(1.1); }
.station.me .bld::after {
  content: ''; position: absolute; left: 50%; bottom: calc(var(--road-h) * -.5); width: 150%; height: var(--road-h); transform: translateX(-50%); z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--me) 30%, transparent), transparent);
}
.me-tag {
  position: absolute; left: 50%; top: -1.15rem; transform: translateX(-50%); background: var(--me); color: #fff;
  font-size: .68rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; letter-spacing: 0;
}
.bld .badge {
  position: absolute; right: -2px; top: -2px; width: 20px; height: 20px; border-radius: 50%; z-index: 2;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; box-shadow: 0 0 0 2px #fff; animation: badge-in .45s var(--spring);
}
.bld .badge.done { background: var(--green); color: #fff; }
.bld .badge.wait { background: #e5e5ea; color: var(--muted); }
.bld .badge.bot { background: #8e8e93; color: #fff; font-size: 8px; }
@keyframes badge-in { from { transform: scale(.3); opacity: 0; } }
.smoke circle { fill: #d1d1d6; opacity: 0; transform-box: fill-box; transform-origin: center; animation: smoke 4s ease-out infinite; }
.smoke circle:nth-child(2) { animation-delay: 1.3s; }
.smoke circle:nth-child(3) { animation-delay: 2.6s; }
@keyframes smoke { 0% { opacity: 0; transform: translate(0, 6px) scale(.5); } 25% { opacity: .9; } 100% { opacity: 0; transform: translate(4px, -16px) scale(1.7); } }
.scene.compact { --bld-w: clamp(44px, 12cqw, 84px); --top: 6px; }
.scene.compact .lbl b { font-size: .82rem; font-weight: 500; color: var(--ink-2); }
.chain-legend { display: flex; gap: 22px; font-size: .82rem; color: var(--muted); margin-top: 14px; justify-content: center; flex-wrap: wrap; }
.chain-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chain-legend svg { width: 15px; height: 15px; color: var(--muted-2); }
@container (max-width: 560px) {
  .scene:not(.compact) { grid-template-columns: repeat(4, minmax(0, 1fr)); --bld-w: clamp(48px, 15cqw, 80px); }
  .scene:not(.compact) .station.customer { display: none; }
  .lbl b { font-size: .8rem; }
  .lbl small { font-size: .72rem; }
}

/* Lieferkette in 3D: Canvas mit HTML-Beschriftungen darüber */
.s3 { position: relative; width: 100%; touch-action: pan-y; container-type: inline-size; }
.s3 canvas { display: block; width: 100%; outline: none; }
.s3-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.s3-lbl { position: absolute; transform: translateX(-50%); margin: 0; align-items: center; }
.s3-lbl b, .s3-lbl small { max-width: 100%; }
.s3-lbl.side { transform: none; align-items: flex-start; text-align: left; width: max-content; max-width: 46%; }
.s3-lbl.side b { hyphens: none; white-space: nowrap; }
.s3.compact .s3-lbl b { font-size: .82rem; font-weight: 500; color: var(--ink-2); }
.s3-badge {
  position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; box-shadow: 0 0 0 2px #fff, 0 2px 6px rgb(0 0 0 / .12);
  animation: badge-in .45s var(--spring);
}
.s3-badge.done { background: var(--green); color: #fff; }
.s3-badge.wait { background: #e5e5ea; color: var(--muted); }
.s3-badge.bot { background: #8e8e93; color: #fff; font-size: 8px; }
.s3-overlay [hidden] { display: none; }
.s3-overlay .off { visibility: hidden; }
.is-3d .chain-legend { margin-top: 6px; }
.s3-tag { top: auto; transform: translate(-50%, -100%); box-shadow: 0 2px 8px rgb(0 0 0 / .14); }
.hero-scene.is-3d { padding-bottom: 6px; }
@container (max-width: 560px) {
  .s3-lbl b { font-size: .78rem; }
  .s3-lbl small { font-size: .7rem; }
}

/* Fahrende Lastwagen, fliegende Bestellungen */
.flow-layer { position: relative; }
.truck-token { position: absolute; left: 0; top: 0; width: 78px; z-index: 6; pointer-events: none; will-change: transform, opacity; }
.truck-svg { width: 100%; height: auto; display: block; overflow: visible; }
.truck-token .wheel { transform-box: fill-box; transform-origin: center; }
.truck-token.driving .wheel { animation: wheel .45s linear infinite; }
@keyframes wheel { to { transform: rotate(-360deg); } }
.order-token {
  position: absolute; left: 0; top: 0; z-index: 7; display: inline-flex; align-items: center; gap: 4px; pointer-events: none;
  padding: 4px 10px 4px 8px; background: rgba(255, 255, 255, .95); color: var(--blue-ink); border-radius: 99px;
  font-weight: 600; font-size: .82rem; line-height: 1; box-shadow: 0 6px 18px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .08); will-change: transform, opacity;
}
.order-token svg { width: 14px; height: 14px; }
.qty-bubble { position: absolute; left: 0; top: 0; z-index: 8; pointer-events: none; background: var(--green); color: #fff; font-weight: 600; padding: 3px 10px; border-radius: 99px; font-size: .86rem; white-space: nowrap; box-shadow: 0 6px 16px rgba(52, 199, 89, .35); }

/* ---------- Kennzahlen (Kacheln wie in Apple Health) ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.kpi {
  appearance: none; font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; border: 0;
  background: var(--surface); border-radius: var(--radius); padding: 16px 18px 0; position: relative; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .35s var(--spring), box-shadow .35s var(--spring);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.kpi:active { transform: scale(.985); }
.kpi-top { display: flex; align-items: center; gap: 6px; color: var(--c-ink, var(--c)); }
.kpi-ic { display: grid; color: inherit; }
.kpi-ic svg { width: 16px; height: 16px; }
.kpi .label { font-size: .88rem; font-weight: 600; letter-spacing: -.012em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; }
.kpi-more { color: #c7c7cc; display: grid; transition: transform .3s var(--spring), color .2s; }
.kpi-more svg { width: 16px; height: 16px; }
.kpi:hover .kpi-more { color: var(--muted); transform: translateX(2px); }
.kpi-mid { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.kpi .value { font-size: clamp(1.7rem, 1.2rem + 1.1vw, 2.35rem); font-weight: 600; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.delta { font-size: .84rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.delta.good { color: var(--green-ink); }
.delta.bad { color: var(--red-ink); }
.kpi .sub { font-size: .84rem; color: var(--muted); margin-top: 6px; }
.kpi .spark { display: block; width: calc(100% + 36px); height: clamp(26px, 2.6vw, 38px); margin: 10px -18px 0; }
.kpi.bad .value { color: var(--red-ink); }
.kpi.static { cursor: default; padding-bottom: 18px; }
.kpi.static:hover { transform: none; box-shadow: var(--shadow); }
.kpi.static .bar { display: none; }
.kpi.static .label { color: var(--muted); font-weight: 500; }
.kpi.static .value { margin-top: 10px; }

.ampel { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 14px; font-weight: 500; background: var(--surface); box-shadow: var(--shadow); color: var(--ink-2); }
.ampel .lights { display: flex; gap: 4px; background: #1d1d1f; padding: 4px 6px; border-radius: 99px; flex: none; }
.ampel .lights i { width: 10px; height: 10px; border-radius: 50%; background: #48484a; display: block; }
.ampel.red .lights i:nth-child(1) { background: var(--red); }
.ampel.yellow .lights i:nth-child(2) { background: #ffcc00; }
.ampel.green .lights i:nth-child(3) { background: var(--green); }

.story { font-size: clamp(1rem, .9rem + .3vw, 1.18rem); color: var(--muted); max-width: 72ch; line-height: 1.5; letter-spacing: -.016em; }
.story b { color: var(--ink); font-weight: 600; }
.week-title { display: flex; align-items: baseline; gap: 10px; }
.week-title h2 { font-size: clamp(1.9rem, 1.3rem + 1.6vw, 3rem); letter-spacing: -.034em; font-weight: 700; }
.week-title h2.bump { animation: bump .7s var(--spring); }
@keyframes bump { 35% { transform: translateY(-3px); color: var(--blue); } }

/* ---------- Bestellen ---------- */
.order-panel { position: static; }
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; gap: 10px; align-items: center; }
.stepper .btn { width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 1.5rem; font-weight: 400; color: var(--blue-ink); }
.stepper input {
  font-size: clamp(2.6rem, 2rem + 1.6vw, 3.6rem); font-weight: 600; text-align: center; height: auto; padding: 6px 0; letter-spacing: -.035em;
  border: 0; background: transparent; box-shadow: none; font-variant-numeric: tabular-nums; appearance: textfield; -moz-appearance: textfield;
  border-radius: 14px; transition: background .2s;
}
.stepper input:hover { background: var(--fill-2); }
.stepper input:focus { background: var(--fill-2); box-shadow: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; justify-content: center; }
.quick .btn { border-radius: 99px; font-size: .84rem; padding: 6px 12px; background: var(--fill-2); }
.quick .btn:hover { background: var(--fill); }
#orderSubmit { margin-top: 16px !important; }
.order-state { margin-top: 12px; text-align: center; }
.order-state .banner.ok { animation: pop .45s var(--spring); text-align: left; }
.order-state > p { color: var(--muted) !important; }

/* Gruppierte Liste (Team-Status) */
.waitlist { display: flex; flex-direction: column; margin-top: 2px; }
.waitlist .item { display: flex; align-items: center; gap: 12px; font-size: .94rem; padding: 10px 0; position: relative; }
.waitlist .item + .item::before { content: ''; position: absolute; left: 46px; right: 0; top: 0; border-top: .5px solid var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .74rem; font-weight: 600; color: #fff; background: var(--c); letter-spacing: 0; }
.avatar.empty { background: #e5e5ea; color: var(--muted); }
.waitlist .who { flex: 1; min-width: 0; line-height: 1.3; }
.waitlist .who b { display: block; font-size: .94rem; font-weight: 600; color: var(--ink) !important; }
.waitlist .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state-chip { font-size: .84rem; font-weight: 500; white-space: nowrap; }
.state-chip.done { color: var(--green-ink); }
.state-chip.wait { color: var(--muted-2); }

.timer { font-family: var(--mono); font-weight: 600; font-size: .95rem; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--fill); color: var(--ink); }
.timer.low { background: var(--red); color: #fff; animation: pulse 1s infinite; }
.timer svg { width: 15px; height: 15px; }
@keyframes pulse { 50% { opacity: .55; } }

.pipeline { display: flex; gap: 10px; flex-wrap: wrap; }
.pipeline .slot { border-radius: 14px; padding: 10px 14px 12px; min-width: 104px; text-align: center; background: var(--fill-2); }
.pipeline .slot .slot-ic { display: block; width: 46px; margin: 0 auto 4px; }
.pipeline .slot b { display: block; font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pipeline .slot small { font-size: .78rem; }

/* ---------- Team- und Rollenwahl ---------- */
.teams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--gap); }
.team-card { padding-top: 18px; }
.team-card header h3 { display: flex; align-items: center; gap: 8px; }
.seat {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 6px; border-radius: 12px;
  border: 0; background: transparent; cursor: pointer; font: inherit; color: inherit; transition: background .2s; position: relative;
}
.seat + .seat::before { content: ''; position: absolute; left: 58px; right: 6px; top: 0; border-top: .5px solid var(--line); }
.seat:hover { background: var(--fill-2); }
.seat.mine { background: rgba(0, 113, 227, .08); }
.seat .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.seat .ic svg { width: 20px; height: 20px; }
.seat .t { flex: 1; min-width: 0; }
.seat .t b { display: block; font-size: .96rem; font-weight: 600; }
.seat .t span { font-size: .84rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .free { font-size: .84rem; font-weight: 500; color: var(--blue-ink); }

/* ---------- Startseite ---------- */
.hero { text-align: center; padding: clamp(20px, 6vh, 80px) 0 8px; }
.hero .eyebrow { font-size: clamp(1rem, .9rem + .4vw, 1.3rem); font-weight: 600; color: var(--orange-ink); letter-spacing: -.014em; }
.hero h1 { font-size: clamp(2.4rem, 1.4rem + 4vw, 5rem); letter-spacing: -.045em; line-height: 1.04; margin-top: 6px; font-weight: 700; }
.hero p { color: var(--muted); margin: 14px auto 0; font-size: clamp(1.05rem, .95rem + .5vw, 1.45rem); max-width: 34ch; letter-spacing: -.02em; line-height: 1.35; }
.hero-scene { --pad: clamp(14px, 2vw, 28px); width: min(100%, 980px); margin: clamp(24px, 5vh, 56px) auto 0; padding: var(--pad) var(--pad) clamp(12px, 1.6vw, 22px); overflow: hidden; }
.join-card { width: min(100%, 420px); margin: clamp(20px, 4vh, 40px) auto 14px; }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.chart-box { position: relative; height: clamp(240px, 30vh, 380px); }
.chart-box.sm { height: clamp(190px, 24vh, 300px); }
.chart-box.lg { height: clamp(300px, 42vh, 520px); }
.section-title { font-size: .84rem; font-weight: 600; color: var(--muted); margin: 6px 0 10px; }
.explain { font-size: .95rem; color: var(--ink-2); line-height: 1.6; }
.explain ul { padding-left: 1.1em; margin: 0; }
.explain li { margin: 5px 0; }
.flash { animation: flash 1.4s var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 2px rgba(0, 113, 227, .35); } 100% { box-shadow: var(--shadow); } }

.overlay-state { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 80; display: grid; place-items: center; text-align: center; padding: 20px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .3s; }
.overlay-state .box { background: rgba(255, 255, 255, .92); color: var(--ink); padding: 30px 36px; border-radius: 22px; box-shadow: var(--shadow-lg); max-width: 420px; }
.overlay-state .box svg { color: var(--muted); }
.overlay-state h2 { margin: 10px 0 6px; }

/* ---------- Mittlere Breiten ---------- */
@media (max-width: 1100px) {
  .hide-md { display: none !important; }
  #gOrder > * { max-width: 560px; margin-left: auto; margin-right: auto; }
}
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .show-sm { display: inline; }
  th[data-short] { font-size: 0 !important; }
  th[data-short]::after { content: attr(data-short); font-size: .74rem; }
  table.data th, table.data td { padding: 9px 6px; }
  .topbar { gap: 10px; }
  .topbar .logo span, .topbar .team-chip { display: none; }
  .topbar .team-chip + *::before { content: none !important; }
  .kpis, #gKpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 14px 14px 0; }
  .kpi .spark { width: calc(100% + 28px); margin: 8px -14px 0; }
  .kpi .label { font-size: .82rem; }
  .kpi-more { display: none; }
  .order-panel { position: static; }
  .kpis > .kpi.static:last-child:nth-child(odd) { grid-column: span 2; }
  /* Detailblatt von unten wie in iOS */
  .modal-back.sheet { place-items: end center; padding: 0; }
  .modal-back.sheet .modal { border-radius: 22px 22px 0 0; max-height: 92dvh; animation: sheet-up .55s var(--spring); width: 100%; }
  .modal-back.sheet.closing .modal { animation: sheet-down .25s forwards; }
  .sheet-head { padding: 22px 18px 4px; }
  .sheet-head::before { content: ''; position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: #d1d1d6; }
  .sheet-body { padding: 12px 18px 24px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .stat:nth-child(n + 3) { border-top: .5px solid var(--line); }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
