:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1f2733;
  --muted: #6b7686;
  --line: #e3e8ef;
  --primary: #1f5fbf;
  --primary-d: #184c99;
  --danger: #c2362f;
  --warn: #b8860b;
  --ok: #1f8a4c;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .6rem 1.25rem; box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.brand span { color: var(--primary); }
.mainnav { display: flex; gap: .25rem; }
.mainnav a { padding: .4rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.mainnav a:hover { background: var(--bg); text-decoration: none; }
.mainnav a.active { background: var(--primary); color: #fff; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.uname { font-size: .9rem; color: var(--muted); }
.inline { display: inline; }

.container { max-width: 1040px; margin: 1.5rem auto; padding: 0 1.25rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 0; }

/* Pagehead */
.pagehead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.head-actions { display: flex; gap: .5rem; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 720px){ .cols { grid-template-columns: 1fr; } }
.stat { text-align: center; }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: .9rem; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tbody tr:hover { background: #fafbfd; }

/* Badges */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.status-AKTIV { background: #e7f5ee; color: var(--ok); }
.status-GEKUENDIGT { background: #fdf3e3; color: var(--warn); }
.status-AUSGETRETEN { background: #fbe9e8; color: var(--danger); }

/* Buttons */
.btn { display: inline-block; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .45rem .9rem; border-radius: 8px; font-size: .9rem; font-weight: 500; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* Forms */
.form label, .filters label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .9rem; color: var(--ink); }
input, select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin-top: .25rem; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px){ .grid2 { grid-template-columns: 1fr; } }
.form label small { display: block; font-weight: 400; margin-top: .15rem; font-size: .78rem; }
.form-actions { display: flex; gap: .5rem; margin-top: .5rem; }
.filters { display: flex; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input, .filters select { width: auto; }
.addform summary { display: inline-block; margin-top: .5rem; }
.addform[open] summary { margin-bottom: 1rem; }

.snap-hint { font-size: .8rem; color: var(--muted); }
.inline-add { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; }
.inline-add input { width: auto; margin-top: 0; }
.rowbtns { white-space: nowrap; display: flex; gap: .35rem; }
.ts-grid td.rowbtns, .table td.rowbtns { text-align: right; }
.table tr.row-current td { background: #eef5ff; }
.table tr.row-overlap td { background: #fdf3e3; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; }

.linklist { list-style: none; padding: 0; margin: 0; columns: 2; }
.linklist li { padding: .25rem 0; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: #e7f5ee; color: var(--ok); border-color: #b8e3ca; }
.alert-danger { background: #fbe9e8; color: var(--danger); border-color: #f3c6c3; }
.alert-warning { background: #fdf3e3; color: var(--warn); border-color: #f0dcae; }
.alert-info { background: #e8f0fb; color: var(--primary-d); border-color: #c6dcf6; }
.alert ul { margin: .25rem 0 0 1rem; padding: 0; }

/* Login */
body.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.logincard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; width: 340px; box-shadow: var(--shadow); }
.loginlogo { text-align: center; margin: 0; }
.logincard .muted { text-align: center; margin-top: .25rem; margin-bottom: 1.25rem; }

/* Error */
.errorbox { text-align: center; padding: 3rem 1rem; }
.errorbox h1 { font-size: 3rem; color: var(--primary); }

/* Monatsnavigation */
.monthnav { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .6rem 1rem; }
.monthpick { display: flex; align-items: center; gap: .5rem; margin: 0; }
.monthpick select { width: auto; margin-top: 0; }

/* ---------- Stundenzettel-Raster ---------- */
.tablewrap { overflow-x: auto; padding: .5rem; }
.ts-grid { font-size: .9rem; }
.ts-grid th, .ts-grid td { padding: .3rem .5rem; vertical-align: middle; white-space: nowrap; }
.ts-grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.ts-grid input, .ts-grid select { margin-top: 0; padding: .3rem .4rem; }
.ts-grid input[type="time"] { width: 7.5rem; }
.ts-grid input[type="number"] { width: 5rem; }
.ts-grid .note { width: 100%; min-width: 8rem; }
.ts-grid select.js-type { width: 7.5rem; }
.daycell .wd { color: var(--muted); font-size: .8rem; }
.daycell .holi { color: #9a6400; font-size: .72rem; }
.js-hours { font-weight: 600; }

/* Tagesfarben — dezent, aber klar unterscheidbar */
.ts-grid tr.is-saturday td { background: #f1f3f5; }                 /* Samstag hellgrau */
.ts-grid tr.is-sunday td   { background: #dfe3e8; }                 /* Sonntag dunkler grau */
.ts-grid tr.is-holiday td  { background: #ffe9cc; }                 /* Feiertag hellorange */
.ts-grid input:disabled, .ts-grid select:disabled { background: #f3f4f6; color: var(--muted); }

/* Summenzeile */
.sum-grid { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: .5rem; }
.sum-grid > div { display: flex; flex-direction: column; }
.sum-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.sum-val { font-size: 1.4rem; font-weight: 700; }
.sum-val.neg { color: var(--danger); }
.sum-val.pos { color: var(--ok); }
.sum-break { font-size: .85rem; }

.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--line); }

/* Legende */
.legend { display: flex; align-items: center; gap: .5rem 1.25rem; flex-wrap: wrap; font-size: .85rem; margin-top: 1rem; }
.legend .lg { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); vertical-align: middle; margin-right: .35rem; }
.lg-sat { background: #f1f3f5; }
.lg-sun { background: #dfe3e8; }
.lg-holi { background: #ffe9cc; }
