:root {
  --bg: #eef0f3;
  --surface: #ffffff;
  --border: #d7dbe1;
  --text: #1b2430;
  --text-muted: #5b6572;
  --accent: #2f5d8a;
  --accent-dark: #22456a;
  --ok: #2f7a4f;
  --warn: #b3541e;
  --danger: #b3311e;
  --radius: 8px;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

h1, h2 { font-weight: 600; letter-spacing: -0.01em; }

.screen { min-height: 100vh; }

/* ---------- Login ---------- */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

#login-screen[hidden] {
  display: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: min(340px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  text-align: center;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

input, select, button {
  font: inherit;
  color: var(--text);
}

input, select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); background: transparent; }

.error-text { color: var(--danger); font-size: 13px; margin: 0; }

.version-badge {
  position: fixed;
  bottom: 6px;
  right: 10px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  pointer-events: none;
  z-index: 10;
}

/* ---------- App shell ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.tabs button {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 4px;
}
.tabs button:hover { background: transparent; color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.summary-box {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.summary-box .stat { display: flex; flex-direction: column; }
.summary-box .stat .value { font-size: 22px; font-weight: 700; }
.summary-box .stat .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.summary-box .stat.over .value { color: var(--warn); }
.summary-box .stat.ok .value { color: var(--ok); }

.urlaub-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.gesamtsaldo-zeile {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

#gesamtsaldo-table {
  margin-top: 12px;
}

/* ---------- Forms ---------- */

.row-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

.row-form label { min-width: 110px; }
.row-form label.grow { flex: 1; min-width: 160px; }

/* ---------- Tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}

.data-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #eceef1;
}

.data-table tbody tr:hover { background: #f7f8fa; }

.data-table .subtotal-row {
  background: #f4f6f8;
  font-weight: 600;
  font-size: 12.5px;
}
.data-table .subtotal-row td { border-bottom: 1px solid var(--border); }
.data-table .subtotal-row .over { color: var(--warn); }
.data-table .subtotal-row .ok { color: var(--ok); }
.data-table td.over { color: var(--warn); font-weight: 600; }
.data-table td.ok { color: var(--ok); }

.merge-panel {
  background: #fbeee7;
  border: 1px solid #e8c4b0;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.merge-panel p { margin: 0 0 10px; font-size: 13.5px; }

.data-table tbody tr.kontrolle-noetig { background: #fbeee7; }

/* ---------- Stechuhr ---------- */

.stechuhr-panel .stechuhr-status {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.stechuhr-panel .stechuhr-status.laeuft-arbeit { color: var(--ok); font-weight: 600; }
.stechuhr-panel .stechuhr-status.laeuft-pause { color: var(--warn); font-weight: 600; }

.stechuhr-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.stechuhr-btn {
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
}

.stechuhr-btn.laeuft {
  background: var(--ok);
}
.stechuhr-btn.laeuft:hover { background: #245e3d; }

.stechuhr-btn.pause-laeuft {
  background: var(--warn);
}
.stechuhr-btn.pause-laeuft:hover { background: #8f4318; }

.stechuhr-btn:disabled, .stechuhr-projekt-zeile button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stechuhr-projekt-zeile {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.stechuhr-projekt-zeile label { min-width: 200px; }

.stechuhr-notiz-zeile {
  margin-top: 12px;
}
.stechuhr-notiz-zeile label { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Arbeitsmodell / Wochenmuster ---------- */

.arbeitsmodell-box {
  width: 100%;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 4px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.arbeitsmodell-auswahl { max-width: 340px; }

.wochenmuster-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.wochenmuster-grid label { min-width: 56px; }
.wochenmuster-grid input { width: 100%; }

.wochenmuster-summe {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-left: 8px;
  align-self: center;
}

.urlaub-zeile {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.urlaub-vorschlag {
  font-size: 12.5px;
  color: var(--text-muted);
}
.urlaub-vorschlag button {
  margin-left: 6px;
  padding: 3px 9px;
  font-size: 12px;
}

.arbeitszeit-hinweis {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.perioden-box {
  margin-bottom: 20px;
}
.perioden-box .badge.wochenmuster { background: #e4edf6; color: var(--accent-dark); }
.perioden-box .badge.flexibel { background: #f4ecd8; color: var(--warn); }

.data-table .link-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}
.data-table .link-btn:hover { text-decoration: underline; background: none; }

.sort-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0 0 4px;
  font-size: 12px;
}
.sort-btn:hover { color: var(--text); background: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.urlaub { background: #e4edf6; color: var(--accent-dark); }
.badge.krankheit { background: #f7e6e2; color: var(--danger); }
.badge.kurzarbeit { background: #f4ecd8; color: var(--warn); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 14px; }
  .row-form label { min-width: 100%; }
}
