/* ============================================
   Urlaubsverwaltung – Design System
   ============================================ */

:root {
  /* Light Theme (Default) */
  --bg: #f7f6f2;
  --bg-elevated: #ffffff;
  --bg-subtle: #efece4;
  --bg-hover: #ebe8df;
  --border: #e2ddd0;
  --border-strong: #c9c2b0;
  --text: #1a1916;
  --text-muted: #6b6759;
  --text-subtle: #9a9484;

  --accent: #b4602e;
  --accent-hover: #9a4f24;
  --accent-soft: #f3e3d4;

  --success: #4a7c59;
  --success-soft: #e0ebde;
  --warning: #c08a2e;
  --warning-soft: #f5ead0;
  --danger: #a83f3f;
  --danger-soft: #f1dcd9;
  --info: #4a6b9c;
  --info-soft: #dde6f1;

  --shadow-sm: 0 1px 2px rgba(26, 25, 22, 0.04), 0 1px 3px rgba(26, 25, 22, 0.06);
  --shadow-md: 0 4px 6px rgba(26, 25, 22, 0.04), 0 10px 15px rgba(26, 25, 22, 0.06);
  --shadow-lg: 0 10px 25px rgba(26, 25, 22, 0.08), 0 20px 40px rgba(26, 25, 22, 0.06);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #14130f;
  --bg-elevated: #1f1d18;
  --bg-subtle: #28251f;
  --bg-hover: #322e26;
  --border: #2f2c25;
  --border-strong: #45413a;
  --text: #f0ece1;
  --text-muted: #a39d8a;
  --text-subtle: #6e695c;

  --accent: #d97a48;
  --accent-hover: #e88c5c;
  --accent-soft: #3d2a1d;

  --success: #7ba88a;
  --success-soft: #2a3a2f;
  --warning: #d9a857;
  --warning-soft: #3d3220;
  --danger: #d96565;
  --danger-soft: #3d2424;
  --info: #7a9bd0;
  --info-soft: #243140;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Mitarbeiter-Picker (Chip-Buttons)
   ============================================ */
.employee-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.emp-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s;
}

.emp-chip:hover {
  background: var(--bg-hover);
}

.emp-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.emp-chip.active .color-chip {
  border-color: rgba(255,255,255,0.4);
}

/* ============================================
   Jahresansicht (12 Mini-Kalender)
   ============================================ */
.year-months-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 1100px) { .year-months-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .year-months-grid { grid-template-columns: 1fr; } }

.year-month {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.year-month-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  text-align: center;
  margin-bottom: 0.6rem;
}

.year-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.year-weekday {
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-subtle);
  padding: 0.2rem 0;
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.year-weekday.weekend { color: var(--text-muted); }

.year-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}

.year-day:hover:not(.empty) {
  filter: brightness(1.08);
  outline: 1px solid var(--border-strong);
}

.year-day.empty { background: transparent; cursor: default; }
.year-day.empty:hover { filter: none; outline: none; }
.year-day.weekend { background: transparent; color: var(--text-subtle); }
.year-day.holiday {
  background: var(--info-soft);
  color: var(--info);
  font-weight: 600;
}
.year-day.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  font-weight: 700;
}
.year-day.absent {
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Day-Detail Modal Items */
.day-detail-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.6rem;
  background: var(--bg-elevated);
}

.day-detail-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.day-detail-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.day-detail-meta {
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.day-detail-actions {
  display: flex;
  gap: 0.4rem;
}

/* Quick-Buttons im Überstunden-Modal */
.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.quick-buttons .btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
  min-width: 48px;
  text-align: center;
  justify-content: center;
}

/* ============================================
   Picker-Zelle (auswählbar im Kalender)
   ============================================ */
