:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #f0f2ed;
  --text: #1b231e;
  --muted: #66706a;
  --border: #e1e5de;
  --brand: #1f3d2b;
  --brand-2: #2f5c40;
  --accent: #b8e07a;
  --pos: #23864a;
  --neg: #c2362f;
  --warn: #b7791f;
  --urlaub: #2f6fd6;
  --krank: #d64b3f;
  --ueberstunden: #7a55c9;
  --sonderurlaub: #1a9a8f;
  --sonstiges: #8a8f87;
  --holiday: #fbecd0;
  --weekend: #f0f2ed;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714; --surface: #1a211d; --surface-2: #222b25; --text: #e7ece8; --muted: #9aa49d;
    --border: #2d3830; --brand: #16301f; --brand-2: #2a5038; --pos: #5cc485; --neg: #f07068;
    --holiday: #3a3020; --weekend: #1e2621; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.num { font-variant-numeric: tabular-nums; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #e6efe8; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; color: #fff; }
.logo img { width: 30px; height: 30px; }
.logo small { display: block; font-weight: 500; font-size: 11px; color: var(--accent); letter-spacing: .04em; text-transform: uppercase; }
.navsec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #9fb7a7; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: #dfe9e2; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.on { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.nav .badge { margin-left: auto; background: var(--accent); color: var(--brand); border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.side .me a { color: #b9cdbf; font-size: 12px; margin-right: 10px; }
main { padding: 24px 28px 60px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stack > * + * { margin-top: 18px; }

/* Controls */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--neg); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 7px 10px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.check input { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; }
.seg button.on { background: var(--brand-2); color: #fff; }
.daypick { display: flex; gap: 4px; }
.daypick label { margin: 0; display: flex; align-items: center; justify-content: center; width: 36px; height: 34px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; color: var(--text); }
.daypick input { display: none; }
.daypick input:checked + span { font-weight: 700; }
.daypick label:has(input:checked) { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.scroll { overflow-x: auto; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--muted); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); font-weight: 600; }
.pill.ok { background: rgba(35,134,74,.12); color: var(--pos); }
.pill.wait { background: rgba(183,121,31,.14); color: var(--warn); }
.pill.no { background: rgba(194,54,47,.12); color: var(--neg); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--sonstiges); flex: none; }
.t-urlaub { background: var(--urlaub); } .t-krank { background: var(--krank); } .t-ueberstunden { background: var(--ueberstunden); }
.t-sonderurlaub { background: var(--sonderurlaub); } .t-sonstiges { background: var(--sonstiges); }
.warnbox { background: rgba(183,121,31,.12); color: var(--warn); border-radius: 9px; padding: 9px 12px; font-size: 14px; }
.mirrorbar { background: rgba(47,111,214,.1); color: var(--urlaub); border: 1px solid rgba(47,111,214,.25); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 16px; }
.bigbtn:disabled { opacity: .45; cursor: not-allowed; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* Stoppuhr */
.clock { text-align: center; padding: 34px 18px; }
.clock .time { font-size: 64px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.clock .state { color: var(--muted); margin: 6px 0 22px; }
.bigbtn { width: 100%; max-width: 340px; padding: 20px; font-size: 20px; font-weight: 700; border-radius: 16px; border: 0; cursor: pointer; color: #fff; background: var(--pos); }
.bigbtn.stop { background: var(--neg); }
.clock input { max-width: 340px; margin: 0 auto 12px; display: block; }
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }

/* Presence */
.person { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.st { width: 10px; height: 10px; border-radius: 50%; }
.st.anwesend { background: var(--pos); box-shadow: 0 0 0 3px rgba(35,134,74,.18); }
.st.gegangen { background: var(--muted); }
.st.fehlt { background: transparent; border: 2px solid var(--border); }
.st.abwesend { background: var(--urlaub); }
.teamhead { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 6px; margin: 10px 0 2px; }

/* Stundentafel */
.week { display: grid; grid-template-columns: repeat(7, minmax(108px, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 180px; display: flex; flex-direction: column; gap: 6px; }
.day.we { background: var(--weekend); }
.day.hol { background: var(--holiday); }
.day.today { border-color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2); }
.day .dh { display: flex; justify-content: space-between; align-items: baseline; font-weight: 650; }
.day .dh small { font-weight: 500; color: var(--muted); }
.day .tag { font-size: 12px; display: flex; gap: 6px; align-items: center; color: var(--muted); }
.entry { background: rgba(47,92,64,.1); border-left: 3px solid var(--brand-2); border-radius: 6px; padding: 6px 8px; font-size: 13px; cursor: pointer; }
.entry:hover { background: rgba(47,92,64,.18); }
.entry.run { border-left-color: var(--pos); background: rgba(35,134,74,.12); }
.entry.locked { cursor: default; border-left-color: var(--muted); background: var(--surface-2); }
.entry.locked:hover { background: var(--surface-2); }
.entry .n { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day .sum { margin-top: auto; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 8px; justify-content: space-between; border-top: 1px dashed var(--border); padding-top: 6px; }
.day .sum span:first-child { color: var(--text); font-weight: 600; }
.day .add { border: 1px dashed var(--border); background: none; border-radius: 6px; color: var(--muted); padding: 4px; cursor: pointer; font-size: 13px; }
.day .add:hover { color: var(--text); border-color: var(--muted); }
.day .w { font-size: 11px; color: var(--warn); }

/* Planer */
.plan { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.plan th, .plan td { border-bottom: 1px solid var(--border); padding: 0; text-align: center; min-width: 26px; height: 30px; }
.plan th { font-weight: 600; color: var(--muted); padding: 4px 0; }
.plan td.name, .plan th.name { text-align: left; padding: 0 12px 0 0; white-space: nowrap; position: sticky; left: 0; background: var(--surface); min-width: 150px; font-size: 13px; }
.plan .we { background: var(--weekend); }
.plan .hol { background: var(--holiday); }
.plan .cell { display: block; margin: 3px 2px; height: 22px; border-radius: 4px; }
.plan .cell.pend { opacity: .45; background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.5) 4px 8px); }
.plan .cell.half { height: 11px; margin-top: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--brand); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .logo { color: var(--text); padding: 0 0 18px; }
.login .logo small { color: var(--brand-2); }
.err { color: var(--neg); font-size: 14px; min-height: 20px; margin-bottom: 8px; }

/* Modal & Toast */
.modal { position: fixed; inset: 0; background: rgba(10,20,14,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal-card .actions .left { margin-right: auto; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--neg); color: #fff; }

/* Mobil */
.mobnav { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 16px 16px 96px; }
  .grid2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .kpi { padding: 10px; }
  .kpi .v { font-size: 17px; }
  .kpi .v .muted { display: block; font-size: 12px !important; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .clock .time { font-size: 52px; }
  .mobnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--brand); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; justify-content: space-around; }
  .mobnav a { color: #cfdcd3; text-decoration: none; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 6px; border-radius: 8px; }
  .mobnav a.on { color: #fff; background: rgba(255,255,255,.12); }
  .mobnav svg { width: 22px; height: 22px; }
  .row { grid-template-columns: 1fr; }
  .hide-m { display: none; }
}
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
