:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #1a1f2e;
  --muted: #6b7280;
  --border: #e3e7f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e7f7ed;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(20,25,40,.08), 0 8px 24px rgba(20,25,40,.06);
  --radius: 16px;
  --radius-sm: 10px;
}
:root[data-theme="dark"] {
  --bg: #0e1118;
  --surface: #171b25;
  --surface-2: #1f2430;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --border: #2a3040;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: #20243a;
  --green: #34d399;
  --green-soft: #14271f;
  --red: #f87171;
  --red-soft: #2a1a1c;
  --amber: #fbbf24;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 12px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; }
a { cursor: pointer; text-decoration: none; color: inherit; }
.muted { color: var(--muted); }
input, select, textarea, button { font: inherit; }

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, var(--primary-soft), var(--bg)); }
.login-card { background: var(--surface); padding: 36px 32px; border-radius: var(--radius);
  box-shadow: var(--shadow); width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px;
  border: 1px solid var(--border); }
.login-logo { font-size: 44px; text-align: center; }
.login-card h1 { text-align: center; }
.login-card p { text-align: center; margin: 0 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.error-msg { color: var(--red); font-size: 14px; min-height: 18px; text-align: center; }

/* ---------- Inputs ---------- */
input, select, textarea {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn { border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 16px;
  cursor: pointer; font-weight: 600; background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; gap: 8px; transition: .15s; }
.btn:hover { filter: brightness(1.03); transform: translateY(-1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.icon { padding: 8px 12px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 8px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; padding: 8px 10px 16px; }
.brand-icon { font-size: 24px; }
#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 600; }
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.active { background: var(--primary-soft); color: var(--primary); }
:root[data-theme="dark"] #nav a.active { color: var(--primary-hover); }
.sidebar-foot { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.userline { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }

.content { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 26px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar h1 { font-size: 22px; }
#menuBtn { display: none; }
.view { padding: 24px 26px 60px; }

/* ---------- Cards / Grid ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.card .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.value.green { color: var(--green); } .value.red { color: var(--red); } .value.primary { color: var(--primary); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; }
.panel-body { padding: 4px 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 20px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.amount-in { color: var(--green); font-weight: 700; }
.amount-out { color: var(--red); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,14,22,.55); display: grid; place-items: center;
  z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(520px, 96vw); max-height: 92vh; overflow: auto; border: 1px solid var(--border); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.modal-foot { padding: 16px 22px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.segmented { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); }
.segmented label { flex: 1; }
.segmented input { display: none; }
.segmented span { display: block; text-align: center; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Kalender (Dienstplan/Urlaub) ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 16px 20px; }
.cal-head { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px; text-transform: uppercase; }
.cal-cell { min-height: 92px; border: 1px solid var(--border); border-radius: 10px; padding: 6px; background: var(--surface);
  display: flex; flex-direction: column; gap: 4px; }
.cal-cell.dim { opacity: .4; }
.cal-cell.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.cal-cell.holiday { background: var(--red-soft); }
.cal-cell.weekend { background: var(--surface-2); }
.cal-date { font-size: 12px; font-weight: 700; }
.cal-hol { font-size: 10px; color: var(--red); font-weight: 600; }
.cal-item { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--primary-soft); color: var(--primary);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav strong { min-width: 150px; text-align: center; }

/* ---------- Urlaub Jahresleiste ---------- */
.year-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; padding: 8px 20px; }
.year-track { position: relative; height: 26px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.year-bar { position: absolute; top: 3px; height: 20px; border-radius: 6px; font-size: 10px; color: #fff;
  display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; cursor: pointer; }
.months-axis { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 4px 20px; }
.months-axis .m { display: grid; grid-template-columns: repeat(12, 1fr); font-size: 10px; color: var(--muted); }
.months-axis .m span { text-align: center; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; cursor: pointer; font-weight: 600; }
.chip.active { background: var(--primary); color: #fff; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; top: 0; z-index: 40; transition: .25s; width: 250px; }
  .sidebar.open { left: 0; box-shadow: var(--shadow); }
  #menuBtn { display: inline-flex; }
  .form-row { grid-template-columns: 1fr; }
  th, td { padding: 10px 14px; }
}
