:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #243349;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --border: #334155;
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
.loading { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Auth */
.auth-screen {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 8px;
}
.auth-screen h1 { margin: 4px 0; font-size: 1.6rem; }
.auth-screen .muted { max-width: 320px; }
.pulse { color: var(--green); font-size: 2.4rem; letter-spacing: -4px; }
.code-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; width: 100%; max-width: 280px; }
.code-form input {
  font-size: 1.6rem; text-align: center; letter-spacing: 0.5rem;
  padding: 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text);
}
.code-form button, .ghost {
  cursor: pointer; border: none; border-radius: 12px;
}
.code-form button {
  padding: 14px; font-size: 1rem; font-weight: 600;
  background: var(--green); color: #052e16;
}
.err { color: var(--red); min-height: 1.2em; margin: 0; font-size: 0.9rem; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(15, 23, 42, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.actions { display: flex; gap: 6px; }
.ghost {
  background: var(--panel); color: var(--text);
  font-size: 1.1rem; padding: 8px 12px; line-height: 1;
}
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.up { background: var(--green); }
.dot.down { background: var(--red); }
.dot.warn { background: var(--amber); }

main { padding: 16px; max-width: 760px; margin: 0 auto; }
section { margin-bottom: 22px; }
h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 10px; }

.grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 520px) { .grid { grid-template-columns: 1fr 1fr; } }

/* Toolbar met view/filter-schakelaars */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 12px; font-size: 0.82rem; cursor: pointer; line-height: 1;
}
.seg button.active { background: var(--green); color: #052e16; font-weight: 600; }
#seg-view button { font-size: 1rem; padding: 8px 14px; }

.allclear {
  text-align: center; padding: 28px 16px; font-size: 1.1rem; font-weight: 600;
  color: var(--green); background: var(--panel); border: 1px solid rgba(34,197,94,.4);
  border-radius: 14px; margin-bottom: 16px;
}

/* Tegel-weergave: zo veel mogelijk op één scherm */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.tile {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); padding: 7px 8px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
}
.tile .thead { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 18px; }
.tile .ticon { width: 20px; height: 20px; border-radius: 5px; object-fit: contain; flex: 0 0 auto; }
.tile .tn { font-size: 0.64rem; font-weight: 600; line-height: 1.15; word-break: break-word; }
.tile .tv { font-size: 0.62rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .dot { width: 9px; height: 9px; flex: 0 0 auto; }
.tile.up { border-color: rgba(34,197,94,.35); }
.tile.bad { border-color: var(--red); background: #2a1518; }
.tile.warnc { border-color: var(--amber); background: #2a2113; }

/* App-icoon in een regel (list item / media object) */
.card .cicon { width: 30px; height: 30px; border-radius: 7px; object-fit: contain; flex: 0 0 auto; background: var(--panel-2); }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; display: flex; align-items: center; gap: 10px;
}
.card .meta { flex: 1; min-width: 0; }
.card .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: 0.8rem; color: var(--muted); }
.card .right { text-align: right; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.card.bad { border-color: var(--red); background: #2a1518; }
.card.warnc { border-color: var(--amber); background: #2a2113; }

.incident, .report, .hist {
  background: var(--panel); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.incident.critical, .report.fatal { border-left-color: var(--red); }
.incident.warn, .report.error, .report.warn { border-left-color: var(--amber); }
.incident .t, .report .t, .hist .t { font-weight: 600; }
.incident .m, .report .m, .hist .m { font-size: 0.85rem; color: var(--muted); margin-top: 2px; word-break: break-word; }
.incident .ts, .report .ts, .hist .ts { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.report pre { font-size: 0.7rem; color: var(--muted); white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; max-height: 80px; overflow: auto; }
.hist.resolved { opacity: 0.6; border-left-color: var(--green); }

.hint {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 0.85rem; color: var(--muted); margin: 0 0 16px;
}
.footer { text-align: center; font-size: 0.75rem; margin-top: 20px; }
