/* H24 Wochenplan */
:root {
  --bg: #f3f4f6; --surface: #ffffff; --ink: #18212b; --muted: #566171; --line: #dde1e7; --line-strong: #c3c9d2;
  --brand: #12474d; --brand-ink: #ffffff; --focus: #1a73e8;
  --ok: #17663f;    --ok-bg: #e2f3e9;    --ok-line: #9fd2b3;    --ok-solid: #1f7a4d;
  --tight: #7a4d00; --tight-bg: #fff0c2; --tight-line: #efce6d; --tight-solid: #b97a00;
  --short: #a5201a; --short-bg: #fde2df; --short-line: #f0a39d; --short-solid: #c8322a;
  --open: #3f506a;  --open-bg: #e8edf4;  --open-line: #b9c4d4;  --open-solid: #64748b;
  --none: #667181;  --none-bg: #f1f3f6;  --none-line: #dde1e7;  --none-solid: #98a2b0;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #1a2029; --ink: #e8ecf1; --muted: #9aa5b4; --line: #2b3441; --line-strong: #3a4554;
    --brand: #2a7d86; --focus: #6aa8ff;
    --ok: #7fdca6;    --ok-bg: #16311f;    --ok-line: #2c5a3d;    --ok-solid: #2f9a63;
    --tight: #f4c95a; --tight-bg: #3a2f10; --tight-line: #6b5518; --tight-solid: #c98d12;
    --short: #ff9a92; --short-bg: #3d1a18; --short-line: #7a2f2b; --short-solid: #d9463d;
    --open: #a9b8cf;  --open-bg: #202a38;  --open-line: #364457;  --open-solid: #64748b;
    --none: #98a2b0;  --none-bg: #1e252f;  --none-line: #2b3441;  --none-solid: #566171;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; overflow-x: hidden; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Kopfzeile */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-size: 13px; letter-spacing: .5px; }
.chips { display: flex; gap: 6px; overflow-x: auto; flex: 1; padding: 2px; scrollbar-width: thin; }
.chip { flex: none; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { border-color: var(--brand); }
a.btn { text-decoration: none; color: var(--ink); display: inline-block; }
a { color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--short); border-color: var(--short-line); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); padding: 5px 10px; border-radius: 999px; background: var(--none-bg); white-space: nowrap; }
.live i { width: 9px; height: 9px; border-radius: 50%; background: var(--none-solid); }
.live.on i { background: var(--ok-solid); box-shadow: 0 0 0 0 rgba(31,122,77,.5); animation: pulse 2.4s infinite; }
.live.stale i { background: var(--tight-solid); }
.live.off i { background: var(--short-solid); }
.live.stale { background: var(--tight-bg); color: var(--tight); }
.live.off { background: var(--short-bg); color: var(--short); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,122,77,.45); } 70% { box-shadow: 0 0 0 8px rgba(31,122,77,0); } 100% { box-shadow: 0 0 0 0 rgba(31,122,77,0); } }
@media (prefers-reduced-motion: reduce) { .live.on i { animation: none; } }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-weight: 600; font-size: 14px; background: var(--surface); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.18); padding: 6px; z-index: 30; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; border-radius: 6px; color: var(--ink); text-decoration: none; cursor: pointer; font-size: 14px; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--none-bg); }
.usermenu .who { padding: 8px 10px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* Werkzeugleiste */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 20px 4px; }
.toolbar h1 { font-size: 20px; margin-right: 6px; }
.toolbar .period { color: var(--muted); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 14px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--none-bg); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.spacer { flex: 1; }

/* Hinweisband */
.banner { margin: 8px 20px 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 14px; }
.banner.short { background: var(--short-bg); border-color: var(--short-line); color: var(--short); }
.banner.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.banner.tight { background: var(--tight-bg); border-color: var(--tight-line); color: var(--tight); }
.banner b { font-weight: 700; }
.banner button { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 999px; padding: 3px 11px; cursor: pointer; font-weight: 600; font-size: 13px; }
.banner button:hover { background: rgba(255,255,255,.55); }

main { padding: 8px 20px 60px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 4px 20px 0; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line-strong); display: inline-block; }
.sw.ok { background: var(--ok-bg); border-color: var(--ok-solid); }
.sw.tight { background: var(--tight-bg); border-color: var(--tight-solid); }
.sw.short { background: var(--short-bg); border-color: var(--short-solid); }
.sw.open { background: repeating-linear-gradient(135deg, var(--open-bg) 0 4px, var(--surface) 4px 8px); border-color: var(--open-solid); }
.sw.none { background: var(--none-bg); }

