:root {
  --blau: #3BA1DB;
  --navy: #021836;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #0e1b2e;
  --muted: #5d6b7e;
  --line: #dfe4ea;
  --gruen: #1f9d63;
  --rot: #c0392b;
  --gelb: #b7791f;
  --gelb-bg: #fff6e0;
  --radius: 14px;
  --font-h: 'Poppins', system-ui, sans-serif;
  --font-b: 'Source Sans 3', 'Source Sans Pro', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07111f; --card: #0f1d31; --text: #e8eef6; --muted: #93a3b8; --line: #1e3050;
    --gelb-bg: #2d2412;
  }
}
:root[data-theme="dark"] { --bg: #07111f; --card: #0f1d31; --text: #e8eef6; --muted: #93a3b8; --line: #1e3050; --gelb-bg: #2d2412; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 17px/1.45 var(--font-b); -webkit-font-smoothing: antialiased; min-height: 100vh; }
h1, h2, h3 { font-family: var(--font-h); font-weight: 600; margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--blau); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--navy); color: #fff; }
.brand { color: #fff; text-decoration: none; font: 700 1.1rem var(--font-h); display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blau); }
#nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
#nav a, #nav button { color: #cfe3f3; text-decoration: none; font: 500 .9rem var(--font-h); padding: 6px 10px; border-radius: 8px; background: none; border: 0; cursor: pointer; }
#nav a.aktiv { background: rgba(59,161,219,.25); color: #fff; }
#nav .sym { display: none; }
/* Handy: Navigation als Leiste unten */
@media (max-width: 640px) {
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    background: var(--navy); padding: 6px 4px max(6px, env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(0,0,0,.15); }
  #nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; padding: 6px 2px; text-align: center; }
  #nav .sym { display: block; font-size: 1.15rem; line-height: 1; }
  main { padding-bottom: 110px; }
  #toast { bottom: 84px; }
}

main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.grow { flex: 1 1 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blau); outline-offset: 0; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 1rem var(--font-h); border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer; background: var(--blau); color: #fff; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sek { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.rot { background: var(--rot); }
.btn.gruen { background: var(--gruen); }
.btn.klein { padding: 7px 12px; font-size: .88rem; border-radius: 9px; }
.btn.voll { width: 100%; }
.btn.riesig { width: 100%; padding: 22px; font-size: 1.25rem; border-radius: 16px; }

.uhr { font: 700 2.6rem var(--font-h); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-block; font: 600 .8rem var(--font-h); padding: 4px 10px; border-radius: 99px; background: var(--line); color: var(--muted); }
.status-pill.an { background: rgba(31,157,99,.15); color: var(--gruen); }
.status-pill.pause { background: var(--gelb-bg); color: var(--gelb); }

.timer-laeuft { border-left: 4px solid var(--blau); }
.hinweis { background: var(--gelb-bg); color: var(--gelb); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: .92rem; }
.fehler { color: var(--rot); font-size: .92rem; margin-top: 8px; min-height: 1em; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.liste li:first-child { border-top: 0; }
.liste .dauer { font: 600 .95rem var(--font-h); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; font-size: .75rem; padding: 2px 7px; border-radius: 6px; background: var(--line); color: var(--muted); }
.tag.freigegeben { background: rgba(59,161,219,.15); color: var(--blau); }
.tag.uebertragen { background: rgba(31,157,99,.15); color: var(--gruen); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; font: 600 .92rem var(--font-h); padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; }
.tabs button.aktiv { background: var(--navy); color: #fff; border-color: var(--navy); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
th { font: 600 .8rem var(--font-h); color: var(--muted); border-top: 0; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabelle { overflow-x: auto; }
main.breit { max-width: 1180px; }
table.breit { min-width: 900px; }
table.breit td:first-child { min-width: 220px; }
table.breit select.klein-input { min-width: 190px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; transition: transform .25s; max-width: calc(100% - 32px); z-index: 20; }
#toast.zeigen { transform: translateX(-50%) translateY(0); }

.qr-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.qr-karte { text-align: center; }
.qr-karte svg, .qr-karte img { width: 160px; height: 160px; }
.einladung { word-break: break-all; background: var(--bg); padding: 10px; border-radius: 8px; font-size: .85rem; }

/* Terminal */
.personen { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; margin-top: 12px; }
.person { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 4px 10px; border-radius: 16px; border: 2px solid var(--line); background: var(--bg); color: var(--text); font: 700 1.6rem var(--font-h); cursor: pointer; transition: transform .1s; }
.person small { font: 400 .8rem var(--font-b); color: var(--muted); }
.person:active { transform: scale(.97); }
.person.gewaehlt { background: var(--gruen); border-color: var(--gruen); color: #fff; box-shadow: 0 6px 18px rgba(31,157,99,.35); }
.person.gewaehlt small { color: rgba(255,255,255,.85); }
.laeuft-punkt { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--gruen); box-shadow: 0 0 0 3px var(--card); animation: puls 1.6s infinite; }
.person.gewaehlt .laeuft-punkt { background: #fff; box-shadow: 0 0 0 3px var(--gruen); }

.projekte { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.projekt { text-align: left; padding: 14px; min-height: 64px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--text); font: 600 1rem var(--font-h); cursor: pointer; line-height: 1.25; overflow-wrap: anywhere; }
.projekt small { display: block; font: 400 .78rem var(--font-b); color: var(--muted); margin-top: 3px; }
.projekt.intern { border-style: dashed; }
.projekt.gewaehlt { border-color: var(--blau); background: rgba(59,161,219,.12); box-shadow: 0 0 0 3px rgba(59,161,219,.25); }
.projekt.aktiv-laeuft { border-color: var(--gruen); background: rgba(31,157,99,.12); box-shadow: 0 0 0 3px rgba(31,157,99,.25); }
.projekt.neu { border-style: dashed; color: var(--blau); text-align: center; background: transparent; }
.linkbtn { background: none; border: 0; padding: 0; margin-top: 10px; color: var(--muted); font: inherit; font-size: .88rem; text-decoration: underline; cursor: pointer; }

.timer { text-align: center; transition: border-color .2s, background .2s; }
.timer.laeuft { border: 2px solid var(--gruen); background: linear-gradient(0deg, var(--card), rgba(31,157,99,.08)); }
.timer-kopf { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.timer .uhr { font-size: 3.2rem; margin: 12px 0; }
.timer.laeuft .uhr { color: var(--gruen); }
.timer.laeuft .status-pill { animation: puls 1.6s infinite; }
.timer label, .timer #notiz { text-align: left; }
.zeiten { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; text-align: left; }
.zeiten input[type=time] { font: 600 1.2rem var(--font-h); text-align: center; }
@keyframes puls { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .laeuft-punkt, .timer.laeuft .status-pill { animation: none; } }

.liste li.markiert { background: rgba(59,161,219,.08); border-radius: 10px; }
.eintrag { flex: 1; display: flex; gap: 10px; align-items: flex-start; text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 0 4px; cursor: pointer; min-width: 0; }
.eintrag .grow { min-width: 0; }

.dialog { border: 0; border-radius: 18px; padding: 22px; width: min(440px, calc(100% - 32px)); background: var(--card); color: var(--text); }
.dialog::backdrop { background: rgba(2,24,54,.55); }
.dialog .row { margin-top: 14px; }
.pin-eingabe { font: 700 2rem var(--font-h); text-align: center; letter-spacing: .4em; }
.treffer { max-height: 50vh; overflow-y: auto; }
.treffer-btn.moco { border-color: rgba(59,161,219,.4); }
.treffer-btn { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.treffer-btn .small { color: var(--blau); white-space: nowrap; }

.klein-input { padding: 6px 8px; font-size: .9rem; border-radius: 8px; }
.warnzeile td { background: var(--gelb-bg); }
.tag.warn { background: var(--gelb-bg); color: var(--gelb); }
.tabs.scroll { overflow-x: auto; }
.tabs.scroll button { flex: 1 0 auto; }
.aktionen { display: flex; flex-direction: column; gap: 4px; min-width: 170px; }

/* Urlaub */
.kennzahlen { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.kennzahlen > div { background: var(--bg); border-radius: 12px; padding: 12px 4px; display: flex; flex-direction: column; gap: 2px; }
.zahl-gross { font: 700 1.6rem var(--font-h); }
.minus { color: var(--rot); } .plus { color: var(--gruen); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; margin: 10px 0 0; }
.check input { width: auto; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 10px; }
.kal-kopf { font: 600 .75rem var(--font-h); color: var(--muted); text-align: center; padding: 4px 0; }
.kal-tag { min-height: 64px; background: var(--bg); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.kal-tag.leer { background: transparent; }
.kal-tag.we { opacity: .45; }
.kal-tag.fei { background: var(--gelb-bg); }
.kal-tag.heute { outline: 2px solid var(--blau); }
.kal-nr { font: 600 .78rem var(--font-h); color: var(--muted); }
.kal-fei { font-size: .62rem; color: var(--gelb); line-height: 1.1; }
.kal-person { font: 700 .7rem var(--font-h); border-radius: 5px; padding: 1px 4px; background: var(--blau); color: #fff; white-space: nowrap; }
.kal-person.art-krank, .kal-person.art-abwesend, .kal-person.art-sonstiges { background: var(--muted); }
.kal-person.offen { background: transparent; color: var(--blau); outline: 1.5px dashed var(--blau); outline-offset: -1.5px; }
@media (max-width: 520px) { .kal-tag { min-height: 48px; } .kal-fei { display: none; } .kennzahlen { grid-template-columns: repeat(2, 1fr); } }
.tag.st-genehmigt, .tag.st-erstattet { background: rgba(31,157,99,.15); color: var(--gruen); }
.tag.st-beantragt, .tag.st-eingereicht { background: rgba(59,161,219,.15); color: var(--blau); }
.tag.st-abgelehnt { background: rgba(192,57,43,.12); color: var(--rot); }
.tag.st-storniert { text-decoration: line-through; }

/* Spesen */
.upload { cursor: pointer; }
.hinweis.laden { animation: puls 1.4s infinite; }
.beleg-raster { display: grid; grid-template-columns: 140px 1fr; gap: 14px; margin-top: 10px; }
@media (max-width: 520px) { .beleg-raster { grid-template-columns: 1fr; } }
.beleg-bild { display: flex; align-items: center; justify-content: center; min-height: 160px; background: var(--bg); border-radius: 10px; overflow: hidden; text-decoration: none; }
.beleg-bild img { width: 100%; height: 100%; max-height: 320px; object-fit: contain; }
.beleg-bild .pdf, .beleg-mini { font: 700 1rem var(--font-h); color: var(--muted); }
.zahlart { border: 0; padding: 0; margin: 12px 0 0; }
.beleg-zeile { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.beleg-zeile:first-of-type { border-top: 0; }
.beleg-mini { flex: 0 0 56px; height: 72px; border-radius: 8px; background: var(--bg) center/cover no-repeat; display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: .75rem; }
.eintrag:disabled { cursor: default; }

@media print {
  .top, .noprint, #toast { display: none !important; }
  body { background: #fff; }
  .card { border: 0; }
  .qr-karte { break-inside: avoid; border: 1px dashed #999; padding: 16px; }
  .qr-karte svg, .qr-karte img { width: 5cm; height: 5cm; }
}
