:root {
  --bg: #101114;
  --panel: #181a1f;
  --panel-light: #22252c;
  --text: #f2f4f8;
  --text-muted: #9ca3af;
  --accent: #b794f4;
  --accent2: #9ae6b4;
  --error: #f87171;
  --warn: #facc15;
  --ok: #4ade80;
  --info: #60a5fa;
  --radius: 10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.error-text { color: var(--error); margin-top: 10px; font-size: 14px; }

/* ---------- Login ---------- */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-box {
  background: var(--panel); border-radius: var(--radius);
  padding: 36px 32px; width: 100%; max-width: 380px; text-align: center;
  border: 1px solid var(--panel-light);
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box form { margin-top: 24px; display: flex; flex-direction: column; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px; background: var(--panel); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px; flex-shrink: 0;
  border-right: 1px solid var(--panel-light);
}
.brand { font-size: 18px; font-weight: 700; padding: 6px 10px 18px; letter-spacing: 0.5px; }
.brand span { color: var(--accent); }
.sidebar a {
  color: var(--text-muted); text-decoration: none; padding: 11px 12px;
  border-radius: 8px; font-size: 15px;
}
.sidebar a:hover { background: var(--panel-light); color: var(--text); }
.sidebar a.active { background: var(--panel-light); color: var(--accent); font-weight: 600; }
.sidebar-footer {
  margin-top: auto; padding: 12px 10px 4px; display: flex;
  flex-direction: column; gap: 8px; font-size: 13px;
}

main { flex: 1; padding: 24px; max-width: 1400px; min-width: 0; }
main h2 { font-size: 20px; margin-bottom: 18px; }

/* ---------- Komponenten ---------- */
input, select, textarea {
  background: var(--panel-light); border: 1px solid #2e323b;
  color: var(--text); border-radius: 8px; padding: 10px 12px;
  font-size: 15px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 4px; }

.btn {
  background: var(--panel-light); color: var(--text); border: 1px solid #2e323b;
  border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer;
  min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #14101c; border: none; font-weight: 600; }
.btn.danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn.small { padding: 6px 12px; min-height: 32px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  background: var(--panel); border-radius: var(--radius);
  padding: 18px; border: 1px solid var(--panel-light);
}
.card h3 { font-size: 14px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
.card .big { font-size: 26px; font-weight: 700; }

.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.status-dot.ok { background: var(--ok); }
.status-dot.err { background: var(--error); }
.status-dot.warn { background: var(--warn); }
.status-dot.info { background: var(--info); }

.badge {
  display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 20px;
  background: var(--panel-light); color: var(--text-muted);
}
.badge.ok { color: var(--ok); }
.badge.err { color: var(--error); }
.badge.warn { color: var(--warn); }
.badge.info { color: var(--info); }
.badge.accent { color: var(--accent); }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--panel-light); font-size: 14px; }
th { color: var(--text-muted); font-weight: 500; font-size: 13px; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ---------- Kamera-/Event-Kacheln ---------- */
.tile {
  background: var(--panel); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--panel-light);
}
.tile img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #000; }
.tile .tile-body { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile .tile-title { font-weight: 600; }
.tile .tile-sub { font-size: 13px; color: var(--text-muted); }

.event-row { display: flex; gap: 14px; background: var(--panel); border-radius: var(--radius); padding: 12px; border: 1px solid var(--panel-light); align-items: center; }
.event-row img { width: 130px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #000; flex-shrink: 0; }
.event-row .ev-info { flex: 1; min-width: 0; }
.event-row .ev-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: end; }
.filters > div { min-width: 140px; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: var(--panel); border-radius: var(--radius); border: 1px solid var(--panel-light);
  padding: 24px; width: 100%; max-width: 700px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; }

/* ---------- Vollbild-Viewer ---------- */
.viewer {
  position: fixed; inset: 0; background: #000; z-index: 300;
  overflow: hidden; cursor: zoom-out;
}
.viewer img {
  position: absolute; top: 50%; left: 50%;
  transform-origin: center; max-width: none; max-height: none;
}
.viewer-bar {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 2;
}
.viewer-bar .btn { background: rgba(24,26,31,0.85); }
.viewer-title {
  position: absolute; top: 12px; left: 14px; z-index: 2;
  background: rgba(24,26,31,0.85); padding: 8px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-light); color: var(--text); padding: 12px 22px;
  border-radius: 10px; border: 1px solid var(--accent); z-index: 200; font-size: 14px;
  max-width: 90vw;
}
.toast.error { border-color: var(--error); }

pre.code {
  background: #0b0c0f; padding: 14px; border-radius: 8px; overflow-x: auto;
  font-size: 12.5px; line-height: 1.5; color: #c8d0dc;
}

/* ---------- Mobil ---------- */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; flex-wrap: wrap; padding: 8px;
    position: sticky; top: 0; z-index: 50; border-right: none;
    border-bottom: 1px solid var(--panel-light); align-items: center;
  }
  .brand { padding: 6px 10px; font-size: 15px; }
  .sidebar a { padding: 8px 10px; font-size: 13px; }
  .sidebar-footer { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; padding: 0 6px; }
  main { padding: 14px; }
  .event-row { flex-direction: column; align-items: stretch; }
  .event-row img { width: 100%; }
}
