:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --sidebar: #111827;
  --sidebar-muted: #9ca3af;
  --text: #111827;
  --muted: #64748b;
  --border: #dbe3ef;
  --border-strong: #b8c5d8;
  --accent: #0e7490;
  --accent-strong: #155e75;
  --accent-soft: #e0f2fe;
  --teal: #0f766e;
  --work: #16a34a;
  --work-soft: #dcfce7;
  --school: #f59e0b;
  --school-soft: #fef3c7;
  --missing: #dc2626;
  --missing-soft: #fee2e2;
  --sick: #7c3aed;
  --sick-soft: #ede9fe;
  --vacation: #2563eb;
  --vacation-soft: #dbeafe;
  --away: #475569;
  --away-soft: #e2e8f0;
  --shadow: 0 16px 35px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 280px;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  color: #fff;
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand small,
.nav-link strong,
.nav-link small {
  display: block;
}

.brand small,
.nav-link small {
  color: var(--sidebar-muted);
  font-size: 0.78rem;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e5e7eb;
}

.nav-link:hover,
.nav-link.is-active {
  border-color: rgba(34, 211, 238, 0.26);
  background: rgba(14, 116, 144, 0.26);
}

.nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(14, 116, 144, 0.18);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.status-light {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--missing);
}

.status-light.is-ready {
  background: var(--work);
}

.status-light.is-missing {
  background: var(--missing);
}

.app-main {
  min-height: 100vh;
  margin-left: 280px;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 20px;
  max-width: 1480px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar h1,
.topbar p,
.section-heading h2,
.section-heading p,
.month-toolbar h2,
.editor-head h2,
.settings-panel h2,
.export-strip h2,
.day-summary h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 1.65rem;
  line-height: 1.2;
}

.topbar p:last-child {
  max-width: 760px;
  color: var(--muted);
}

.eyebrow,
.metric-label {
  display: block;
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions,
.action-row,
.modal-actions,
.editor-actions,
.save-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.content {
  max-width: 1480px;
  margin: 0 auto;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 14px;
  max-width: 1480px;
  margin: 28px auto 0;
  padding: 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

.button,
.icon-button,
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.button {
  padding: 9px 14px;
}

.button:hover,
.icon-button:hover,
.drag-handle:hover {
  transform: translateY(-1px);
}

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

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary {
  color: var(--text);
  border-color: var(--border);
  background: #fff;
}

.button-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.button-danger {
  color: #fff;
  background: var(--missing);
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--muted);
  border-color: var(--border);
  background: #fff;
  font-size: 1.3rem;
  line-height: 1;
}

.alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 600;
}

.alert-error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff1f2;
}

.alert-success {
  color: #166534;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.overview-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.section-block,
.editor-panel,
.settings-panel,
.day-summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 126px;
  padding: 16px;
}

.metric-card strong {
  display: block;
  font-size: 1.65rem;
  line-height: 1.25;
}

.metric-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-missing-soft {
  border-color: #fecaca;
  background: #fff7f7;
}

