:root {
  --bg: #f4f6f9; --panel: #fff; --text: #1b2430; --muted: #6b7686; --line: #e1e6ee;
  --primary: #2563eb; --primary-d: #1d4ed8; --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #111827; color: #d1d5db; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; padding: .4rem .6rem 1rem; }
.sidebar a.nav { color: inherit; text-decoration: none; padding: .55rem .7rem; border-radius: 8px; display: block; }
.sidebar a.nav:hover { background: #1f2937; }
.sidebar a.nav.active { background: var(--primary); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .who { padding: .5rem .7rem; font-size: .85rem; color: #9ca3af; }
.main { flex: 1; padding: 1.5rem 2rem 3rem; min-width: 0; max-width: 1200px; }
@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: .3rem .6rem; }
  .sidebar .spacer { display: none; }
  .main { padding: 1rem; }
}

/* Bausteine */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; }
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: .45rem .85rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: #f1f4f9; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-d); }
button.danger { color: var(--danger); border-color: #f3c1c1; }
button.danger:hover { background: #fdf1f1; }
button.small { padding: .25rem .55rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid #cfd6e2; border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 2.1rem; width: 3.2rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3ff; border-color: var(--primary); }
label.field { display: block; margin-bottom: .8rem; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row.auto > * { flex: 0 0 auto; min-width: 0; }
.check { display: flex; align-items: center; gap: .45rem; margin-bottom: .4rem; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: .25rem; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; background: #eef1f6; color: #3b4658; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: #9ca3af; margin-right: .4rem; }
.dot.ok { background: var(--ok); } .dot.off { background: var(--danger); }
.empty { text-align: center; padding: 2rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.display-card h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.display-card .meta { color: var(--muted); font-size: .85rem; }

/* Medien */
.dropzone { border: 2px dashed #b9c4d6; border-radius: var(--radius); padding: 1.4rem; text-align: center; color: var(--muted); background: #fafcff; margin-bottom: 1rem; }
.dropzone.over { border-color: var(--primary); background: #eef4ff; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.media-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-item .thumb { aspect-ratio: 16/10; background: #0b1220; display: flex; align-items: center; justify-content: center; position: relative; }
.media-item .thumb img, .media-item .thumb video { width: 100%; height: 100%; object-fit: contain; }
.media-item .thumb .tag { position: absolute; left: 6px; top: 6px; }
.media-item .info { padding: .5rem .65rem; font-size: .85rem; }
.media-item .info .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .acts { padding: 0 .65rem .6rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.media-item.pick { cursor: pointer; }
.media-item.pick:hover { outline: 2px solid var(--primary); }
.progress { height: 6px; background: #e5eaf2; border-radius: 3px; overflow: hidden; margin-top: .5rem; }
.progress > div { height: 100%; background: var(--primary); width: 0; }

/* Timeline-Editor */
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { border: 1px solid #cfd6e2; border-radius: 999px; padding: .25rem .7rem; cursor: pointer; user-select: none; background: #fff; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.layout-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.layout-opt { border: 2px solid var(--line); border-radius: 8px; padding: .5rem; cursor: pointer; background: #fff; }
.layout-opt.on { border-color: var(--primary); background: #f3f7ff; }
.layout-opt .prev { display: grid; gap: 2px; height: 56px; margin-bottom: .35rem; }
.layout-opt .prev div { background: #c7d2e3; border-radius: 2px; display: flex; align-items: center; justify-content: center; font-size: .6rem; color: #475569; overflow: hidden; min-width: 0; }
.zone-box { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; background: #fcfdff; }
.zone-box > header { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); background: #f3f6fb; border-radius: 8px 8px 0 0; flex-wrap: wrap; }
.zone-box > header h3 { margin: 0; font-size: 1rem; flex: 1; }
.item { display: flex; gap: .8rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); align-items: flex-start; flex-wrap: wrap; }
.item:last-child { border-bottom: 0; }
.item .nr { width: 1.6rem; height: 1.6rem; background: #e5eaf2; border-radius: 50%; text-align: center; line-height: 1.6rem; font-size: .8rem; flex: none; }
.item .thumb { width: 96px; height: 60px; background: #0b1220; border-radius: 6px; overflow: hidden; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .75rem; text-align: center; }
.item .thumb img, .item .thumb video { width: 100%; height: 100%; object-fit: contain; }
.item .body { flex: 1; min-width: 220px; }
.item .opts { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .35rem; }
.item .opts label { display: flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); }
.item .opts input[type=number] { width: 5.5rem; } .item .opts select { width: auto; }
.item .opts input[type=text], .item textarea { width: 100%; }
.item .side { display: flex; gap: .25rem; }
.sticky-bar { position: sticky; bottom: 0; background: rgba(244,246,249,.95); padding: .75rem 0; border-top: 1px solid var(--line); display: flex; gap: .6rem; margin-top: 1rem; z-index: 5; }

/* Modal & Toast */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; padding: 1.2rem 1.3rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 900px; }
.modal h2 { margin-top: 0; }
.modal .foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: #111827; color: #fff; padding: .6rem .9rem; border-radius: 8px; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: #b91c1c; }
.preview-frame { width: 100%; aspect-ratio: 16/9; border: 0; background: #000; border-radius: 8px; }
.url-box { display: flex; gap: .4rem; }
.url-box input { font-family: ui-monospace, monospace; font-size: .85rem; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { text-align: center; }
.error { color: var(--danger); margin: .4rem 0; min-height: 1.2em; }

/* Live-Ansicht */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; align-items: start; }
.live { position: relative; width: 100%; background: #000; border-radius: 8px; overflow: hidden; cursor: zoom-in; margin: .6rem 0; }
.live iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; pointer-events: none; background: #000; }
.live.portrait { max-width: 200px; margin-left: auto; margin-right: auto; }
.seg { display: inline-flex; border: 1px solid #cfd6e2; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: #fff; }
.seg button.on { background: var(--primary); color: #fff; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { max-width: 260px; }
.ig-thumb { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff;
            background: linear-gradient(135deg, #5851db, #c13584 55%, #fcaf45); text-align: center; padding: .4rem; }
.ig-thumb strong { font-size: 1.3rem; }
.badge.ig { background: #fce7f3; color: #9d174d; }

/* Kalender */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head { background: #fafbfd; padding: .4rem .5rem; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.cal-cell { background: #fff; min-height: 104px; padding: .3rem .4rem; cursor: pointer; min-width: 0; }
.cal-cell:hover { background: #f3f7ff; }
.cal-cell.other { background: #f7f8fb; color: #9aa5b5; }
.cal-cell.today .cal-num { background: var(--primary); color: #fff; border-radius: 999px; }
.cal-num { display: inline-block; min-width: 1.5rem; text-align: center; font-size: .85rem; font-weight: 600; margin-bottom: .2rem; }
.cal-ev { display: flex; align-items: center; gap: .3rem; background: #eef3ff; border-radius: 6px; padding: 2px 4px; margin-bottom: 3px; font-size: .78rem; cursor: pointer; min-width: 0; }
.cal-ev:hover { background: #dbe7ff; }
.cal-ev img, .cal-ev .pv { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; flex: none; text-align: center; line-height: 22px; background: #cbd5e1; }
.cal-ev .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 800px) { .cal-cell { min-height: 70px; } .cal-ev .tt { display: none; } }
