:root {
  --bg: #f3f5f1;
  --card-bg: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e2e6dc;
  --green: #008543;
  --green-dark: #006b36;
  --lime: #b0ca1e;
  --orange: #f5b400;
  --red: #b72221;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}
button, input, select { font-family: inherit; font-size: 14px; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 3px solid var(--lime);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo { height: 58px; width: auto; }
.topbar h1 { font-size: 19px; margin: 0 12px 0 0; color: var(--green); }
.topbar h1 span { color: var(--muted); font-weight: 400; }
.tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 9px 15px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.tab:hover { background: #eef3e6; }
.tab.active { background: var(--green); color: #fff; }

.page { max-width: 1240px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.tab-panel { display: flex; flex-direction: column; gap: 20px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

/* ---------- Bausteine ---------- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; }
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h3 { margin: 16px 0 8px; font-size: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.5; max-width: 820px; }
.detail { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.warn { color: #b45309; }
.error { color: var(--red); min-height: 1.2em; margin: 0; font-size: 13px; }
.ok-text { color: var(--green); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.empty-note { color: var(--muted); padding: 10px 0; }
code { background: #f1f3ee; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.primary, .secondary {
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.primary { background: var(--green); color: #fff; border: 1px solid var(--green); }
.primary:hover { background: var(--green-dark); }
.secondary { background: #fff; color: var(--text); border: 1px solid #cfd5c7; }
.secondary:hover { background: #f3f6ee; }
.danger { color: var(--red); border-color: #f0c4c3; }
.small { padding: 5px 10px !important; font-size: 12px !important; }
.icon-btn { border: 1px solid transparent; background: none; cursor: pointer; padding: 4px 7px; border-radius: 6px; color: var(--muted); font-size: 15px; }
.icon-btn:hover { background: #f1f3ee; color: var(--text); border-color: var(--border); }
.icon-btn:disabled { opacity: .3; cursor: default; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #e8ebe4; color: #374151; white-space: nowrap; }
.badge.live { background: #dcf3d3; color: #1e5b14; }
.badge.info { background: #e0ecff; color: #1e40af; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: #991b1b; }

.settings-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin-bottom: 10px; }
.settings-row label, .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.settings-row input[type="text"], .settings-row input[type="number"], .settings-row select,
.field input, .field select, select.plain, input.plain {
  padding: 8px 10px; border: 1px solid #cfd5c7; border-radius: 8px; background: #fff; color: var(--text);
}
.settings-row input[type="number"] { width: 120px; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 14px !important; color: var(--text) !important; cursor: pointer; }
.segmented { display: inline-flex; border: 1px solid #cfd5c7; border-radius: 8px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.segmented button { border: 0; background: #fff; padding: 7px 13px; cursor: pointer; border-right: 1px solid #e2e6dc; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--green); color: #fff; }

/* ---------- Anmeldung ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20, 30, 15, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 32px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card h2 { margin: 0; text-align: center; }
.login-card input { padding: 11px 12px; border: 1px solid #cfd5c7; border-radius: 8px; font-size: 15px; }
.login-logo { width: 220px; align-self: center; }

/* ---------- Upload ---------- */
.dropzone {
  display: block;
  border: 2px dashed #b9c8a8;
  border-radius: 14px;
  padding: 26px;
  text-align: center;
  background: #f8faf5;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.drag { background: #eef6e4; border-color: var(--green); }
.dropzone strong { display: block; font-size: 16px; color: var(--green); margin-bottom: 4px; }
.upload-options { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin: 14px 0 0; }
.upload-queue { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) 200px 190px auto; gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; }
.upload-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 8px; background: #e8ebe4; border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
.upload-row.done .progress i { background: var(--lime); }
.upload-row.failed .progress i { background: var(--red); }

/* ---------- Mediathek ---------- */
.lib-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 6px 0 14px; }
.lib-tools input[type="search"] { padding: 8px 10px; border: 1px solid #cfd5c7; border-radius: 8px; min-width: 220px; }
.lib-summary { margin-left: auto; color: var(--muted); font-size: 13px; }
.media-list { display: flex; flex-direction: column; gap: 8px; }
.media-row {
  display: grid;
  grid-template-columns: 22px 150px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.media-row.disabled { opacity: .55; }
.media-row.dragging { opacity: .4; }
.media-row.drop-before { box-shadow: 0 -3px 0 var(--green); }
.media-row.drop-after { box-shadow: 0 3px 0 var(--green); }
.drag-handle { cursor: grab; color: #a3ab98; font-size: 18px; text-align: center; user-select: none; }
.media-thumb { position: relative; width: 150px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #1f2328; cursor: pointer; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .dur { position: absolute; right: 5px; bottom: 5px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.media-thumb .ov { position: absolute; right: 5px; top: 5px; width: 42px; filter: drop-shadow(0 0 2px rgba(0,0,0,.6)); }
.media-thumb .spinner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; }
.media-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.media-title { border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; margin-left: -7px; font-size: 15px; font-weight: 600; background: none; width: 100%; }
.media-title:hover, .media-title:focus { border-color: #cfd5c7; background: #fff; }
.media-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--muted); font-size: 12px; }
.media-controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.media-controls select, .media-controls input[type="number"] { padding: 5px 8px; border: 1px solid #cfd5c7; border-radius: 7px; background: #fff; font-size: 13px; }
.media-controls input[type="number"] { width: 70px; }
.media-controls .check { font-size: 13px !important; }
.media-side { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.cat-video { border-left: 5px solid var(--green); }
.cat-logo { border-left: 5px solid var(--lime); }
.cat-image { border-left: 5px solid #3b82f6; }
.cat-season { border-left: 5px solid #dc2626; }

.places { position: relative; }
.places-pop {
  position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 4px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 220px;
}

/* ---------- Saisons ---------- */
.season-list { display: flex; flex-direction: column; gap: 8px; }
.season-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; }
.season-row input[type="text"] { padding: 6px 9px; border: 1px solid #cfd5c7; border-radius: 7px; min-width: 180px; }
.season-row input[type="date"] { padding: 5px 8px; border: 1px solid #cfd5c7; border-radius: 7px; }

/* ---------- Vorschau ---------- */
.preview-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 6px 0 16px; }
.preview-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.preview-controls select, .preview-controls input[type="date"] { padding: 8px 10px; border: 1px solid #cfd5c7; border-radius: 8px; background: #fff; }
.tv-screen { position: relative; width: 100%; max-width: 860px; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; border: 6px solid #1f2328; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.tv-screen iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; background: #000; }
.preview-meta { margin: 12px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.sequence { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.seq-tile { border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; background: #fff; }
.seq-tile:hover { border-color: #a3ab98; }
.seq-tile.active { border-color: var(--green); }
.seq-thumb { position: relative; aspect-ratio: 16 / 9; background: #1f2328; display: flex; align-items: center; justify-content: center; font-size: 30px; overflow: hidden; }
.seq-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.seq-thumb.special { background: linear-gradient(160deg, #005c2f, var(--green)); }
.seq-thumb .ov { position: absolute; right: 4px; bottom: 4px; width: 34px; }
.seq-label { padding: 5px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seq-label .nr { color: var(--muted); margin-right: 4px; }
.seq-tile.cat-video { border-top: 4px solid var(--green); border-left-width: 2px; }
.seq-tile.cat-logo { border-top: 4px solid var(--lime); border-left-width: 2px; }
.seq-tile.cat-image { border-top: 4px solid #3b82f6; border-left-width: 2px; }
.seq-tile.cat-season { border-top: 4px solid #dc2626; border-left-width: 2px; }
.seq-tile.cat-special { border-top: 4px solid #6b7280; border-left-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Bildschirme ---------- */
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.inline-form input[type="text"] { padding: 9px 11px; border: 1px solid #cfd5c7; border-radius: 8px; min-width: 260px; }
.players-list { display: flex; flex-direction: column; gap: 16px; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.player-name { font-size: 17px; font-weight: 600; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; margin-left: -7px; background: none; min-width: 260px; }
.player-name:hover, .player-name:focus { border-color: #cfd5c7; background: #fff; }
.player-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: #d1d5db; display: inline-block; }
.status-dot.online { background: #16a34a; box-shadow: 0 0 0 4px #d1fae5; }
.status-dot.offline { background: #dc2626; }
.live-line { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.player-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
.player-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.player-grid select { padding: 8px 10px; border: 1px solid #cfd5c7; border-radius: 8px; background: #fff; }
.pair-box { background: #fef3c7; border: 1px solid #fcd34d; padding: 8px 14px; border-radius: 10px; }
.pair-code { font-size: 22px; letter-spacing: 3px; font-family: Consolas, monospace; margin: 0 8px; }

/* ---------- Einstellungen ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.overlay-preview { position: relative; width: 100%; max-width: 480px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #2b3a2b center / cover no-repeat; margin-top: 8px; }
.overlay-preview img { position: absolute; }
.rule-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.rule-line input[type="number"] { width: 70px; padding: 6px 8px; border: 1px solid #cfd5c7; border-radius: 7px; }

/* ---------- Video-Vorschau (Dialog) ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-box { position: relative; width: min(1100px, 100%); }
.modal-box video, .modal-box img { width: 100%; max-height: 80vh; background: #000; border-radius: 8px; display: block; object-fit: contain; }
.modal-close { position: absolute; top: -40px; right: 0; background: none; border: 0; color: #fff; font-size: 30px; cursor: pointer; }
.modal-title { color: #fff; margin: 10px 0 0; }

@media (max-width: 760px) {
  .page { padding: 14px; }
  .media-row { grid-template-columns: 110px minmax(0, 1fr); }
  .media-row .drag-handle { display: none; }
  .media-thumb { width: 110px; }
  .media-side { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .upload-row { grid-template-columns: 1fr; }
}