/* Wochenblöcke */
.week { margin-top: 16px; }
.week-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 6px 2px; }
.week-title h2 { font-size: 15px; }
.week-title span { color: var(--muted); font-size: 13px; }
.weekgrid { display: grid; grid-template-columns: 118px repeat(7, minmax(0, 1fr)); gap: 6px; }
.labels, .day { display: flex; flex-direction: column; gap: 6px; }
.lab { height: 78px; display: flex; flex-direction: column; justify-content: center; padding: 0 6px 0 2px; }
.lab.head { height: 64px; }
.lab b { font-size: 14px; }
.lab small { color: var(--muted); font-size: 12px; }
.dayhead, .cell { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-align: left; }
.dayhead { height: 64px; padding: 8px 10px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; width: 100%; }
.dayhead .d { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.dayhead .d small { font-weight: 600; color: inherit; opacity: .8; margin-left: 4px; font-size: 13px; }
.dayhead .s { font-size: 12px; font-weight: 600; }
.cell { height: 78px; padding: 8px 10px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; width: 100%; }
.cell .num { font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cell .need { font-size: 12px; font-weight: 600; line-height: 1.25; }
.cell:hover, .dayhead:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.st-ok.cell { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.st-tight.cell { background: var(--tight-bg); border-color: var(--tight-line); color: var(--tight); }
.st-short.cell { background: var(--short-bg); border-color: var(--short-line); color: var(--short); }
.st-open.cell { background: repeating-linear-gradient(135deg, var(--open-bg) 0 6px, var(--surface) 6px 12px); border-color: var(--open-line); color: var(--open); }
.st-none.cell { background: var(--none-bg); border-color: var(--none-line); color: var(--none); }
.cell .num { color: var(--ink); }
.st-none.cell .num { color: var(--none); }
.dayhead.st-ok { background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; }
.dayhead.st-tight { background: var(--tight-solid); border-color: var(--tight-solid); color: #fff; }
.dayhead.st-short { background: var(--short-solid); border-color: var(--short-solid); color: #fff; }
.dayhead.st-open { background: var(--open-solid); border-color: var(--open-solid); color: #fff; }
.dayhead.st-none { background: var(--none-bg); color: var(--ink); }
.day.past { opacity: .62; }
.day.today .dayhead { box-shadow: 0 0 0 3px var(--focus); }
.today-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; background: rgba(255,255,255,.28); border-radius: 4px; padding: 1px 5px; margin-left: 6px; }
.day.today .dayhead.st-none .today-badge { background: var(--focus); color: #fff; }

/* Übersicht aller Häuser */
.ovwrap { overflow-x: auto; margin-top: 12px; }
.ov { border-collapse: separate; border-spacing: 4px; min-width: 100%; }
.ov th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; padding: 0 2px 4px; }
.ov th.first, .ov td.first { text-align: left; position: sticky; left: 0; background: var(--bg); z-index: 1; min-width: 150px; padding-right: 8px; }
.ov td.first b { display: block; font-size: 15px; }
.ov td.first small { color: var(--muted); font-size: 12px; }
.ov .tile { width: 100%; min-width: 68px; border-radius: 8px; padding: 6px 4px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); text-align: center; font-size: 12px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.ov .tile b { display: block; font-size: 12px; }
.ov .tile.st-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.ov .tile.st-tight { background: var(--tight-bg); border-color: var(--tight-line); color: var(--tight); }
.ov .tile.st-short { background: var(--short-bg); border-color: var(--short-line); color: var(--short); }
.ov .tile.st-open { background: repeating-linear-gradient(135deg, var(--open-bg) 0 5px, var(--surface) 5px 10px); border-color: var(--open-line); color: var(--open); }
.ov .tile.st-none { background: var(--none-bg); color: var(--none); }
.ov .tile.past { opacity: .55; }
.ov .tile.today { box-shadow: 0 0 0 2px var(--focus); }
.ov tr.warn td.first small { color: var(--tight); font-weight: 600; }

/* Detailfenster */
.scrim { position: fixed; inset: 0; background: rgba(16,24,40,.42); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .18s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer { visibility: hidden; position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface); z-index: 41; transform: translateX(105%); transition: transform .2s ease; box-shadow: -8px 0 32px rgba(16,24,40,.22); display: flex; flex-direction: column; }
.drawer.show { transform: none; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .drawer, .scrim { transition: none; } }
.drawer header { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.drawer header h2 { font-size: 18px; }
.drawer header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.drawer .x { margin-left: auto; border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.drawer .body { overflow-y: auto; padding: 14px 18px 30px; display: flex; flex-direction: column; gap: 14px; }
.block { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.block.st-ok { border-color: var(--ok-line); } .block.st-tight { border-color: var(--tight-line); } .block.st-short { border-color: var(--short-line); } .block.st-open { border-color: var(--open-line); }
.block h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; }
.pill.st-ok { background: var(--ok-bg); color: var(--ok); } .pill.st-tight { background: var(--tight-bg); color: var(--tight); }
.pill.st-short { background: var(--short-bg); color: var(--short); } .pill.st-open { background: var(--open-bg); color: var(--open); } .pill.st-none { background: var(--none-bg); color: var(--none); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 10px 0 8px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 999px; background: var(--none-bg); overflow: hidden; margin: 4px 0 10px; }
.bar i { display: block; height: 100%; background: var(--ok-solid); }
.bar i.tight { background: var(--tight-solid); } .bar i.short { background: var(--short-solid); }
.staff { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.staff li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 5px 8px; background: var(--none-bg); border-radius: 6px; }
.staff li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.empty { color: var(--muted); font-size: 14px; padding: 30px 0; text-align: center; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* Formulare, Anmeldung, Verwaltung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.card h1 { font-size: 22px; margin: 14px 0 4px; } .card p { color: var(--muted); margin: 0 0 18px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 5px; }
input[type=text], input[type=password], input[type=number], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
input[type=number] { width: 90px; }
.err { background: var(--short-bg); color: var(--short); border: 1px solid var(--short-line); padding: 9px 12px; border-radius: 8px; font-size: 14px; margin-top: 12px; }
.ok-msg { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); padding: 9px 12px; border-radius: 8px; font-size: 14px; margin-top: 12px; }
.card .btn { width: 100%; margin-top: 20px; padding: 11px; }
.adminwrap { max-width: 1180px; margin: 0 auto; padding: 18px 20px 60px; }
.tabs { display: flex; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
table.t { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.t th, table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: top; }
table.t th { background: var(--none-bg); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
table.t tr:last-child td { border-bottom: 0; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--none-bg); color: var(--muted); font-weight: 600; display: inline-block; margin: 1px 2px 1px 0; }
.tag.on { background: var(--ok-bg); color: var(--ok); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row > div { flex: 1 1 180px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h3 { margin-bottom: 8px; font-size: 16px; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 460px; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(16,24,40,.45); }
.pwbox { font: 600 20px/1.3 ui-monospace, Menlo, Consolas, monospace; background: var(--none-bg); border-radius: 8px; padding: 12px; margin: 12px 0; word-break: break-all; user-select: all; }

/* Handy: jede Woche als Liste von Tageskarten */
@media (max-width: 860px) {
  .top { flex-wrap: wrap; padding: 8px 12px; } .chips { order: 3; flex-basis: 100%; }
  .toolbar { padding: 10px 12px 2px; } main { padding: 6px 12px 50px; } .banner { margin: 8px 12px 0; } .legend { padding: 4px 12px 0; }
  .legend { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; padding-bottom: 4px; }
  .weekgrid { grid-template-columns: 1fr; gap: 10px; } .labels { display: none; }
  .day { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; gap: 6px; }
  .dayhead { height: auto; min-height: 48px; flex-direction: row; align-items: center; }
  .cell { height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 9px 12px; }
  .cell::before { content: attr(data-label); flex: 0 0 82px; font-size: 13px; font-weight: 600; color: var(--ink); }
  .cell .num { font-size: 22px; min-width: 42px; } .cell .need { margin-left: auto; text-align: right; }
  .brand span:last-child { display: none; }
  #btn-print { display: none; } .right { margin-left: auto; min-width: 0; } .live { font-size: 12px; white-space: normal; max-width: 60vw; line-height: 1.25; } .usermenu summary { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Druck: Din-A4 quer, vier Wochen auf einer Seite wie die handgepflegte Liste */
@media print {
  @page { size: A4 landscape; margin: 6mm; }
  body { background: #fff; color: #000; font-size: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .top, .toolbar .seg, .toolbar .btn, .banner, .scrim, .drawer, .usermenu, .ovwrap + .note { display: none !important; }
  .toolbar { padding: 0 0 2px; } .toolbar h1 { font-size: 15px; } .toolbar .period { font-size: 10px; }
  .legend { padding: 0 0 2px; font-size: 8px; gap: 2px 10px; } .sw { width: 9px; height: 9px; }
  main { padding: 0; }
  .week { margin-top: 3px; break-inside: avoid; } .week-title { margin: 0 0 1px; } .week-title h2 { font-size: 10px; } .week-title span { font-size: 9px; }
  .weekgrid { gap: 2px; grid-template-columns: 64px repeat(7, 1fr); }
  .labels, .day { gap: 2px; }
  .lab { height: 30px; } .lab.head { height: 24px; } .lab small { display: none; } .lab b { font-size: 10px; }
  .dayhead { height: 24px; padding: 2px 6px; flex-direction: row; align-items: center; justify-content: space-between; border-radius: 5px; }
  .dayhead .d { font-size: 10px; } .dayhead .s { font-size: 8px; } .today-badge { display: none; }
  .cell { height: 30px; padding: 2px 6px; flex-direction: row; align-items: center; justify-content: space-between; border-radius: 5px; }
  .cell .num { font-size: 14px; } .cell .need { font-size: 8px; text-align: right; }
  .day.past { opacity: 1; } .day.today .dayhead { box-shadow: none; }
  #view > .note { display: none; }
  .print-only { display: inline !important; font-size: 10px; color: #333; }
}
.print-only { display: none; }

/* Hinweis auf Live-Änderungen */
.cell.flash, .ov .tile.flash { animation: flash 2.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--focus); } 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } }
@media (prefers-reduced-motion: reduce) { .cell.flash { animation: none; outline: 3px solid var(--focus); } }
