:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --line: #dfe3dc;
  --text: #1b2420;
  --muted: #5f6b65;
  --brand: #0f5c4d;
  --brand-2: #157a66;
  --brand-soft: #e2f0ec;
  --accent: #f4c430;
  --ok: #1d7a46;
  --ok-soft: #e3f3e8;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --bad: #b3261e;
  --bad-soft: #fde7e5;
  --info: #255b9a;
  --info-soft: #e5eefa;
  --vac: #2f6fb0;
  --abs: #7a5aa6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1a201d;
    --surface-2: #222a26;
    --line: #2f3a35;
    --text: #e8eeea;
    --muted: #9aa8a1;
    --brand: #4fc0a4;
    --brand-2: #6fd4ba;
    --brand-soft: #1d3a33;
    --ok: #63c98d; --ok-soft: #173326;
    --warn: #f0b85a; --warn-soft: #3a2c12;
    --bad: #ff8a80; --bad-soft: #3b1d1b;
    --info: #8db8ec; --info-soft: #1b2a3d;
    --vac: #7fb2e6; --abs: #b99be0;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.num { font-variant-numeric: tabular-nums; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.offline { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; text-align: center; font-size: .9rem; }

/* Layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.brand.has-logo { flex-direction: column; align-items: flex-start; gap: 6px; }
.brand.has-logo img.logo { width: auto; height: auto; max-width: 170px; max-height: 40px; display: block; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 12px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text);
  text-decoration: none; font-size: .95rem;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .badge { margin-left: auto; }
.side .spacer { flex: 1; }
.main { padding: 24px 28px 96px; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 96px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: .72rem;
    color: var(--muted); text-decoration: none; min-height: 56px; justify-content: center;
  }
  .bottom-nav a.active { color: var(--brand); font-weight: 600; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .mobile-top { display: flex !important; }
}
.mobile-top { display: none; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.mobile-top .brand { padding: 0; }
.mobile-top .brand.has-logo img.logo { max-height: 26px; max-width: 130px; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card, .grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 860px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stat { padding: 14px 16px; }
.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: .82rem; color: var(--muted); }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* Clock */
.clock { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; }
.clock .status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.pause { background: var(--accent); box-shadow: 0 0 0 4px var(--warn-soft); }
.clock .big { font-size: 2.6rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.1; }
.clock-actions { display: grid; gap: 10px; min-width: 250px; }
@media (max-width: 860px) {
  .clock { grid-template-columns: 1fr; }
  .clock-actions { min-width: 0; }
}

/* Buttons & forms */
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; min-height: 40px; font-size: .95rem;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 1px;
}
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.ghost { border-color: transparent; background: transparent; }
button.small, .btn.small { min-height: 32px; padding: 5px 10px; font-size: .85rem; }
button.huge { min-height: 64px; font-size: 1.15rem; font-weight: 700; border-radius: 14px; }
button.huge.start { background: var(--ok); border-color: var(--ok); color: #fff; }
button.huge.stop { background: var(--bad); border-color: var(--bad); color: #fff; }
button.huge.pause { background: var(--accent); border-color: var(--accent); color: #2b2100; }
@media (prefers-color-scheme: dark) {
  button.primary, .btn.primary, button.huge.start, button.huge.stop { color: #0d1411; }
}
button:disabled { opacity: .55; cursor: not-allowed; }
label { display: block; font-size: .86rem; font-weight: 600; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; font-weight: 400; }
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); min-height: 42px;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 3px; }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.err { color: var(--bad); font-size: .9rem; margin: 6px 0 10px; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.r, th.r { text-align: right; }
tr.weekend td { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--brand-soft); }
tfoot td { font-weight: 700; }

/* Chips & badges */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.vac { background: color-mix(in srgb, var(--vac) 16%, transparent); color: var(--vac); }
.chip.abs { background: color-mix(in srgb, var(--abs) 16%, transparent); color: var(--abs); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; font-weight: 700; }

/* Findings */
.findings { list-style: none; margin: 0; padding: 0; }
.findings li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.findings li:last-child { border-bottom: 0; }
.findings .ref { font-size: .78rem; color: var(--muted); }
.sev-fehler { border-left: 3px solid var(--bad); padding-left: 8px; }
.sev-verstoss { border-left: 3px solid var(--bad); padding-left: 8px; }
.sev-warnung { border-left: 3px solid var(--warn); padding-left: 8px; }
.sev-hinweis { border-left: 3px solid var(--info); padding-left: 8px; }

/* Days */
.days { display: grid; gap: 10px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.day.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.day.off { background: var(--surface-2); }
.day-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.day-head .date { font-weight: 700; min-width: 135px; }
.day-head .figures { margin-left: auto; display: flex; gap: 14px; font-variant-numeric: tabular-nums; font-size: .9rem; flex-wrap: wrap; }
.day-head .figures span b { font-weight: 700; }
.blocks { margin-top: 8px; display: grid; gap: 6px; }
.block { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 10px; background: var(--surface-2); border-radius: 9px; font-size: .92rem; }
.block .t { font-weight: 600; font-variant-numeric: tabular-nums; }
.block .acts { margin-left: auto; display: flex; gap: 6px; }
.day .findings { margin-top: 6px; }
.day .findings li { padding: 4px 0; border: 0; font-size: .86rem; }

/* Tabs */
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; min-height: 34px; padding: 6px 12px; }
.tabs button.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

/* Calendar */
.cal { border-collapse: separate; border-spacing: 0; font-size: .8rem; }
.cal th, .cal td { padding: 4px 2px; text-align: center; border-bottom: 1px solid var(--line); min-width: 28px; }
.cal th.name, .cal td.name { text-align: left; position: sticky; left: 0; background: var(--surface); min-width: 140px; padding-left: 8px; z-index: 1; }
.cal td.we { background: var(--surface-2); }
.cal td.hol { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.cal .cell { display: block; height: 22px; border-radius: 5px; }
.cal .cell.ferien { background: var(--vac); }
.cal .cell.abwesend { background: var(--abs); }
.cal .cell.beantragt { opacity: .45; background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.5) 4px 8px); }
.cal .cell.half { height: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 26px; }
.auth .brand { padding: 0 0 18px; }
.qr { background: #fff; padding: 8px; border-radius: 10px; display: inline-block; }
.qr svg { display: block; width: 200px; height: 200px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; background: var(--surface-2); padding: 6px 9px; border-radius: 8px; font-size: .9rem; }

/* Dialog & toast */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 20, 15, .45); }
dialog .dlg { padding: 20px; overflow-y: auto; max-height: calc(100vh - 32px); }
dialog .dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; max-width: calc(100vw - 32px); font-size: .92rem; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); color: #fff; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; margin-bottom: 8px; }
.notice.info { background: var(--info-soft); color: var(--info); }
.empty { color: var(--muted); padding: 14px 0; text-align: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.vac-table td:nth-child(n+2), .vac-table th:nth-child(n+2) { text-align: right; }
.break-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto auto; gap: 8px; align-items: end; margin-bottom: 8px; }
@media (max-width: 560px) { .break-row { grid-template-columns: 1fr 1fr; } }
.hide-sm { }
@media (max-width: 560px) { .hide-sm { display: none !important; } }
@media (max-width: 560px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 1.22rem; }
  .card { padding: 14px; }
  .period { flex-wrap: nowrap; width: 100%; justify-content: space-between; }
  .period b { font-size: .86rem; text-align: center; }
  .day-head .figures { margin-left: 0; width: 100%; gap: 10px; }
  .clock .big { font-size: 2.2rem; }
}