.segmented-actions {
  display: inline-flex;
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.segmented-actions a {
  padding: 7px 10px;
  background: #fff;
  font-weight: 700;
  font-size: 0.84rem;
}

.segmented-actions a + a {
  border-left: 1px solid var(--border);
}

.section-block {
  margin-top: 18px;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading.slim {
  align-items: center;
}

.section-heading p,
.export-strip p,
.day-summary p,
.privacy-list p {
  color: var(--muted);
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.88rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.week-day-card {
  display: flex;
  min-height: 250px;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 8px;
  background: #fff;
}

.week-day-card:hover,
.calendar-day:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(14, 116, 144, 0.12);
  transform: translateY(-2px);
}

.week-day-card.is-today,
.calendar-day.is-today {
  outline: 2px solid rgba(14, 116, 144, 0.28);
  outline-offset: 2px;
}

.day-date {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.day-date span {
  color: var(--muted);
  font-weight: 700;
}

.day-date strong {
  font-size: 2rem;
  line-height: 1;
}

.day-full-date {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.day-status-badge {
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.preview-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #334155;
  font-size: 0.9rem;
}

.preview-list li {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.empty-copy {
  margin: 0;
  color: var(--muted);
}

.status-arbeit {
  border-color: var(--work);
  background: var(--work-soft);
  color: #166534;
}

.status-berufsschule {
  border-color: var(--school);
  background: var(--school-soft);
  color: #92400e;
}

.status-missing {
  border-color: var(--missing);
  background: var(--missing-soft);
  color: #991b1b;
}

.status-krank {
  border-color: var(--sick);
  background: var(--sick-soft);
  color: #5b21b6;
}

.status-urlaub {
  border-color: var(--vacation);
  background: var(--vacation-soft);
  color: #1d4ed8;
}

.status-abwesend,
.status-sonstiges {
  border-color: var(--away);
  background: var(--away-soft);
  color: #334155;
}

.export-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.export-strip form {
  margin: 0;
}

.month-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekday {
  padding: 10px 6px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  display: flex;
  min-height: 128px;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--border);
  border-top-width: 4px;
  border-radius: 8px;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.calendar-day.is-empty {
  border-style: dashed;
  background: #f1f5f9;
  box-shadow: none;
}

.calendar-number {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.calendar-status {
  font-size: 0.76rem;
  font-weight: 800;
}

.calendar-preview {
  display: -webkit-box;
  overflow: hidden;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.day-editor-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.day-summary {
  align-self: start;
  padding: 18px;
}

.day-summary h2 {
  margin-top: 16px;
  font-size: 1.55rem;
}

.day-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.1rem;
}

.editor-panel {
  padding: 18px;
}

.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
}

.field span {
  font-size: 0.88rem;
}

.compact-field {
  min-width: 220px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 72px;
  resize: vertical;
  overflow-wrap: anywhere;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(14, 116, 144, 0.16);
}

.editor-list {
  display: grid;
  gap: 10px;
}

.editor-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.editor-row.is-dragging {
  opacity: 0.55;
}

.drag-handle {
  width: 38px;
  height: 38px;
  color: var(--muted);
  border-color: var(--border);
  background: #fff;
  font-weight: 800;
}

.editor-actions {
  justify-content: space-between;
  margin-top: 16px;
}

.save-state {
  min-width: 120px;
  color: var(--muted);
  text-align: right;
  font-weight: 700;
}

.save-state.is-success {
  color: var(--work);
}

.save-state.is-error {
  color: var(--missing);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.settings-panel {
  padding: 18px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.privacy-list {
  display: grid;
  gap: 10px;
}

.privacy-list p {
  margin: 0;
}

.modal[aria-hidden="true"] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
}

.modal-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-span {
  grid-column: 1 / -1;
}

.inline-status,
.generation-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #cbd5e1;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.spinner-large {
  width: 42px;
  height: 42px;
  border-width: 5px;
}

.page-blocker[hidden] {
  display: none;
}

.page-blocker {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.68);
}

.page-blocker-card {
  display: grid;
  width: min(380px, 100%);
  justify-items: center;
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  text-align: center;
}

.page-blocker-card strong {
  font-size: 1.2rem;
}

.page-blocker-card span:last-child {
  color: var(--muted);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid,
  .overview-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
    border-radius: 0;
  }

  .app-main {
    margin-left: 0;
    padding: 16px;
  }

  .sidebar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar,
  .section-heading,
  .editor-head,
  .export-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: grid;
  }

  .day-editor-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 104px;
    padding: 10px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    padding: 16px;
  }

  .sidebar-nav,
  .overview-grid,
  .overview-grid.compact,
  .week-grid,
  .form-grid,
  .month-toolbar {
    grid-template-columns: 1fr;
  }

  .nav-link {
    min-height: 50px;
  }

  .topbar-actions,
  .action-row,
  .modal-actions,
  .editor-actions,
  .save-cluster {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .topbar-actions a,
  .topbar-actions button {
    width: 100%;
  }

  .calendar-grid {
    gap: 5px;
  }

  .calendar-weekday {
    padding: 6px 2px;
    font-size: 0.78rem;
  }

  .calendar-day {
    min-height: 82px;
    padding: 8px;
  }

  .calendar-status,
  .calendar-preview {
    display: none;
  }

  .editor-row {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
    padding: 8px;
  }

  .footer {
    flex-direction: column;
    text-align: center;
  }
}