.picker-cell {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.picker-cell:hover:not(.selected) {
  background: var(--bg-hover);
}

.picker-cell.selected-new {
  color: #fff;
}

.picker-cell.selected-new .day-num {
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.picker-cell.selected-new .day-meta {
  color: rgba(255,255,255,0.9);
}

.picker-cell.selected-delete {
  outline: 3px dashed #a83f3f;
  outline-offset: -3px;
}

.day-entry.to-delete {
  opacity: 0.55;
  text-decoration: line-through;
}

.picker-cell.has-existing:not(.selected) {
  background: var(--info-soft);
}

/* ============================================
   Wochentage-Eingabe (Mitarbeiterformular)
   ============================================ */
.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.6rem;
  margin-top: 0.5rem;
}

@media (max-width: 800px) {
  .weekday-grid { grid-template-columns: repeat(4, 1fr); }
}

.weekday-cell {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.weekday-cell .form-control {
  padding: 0.45rem 0.5rem;
  font-size: 0.95rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.weekly-summary {
  display: flex;
  gap: 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Wochentage-Anzeige (Detail) */
.weekday-display {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

@media (max-width: 800px) {
  .weekday-display { grid-template-columns: repeat(4, 1fr); }
}

.weekday-pill {
  text-align: center;
  padding: 0.6rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.weekday-pill.off {
  opacity: 0.45;
  background: transparent;
}

.weekday-pill-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.weekday-pill-hours {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  margin-top: 0.2rem;
}

/* ============================================
   View-Switcher (Monat/Jahr)
   ============================================ */
.view-switcher {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-switcher .btn {
  border: none;
  border-radius: 0;
  background: transparent;
}

.view-switcher .btn.active {
  background: var(--accent);
  color: #fff;
}

.view-switcher .btn + .btn {
  border-left: 1px solid var(--border-strong);
}

.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.filter-check input { cursor: pointer; }

/* ============================================
   Große Monatsansicht
   ============================================ */
.month-large {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.month-large-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.weekday-header {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 0.5rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.weekday-header.weekend { color: var(--text-muted); }

.day-large {
  min-height: 110px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--bg-elevated);
  position: relative;
}

.day-large:nth-child(7n) { border-right: none; }

.day-large.outside {
  background: var(--bg-subtle);
  opacity: 0.5;
}

.day-large.weekend {
  background: var(--bg-subtle);
}

.day-large.today {
  background: var(--accent-soft);
}

.day-large.today .day-num {
  background: var(--accent);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.day-large.holiday {
  background: var(--info-soft);
}

.day-num {
  font-size: 0.9rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.day-large.outside .day-num { color: var(--text-subtle); }

.day-meta {
  font-size: 0.7rem;
  color: var(--info);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.day-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 0.2rem;
}

.day-entry {
  font-size: 0.72rem;
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-entry.more {
  background: var(--bg-hover) !important;
  color: var(--text-muted);
}

@media (max-width: 800px) {
  .day-large {
    min-height: 70px;
    padding: 0.3rem;
  }
  .day-entry { font-size: 0.65rem; padding: 1px 4px; }
}

/* ============================================
   Bestehende Komponenten
   ============================================ */
/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h1 { font-size: 2rem; font-weight: 400; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ============================================
   Layout
   ============================================ */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.25rem;
}

.nav {
  flex: 1;
  padding: 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.92rem;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: all 0.15s;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.main {
  padding: 2rem 2.5rem 4rem;
  max-width: 1400px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 2.1rem;
  font-weight: 400;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ============================================
   Components
   ============================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  text-decoration: none;
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover { filter: brightness(1.08); color: #fff; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover { filter: brightness(1.08); color: #fff; }

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  position: relative;
  overflow: hidden;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 400;
  margin-top: 0.4rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stat-accent { color: var(--accent); }
.stat-success { color: var(--success); }
.stat-warning { color: var(--warning); }
.stat-danger { color: var(--danger); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

thead th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-subtle); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-neutral { background: var(--bg-subtle); color: var(--text-muted); }

/* Typ-spezifische Badges für Abwesenheiten */
.badge.type-urlaub      { background: rgba(74, 124, 89, 0.15);  color: #3a6347; }
.badge.type-krank       { background: rgba(168, 63, 63, 0.15);  color: #8a3232; }
.badge.type-fortbildung { background: rgba(192, 138, 46, 0.18); color: #8c6620; }

[data-theme="dark"] .badge.type-urlaub      { background: rgba(123, 168, 138, 0.20); color: #a8d4b6; }
[data-theme="dark"] .badge.type-krank       { background: rgba(217, 101, 101, 0.20); color: #f0a5a5; }
[data-theme="dark"] .badge.type-fortbildung { background: rgba(217, 168, 87, 0.22);  color: #f0c878; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.4rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-control[type="color"] {
  height: 42px;
  padding: 0.2rem;
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: end;
}

.form-row > * { flex: 1; min-width: 150px; }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-body);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}

/* Login-Page */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 30%, var(--accent-soft) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, var(--info-soft) 0%, transparent 40%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

.auth-sub {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info  { background: var(--info-soft);   color: var(--info); }

/* Empty state */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  opacity: 0.4;
  margin-bottom: 0.5rem;
}

/* Two-column section */
.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1000px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Inline form (compact) */
.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  flex-wrap: wrap;
}

.inline-form .form-control { padding: 0.4rem 0.6rem; font-size: 0.9rem; }

/* Section */
.section { margin-bottom: 2rem; }

.section-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-bar {
  width: 4px;
  height: 1.2rem;
  background: var(--accent);
  border-radius: 2px;
}

/* Avatar / Color marker */
.color-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.filter-bar .form-control { padding: 0.4rem 0.6rem; font-size: 0.9rem; }
.filter-bar label { font-size: 0.85rem; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Calendar */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 1100px) { .calendar-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .calendar-grid { grid-template-columns: 1fr; } }

.month {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.month-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 0.6rem;
  font-weight: 500;
  text-align: center;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 0.78rem;
}

.weekday {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-subtle);
  padding: 0.2rem 0;
  text-transform: uppercase;
  font-weight: 500;
}

.day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  position: relative;
  cursor: default;
  background: var(--bg-subtle);
  color: var(--text);
}

.day.empty { background: transparent; }
.day.weekend { color: var(--text-subtle); background: transparent; }
.day.holiday {
  background: var(--info-soft);
  color: var(--info);
  font-weight: 600;
}
.day.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  font-weight: 600;
}

.day.absent {
  color: #fff;
  font-weight: 600;
}

.day-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
  max-width: 200px;
  white-space: normal;
  width: max-content;
}

.day:hover .day-tooltip { opacity: 1; }

/* Calendar legend */
.calendar-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

/* Action group in tables */
.action-group {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

/* Helper */
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: 0.5rem; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ============================================
   Responsive / Mobile (iPhone Safari)
   ============================================ */

/* ---- Tablet ---- */
@media (max-width: 1024px) {
  .two-col { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .year-months-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Mobile (≤ 768px) ---- */
@media (max-width: 768px) {

  /* Basisschrift etwas größer für Touch */
  html { font-size: 16px; }

  /* ── App-Layout ─────────────────────────── */
  .app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* Safari iOS */
  }

  /* Sidebar → fixierte Bottom-Tab-Bar (2 Zeilen) */
  .sidebar {
    order: 2;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    width: 100%;
    flex-direction: column;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 16px rgba(0,0,0,0.10);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-elevated);
  }

  .brand { display: none; }
  .sidebar-footer { display: none; }

  .nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 0;
    gap: 0;
  }

  .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px 8px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 0;
    min-height: 52px;
    color: var(--text-muted);
    border-top: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    text-decoration: none;
  }

  .nav-item.active {
    color: var(--accent);
    background: var(--accent-soft);
    border-top: 2px solid var(--accent);
    font-weight: 600;
  }

  /* Trennlinie zwischen den zwei Zeilen */
  .nav-item:nth-child(5),
  .nav-item:nth-child(6),
  .nav-item:nth-child(7),
  .nav-item:nth-child(8) {
    border-top: 1px solid var(--border);
  }

  /* Main-Content */
  .main {
    order: 1;
    flex: 1;
    padding: 14px 14px 0;
    /* 2 Zeilen Tab-Bar (104px) + Home-Indicator + Puffer */
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 20px));
    max-width: 100%;
    overflow-x: hidden;
  }

  /* ── Page Header ────────────────────────── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }
  .page-title { font-size: 1.4rem; }
  .page-subtitle { font-size: 0.85rem; }

  .page-actions {
    width: 100%;
    display: flex;
    gap: 6px;
  }
  .page-actions > * { flex: 1; }
  .page-actions .btn { justify-content: center; text-align: center; }

  /* ── Stats ──────────────────────────────── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 1.5rem; }
  .stat-label { font-size: 0.72rem; }
  .stat-sub { font-size: 0.78rem; }

  /* ── Karten ─────────────────────────────── */
  .card { padding: 12px; }
  .card-header { margin-bottom: 10px; padding-bottom: 8px; }

  /* ── Tabellen ───────────────────────────── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }
  /* KEIN min-width auf table – scrollt stattdessen */
  table { font-size: 0.82rem; }
  thead th { padding: 8px 10px; font-size: 0.7rem; }
  tbody td { padding: 8px 10px; }

  /* ── Filter-Bar ─────────────────────────── */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
  }
  .filter-bar label { font-size: 0.82rem; }
  .filter-bar .form-control { width: 100%; }
  .filter-bar > form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  /* Filter-Checkboxen nebeneinander auf Mobile */
  .filter-bar .flex {
    flex-wrap: wrap;
    gap: 6px;
  }
  .filter-check { font-size: 0.85rem; }

  /* ── Formulare ──────────────────────────── */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-row { flex-direction: column; gap: 8px; }
  .form-row > * { min-width: 0; width: 100%; }
  .form-control { font-size: 16px; } /* Verhindert Auto-Zoom in Safari */
  select.form-control { font-size: 16px; }
  .weekly-summary { gap: 1rem; padding: 0.85rem 1rem; }

  /* Wochentage-Grid */
  .weekday-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .weekday-display { grid-template-columns: repeat(4, 1fr); gap: 4px; }

  /* ── Kalender (Monat) ───────────────────── */
  .month-large { border-radius: var(--radius-sm); }
  .weekday-header { padding: 6px 2px; font-size: 0.65rem; }
  .day-large {
    min-height: 52px;
    padding: 3px;
  }
  .day-num { font-size: 0.78rem; }
  .day-entry {
    font-size: 0.6rem;
    padding: 1px 3px;
    border-radius: 2px;
  }
  .day-meta { font-size: 0.6rem; }

  /* ── Kalender (Jahr) ────────────────────── */
  .year-months-grid { grid-template-columns: 1fr; gap: 10px; }
  .year-month { padding: 10px; }
  .year-day { font-size: 0.72rem; }

  /* ── Modals ─────────────────────────────── */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.25rem 1rem;
    max-height: 85vh;
    /* Safe Area am unteren Rand */
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }

  /* ── Buttons ────────────────────────────── */
  .btn { min-height: 40px; } /* bessere Touch-Targets */
  .btn-sm { min-height: 34px; }

  /* ── Employee-Picker ────────────────────── */
  .employee-picker { gap: 6px; }
  .emp-chip {
    padding: 8px 12px;
    font-size: 0.88rem;
    min-height: 40px;
  }

  /* ── Quick-Buttons (Überstunden) ────────── */
  .quick-buttons { gap: 5px; }
  .quick-buttons .btn {
    padding: 7px 8px;
    font-size: 0.78rem;
    min-width: 44px;
    min-height: 36px;
    flex: 1;
  }

  /* ── View-Switcher ──────────────────────── */
  .view-switcher { width: 100%; }
  .view-switcher .btn {
    flex: 1;
    justify-content: center;
    padding: 8px 6px;
    font-size: 0.85rem;
  }

  /* ── Two-Col → Single ───────────────────── */
  .two-col { grid-template-columns: 1fr; gap: 12px; }

  /* ── Section-Titel ──────────────────────── */
  .section { margin-bottom: 14px; }
  .section-title { font-size: 1rem; margin-bottom: 8px; }

  /* ── Abstand zwischen Karten ────────────── */
  .mb-2 { margin-bottom: 12px; }
  .mt-2 { margin-top: 12px; }
  .mt-3 { margin-top: 14px; }
}

/* ---- iPhone SE / klein (≤ 375px) ---- */
@media (max-width: 375px) {
  html { font-size: 15px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-value { font-size: 1.3rem; }
  .nav-item { font-size: 11px; padding: 10px 4px 8px; min-height: 56px; }
  .day-large { min-height: 42px; }
  .quick-buttons .btn { font-size: 0.72rem; min-width: 38px; }
}

