:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; }
code, .mono { font-family: ui-monospace, Consolas, monospace; }

/* ---------- Buttons & Formulare ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 4px 8px; color: inherit; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=color] { padding: 2px; height: 36px; width: 60px; }
input[type=checkbox] { width: 16px; height: 16px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { flex-direction: row; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-weight: 400; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 20% 10%, #1e3a5f, #0b1220 70%); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 28px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card .logo { color: var(--text); }
.auth-card .btn { justify-content: center; padding: 10px; }

.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.logo-mark { width: 26px; height: 18px; border-radius: 4px; background: var(--primary); box-shadow: inset 0 0 0 3px #93c5fd; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100%; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); display: flex;
  flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { color: #fff; padding: 0 8px 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav .nav-sep { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .5; }
.sidebar-foot { font-size: 12px; padding: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.spacer { flex: 1; }
.menu-toggle { display: none; }
.tenant-switch { display: flex; align-items: center; gap: 8px; }
.tenant-switch select { min-width: 220px; }
.tenant-label { font-weight: 600; }
.user-menu { position: relative; }
.user-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 14px; cursor: pointer; font: inherit; }
.user-btn small { color: var(--muted); margin-left: 6px; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; padding: 6px; z-index: 20; }
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; font: inherit; cursor: pointer; }
.dropdown button:hover { background: var(--surface-2); }

#banner:empty { display: none; }
.banner { margin: 16px 24px 0; padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: #92400e; }
.banner.danger { background: var(--danger-soft); color: #991b1b; }
.banner.info { background: #fdf0e6; color: #7c3a12; }

.view { padding: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { flex: 1; }

/* ---------- Karten / Kennzahlen ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 18px; }
.card + .card { margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--primary); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 4px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: #166534; border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: #92400e; border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: #991b1b; border-color: transparent; }
.badge.info { background: var(--primary-soft); color: #1e40af; border-color: transparent; }
.badge.frame { background: #fdf0e6; color: #9a4a1c; border-color: transparent; }
.cap-input { margin-top: 5px; width: 100%; padding: 4px 8px; font-size: 13px; }
.caption-meta { font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Medien ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-card { overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 16 / 9; background: #0f172a; display: flex; align-items: center; justify-content: center; position: relative; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: contain; }
.media-thumb .type { position: absolute; left: 8px; top: 8px; }
.media-info { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.media-info .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-info .meta { font-size: 12px; color: var(--muted); }
.media-actions { display: flex; gap: 4px; padding: 0 12px 12px; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted);
  margin-bottom: 18px; background: var(--surface); cursor: pointer; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.upload-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.upload-item { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.upload-item .bar { flex: 1; margin: 0; }

/* ---------- Playlist-Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.items { display: flex; flex-direction: column; gap: 8px; padding: 14px; min-height: 120px; }
.item { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.item.dragging { opacity: .4; }
.item .handle { cursor: grab; color: var(--muted); font-size: 18px; padding: 0 4px; user-select: none; }
.item .thumb { width: 96px; height: 54px; border-radius: 4px; background: #0f172a; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; text-align: center; padding: 2px; }
.item .thumb img, .item .thumb video { width: 100%; height: 100%; object-fit: cover; }
.item .grow { flex: 1; min-width: 0; }
.item .grow .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item input[type=number] { width: 80px; }
.picker { max-height: 60vh; overflow-y: auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px; }
.picker button { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 0; cursor: pointer; overflow: hidden; text-align: left; font: inherit; }
.picker button:hover { border-color: var(--primary); }
.picker .thumb { aspect-ratio: 16/9; background: #0f172a; }
.picker .thumb img, .picker .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker .cap { font-size: 12px; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--text); }
dialog::backdrop { background: rgba(15, 23, 42, .5); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 64px); }
.modal-head { padding: 18px 20px 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.error { background: var(--danger); }

/* ---------- Mobil ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; }
  .menu-toggle { display: block; }
  .topbar { padding: 10px 16px; }
  .view { padding: 16px; }
  .banner { margin: 12px 16px 0; }
  .editor { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .tenant-switch select { min-width: 0; max-width: 46vw; }
  .user-btn small { display: none; }
}

/* =====================================================================
 * Version 0.2: Player-Details, Gruppen, Layouts, Widgets, Lizenzen, 2FA
 * ===================================================================== */
