:root {
  color-scheme: light;
  --background: #f7f9fa;
  --foreground: #0f1f23;
  --surface: #ffffff;
  --surface-elevated: #eef4f6;
  --sidebar: #364144;
  --sidebar-foreground: #f7f9fa;
  --sidebar-muted: rgba(247, 249, 250, 0.72);
  --brand: #00aec9;
  --brand-dark: #0093ab;
  --brand-foreground: #ffffff;
  --muted-foreground: #5a6b6f;
  --border: rgba(15, 31, 35, 0.1);
  --danger: oklch(0.6 0.22 25);
  --danger-bg: #fee4e2;
  --success: #166534;
  --success-bg: #dcfce7;
  --warning: #92400e;
  --warning-bg: #fef3c7;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 22px;
  --shadow-elegant: 0 30px 60px -30px rgba(15, 31, 35, 0.25);
  --shadow-glow: 0 0 0 1px rgba(0, 174, 201, 0.25), 0 20px 60px -20px rgba(0, 174, 201, 0.35);
  --gradient-hero: radial-gradient(120% 80% at 80% 0%, rgba(0, 174, 201, 0.18) 0%, transparent 60%),
    linear-gradient(180deg, #ffffff 0%, #eef4f6 100%);
  font-family: "Inter", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body, #app {
  height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

::selection {
  background: var(--brand);
  color: var(--brand-foreground);
}

a { color: var(--brand); }

/* ── Blazor shell ─────────────────────────────────────────── */

#blazor-error-ui {
  background: #fff8e6;
  border-top: 1px solid rgba(15, 31, 35, 0.12);
  bottom: 0;
  box-shadow: 0 -4px 16px rgba(15, 31, 35, 0.08);
  display: none;
  left: 0;
  padding: 0.75rem 3rem 0.75rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 2000;
  font-size: 0.9rem;
}

#blazor-error-ui .reload { color: var(--brand); margin-left: 0.5rem; }

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.loading-progress {
  position: relative;
  display: block;
  width: 6rem;
  height: 6rem;
  margin: 22vh auto 1rem;
}

.loading-progress circle {
  fill: none;
  stroke: var(--surface-elevated);
  stroke-width: 0.55rem;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
}

.loading-progress circle:last-child {
  stroke: var(--brand);
  stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
  transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
  text-align: center;
  font-weight: 600;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.loading-progress-text::after {
  content: var(--blazor-load-percentage-text, "Laden …");
}

/* ── Auth pages ───────────────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--gradient-hero);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-elegant);
}

.auth-brand {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.auth-logo {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
  color: var(--brand);
}

.auth-brand h1 {
  font-size: 1.75rem;
  margin: 0;
}

.auth-subtitle {
  color: var(--muted-foreground);
  margin: 0 0 1.75rem;
  font-size: 0.95rem;
}

.auth-form {
  display: grid;
  gap: 0.25rem;
}

.auth-form .btn.primary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  font-weight: 600;
}

/* ── CMS shell ────────────────────────────────────────────── */

.cms-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.cms-sidebar {
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.cms-brand {
  padding: 0 0.5rem;
}

.cms-brand a {
  display: inline-flex;
  align-items: center;
}

.cms-brand-logo {
  display: block;
  height: 2rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  mix-blend-mode: lighten;
}

.cms-sidebar nav {
  display: grid;
  gap: 0.25rem;
}

.cms-sidebar a {
  color: var(--sidebar-muted);
  text-decoration: none;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.925rem;
  transition: background 0.15s, color 0.15s;
}

.cms-sidebar a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-foreground);
}

.cms-sidebar a.active {
  background: rgba(0, 174, 201, 0.18);
  color: #fff;
}

.cms-sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cms-sidebar-footer .btn {
  width: 100%;
  justify-content: center;
  color: var(--sidebar-muted);
  border-color: rgba(255, 255, 255, 0.15);
  background: transparent;
}

.cms-sidebar-footer .btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-foreground);
}

.cms-main {
  padding: clamp(1.25rem, 3vw, 2.5rem);
  min-width: 0;
}

.cms-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  position: sticky;
  top: 0;
  z-index: 100;
}

.cms-topbar-brand {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 700;
  font-size: 1rem;
}

.cms-topbar-brand .cms-brand-logo {
  height: 1.65rem;
}

.cms-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.cms-menu-toggle svg { width: 1.25rem; height: 1.25rem; }

.cms-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 31, 35, 0.45);
  z-index: 150;
  border: none;
  cursor: pointer;
}

/* ── Shared components ────────────────────────────────────── */

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.75rem;
}

.muted { color: var(--muted-foreground); }

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(15, 31, 35, 0.04);
}

.table-wrap + .panel,
.panel-create {
  margin-top: 1.75rem;
}

.subpanel {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.panel h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  margin: 0 0 1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.card {
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: rgba(0, 174, 201, 0.35);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.card p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
}

.field.inline {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.checkbox, .publish-toggle {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted-foreground);
  cursor: pointer;
}

.checkbox input[type="checkbox"],
.checkbox input[type="radio"],
.publish-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-grid { display: grid; gap: 0.35rem; }

.checkbox-grid .checkbox { margin-bottom: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-foreground);
}

.btn.primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-elevated);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
  background: var(--surface-elevated);
}

.table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.draft { background: var(--warning-bg); color: var(--warning); }

.alert {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert.ok { background: var(--success-bg); color: var(--success); }

.alert.toast {
  position: fixed;
  bottom: 6rem;
  right: clamp(1.25rem, 3vw, 2.5rem);
  z-index: 1101;
  margin: 0;
  max-width: min(420px, calc(100vw - 2.5rem));
  box-shadow: 0 10px 28px rgba(15, 31, 35, 0.14);
  border: 1px solid var(--border);
  pointer-events: none;
}

@media (max-width: 900px) {
  .alert.toast {
    bottom: 5.5rem;
    right: 1rem;
    left: auto;
    max-width: min(420px, calc(100vw - 2rem));
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.actions.sticky {
  position: sticky;
  bottom: 1rem;
  z-index: 100;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  background: rgba(247, 249, 250, 0.92);
  backdrop-filter: blur(8px);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.actions-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 31, 35, 0.4);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 500;
}

.modal {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  width: min(480px, 100%);
  box-shadow: var(--shadow-elegant);
}

input[type="file"] {
  display: block;
  margin: 0.35rem 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  color: var(--foreground);
  cursor: pointer;
}

.panel > input[type="file"] {
  margin-top: 0.75rem;
  margin-bottom: 1rem;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.925rem;
  background: var(--surface);
  color: var(--foreground);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 174, 201, 0.18);
}

.team-photo {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.team-photo-sm {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 999px;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 900px) {
  .cms-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .cms-topbar { display: flex; }

  .cms-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 200;
    width: min(280px, 85vw);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-elegant);
  }

  .cms-shell.sidebar-open .cms-sidebar {
    transform: translateX(0);
  }

  .cms-shell.sidebar-open .cms-sidebar-backdrop {
    display: block;
  }

  .cms-main { padding: 1.25rem; }

  .page-header { flex-direction: column; }

  .actions.sticky { position: static; }
}

@media (max-width: 480px) {
  .auth-card { padding: 1.5rem; }

  .cards { grid-template-columns: 1fr; }
}
