:root {
  --bg: #001935;
  --bg-elev: #072544;
  --bg-elev2: #0d3157;
  --border: #1c3f63;
  --text: #e8eef6;
  --muted: #8ea3bd;
  --accent: #95c11f;
  --accent-2: #4a9eff;
  --danger: #ff6b6b;
  --warn: #e0b341;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 80% -10%, #073061 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,25,53,.72);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { width: 40px; height: 40px; display: block; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.brand .sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev);
  white-space: nowrap;
}
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status--on  { color: #c3df8a; border-color: #4d6a15; background: rgba(149,193,31,.12); }
.status--on  .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(149,193,31,.20); }
.status--off .dot { background: var(--warn); }
.status--err { color: #ffb3ae; border-color: #6b2320; background: #2a1513; }
.status--err .dot { background: var(--danger); }

main { max-width: 1180px; margin: 0 auto; padding: 26px 24px 60px; }

.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 26px 0 14px; font-weight: 700; }
.section-head { margin-top: 26px; }
.section-head .section-title { margin-bottom: 4px; }
.areas-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.areas-head .section-title { margin: 26px 0 0; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; cursor: pointer; padding: 6px; line-height: 0;
  transition: color .15s, border-color .15s, background .15s;
}
.iconbtn:hover { color: var(--danger); border-color: var(--danger); background: rgba(229,83,75,.12); }
.iconbtn--trash { width: 34px; height: 34px; flex: none; }

.area-right { display: inline-flex; align-items: center; gap: 10px; }
.area-del {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 0 2px; border-radius: 6px;
}
.area-del:hover { color: var(--danger); }
.muted { color: var(--muted); font-weight: 500; }
code { font-family: var(--mono); font-size: .9em; background: var(--bg-elev2); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); }

.tiles { display: flex; flex-wrap: nowrap; gap: 12px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -ms-overflow-style: none; }
.tiles::-webkit-scrollbar { display: none; }
.tile {
  flex: 1 1 auto; min-width: 0;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.tile-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.area {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.area-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elev2), var(--bg-elev));
}
.area-name { font-weight: 650; font-family: var(--mono); font-size: 14px; word-break: break-all; }
.area-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.area-body { padding: 6px 4px 8px; }

/* Eine Zeile pro Knoten: Schlüssel (mit Einrückung nach Tiefe) | Wert | Zeit */
.node {
  display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px;
  align-items: baseline; padding: 5px 8px;
  padding-left: calc(8px + var(--d, 0) * 15px);
  border-radius: 6px;
}
.node:hover { background: var(--bg-elev2); }
.node.flash { animation: flash .8s ease-out; }
@keyframes flash { from { background: rgba(149,193,31,.22); } to { background: transparent; } }
.node .k { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.node.group { cursor: pointer; user-select: none; }
.node.group > .k { color: var(--muted); font-weight: 600; }
.node.group > .k::before { content: "\25B8"; display: inline-block; width: 1.1em; color: var(--muted); }
.node.group.open > .k::before { content: "\25BE"; }
.node.group:hover > .k { color: var(--text); }
.node.leaf > .k { color: var(--text); }
.node .v {
  font-family: var(--mono); font-size: 13px; text-align: right;
  max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.node .v.num { color: #79c0ff; }
.node .v.str { color: #a6e3c1; }
.node .t { font-size: 11px; color: var(--muted); white-space: nowrap; }

.empty { color: var(--muted); font-size: 14px; padding: 20px 4px; }
.empty.hidden, .areas:empty + .empty { }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; border-top: 1px solid var(--border); }
footer #foot-broker { font-family: var(--mono); }

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  main { padding: 18px 14px 48px; }
  /* Auf dem Handy Tiles nicht quetschen -> horizontal scrollen (Leiste bleibt ausgeblendet) */
  .tile { flex: 0 0 auto; min-width: 140px; }
}
