:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1f2630;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4ea1ff;
  --ok: #2ea043;
  --warn: #d29922;
  --bad: #f85149;
  --live: #e5534b;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-width: 320px; }
a { color: var(--accent); }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
button, input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 38px; max-width: 100%;
}
button { cursor: pointer; background: #21262d; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
button.danger { color: var(--bad); }
button.small { min-height: 30px; padding: 4px 8px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; vertical-align: middle; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.brand .dot.on { background: var(--live); box-shadow: 0 0 8px var(--live); }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); scrollbar-width: none; }
nav.tabs button { white-space: nowrap; background: transparent; border-color: transparent; }
nav.tabs button.active { background: var(--panel2); border-color: var(--line); color: var(--accent); }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.muted { color: var(--muted); }
.big { font-size: 22px; font-weight: 700; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.row > label { flex: 1 1 140px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); white-space: nowrap; }
.badge.live { background: var(--live); border-color: var(--live); color: #fff; }
.badge.vorlauf { background: var(--warn); border-color: var(--warn); color: #111; }
.badge.vor { color: var(--muted); }
.badge.nach { color: var(--muted); text-decoration: line-through; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.abgelehnt { color: var(--bad); border-color: var(--bad); }
.badge.getrennt { color: var(--warn); border-color: var(--warn); }
.badge.notfall { color: var(--bad); border-color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
td.actions { white-space: nowrap; text-align: right; }

.signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.sig { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.sig i { width: 9px; height: 9px; border-radius: 50%; background: #484f58; flex: none; }
.sig.on i { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

.key { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; }
.list-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--panel2); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.list-item .info { min-width: 0; flex: 1 1 180px; }

pre.log { background: #010409; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; max-height: 220px; margin: 8px 0 0; }

#toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: calc(100% - 32px); z-index: 50; display: flex; flex-direction: column; gap: 6px; }
#toast div { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px #0008; }
#toast div.err { border-left-color: var(--bad); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(760px, calc(100% - 20px)); max-height: calc(100% - 20px); }
dialog::backdrop { background: #000a; }
dialog .head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
dialog .body { padding: 14px; }
.copyrow { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.copyrow input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.copyrow span { width: 74px; flex: none; font-size: 12px; color: var(--muted); }

.login { max-width: 360px; margin: 12vh auto; }
.hidden { display: none !important; }

@media (max-width: 500px) {
  main { padding: 10px; }
  header.top { padding: 8px 10px; }
  nav.tabs { padding: 6px 10px; }
  .copyrow span { width: 54px; }
  th, td { padding: 6px 4px; }
}

button.copied { background: var(--ok); border-color: var(--ok); color: #fff; }
.copyrow button { min-width: 92px; }
