:root {
  --bg: #0d0f12; --panel: #161a1f; --panel2: #1d2228; --line: #2a3038; --text: #e8ecf1; --muted: #8b95a3;
  --accent: #ffb000; --go: #19b35a; --go-d: #128043; --red: #ff3b3b; --red-bg: #4a1414; --yellow: #ffcc00; --yellow-bg: #463a08;
  --green: #2bd46a; --blue: #3aa0ff; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); height: 100%; }
body { font-size: 15px; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 8px 14px; }
button:hover { border-color: #46505c; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--red); }
button.small { padding: 4px 9px; font-size: 13px; }
input, select, textarea { background: #0b0d10; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #ffb00066; border-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
label { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* top bar */
header.top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #08090b; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
header.top .brand { font-weight: 800; letter-spacing: .5px; }
header.top .brand b { color: var(--accent); }
header.top nav { display: flex; gap: 2px; flex-wrap: wrap; }
header.top nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 7px; }
header.top nav a.on, header.top nav a:hover { color: var(--text); background: var(--panel2); }
header.top .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--panel2); font-size: 13px; border: 1px solid var(--line); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.green { background: var(--green); } .dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); }
.showname { font-weight: 600; }

main { padding: 14px; max-width: 1800px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 12px; } h2 { font-size: 16px; margin: 0 0 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* dashboard grid */
.dash-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.dash-head select { font-size: 16px; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.w1 { grid-column: span 1; } .w2 { grid-column: span 2; } .w3 { grid-column: span 3; } .w4 { grid-column: span 4; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .w3, .w4 { grid-column: span 2; } }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } .w1, .w2, .w3, .w4 { grid-column: span 1; } header.top nav a { padding: 6px 7px; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.card > .title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.card > .title .grow { flex: 1; }

/* caller */
.go { background: var(--go); border-color: var(--go); color: #fff; font-size: 26px; font-weight: 800; padding: 14px 28px; letter-spacing: 2px; border-radius: 12px; }
.go:active { background: var(--go-d); }
.cue-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow: auto; }
.cue { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; background: var(--panel2); border: 1px solid transparent; }
.cue.clickable { cursor: pointer; }
.cue.clickable:hover { border-color: #46505c; }
.cue.done { opacity: .45; }
.cue.current { background: #0f3a22; border-color: var(--go); }
.cue.next { border-color: var(--accent); }
.cue .num { color: var(--muted); font-size: 13px; text-align: right; }
.cue .t { font-weight: 600; }
.cue .n { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cue .meta { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: #2b2410; color: var(--accent); border: 1px solid #5a4710; margin-left: 6px; font-weight: 600; }
.tag.std { background: #2d2f12; color: var(--yellow); }
.now-title { font-size: 30px; font-weight: 800; line-height: 1.15; }
.now-time { font-size: 44px; font-weight: 800; }
.next-list .cue { padding: 7px 10px; }
.label-sm { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

/* timer */
.tdisplay { text-align: center; padding: 6px 0; }
.tdisplay .big { font-size: clamp(48px, 7vw, 96px); font-weight: 800; line-height: 1; }
.tdisplay .lbl { color: var(--muted); margin-top: 4px; min-height: 20px; }
.col-yellow { color: var(--yellow); } .col-red { color: var(--red); } .col-green { color: var(--green); }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.tctl { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.tmsg { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.tmsg input { flex: 1; min-width: 140px; }
.msg-active { margin-top: 8px; padding: 6px 10px; background: #2b2410; border: 1px solid #5a4710; border-radius: 8px; color: var(--accent); }

/* funk */
.funk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.funk-grid.large { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.ftile { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; position: relative; }
.ftile.alarm { background: var(--red-bg); border-color: var(--red); }
.ftile.warn { background: var(--yellow-bg); border-color: var(--yellow); }
.ftile.idle { opacity: .5; }
.ftile .hd { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.ftile .name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.large .ftile .name { font-size: 20px; }
.ftile .sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ftile .alarms { color: #ffd0d0; font-weight: 700; font-size: 13px; margin-top: 4px; min-height: 18px; }
.meter { display: grid; grid-template-columns: 34px 1fr 64px; gap: 6px; align-items: center; font-size: 12px; margin-top: 6px; }
.meter .k { color: var(--muted); }
.meter .v { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: #0b0d10; border-radius: 5px; overflow: hidden; border: 1px solid #262b31; }
.large .bar { height: 14px; }
.bar > i { display: block; height: 100%; background: var(--green); }
.bar > i.y { background: var(--yellow); } .bar > i.r { background: var(--red); } .bar > i.b { background: var(--blue); }

/* ready */
.ampel { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.ampel .lamp { width: 64px; height: 64px; border-radius: 50%; background: #333; flex: none; box-shadow: inset 0 0 0 3px #0006; }
.lamp.green { background: var(--green); box-shadow: 0 0 30px #2bd46a66; } .lamp.yellow { background: var(--yellow); box-shadow: 0 0 30px #ffcc0066; } .lamp.red { background: var(--red); box-shadow: 0 0 30px #ff3b3b66; }
.ampel .state { font-size: 24px; font-weight: 800; }
.checks { display: flex; flex-direction: column; gap: 4px; }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 7px 8px; border-radius: 7px; background: var(--panel2); align-items: start; }
.check.manual { cursor: pointer; }
.check .ic { font-weight: 800; }
.check.ok .ic { color: var(--green); } .check.bad .ic { color: var(--red); } .check.open .ic { color: var(--yellow); }
.check .d { font-size: 12px; color: var(--muted); }

/* log */
.log { font-size: 13px; display: flex; flex-direction: column; gap: 2px; max-height: 40vh; overflow: auto; }
.log div { display: grid; grid-template-columns: 62px 56px 1fr; gap: 6px; padding: 3px 4px; border-radius: 4px; }
.log .alarm { background: var(--red-bg); } .log .warn { background: var(--yellow-bg); }
.log .src { color: var(--muted); }

.clock { font-size: clamp(40px, 6vw, 80px); font-weight: 800; text-align: center; }

/* tables / editor */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
table.ed { width: 100%; border-collapse: collapse; }
table.ed th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); }
table.ed td { padding: 4px; border-bottom: 1px solid #1f242a; vertical-align: top; }
table.ed input, table.ed select { width: 100%; }
table.ed td.nowrap { white-space: nowrap; width: 1%; }
.form { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; align-items: center; max-width: 720px; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form { grid-template-columns: 1fr; } table.ed { font-size: 13px; } }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.chlist { display: grid; grid-template-columns: 40px 1fr 1fr 60px; gap: 6px; align-items: center; margin-top: 8px; }
.raw { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: #050607; border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 340px; overflow: auto; white-space: pre-wrap; }
.wedit { display: grid; grid-template-columns: 1fr; gap: 8px; }
.wrow { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(92vw, 380px); }
.modal input { width: 100%; font-size: 24px; text-align: center; letter-spacing: 6px; margin: 10px 0; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #222830; border: 1px solid var(--line); padding: 10px 16px; border-radius: 9px; z-index: 200; display: none; }
#toast.err { border-color: var(--red); color: #ffd0d0; }
.conn-lost { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; padding: 4px; font-weight: 700; z-index: 300; }
.empty { color: var(--muted); padding: 10px; text-align: center; }
body.fs header.top { display: none; }

/* mobile header */
@media (max-width: 900px) {
  header.top { flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
  header.top nav { order: 5; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  header.top nav a { white-space: nowrap; }
  #pClock, #pShow .muted { display: none; }
}
.clock { overflow: hidden; white-space: nowrap; }
.w1 .clock { font-size: clamp(32px, 4vw, 64px); }
.chlist { grid-template-columns: 40px 1fr 1fr 80px; }
.chlist label.row { flex-wrap: nowrap; }

/* Dokumente */
.doc { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 9px; border-radius: 99px; background: #12263b; color: #9ccfff; border: 1px solid #24476b; margin: 4px 6px 0 0; cursor: pointer; font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc:hover { border-color: var(--blue); }
.doc .x { color: var(--muted); margin-left: 4px; }
.doc-big { display: flex; align-items: center; gap: 10px; padding: 14px; font-size: 18px; border-radius: 10px; background: #12263b; border: 1px solid #24476b; color: #cfe6ff; cursor: pointer; margin-bottom: 6px; font-weight: 600; }
.upl { display: inline-flex; align-items: center; cursor: pointer; border: 1px dashed #46505c; border-radius: 99px; padding: 2px 9px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.upl input { display: none; }
.drop { border: 2px dashed #46505c; border-radius: 12px; padding: 24px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--text); }
.docwrap { display: flex; flex-direction: column; height: calc(100vh - 58px); margin: -14px; }
.doctb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.doctb .sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.doctb button.on { border-color: var(--accent); background: #2b2410; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #0008; padding: 0; }
.swatch.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.docbody { flex: 1; min-height: 0; position: relative; background: #2a2f36; }
.dv-scroll { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.dv-pages { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px; }
.dv-page { position: relative; background: #fff; box-shadow: 0 2px 12px #0008; flex: none; }
.dv-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.dv-num { position: absolute; right: -34px; top: 0; color: #889; font-size: 12px; }
.dv-status { position: absolute; top: 40%; left: 0; right: 0; text-align: center; color: #ccd; display: none; }
.dv-single .dv-scroll { overflow: hidden; display: flex; align-items: center; justify-content: center; }
.dv-single .dv-pages { padding: 0; gap: 0; }
.dv-single .dv-num { display: none; }
@media (max-width: 900px) { .docwrap { height: calc(100vh - 100px); } }
table.ed select[data-attach] { width: auto; max-width: 260px; }
table.ed input[data-f$="|screen"] { width: 170px; }
