:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-press: #0062c4;
  --green: #1f8a3b;
  --orange: #b25000;
  --red: #d70015;
  --indigo: #4b44c8;
  --bar: rgba(245, 245, 247, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --seg-on: #ffffff;
  --radius: 18px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font: 100%/1.47 -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI Variable Text', 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #0a84ff;
    --accent-press: #3a9bff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --indigo: #7d7aff;
    --bar: rgba(0, 0, 0, 0.66);
    --seg-on: #636366;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }

/* Kopfzeile: durchscheinend, Inhalt läuft darunter */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 max(24px, calc((100vw - 1180px) / 2));
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; font-size: 1.06rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; }
.bar .spacer { flex: 1; }

main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 96px; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); line-height: 1.08; letter-spacing: -0.025em; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 1.375rem; line-height: 1.2; letter-spacing: -0.015em; font-weight: 600; margin: 0; }
.sub { color: var(--muted); font-size: 1.05rem; margin: 0; }
.muted { color: var(--muted); }
.section { margin-top: 48px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }

/* Zähler */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 28px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 2rem; line-height: 1.05; letter-spacing: -0.03em; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.875rem; }
.stat.accent b { color: var(--accent); }
.stat.green b { color: var(--green); }

/* Knöpfe: Rückmeldung beim Drücken, sofort */
.btn {
  appearance: none; border: 0; border-radius: 980px; padding: 10px 20px; min-height: 40px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 0.95rem; cursor: pointer;
  transition: transform 160ms var(--ease), background-color 160ms var(--ease), opacity 160ms;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(0.97); background: var(--accent-press); transition-duration: 60ms; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.big { min-height: 48px; padding: 12px 26px; font-size: 1.02rem; }
.btn.quiet { background: var(--surface-2); color: var(--text); }
.btn.quiet:active { background: var(--line); }
.btn.green { background: var(--green); }
.btn.danger { background: transparent; color: var(--red); padding: 8px 12px; }
.btn.danger.armed { background: var(--red); color: #fff; }
.icon-btn {
  appearance: none; border: 0; width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  background: var(--surface-2); display: inline-grid; place-items: center; font-size: 1.1rem; line-height: 1;
  transition: transform 160ms var(--ease);
}
.icon-btn:active { transform: scale(0.92); }

input[type='search'], input[type='date'], input[type='password'], input[type='text'], select, input.qty {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 14px; min-height: 44px; outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .tile:focus-visible {
  outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent);
}
.search { width: 100%; font-size: 1.25rem; min-height: 56px; padding: 0 20px; border-radius: 16px; box-shadow: var(--shadow); border: 0; }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; padding: 4px 10px; border-radius: 980px; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.geplant, .pill.offen { color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, transparent); }
.pill.angenommen, .pill.uebertragen { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pill.abgeschlossen { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.pill.fehler { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.pill.angenommen::before { animation: pulse 1.2s ease-in-out infinite; }
.chip { font-size: 0.85rem; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.chip.on::before { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 20%, transparent); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* Tageskarten */
.days { display: grid; gap: 12px; }
.day { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; display: grid; gap: 14px; animation: rise 360ms var(--ease) both; }
.day-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.day-date { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }
.day-date small { display: block; font-size: 0.85rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.day-sum { color: var(--muted); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.day-head .spacer { flex: 1; }
.day-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-note { color: var(--muted); font-size: 0.95rem; margin: -6px 0 0; }
.day-error { color: var(--red); font-size: 0.95rem; margin: 0; }
.today { color: var(--accent); font-weight: 600; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.mini { position: relative; flex: 0 0 auto; width: 76px; }
.mini .ph { width: 76px; height: 76px; border-radius: 12px; background: var(--surface-2) center/contain no-repeat; }
.mini .n { position: absolute; top: 4px; right: 4px; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--text); color: var(--bg); font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.mini .t { font-size: 0.72rem; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 56px 24px; color: var(--muted); background: var(--surface); border-radius: var(--radius); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Planer (Max) */
.composer { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; margin-top: 28px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.tile {
  padding: 10px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
  display: grid; gap: 8px; position: relative; animation: rise 280ms var(--ease) both;
}
.pick {
  appearance: none; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 10px; display: block; width: 100%;
  transition: transform 200ms var(--ease);
}
.pick:hover { transform: translateY(-2px); }
.pick:active { transform: scale(0.97); transition-duration: 60ms; }
.pick:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.tile .ph { aspect-ratio: 1; border-radius: 10px; background: var(--surface-2) center/contain no-repeat; transition: background-color 200ms var(--ease); }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--surface-2); }
.seg button {
  flex: 1; appearance: none; border: 0; background: transparent; border-radius: 7px; padding: 5px 0; cursor: pointer;
  font-size: 0.8rem; font-weight: 600; color: var(--muted); transition: background-color 160ms var(--ease), color 160ms;
}
.seg button[aria-pressed='true'] { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.seg button:disabled { opacity: 0.35; cursor: default; }
.tile .t { font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.in::after { content: '✓'; position: absolute; top: 14px; right: 14px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; }
/* Fassung: Motiv auf passendem Textilgrund zeigen */
:is(.tile, .line, .mini) .ph.dunkel { background-color: #1d1d1f; }
:is(.tile, .line, .mini) .ph.hell { background-color: #ececee; }
.tone { position: absolute; left: 14px; top: 14px; font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 980px; background: rgba(255, 255, 255, 0.92); color: #1d1d1f; }
.tone.dunkel { background: rgba(29, 29, 31, 0.9); color: #f5f5f7; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.mini .tone { left: 4px; top: auto; bottom: 22px; font-size: 0.65rem; padding: 1px 6px; }
.line .t { display: grid; min-width: 0; }
.line .t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .t small { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.basket { position: sticky; top: 76px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 14px; }
.basket > * { min-width: 0; }
.basket .btn { white-space: normal; text-align: center; }
.basket input[type='date'], .basket input[type='text'] { width: 100%; }
.basket label { font-size: 0.85rem; color: var(--muted); display: grid; gap: 6px; }
.lines { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; }
.line { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; }
.line .ph { width: 44px; height: 44px; border-radius: 9px; background: var(--surface-2) center/contain no-repeat; }
.line .t { font-size: 0.9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper { display: flex; align-items: center; gap: 6px; }
input.qty { width: 58px; min-height: 32px; padding: 4px 6px; text-align: center; font-variant-numeric: tabular-nums; border-radius: 9px; }
input.qty::-webkit-inner-spin-button { appearance: none; }
.basket-total { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.95rem; }

/* Abrechnung */
.ledger { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { padding: 12px 18px; text-align: right; white-space: nowrap; }
.ledger th:first-child, .ledger td:first-child { text-align: left; }
.ledger th:last-child, .ledger td:last-child { text-align: right; }
.ledger th { font-size: 0.8rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
.ledger tbody td { border-bottom: 1px solid var(--line); }
.ledger tfoot td { font-weight: 700; font-size: 1.02rem; }
.ledger-wrap { overflow-x: auto; }
.edit-hint { margin: -6px 0 0; font-size: 0.9rem; color: var(--orange); }

/* Chuck unten rechts */
.chuck { position: fixed; right: 20px; bottom: 16px; z-index: 15; display: grid; justify-items: center; gap: 6px; opacity: 0; transform: translateY(12px); transition: opacity 400ms var(--ease), transform 400ms var(--ease); pointer-events: none; }
.chuck.ready { opacity: 1; transform: none; }
.chuck-face { width: 132px; height: 132px; cursor: pointer; pointer-events: auto; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.22)); transition: transform 200ms var(--ease); }
.chuck-face:active { transform: scale(0.96); }
.chuck-talk {
  pointer-events: auto; appearance: none; border: 0; cursor: pointer; border-radius: 980px; padding: 8px 14px; font-size: 0.82rem; font-weight: 600;
  background: var(--bar); color: var(--text); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(0, 0, 0, 0.12); transition: transform 160ms var(--ease), background-color 200ms;
}
.chuck-talk:active { transform: scale(0.96); }
.chuck[data-state='listening'] .chuck-talk, .chuck[data-state='speaking'] .chuck-talk { background: var(--accent); color: #fff; }
.chuck[data-state='listening'] .chuck-talk::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #fff; animation: pulse 1.2s ease-in-out infinite; vertical-align: 1px; }
.chuck-error { pointer-events: auto; margin: 0; max-width: 220px; font-size: 0.8rem; text-align: center; color: #fff; background: var(--red); padding: 6px 10px; border-radius: 10px; }
@media (max-width: 700px) { .chuck-face { width: 96px; height: 96px; } }
main { padding-bottom: 210px; }

/* Banner, Hinweise */
.banner { margin-top: 28px; display: flex; align-items: center; gap: 18px; padding: 18px 22px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.banner p { margin: 0; flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 20;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 14px; font-weight: 500; max-width: min(560px, 90vw);
  transition: transform 320ms var(--ease), opacity 320ms var(--ease); pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red); color: #fff; }

/* Anmeldung */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(380px, 100%); display: grid; gap: 14px; text-align: center; }
.login .brand { justify-content: center; font-size: 1.3rem; margin-bottom: 18px; }
.login .brand { flex-direction: column; gap: 14px; font-size: 1.5rem; }
.login .brand-mark { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 10px 28px rgba(10, 132, 255, 0.3); }

@media (max-width: 900px) {
  .composer { grid-template-columns: 1fr; }
  .basket { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 1ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .bar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
