:root {
  --accent: #E2001A;
  --accent-ink: #ffffff;
  --accent-soft: #fdebed;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --ink: #1d1f23;
  --muted: #646a73;
  --line: #e1e3e8;
  --line-strong: #c9ccd3;
  --weekend: #eceef1;
  --holiday: #fbe3e5;
  --today: #fff3c4;
  --ok: #1e7d3a;
  --ok-soft: #e3f4e8;
  --warn: #9a6200;
  --warn-soft: #fff2d6;
  --bad: #b3261e;
  --bad-soft: #fde7e5;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #ff4552; --accent-ink: #1a0003; --accent-soft: #3a1418;
    --bg: #15171a; --surface: #1e2125; --surface-2: #24282d; --ink: #e9eaec; --muted: #a2a8b1;
    --line: #33373d; --line-strong: #474c54; --weekend: #2a2e34; --holiday: #3b2226; --today: #4a4120;
    --ok: #6fd28c; --ok-soft: #1d3324; --warn: #f0b54d; --warn-soft: #3a3020; --bad: #ff8a80; --bad-soft: #3d1f1d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #ff4552; --accent-ink: #1a0003; --accent-soft: #3a1418;
  --bg: #15171a; --surface: #1e2125; --surface-2: #24282d; --ink: #e9eaec; --muted: #a2a8b1;
  --line: #33373d; --line-strong: #474c54; --weekend: #2a2e34; --holiday: #3b2226; --today: #4a4120;
  --ok: #6fd28c; --ok-soft: #1d3324; --warn: #f0b54d; --warn-soft: #3a3020; --bad: #ff8a80; --bad-soft: #3d1f1d;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
[hidden] { display: none !important; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: var(--surface); border-bottom: 3px solid var(--accent); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.logo { width: 32px; height: 32px; border-radius: 50%; }
.brand-text { font-size: 15px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; position: relative; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--accent);
  color: var(--accent-ink); font-size: 11px; line-height: 18px; text-align: center; }
.spacer { flex: 1; }
.btn.menu-toggle { display: none; }

/* Buttons & Formulare */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer;
  white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.grp { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.field > span { font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 10px; min-height: 34px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type="color"] { padding: 2px; height: 34px; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }

/* Layout */
.app { padding: 18px 16px 60px; max-width: 1500px; margin: 0 auto; }
.app.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .spacer { min-width: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.accent { background: var(--accent-soft); }
.kpi.accent .v { color: var(--accent); }

/* Tabellen */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.approved { background: var(--ok-soft); color: var(--ok); }
.badge.rejected, .badge.cancelled { background: var(--bad-soft); color: var(--bad); }
.badge.withdrawn { background: var(--surface-2); color: var(--muted); }
.swatch { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 20px; padding: 0 4px; border-radius: 4px;
  font-size: 11px; font-weight: 700; border: 1px solid rgba(0,0,0,.12); }
.note { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--line-strong); }
.note.warn { background: var(--warn-soft); border-color: var(--warn); }
.note.bad { background: var(--bad-soft); border-color: var(--bad); }
.note.ok { background: var(--ok-soft); border-color: var(--ok); }

/* Plan-Raster */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.plan-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: calc(100vh - 210px); }
table.plan { border-collapse: separate; border-spacing: 0; font-size: 12px; user-select: none; }
table.plan th, table.plan td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; }
table.plan thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-weight: 600; text-align: center; }
table.plan thead tr:nth-child(2) th { top: 22px; }
table.plan .name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 0 10px; min-width: 180px;
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 28px; }
table.plan thead .name { z-index: 4; }
table.plan .name small { color: var(--muted); margin-left: 4px; }
table.plan .mh { height: 22px; padding: 0 4px; text-align: left; }
table.plan .dh { min-width: 30px; height: 34px; line-height: 1.1; font-size: 11px; }
table.plan .dh.we, td.cell.we { background: var(--weekend); }
table.plan .dh.hol, td.cell.hol { background: var(--holiday); }
table.plan .dh.today { box-shadow: inset 0 -3px 0 var(--accent); }
table.plan .grp-row td { background: var(--surface-2); font-weight: 700; font-size: 12px; padding: 4px 10px; position: sticky; left: 0; }
td.cell { width: 30px; min-width: 30px; height: 28px; text-align: center; font-weight: 700; font-size: 11px; cursor: default; position: relative; }
td.cell.edit { cursor: pointer; }
td.cell.edit:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
td.cell.off { background: repeating-linear-gradient(135deg, var(--weekend), var(--weekend) 3px, transparent 3px, transparent 6px); }
td.cell.masked { background: var(--line-strong) !important; color: transparent; }
td.cell.pend { box-shadow: inset 0 0 0 2px var(--warn); }
td.cell.pend::after { content: "?"; position: absolute; top: 0; right: 2px; font-size: 9px; color: var(--warn); }
td.cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; background-image: linear-gradient(var(--accent-soft), var(--accent-soft)); }
td.cell .half { font-size: 9px; }
tr.mine .name { font-weight: 700; color: var(--accent); }
.plan.year td.cell { width: 22px; min-width: 22px; height: 22px; font-size: 10px; }
.plan.year .dh { min-width: 22px; }
.pop { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow);
  padding: 10px; min-width: 220px; max-width: 320px; }
