:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #22251f;
  --muted: #6b6f66;
  --line: #e0dcd2;
  --accent: #3f6f55;
  --accent-text: #ffffff;
  --accent-soft: #e3eee7;
  --danger: #b3261e;
  --warn-bg: #fff4d6;
  --warn-text: #6b4e00;
  --vac-bg: #e8f0fb;
  --vac-text: #1f4b8f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161815; --surface: #1f221e; --surface-2: #282b26; --text: #e8e9e4; --muted: #a0a49b;
    --line: #353932; --accent: #7fb896; --accent-text: #0f1a13; --accent-soft: #24352b;
    --danger: #ff8a80; --warn-bg: #3a3014; --warn-text: #f3d68a; --vac-bg: #1c2a3d; --vac-text: #a9c6f0;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161815; --surface: #1f221e; --surface-2: #282b26; --text: #e8e9e4; --muted: #a0a49b;
  --line: #353932; --accent: #7fb896; --accent-text: #0f1a13; --accent-soft: #24352b;
  --danger: #ff8a80; --warn-bg: #3a3014; --warn-text: #f3d68a; --vac-bg: #1c2a3d; --vac-text: #a9c6f0;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; margin-top: .2rem; }
h3 { font-size: .95rem; margin-top: 1rem; }
a { color: var(--accent); }
.loading { text-align: center; color: var(--muted); padding: 3rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* Kopf + Navigation */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
}
.top-inner { padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.top-inner h1 { margin: 0; flex: 1; font-size: 1.05rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { font-size: .85rem; color: var(--muted); }
.burger {
  display: none; border: 0; background: none; color: var(--text); font-size: 1.4rem; line-height: 1;
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
}
.burger:hover { background: var(--surface-2); }

/* Seitenleiste (breit) bzw. Schublade (schmal) */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 61px); }
nav.side {
  background: var(--surface); border-right: 1px solid var(--line); padding: 12px 8px;
  position: sticky; top: 61px; height: calc(100vh - 61px); overflow-y: auto;
}
nav.side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 14px 12px 4px; }
nav.side .group:first-child { padding-top: 4px; }
nav.side button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none;
  color: var(--text); padding: 9px 12px; font: inherit; font-size: .92rem; border-radius: 8px; cursor: pointer;
}
nav.side button:hover { background: var(--surface-2); }
nav.side button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.side .ico { width: 20px; text-align: center; }
.scrim { display: none; }

main { max-width: 1100px; width: 100%; margin: 0 auto; padding: 16px; }

@media (max-width: 899px) {
  .burger { display: inline-block; }
  .shell { display: block; }
  nav.side {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: min(290px, 85vw); z-index: 50;
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.2);
  }
  body.menu-open nav.side { transform: translateX(0); }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
}

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card > h2:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.grow { flex: 1 1 200px; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 40px; max-width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
input[type="color"] { padding: 2px; width: 48px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; }

button.b, a.b {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .9rem; font-weight: 600; min-height: 40px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none;
}
button.b.secondary { background: transparent; color: var(--accent); }
button.b.ghost { background: transparent; border-color: var(--line); color: var(--text); font-weight: 500; }
button.b.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.b.sm { min-height: 32px; padding: 4px 10px; font-size: .82rem; }
button.icon {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px 6px; border-radius: 6px; min-width: 32px; min-height: 32px;
}
button.icon:hover { background: var(--surface-2); color: var(--text); }
button:disabled { opacity: .5; cursor: default; }

/* Tabellen */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr.current td { background: var(--accent-soft); }
tr.vac td { background: var(--vac-bg); color: var(--vac-text); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .82rem;
  background: var(--surface-2); white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.pkg-code {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-weight: 700; font-size: .8rem;
  background: var(--accent-soft); color: var(--accent);
}
.banner { padding: 10px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 12px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner.vac { background: var(--vac-bg); color: var(--vac-text); }

/* Wochenplan */
.week-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.week-head h2 { margin: 0; flex: 1; min-width: 180px; }
.assign-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.assign {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface);
}
.assign header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.assign header strong { flex: 1; }
.assign ul { margin: 4px 0 0; padding-left: 18px; font-size: .88rem; }
.assign .sub { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-top: 8px; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.day { border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: .8rem; min-height: 84px; background: var(--surface); }
.day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.day.vac { background: var(--vac-bg); color: var(--vac-text); }
.day .d { font-weight: 700; margin-bottom: 4px; }
.day .e { display: flex; align-items: center; gap: 4px; margin-top: 3px; }
@media (max-width: 760px) {
  .days { grid-template-columns: 1fr; }
  .day { min-height: 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .day .d { margin: 0; min-width: 70px; }
  .day .e { margin: 0; }
}

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li .grow { min-width: 0; overflow-wrap: anywhere; }
.done-title { text-decoration: line-through; color: var(--muted); }

.hist { display: flex; gap: 3px; flex-wrap: wrap; }
.hist span { width: 18px; height: 18px; border-radius: 4px; background: var(--surface-2); display: inline-block; }
.hist span.complete { background: var(--accent); }
.hist span.open { background: var(--danger); opacity: .55; }
.hist span.today { outline: 2px solid var(--text); outline-offset: 1px; }
.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; }

/* Login */
.login { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.people { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
.people button {
  border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 16px 8px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.people button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; }

dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: max(calc(100vh - 32px), 360px);
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120%); transition: transform .2s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 100;
  max-width: calc(100vw - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }

/* In der App (WebView) keine eigene Kopfzeile */
/* In der App (WebView): schlanke Kopfzeile nur mit Menü und Seitentitel */
body.embedded .who, body.embedded .logout, body.embedded nav.side [data-act="logout"] { display: none; }
body.embedded .shell { min-height: 0; }

/* Tabellen auf dem Handy untereinander statt nebeneinander */
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack td { border: 0; padding: 3px 0; }
  table.stack td:first-child { font-weight: 700; }
  table.stack td:empty { display: none; }
  table.stack select { width: 100%; max-width: none !important; }
  .table-wrap:has(table.stack) { margin: 0; padding: 0; overflow: visible; }
}

/* Gericht-Auswahl */
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: max(45vh, 240px); overflow-y: auto; margin-top: 4px; }
.pick-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 12px;
  font: inherit; cursor: pointer;
}
.pick-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.crumbs { font-size: .9rem; color: var(--muted); }
.linkish { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 2px; text-decoration: underline; }
.pick-btn { max-width: 100%; text-align: left; justify-content: flex-start; white-space: normal; }

/* Artikel- und Standardlisten */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text); font-size: .9rem;
}
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 26px; height: 26px; border-radius: 50%; font-size: .9rem; }
.chip button:hover { background: rgba(0,0,0,.08); color: var(--danger); }
.item-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item-row .name { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.item-row select { min-height: 34px; padding: 4px 8px; font-size: .85rem; max-width: 170px; }
.toggle {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-width: 38px; height: 34px;
  cursor: pointer; font-size: 1rem; filter: grayscale(1); opacity: .45;
}
.toggle[aria-pressed="true"] { filter: none; opacity: 1; background: var(--accent-soft); border-color: var(--accent); }
