:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #ea7317;
  --accent-dark: #c75c0a;
  --green: #16a34a;
  --green-dark: #15803d;
  --red: #dc2626;
  --red-dark: #b91c1c;
  --blue: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 20px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--accent-dark); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 20px; position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.topbar .right { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); }
.topbar .right .name { color: var(--ink); font-weight: 600; }

.container { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
.container.wide { max-width: 1200px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 16px; }
.card h2 .sub { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 300px; }

/* Buttons */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 9px; font-weight: 600;
}
button:hover { background: #f9fafb; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 13px; border-radius: 7px; }
.btn-danger { color: var(--red-dark); border-color: #f3c4c4; }
.btn-danger:hover { background: #fef2f2; }
.btn-link { border: none; background: none; color: var(--accent-dark); padding: 2px 4px; }

/* Big clock button */
.clock { text-align: center; padding: 10px 0 4px; }
.timer { font-variant-numeric: tabular-nums; font-size: 52px; font-weight: 700; letter-spacing: 1px; margin: 6px 0 4px; }
.timer.idle { color: var(--muted); }
.clock .state { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.bigbtn {
  font-size: 20px; font-weight: 700; padding: 18px 40px; border-radius: 999px;
  border: none; color: #fff; min-width: 220px; transition: transform .05s;
}
.bigbtn:active { transform: scale(.98); }
.bigbtn.start { background: var(--green); }
.bigbtn.start:hover { background: var(--green-dark); }
.bigbtn.stop { background: var(--red); }
.bigbtn.stop:hover { background: var(--red-dark); }

/* Stats */
.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 130px; background: #fafafa; border: 1px solid var(--line); border-radius: 11px; padding: 14px; text-align: center; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.daysum td { background: #fafafa; font-weight: 600; }

.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; font-weight: 600; }
.tag.vacation { background: #e0f2fe; color: #075985; }
.tag.sick { background: #fee2e2; color: #991b1b; }
.tag.manual, .tag.admin { background: #fef3c7; color: #92400e; }
.tag.live { background: #dcfce7; color: #166534; }
.tag.off { background: #f3f4f6; color: #6b7280; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #fde6cf; border-color: var(--accent); }
.field { margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 140px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.right-align { text-align: right; }
.empty { color: var(--muted); font-style: italic; padding: 12px 2px; }
.spacer { flex: 1; }

/* Toast */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90%;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--red-dark); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; display: flex; gap: 9px; justify-content: center; align-items: center; }
.login-card .tagline { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: 14px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border-radius: 999px; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Greeting */
.greeting { font-size: 20px; font-weight: 700; margin: 0 0 2px; }
.greeting .wave { display: inline-block; }
.subtle { color: var(--muted); font-size: 14px; }

/* Dashboard tiles */
.dashgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.tile { background: #fafafa; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .v.small { font-size: 20px; }
.tile .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile .v.pos { color: var(--green-dark); }
.tile .v.neg { color: var(--red-dark); }

/* Progress bar */
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.progress.green > span { background: var(--green); }

/* Mini-Kalender */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-head { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal-day { aspect-ratio: 1 / 1; border-radius: 8px; border: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; justify-content: space-between; font-size: 12px; background: var(--card); min-height: 38px; }
.cal-day .d { font-weight: 600; color: var(--muted); }
.cal-day .h { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-day.weekend { background: #fafafa; }
.cal-day.holiday { background: #f3e8ff; }
.cal-day.worked { background: #e9f7ef; border-color: #b7e4c7; }
.cal-day.worked .h { color: var(--green-dark); }
.cal-day.vac { background: #e0f2fe; border-color: #bae6fd; }
.cal-day.sick { background: #fee2e2; border-color: #fecaca; }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day.future { opacity: .55; }
.cal-day .mark { font-size: 10px; font-weight: 700; }

/* Team-Liste */
.teamlist { display: flex; flex-direction: column; gap: 2px; }
.teamrow { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.teamrow:last-child { border-bottom: none; }
.sdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sdot.active { background: var(--green); box-shadow: 0 0 0 3px #dcfce7; }
.sdot.done { background: #9ca3af; }
.sdot.vacation { background: #0ea5e9; }
.sdot.sick, .sdot.absent { background: #ef4444; }
.sdot.off { background: #e5e7eb; }
.teamrow .tn { font-weight: 600; }
.teamrow .tl { margin-left: auto; color: var(--muted); font-size: 13px; }

/* Bar chart (Admin) */
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { background: var(--line); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.bar-row .bv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Badges für Antragsstatus */
.tag.pending { background: #fef9c3; color: #854d0e; }
.tag.approved { background: #dcfce7; color: #166534; }
.tag.rejected { background: #fee2e2; color: #991b1b; text-decoration: line-through; }

/* Theme-Toggle */
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 15px; line-height: 1; }

@media (max-width: 640px) {
  .timer { font-size: 42px; }
  .topbar { padding: 10px 14px; }
  .topbar .brand { font-size: 16px; }
  .cal-day { min-height: 30px; font-size: 11px; }
  .bar-row { grid-template-columns: 92px 1fr 56px; }
}

/* ===================== Dark Mode ===================== */
html.dark {
  --bg: #0f1419;
  --card: #1a212b;
  --ink: #e5e9ef;
  --muted: #95a1b2;
  --line: #2b3543;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
}
html.dark .stat, html.dark .tile { background: #131922; }
html.dark .cal-day { background: #131922; }
html.dark .cal-day.weekend { background: #11161e; }
html.dark .cal-day.worked { background: #16271d; border-color: #1f4d33; }
html.dark .cal-day.vac { background: #102a3a; border-color: #1d4d68; }
html.dark .cal-day.sick { background: #2e1517; border-color: #5b2326; }
html.dark .cal-day.holiday { background: #241733; }
html.dark tr.daysum td { background: #131922; }
html.dark button:hover { background: #222c39; }
html.dark input, html.dark select, html.dark textarea { background: #131922; color: var(--ink); }
html.dark .tag.off { background: #2b3543; color: #95a1b2; }