.pop .codes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 8px 0; }
.pop .codes button { justify-content: flex-start; height: 30px; font-size: 12px; }

/* Kalender (Antrag) */
.mcal { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; user-select: none; }
.mcal .m h4 { margin: 0 0 6px; font-size: 13px; }
.mcal .g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mcal .g div { text-align: center; padding: 5px 0; border-radius: 5px; font-size: 12px; font-variant-numeric: tabular-nums; }
.mcal .g .wd { color: var(--muted); font-size: 11px; font-weight: 600; }
.mcal .g .d { cursor: pointer; }
.mcal .g .d:hover { outline: 1px solid var(--accent); }
.mcal .g .we, .mcal .g .fx { color: var(--muted); background: var(--weekend); }
.mcal .g .hol { background: var(--holiday); color: var(--bad); }
.mcal .g .t { font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.mcal .g .sel { background: var(--accent); color: var(--accent-ink); }
.mcal .g .has { color: #fff; }

/* Dialog, Toast */
dialog { border: none; border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(10,12,16,.5); }
dialog form { padding: 20px; margin: 0; }
dialog.wide { width: min(980px, calc(100vw - 24px)); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--bad); color: #fff; }

/* Anmeldung */
.auth { min-height: calc(100vh - 40px); display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth .logo-lg { width: 64px; height: 64px; border-radius: 50%; display: block; margin: 0 auto 10px; }
.auth h1 { text-align: center; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.auth form > * + * { margin-top: 12px; }
.otp { font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.codes-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 15px; }
.qr { display: block; margin: 8px auto; border-radius: 8px; background: #fff; padding: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.conf { font-size: 12px; margin-top: 4px; }
.conf .day { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.conf .day.short { background: var(--bad-soft); color: var(--bad); font-weight: 600; }

@media (max-width: 900px) {
  .btn.menu-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); flex-direction: column; padding: 8px;
    border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .brand-text { display: none; }
  .app { padding: 12px 10px 60px; }
  #userBtn { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  table.plan .name { min-width: 120px; max-width: 140px; }
}
@media print {
  .topbar, .toolbar, .no-print, .actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: none; padding: 0; }
  .app { padding: 0; max-width: none; }
  .plan-wrap { max-height: none; overflow: visible; border: none; }
}

/* Halbtage: je Mitarbeiter zwei Zeilen (Vormittag/Nachmittag) */
table.plan tr.ha td.cell, table.plan tr.hb td.cell { height: 15px; font-size: 10px; line-height: 14px; }
table.plan tr.ha td.cell { border-bottom: 1px dashed var(--line); }
table.plan tr.hb td.cell, table.plan tr.hb td.rest, table.plan tr.ha td.name, table.plan tr.ha td.rest { border-bottom: 1px solid var(--line-strong); }
table.plan td.name { border-left: 5px solid transparent; cursor: default; }
table.plan td.name.click { cursor: pointer; }
table.plan td.rest { position: sticky; z-index: 2; background: var(--surface); text-align: center; min-width: 56px; font-size: 11px; font-variant-numeric: tabular-nums; }
table.plan thead th.rest { z-index: 4; }
table.plan td.rest.neg { color: var(--bad); font-weight: 700; }
table.plan td.rest.click { cursor: pointer; text-decoration: underline dotted; }
table.plan tr.retired td.name { color: var(--muted); font-style: italic; }
td.cell.out { background: repeating-linear-gradient(135deg, var(--weekend), var(--weekend) 2px, transparent 2px, transparent 5px); }
td.cell.fix { background: repeating-linear-gradient(135deg, #ffe6a6, #ffe6a6 3px, transparent 3px, transparent 6px); color: var(--muted); }
:root[data-theme="dark"] td.cell.fix { background: repeating-linear-gradient(135deg, #4a3d16, #4a3d16 3px, transparent 3px, transparent 6px); }
table.plan .dh .ft { font-size: 9px; color: var(--bad); font-weight: 700; }
table.plan .dh.today div:last-child { display: inline-block; min-width: 18px; border-radius: 9px; box-shadow: 0 0 0 2px var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; font: inherit; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pop .codes kbd { font: 10px ui-monospace, Consolas, monospace; color: var(--muted); margin-left: auto; }
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--bg); padding: 6px 9px; border-radius: 7px; font-size: 12px; max-width: 360px; box-shadow: var(--shadow); }
:root { --nw: 200px; }
table.plan .name { width: var(--nw); min-width: var(--nw); max-width: var(--nw); }
table.plan .rest { left: var(--nw); }
@media (max-width: 900px) { :root { --nw: 130px; } table.plan .rest { min-width: 44px; } }
