:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e5e7eb;
  --accent: #0f766e; --accent-ink: #fff; --in: #15803d; --out: #b91c1c;
  --k-urlaub: #bfdbfe; --k-krank: #fecaca; --k-bildungsurlaub: #c7d2fe; --k-gleittag: #fde68a;
  --k-mehrarbeit: #fed7aa; --k-feiertag: #ddd6fe; --k-sonstiges: #e5e7eb; --k-berufsschule: #bbf7d0; --k-elternzeit: #fbcfe8; --k-kind_krank: #fda4af; --k-sel: #0f766e;
  --weekend: #eef0f3; --worked: #99f6e4;
}
/* dunkel: Klassisch bei dunklem Gerät (Klasse .dark setzt das Skript) und Design „Nacht“ */
html.dark { --bg: #11151c; --card: #1a2029; --text: #e7eaf0; --muted: #9aa3b2; --line: #2a3240;
          --accent: #2dd4bf; --accent-ink: #062b28; --in: #4ade80; --out: #f87171;
          --k-urlaub: #1e3a8a; --k-krank: #7f1d1d; --k-bildungsurlaub: #3730a3; --k-gleittag: #713f12;
          --k-mehrarbeit: #7c2d12; --k-feiertag: #4c1d95; --k-sonstiges: #374151; --k-berufsschule: #14532d; --k-elternzeit: #831843; --k-kind_krank: #881337; --k-sel: #2dd4bf;
          --weekend: #151a22; --worked: #134e4a; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); }
header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
         padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header h1 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
header img { width: 26px; height: 26px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { border: none; background: none; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
nav button.active { background: var(--bg); color: var(--text); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.page { display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card h3 { font-size: 14px; margin: 18px 0 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar h2 { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.muted { color: var(--muted); } .small { font-size: 13px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
               padding: 7px 13px; border-radius: 8px; cursor: pointer; text-decoration: none; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.danger { color: var(--out); }
button.mini { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
                background: var(--bg); color: var(--text); min-width: 0; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.inline { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.w80 { width: 80px; } .w64 { width: 64px; }
.clock { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.state { font-size: 26px; font-weight: 700; }
.state.in { color: var(--in); } .state.out { color: var(--out); }
.big { font-size: 18px; padding: 16px 28px; border-radius: 12px; min-width: 170px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 6px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.neg { color: var(--out); } .pos { color: var(--in); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
tr.weekend td { color: var(--muted); background: var(--weekend); }
tr.today td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.month tbody tr.day { cursor: default; }
body.is-admin table.month tbody tr.day { cursor: pointer; }
body.is-admin table.month tbody tr.day:hover td { background: var(--bg); }
tr.detail td { background: var(--bg); white-space: normal; }
.detailbox { display: grid; gap: 10px; padding: 6px 2px; }
.detailbox .row { gap: 8px; }
.scroll { overflow-x: auto; }
.login { max-width: 360px; margin: 10vh auto; display: grid; gap: 12px; }
.qr { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; margin-top: 12px; }
.qr svg { width: 200px; height: 200px; background: #fff; border-radius: 8px; }
.err { color: var(--out); min-height: 1.2em; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.in { background: var(--in); }
.hidden { display: none !important; }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--bg);
       border: 1px solid var(--line); color: var(--text); }
.tag.k { border-color: transparent; }
.ue { font-size: 12px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--muted); }
.ue.on { background: var(--k-mehrarbeit); color: var(--text); border-color: transparent; font-weight: 700; }
td input { padding: 4px 6px; }
code { background: var(--bg); padding: 2px 5px; border-radius: 4px; font-size: 13px; word-break: break-all; }
.st-neu { color: var(--in); font-weight: 600; } .st-fehler, .st-konflikt { color: var(--out); font-weight: 600; }
.st-doppelt, .st-übersprungen { color: var(--muted); }

/* Jahreskalender */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); }
.yeargrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; user-select: none; -webkit-user-select: none; }
.mon h4 { margin: 0 0 6px; font-size: 13px; }
.mon .g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mon .wd { font-size: 10px; color: var(--muted); text-align: center; }
.cell { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 12px;
        border-radius: 5px; font-variant-numeric: tabular-nums; }
.cell.d { cursor: default; }
body.is-admin .cell.d { cursor: pointer; }
.cell.we { background: var(--weekend); color: var(--muted); }
.cell.worked::after { content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cell.half { background-image: linear-gradient(135deg, transparent 50%, var(--card) 50%) !important; }
.cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell.pre { opacity: .45; }
.cell.sel { background: var(--k-sel) !important; color: var(--accent-ink) !important; }
.k-urlaub { background: var(--k-urlaub); } .k-krank { background: var(--k-krank); }
.k-bildungsurlaub { background: var(--k-bildungsurlaub); } .k-gleittag { background: var(--k-gleittag); }
.k-mehrarbeit { background: var(--k-mehrarbeit); } .k-feiertag { background: var(--k-feiertag); }
.k-sonstiges { background: var(--k-sonstiges); }
.k-berufsschule { background: var(--k-berufsschule); } .k-elternzeit { background: var(--k-elternzeit); }
.k-kind_krank { background: var(--k-kind_krank); }
.selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border-radius: 10px;
          background: var(--bg); margin-bottom: 10px; position: sticky; top: 64px; z-index: 3; border: 1px solid var(--line); }

@media (max-width: 720px) {
  header { padding: 10px 12px; position: static; }
  .selbar { top: 0; }
  nav button { padding: 6px 8px; font-size: 14px; }
  .clock { grid-template-columns: 1fr; } .big { width: 100%; }
  .qr { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}

.btngroup { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.btngroup button { padding-left: 10px; padding-right: 10px; }
.tag.warn { background: #fff3cd; border-color: #f0c36d; color: #7a5200; font-weight: 600; }
html.dark .tag.warn { background: #4a3a10; border-color: #8a6a1a; color: #ffd98a; }
.tag.lock { background: #e8eefc; border-color: #b8c8f0; color: #23407a; font-weight: 600; }
html.dark .tag.lock { background: #1e2a44; border-color: #3a5288; color: #b9ccff; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: #d4380d; color: #fff;
         font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; vertical-align: 1px; }
.tag.pending { background: #f3ecff; border-color: #cdb6f5; color: #4b2a8a; font-weight: 600; }
html.dark .tag.pending { background: #2e2244; border-color: #5d4590; color: #d9c7ff; }
.st-genehmigt { color: var(--in); font-weight: 600; } .st-abgelehnt { color: var(--out); font-weight: 600; }
.st-offen { color: #4b2a8a; font-weight: 600; } .st-zurueckgezogen { color: var(--muted); }
button.mini.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.nowrap { white-space: nowrap; }
table.audit td { vertical-align: top; }
table.audit tr.cat-anmeldung td, table.audit tr.cat-berichte td { color: var(--muted); }

.httpwarn { background: #fef3c7; color: #78350f; border: 1px solid #f59e0b; border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; }
html.dark .httpwarn { background: #422006; color: #fde68a; border-color: #b45309; }

tr.inactive td { opacity: .6; }
.tag.off { background: #e5e7eb; color: #374151; }
.w48 { width: 48px; } .w56 { width: 56px; }
.sDays td, .sDays th { padding: 3px 4px; }
.detailbox > table { justify-self: start; }
.detailbox > span { white-space: normal; max-width: 900px; }
tr.inactive td:last-child { opacity: 1; }

/* ---------- Designs (data-theme am <html>) ---------- */
/* Synology DSM: blau, kantiger, hell */
html[data-theme="dsm"] {
  --bg: #eef2f7; --card: #fff; --text: #1f2d3d; --muted: #66768a; --line: #d9e1ea;
  --accent: #057feb; --accent-ink: #fff; --in: #10893e; --out: #d1342c; --k-sel: #057feb;
  --weekend: #f2f5f9; --worked: #b9dcfb;
}
html[data-theme="dsm"] header { background: linear-gradient(#fdfeff, #f1f5fa); }
html[data-theme="dsm"] nav button.active { background: #e3f0fd; color: #0567c2; }
html[data-theme="dsm"] .card { border-radius: 6px; box-shadow: 0 1px 2px rgba(15, 40, 80, .06); }
html[data-theme="dsm"] button, html[data-theme="dsm"] input, html[data-theme="dsm"] select { border-radius: 4px; }
html[data-theme="dsm"] .stat { border-radius: 4px; background: #f4f7fb; border: 1px solid #e3e9f0; }
html[data-theme="dsm"] .big { border-radius: 6px; }

/* Nacht: immer dunkel, Bernstein als Akzent, hoher Kontrast */
html[data-theme="dark"] {
  --bg: #0b0d10; --card: #15181d; --text: #f3f5f8; --muted: #a3acb9; --line: #2a3039;
  --accent: #f5a524; --accent-ink: #1a1100; --in: #34d399; --out: #fb7185; --k-sel: #f5a524;
  --weekend: #101318; --worked: #4a3711;
}
html[data-theme="dark"] nav button.active { background: #22262d; color: #f5a524; }

/* Warm & groß: Sandtöne, kräftiger Kontrast, größere Schrift und Bedienelemente */
html[data-theme="warm"] {
  --bg: #f6efe4; --card: #fffdf9; --text: #22180f; --muted: #5f4d3a; --line: #e2d3bd;
  --accent: #b5400b; --accent-ink: #fff; --in: #13702f; --out: #b42318; --k-sel: #b5400b;
  --weekend: #efe5d6; --worked: #f5c9a8;
}
html[data-theme="warm"] body { font-size: 17px; }
html[data-theme="warm"] header h1 { font-size: 20px; }
html[data-theme="warm"] nav button { font-size: 16px; padding: 10px 14px; }
html[data-theme="warm"] button, html[data-theme="warm"] input, html[data-theme="warm"] select { padding: 10px 14px; border-radius: 10px; }
html[data-theme="warm"] button.mini { padding: 5px 10px; font-size: 14px; }
html[data-theme="warm"] label { font-size: 15px; color: var(--text); }
html[data-theme="warm"] th { font-size: 14px; color: var(--text); }
html[data-theme="warm"] .card { border-radius: 16px; border-width: 2px; }
html[data-theme="warm"] .card h2 { font-size: 18px; }
html[data-theme="warm"] .state { font-size: 32px; }
html[data-theme="warm"] .stat b { font-size: 24px; }
html[data-theme="warm"] .big { font-size: 22px; padding: 20px 34px; }

/* Auswahl unter „Mein Zugang“ */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.theme-opt { display: grid; gap: 8px; padding: 10px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
             background: var(--card); color: var(--text); font-size: 14px; text-align: left; }
.theme-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.theme-opt .sw { height: 54px; border-radius: 8px; display: grid; grid-template-columns: 1fr 1fr 1fr; overflow: hidden;
                 border: 1px solid rgba(0, 0, 0, .1); }
.theme-opt .sw i { display: block; }
html.dark { color-scheme: dark; }
html:not(.dark) { color-scheme: light; }

/* ---------- Verwaltung: Unternavigation ---------- */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: var(--card); border: 1px solid var(--line);
          border-radius: 12px; position: sticky; top: 60px; z-index: 4; }
.subnav button { border: 1px solid transparent; background: none; color: var(--muted); font-weight: 600; padding: 7px 12px;
                 border-radius: 8px; white-space: nowrap; }
.subnav button:hover { background: var(--bg); color: var(--text); }
.subnav button.active { background: var(--accent); color: var(--accent-ink); }
.subnav button.active .badge { background: var(--accent-ink); color: var(--accent); }
@media (max-width: 700px) { .subnav { flex-wrap: nowrap; overflow-x: auto; position: static; } }

/* Mitarbeiter bearbeiten */
#usersTable tr.urow td { vertical-align: middle; }
.uform .ugrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.uform fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px;
                  background: var(--card); white-space: normal; }
.uform legend { font-weight: 700; font-size: 13px; padding: 0 4px; color: var(--text); }
.uform input:not([type=checkbox]), .uform select { width: 100%; }
.uform .row label { flex: 1; }
tr.uedit > td { background: var(--bg); }
/* Einstellungen in Gruppen */
.setgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.setgrid fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 14px; margin: 0; display: grid; gap: 10px; align-content: start; }
.setgrid legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
.setgrid p { margin: 0; }
.setgrid input:not([type=checkbox]):not(.w80), .setgrid select { width: 100%; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; padding: 12px 0 4px; margin-top: 4px;
           background: linear-gradient(transparent, var(--card) 30%); }
details.holidays, details.newuser { margin-top: 14px; }
details.holidays summary, details.newuser summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0; }
details.newuser[open] summary { margin-bottom: 8px; }
.subnav button { padding: 7px 10px; }
label.inline input[type=checkbox] { flex: none; }
.subnav { gap: 2px; }
.subnav button { font-size: 14px; padding: 6px 9px; }

/* Firmenlogo */
.brand .brandLogo { height: 30px; width: auto; max-width: 180px; object-fit: contain; }
.brand.has-logo .brandIcon { display: none; }
#loginView .brand { display: flex; align-items: center; gap: 10px; }
#loginView .brandLogo { height: 44px; max-width: 220px; }
.logoPrev { height: 40px; max-width: 200px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
.logoRow { display: grid; gap: 6px; }

/* Abwesenheitskalender */
table.team { width: auto; min-width: 100%; font-size: 13px; }
table.team th, table.team td { padding: 0; border-bottom: 1px solid var(--line); text-align: center; }
table.team th.d, table.team td.d { width: 26px; min-width: 26px; height: 30px; border-left: 1px solid var(--line); }
table.team th.d { font-size: 11px; line-height: 1.15; padding: 4px 0; }
table.team th.nm, table.team td.nm { text-align: left; padding: 4px 10px 4px 2px; position: sticky; left: 0; background: var(--card);
  z-index: 1; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
table.team td.nm small { display: block; color: var(--muted); font-size: 11px; }
table.team .we { background: color-mix(in srgb, var(--muted) 12%, transparent); }
table.team .hol { background: color-mix(in srgb, var(--accent) 14%, transparent); }
table.team .off { background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--muted) 18%, transparent) 4px 5px); }
table.team .today { box-shadow: inset 0 0 0 2px var(--accent); }
table.team tr.hl td.nm { color: var(--accent); font-weight: 700; }
table.team tr.hl td { background-color: color-mix(in srgb, var(--accent) 7%, transparent); }
table.team tr.sum td { font-weight: 700; color: var(--muted); border-top: 2px solid var(--line); }
table.team tr.sum td.many { color: var(--out); }
.ab { display: block; margin: 3px; height: 22px; border-radius: 5px; color: #fff; font-size: 10px; font-weight: 700; line-height: 22px;
  background: var(--k); }
.ab.half { background: linear-gradient(135deg, var(--k) 50%, transparent 50%); color: var(--text); }
.ab.pend { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--k) 28%, var(--card)) 0 4px, var(--card) 4px 8px);
  color: var(--k); outline: 2px dashed var(--k); outline-offset: -2px; }
.ab.offsw { background-color: var(--card); border: 1px solid var(--line);
  background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--muted) 30%, transparent) 4px 5px); }
.k-urlaub { --k: #2e78d6; } .k-krank { --k: #d92d20; } .k-gleittag { --k: #0e9384; } .k-mehrarbeit { --k: #dc6803; }
.k-abwesend { --k: #7d8796; } .k-bildungsurlaub { --k: #6941c6; } .k-sonstiges { --k: #667085; } .k-berufsschule { --k: #0086c9; } .k-elternzeit { --k: #c11574; } .k-kind_krank { --k: #e31b54; }
.tmLegend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); align-items: center; }
.tmLegend .ab { display: inline-block; width: 22px; margin: 0 4px 0 0; vertical-align: middle; text-align: center; }
details.tmPick { position: relative; }
details.tmPick summary { cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--card); }
details.tmPick[open] > div { position: absolute; right: 0; top: 110%; z-index: 5; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; max-height: 320px; overflow: auto; min-width: 220px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
details.tmPick label { display: flex; gap: 8px; align-items: center; padding: 3px 0; white-space: nowrap; }
.ovl { font-size: 12px; color: var(--muted); white-space: normal; margin-top: 3px; }
.ovl b { color: var(--text); }
.ovl.busy b.cnt { color: var(--out); }
.copy { display: flex; gap: 6px; margin: 6px 0; }
.copy input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
td.stamps { font-variant-numeric: tabular-nums; line-height: 1.35; white-space: nowrap; }