.small { font-size: 12px; }
.intro { margin: -8px 0 16px; max-width: 900px; }
.steps { margin: 10px 0 0; padding-left: 20px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.inline-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-row > input:not([type=number]):not([type=color]), .inline-row > select { flex: 1; min-width: 140px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; white-space: nowrap; }
label.inline input[type=number] { width: 80px; }
.color-pair { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.check-col { display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; margin-top: 8px; }
.field-label { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.form-grid.three { grid-template-columns: 2fr 1fr auto; }
.otp-input { font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: .2em; text-align: center; }
.copy-line { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; overflow-x: auto; }
.copy-line code { flex: 1; white-space: nowrap; font-size: 13px; }

/* Player */
.shot-thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 4px; background: #0f172a; display: block; cursor: pointer; }
.empty-thumb { display: flex; align-items: center; justify-content: center; color: #64748b; }
.details { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.shot-big { aspect-ratio: 16 / 9; background: #0f172a; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.shot-big img { width: 100%; height: 100%; object-fit: contain; }
.shot-big .empty { color: #94a3b8; }
table.kv th { background: none; text-transform: none; letter-spacing: 0; font-size: 12px; width: 38%; padding: 6px 8px; vertical-align: top; }
table.kv td { padding: 6px 8px; font-size: 13px; word-break: break-word; }

/* Medien / Playlist-Editor */
.pdf-thumb { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-weight: 800;
  letter-spacing: .1em; color: #fff; background: linear-gradient(135deg, #b91c1c, #7f1d1d); font-size: 18px; }
.upload-item .fname { width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.widget-thumb { font-size: 26px; }
.fit-select { padding: 4px 6px; font-size: 12px; }
.text-preview { aspect-ratio: 16 / 9; border-radius: 8px; display: flex; flex-direction: column; justify-content: center;
  padding: 4%; gap: 2%; white-space: pre-wrap; overflow: hidden; }
.geo { margin: 2px; }

/* Vorschau */
.preview-box { aspect-ratio: 16 / 9; width: 100%; background: #000; border-radius: 8px; overflow: hidden; }
.preview-box.portrait { aspect-ratio: 9 / 16; width: auto; height: min(70vh, 900px); margin: 0 auto; }
.preview-box iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Layouts */
.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.layout-card { overflow: hidden; display: flex; flex-direction: column; }
.layout-mini { display: block; position: relative; aspect-ratio: 16 / 9; margin: 10px 10px 0; border-radius: 6px; overflow: hidden; }
.layout-mini.portrait { aspect-ratio: 9 / 16; height: 160px; margin: 10px auto 0; }
.layout-mini span { position: absolute; border: 2px solid rgba(255,255,255,.85); opacity: .85; }
.layout-editor { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.layout-canvas { position: relative; aspect-ratio: 16 / 9; width: 100%; border-radius: 8px; overflow: hidden; user-select: none; touch-action: none; }
.layout-canvas.portrait { aspect-ratio: 9 / 16; width: auto; height: min(70vh, 720px); margin: 0 auto; }
.zone-box { position: absolute; border: 2px solid; display: flex; align-items: center; justify-content: center; cursor: move;
  color: #fff; text-align: center; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.zone-box.sel { outline: 3px solid #fff; outline-offset: -5px; z-index: 2; }
.zone-label { pointer-events: none; padding: 4px; line-height: 1.3; }
.zone-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #fff 50%); }
.zone-row { display: flex; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.zone-row.sel { background: var(--primary-soft); }
.zone-swatch { width: 10px; border-radius: 3px; flex-shrink: 0; }
.zone-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.zone-fields .nums input[type=number] { width: 70px; }

/* Lizenzen */
.lic-table { max-height: 45vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.lic-table th, .lic-table td { padding: 6px 10px; }
.lic-bulk { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.lic-add { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.lic-add .inline-row { margin-top: 8px; }

/* 2FA */
.qr-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr svg { width: 180px; height: 180px; display: block; background: #fff; border-radius: 8px; }
.secret { display: inline-block; font-size: 15px; margin-top: 4px; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 18px; margin: 8px 0; }
.codes code { font-size: 15px; background: var(--surface-2); padding: 3px 8px; border-radius: 4px; }

@media (max-width: 900px) {
  .details, .layout-editor, .form-grid.three { grid-template-columns: 1fr; }
}
