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

:root {
  --rot: #dc2626;
  --rot-bg: #fef2f2;
  --gelb: #d97706;
  --gelb-bg: #fffbeb;
  --grau: #6b7280;
  --grau-bg: #f9fafb;
  --gruen: #059669;
  --gruen-bg: #f0fdf4;
  --blau: #2563eb;
  --blau-bg: #eff6ff;
  --border: #e5e7eb;
  --text: #111827;
  --text-light: #6b7280;
  --white: #ffffff;
  --sidebar: 240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #f3f4f6;
  line-height: 1.5;
}

/* LOGIN */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  text-align: center;
}

.login-box h1 { font-size: 20px; margin-bottom: 8px; }
.login-box p { color: var(--text-light); margin-bottom: 24px; font-size: 13px; }

.login-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}
.login-box input:focus { border-color: var(--blau); }

/* APP LAYOUT */
#app { display: none; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-logo h2 { font-size: 13px; font-weight: 700; color: var(--text); }
.sidebar-logo p { font-size: 11px; color: var(--text-light); }

.nav-item {
  display: block;
  padding: 9px 20px;
  color: var(--text-light);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: all 0.1s;
}
.nav-item:hover { color: var(--text); background: var(--grau-bg); }
.nav-item.active { color: var(--blau); border-left-color: var(--blau); background: var(--blau-bg); font-weight: 600; }
.nav-item .icon { margin-right: 8px; }

.sidebar-bottom {
  position: absolute;
  bottom: 16px;
  left: 0; right: 0;
  padding: 0 20px;
}

.main {
  margin-left: var(--sidebar);
  padding: 24px;
  max-width: 1100px;
}

/* HEADER */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--blau); color: var(--white); }
.btn-danger { background: var(--rot); color: var(--white); }
.btn-ghost { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn-success { background: var(--gruen); color: var(--white); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* CARDS */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

/* AMPEL-KACHELN */
.ampel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.ampel-card {
  border-radius: 10px;
  padding: 16px 20px;
  border: 1px solid transparent;
}
.ampel-card.kritisch { background: var(--rot-bg); border-color: #fca5a5; }
.ampel-card.bald { background: var(--gelb-bg); border-color: #fcd34d; }
.ampel-card.buffer { background: var(--grau-bg); border-color: var(--border); }
.ampel-card.ok { background: var(--gruen-bg); border-color: #6ee7b7; }

.ampel-card .count { font-size: 32px; font-weight: 800; line-height: 1; }
.ampel-card.kritisch .count { color: var(--rot); }
.ampel-card.bald .count { color: var(--gelb); }
.ampel-card.buffer .count { color: var(--grau); }
.ampel-card.ok .count { color: var(--gruen); }
.ampel-card .label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* EPISODEN-TABELLE */
.ep-table { width: 100%; border-collapse: collapse; }
.ep-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.ep-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ep-table tr:last-child td { border-bottom: none; }
.ep-table tr:hover td { background: var(--grau-bg); cursor: pointer; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-veroeffentlicht { background: var(--gruen-bg); color: var(--gruen); }
.badge-aufgenommen { background: var(--blau-bg); color: var(--blau); }
.badge-produktion { background: var(--gelb-bg); color: var(--gelb); }
.badge-planung { background: var(--grau-bg); color: var(--grau); }

.days-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
}
.days-kritisch { background: var(--rot-bg); color: var(--rot); }
.days-bald { background: var(--gelb-bg); color: var(--gelb); }
.days-ok { background: var(--gruen-bg); color: var(--gruen); }
.days-past { color: var(--text-light); }

/* DETAIL-PANEL */
.detail-panel {
  display: none;
  position: fixed;
  top: 0; right: 0;
  width: 480px;
  height: 100vh;
  background: var(--white);
  border-left: 1px solid var(--border);
  z-index: 100;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
}
.detail-panel.open { display: block; }

.detail-header {
  position: sticky;
  top: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1;
}
.detail-header h2 { font-size: 15px; }

.detail-body { padding: 20px; }

.checkbox-group { margin-bottom: 20px; }
.checkbox-group h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
}
.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--blau);
}
.checkbox-item label { cursor: pointer; font-size: 13px; }
.checkbox-item.checked label { color: var(--grau); text-decoration: line-through; }

/* FORMULAR */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  background: var(--white);
}
.form-group input:focus,
.form-group select:focus { border-color: var(--blau); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--gruen); }
.toast.error { background: var(--rot); }

/* LOADER */
.loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blau);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

/* OVERLAY */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 99;
}
.overlay.open { display: block; }

/* MODAL */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: 12px;
  padding: 28px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-box h2 { font-size: 18px; margin-bottom: 20px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* NOTIFICATIONS */
.notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  color: var(--text-light);
  font-size: 18px;
  display: flex;
  align-items: center;
}
.notif-badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--rot);
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  display: none;
}
.notif-badge.visible { display: flex; }

.notif-panel {
  position: fixed;
  top: 0; right: 0;
  width: 380px;
  height: 100vh;
  background: var(--white);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: none;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}
.notif-panel.open { display: flex; }
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-header h2 { font-size: 15px; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.notif-item:hover { background: var(--grau-bg); }
.notif-item.unread { background: var(--blau-bg); }
.notif-item .notif-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
}
.notif-item .notif-msg {
  font-size: 12px;
  color: var(--text-light);
}
.notif-item .notif-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}
.notif-item.type-success .notif-title { color: var(--gruen); }
.notif-item.type-warning .notif-title { color: var(--gelb); }
.notif-item.type-info .notif-title { color: var(--blau); }
.notif-empty { padding: 40px 20px; text-align: center; color: var(--text-light); font-size: 13px; }

/* TEST MODE BANNER */
.test-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: #92400e;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ACTION BUTTONS */
.action-section {
  margin-bottom: 20px;
}
.action-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-light);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.action-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--grau-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: all 0.1s;
}
.action-btn:hover { background: var(--blau-bg); border-color: var(--blau); }
.action-btn .action-label { font-weight: 500; }
.action-btn .action-desc { font-size: 11px; color: var(--text-light); margin-top: 1px; }
.action-btn .action-icon { font-size: 18px; margin-right: 10px; }
.action-btn-inner { display: flex; align-items: center; }

/* INPUT INLINE */
.inline-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.inline-input-group input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.inline-input-group input:focus { border-color: var(--blau); }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main { margin-left: 0; }
  .detail-panel { width: 100%; }
  .notif-panel { width: 100%; }
}
