/* Layout: feste Seitenleiste + Arbeitsfläche (Desktop), Kopfzeile + Tab-Leiste unten (Handy) */
:root {
  --bg: #F1F4F3;
  --surface: #FFFFFF;
  --surface-2: #F7F9F8;
  --ink: #14211F;
  --muted: #5D6D6A;
  --line: #DCE3E1;
  --accent: #0E7C86;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEFF0;
  --ok: #16794A;
  --ok-soft: #DDF2E6;
  --warn: #B9480D;
  --warn-soft: #FBE8DC;
  --danger: #C0352B;
  --early: #9A6400;
  --early-soft: #FBF0D4;
  --late: #4B4FA8;
  --late-soft: #E6E7F7;
  --shadow: 0 1px 2px rgba(20, 33, 31, .06), 0 4px 16px rgba(20, 33, 31, .05);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1514; --surface: #162020; --surface-2: #1B2726; --ink: #E4ECEA; --muted: #92A39F;
    --line: #283533; --accent: #3DB4BD; --accent-ink: #062224; --accent-soft: #15383A;
    --ok: #4CC98A; --ok-soft: #14322A; --warn: #F08A4B; --warn-soft: #3A2417; --danger: #F0706A; --early: #F2C15C; --early-soft: #3A2E12; --late: #A9ADF5; --late-soft: #25264A;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1514; --surface: #162020; --surface-2: #1B2726; --ink: #E4ECEA; --muted: #92A39F;
  --line: #283533; --accent: #3DB4BD; --accent-ink: #062224; --accent-soft: #15383A;
  --ok: #4CC98A; --ok-soft: #14322A; --warn: #F08A4B; --warn-soft: #3A2417; --danger: #F0706A; --early: #F2C15C; --early-soft: #3A2E12; --late: #A9ADF5; --late-soft: #25264A;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body);
  padding-top: env(safe-area-inset-top, 0px);
}
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono, .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.nav {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font: 700 1rem var(--f-display);
}
.brand b { font-family: var(--f-display); font-size: 1.1rem; display: block; line-height: 1.1; }
.brand span { font-size: .75rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; border: 0;
  background: none; cursor: pointer; text-align: left; color: var(--muted); font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-spacer { flex: 1; }
.userbox { border-top: 1px solid var(--line); padding: 14px 8px 0; display: grid; gap: 8px; }
.userbox .who { display: flex; align-items: center; gap: 10px; }
.userbox .links { display: flex; gap: 12px; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: .85rem; font-weight: 500; }
.topbar { display: none; }

main {
  min-width: 0;
  padding-block: 28px 60px;
  padding-left: max(28px, env(safe-area-inset-left, 0px));
  padding-right: max(28px, env(safe-area-inset-right, 0px));
}
.page { max-width: 1180px; margin: 0 auto; display: grid; gap: 22px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .v { font: 700 1.7rem/1.1 var(--f-display); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .82rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.ghost { border-color: transparent; background: none; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--danger); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; }

label.f { display: grid; gap: 4px; font-size: .82rem; font-weight: 600; color: var(--muted); min-width: 0; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-weight: 400; min-width: 0;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1 1 140px; }
.form-row > .btn { flex: 0 0 auto; }
.form-grid { display: grid; gap: 12px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.early { background: var(--early-soft); color: var(--early); border-color: transparent; }
.chip.late { background: var(--late-soft); color: var(--late); border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .8rem; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 1rem; }

.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); font-size: .92rem; }
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.check {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); background: var(--surface);
  cursor: pointer; flex: none; display: grid; place-items: center; padding: 0;
}
.check:hover { border-color: var(--accent); }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.check svg { width: 14px; height: 14px; }
.done .title { text-decoration: line-through; color: var(--muted); }
.prio-high { box-shadow: inset 3px 0 0 var(--warn); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.weeknav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.weeknav .label { font-weight: 600; min-width: 190px; text-align: center; font-variant-numeric: tabular-nums; }

/* Wochenplan */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(172px, 1fr)); gap: 10px; }
.week-scroll { overflow-x: auto; padding-bottom: 6px; }
.daycol { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-width: 0; }
.daycol.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.daycol-head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: 6px; white-space: nowrap; }
.daycol-head b { font-family: var(--f-display); }
.daycol-body { padding: 10px; display: grid; gap: 6px; align-content: start; flex: 1; }
.shift { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; background: var(--surface-2); border-left: 3px solid; min-width: 0; }
.shift .grow { min-width: 0; flex: 1; }
.shift .n { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift .t { font-family: var(--f-mono); font-size: .75rem; color: var(--muted); white-space: nowrap; }
.addshift { border-top: 1px dashed var(--line); padding: 10px; display: grid; gap: 6px; }
.addshift .times { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.addshift input, .addshift select { padding: 6px 8px; font-size: .85rem; }

.daypills { display: flex; gap: 4px; flex-wrap: wrap; }
.daypill { width: 34px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: .8rem; color: var(--muted); }
.daypill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.c, th.c { text-align: center; }
td.r, th.r { text-align: right; }
.matrix td.c { min-width: 52px; }
.mcell { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; font-size: .78rem; font-weight: 700; }
.mcell.due { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.mcell.done { background: var(--ok-soft); color: var(--ok); }
.mcell.miss { background: var(--warn-soft); color: var(--warn); }

/* Stempeluhr */
.clock { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.clock .big { font: 700 2.4rem/1 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.clock .btn { padding: 14px 22px; font-size: 1rem; }
.clock.running { background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)); border-color: var(--accent); }

.daylist { display: grid; gap: 10px; }
.dayrow { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.dayrow.off { background: var(--surface-2); }
.dayrow.today { border-color: var(--accent); }
.dayrow .d b { font-family: var(--f-display); font-size: 1.05rem; display: block; }

.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.emp-card { display: grid; gap: 10px; }
.emp-card .top { display: flex; gap: 12px; align-items: center; }
.emp-card .top .grow { min-width: 0; flex: 1; }
.emp-card .name { font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; }
.inactive { opacity: .6; }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--accent); color: var(--accent-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; }
.auth-side h1 { font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.05; max-width: 14ch; }
.auth-side p { max-width: 42ch; opacity: .9; }
.auth-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 420px; }
.auth-week div { border: 1px solid currentColor; border-radius: 8px; padding: 8px 0; text-align: center; font: 600 .8rem var(--f-mono); opacity: .55; }
.auth-week div.on { opacity: 1; background: rgba(255,255,255,.16); }
.auth-main { display: grid; place-items: center; padding-block: 40px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.auth-form { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.auth-form .btn { padding: 11px; }
.err { color: var(--danger); font-size: .88rem; min-height: 1.2em; }

/* Modal & Toast */
.modal { position: fixed; inset: 0; background: rgba(8, 16, 15, .5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box { background: var(--surface); border-radius: 14px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; padding: 22px; display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 60; box-shadow: var(--shadow);
}
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; justify-content: space-around;
    padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    border-right: 0; border-top: 1px solid var(--line); z-index: 20; gap: 0;
  }
  .nav .brand, .nav .userbox, .nav .nav-spacer { display: none; }
  .nav-item { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; text-align: center; align-items: center; }
  .topbar {
    display: flex; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 15; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .topbar .brand { padding: 0; }
  main { padding-block: 18px 100px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; }
  .dayrow { grid-template-columns: 1fr; gap: 8px; }
  .weeknav .label { min-width: 0; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Hinweise & Zähler */
.notice { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font-size: .9rem; }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }
@media (max-width: 860px) { .nav-item { position: relative; } .badge { position: absolute; top: 2px; right: 18%; margin: 0; } }
@media (max-width: 860px) { .nav-item { min-width: 0; } .nav-item span:not(.badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* Stempel-Abschnitte und Öffnungszeiten */
.segs { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-btn { font: 500 .82rem var(--f-mono); font-variant-numeric: tabular-nums; padding: 3px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; white-space: nowrap; }
.seg-btn:hover { border-color: var(--accent); }
.seg-btn.run { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.seg-btn.stale { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.hours-grid { display: grid; gap: 8px; max-width: 460px; }
.hours-row { display: grid; grid-template-columns: 110px 1fr auto 1fr; gap: 8px; align-items: center; }
@media (max-width: 480px) { .hours-row { grid-template-columns: 1fr 1fr; } .hours-row b { grid-column: 1 / -1; } .hours-row span { display: none; } }
.seg-btn.auto { background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); }
.clock-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.clock.finished { background: var(--ok-soft); border-color: var(--ok); }
@media (max-width: 480px) { .clock-btns { width: 100%; } .clock-btns .btn { flex: 1; } }
.seg-btn.pending { background: var(--accent-soft); color: var(--accent); border: 1px dashed var(--accent); }
.seg-btn.locked { cursor: default; }
.payset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; min-width: 0; }
.payset legend { font-weight: 600; font-size: .85rem; padding: 0 4px; }
tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }

/* Putz-Fotos, Auswertung, App-Hinweis */
.checkline { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: .9rem; }
.checkline input { width: auto; }
.chipbtn { cursor: pointer; font: inherit; font-size: .78rem; font-weight: 600; }
.mcell.ph { position: relative; }
.mcell.ph::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.proof { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 8px; background: var(--surface-2); }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: 2px; }
.bar span { display: block; height: 100%; background: var(--ok); }
.install { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.install img { border-radius: 11px; flex: none; }
.install .grow { flex: 1; min-width: 200px; }
.seg-btn.locked:hover { border-color: var(--line); }
