:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --fg: #e6e6e6;
  --muted: #8a939e;
  --accent: #6ee7b7;
  --warn: #f59e0b;
  --crit: #ef4444;
  --line: #1f2933;
  --row: #131820;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: ui-sans-serif, system-ui, sans-serif; background: var(--bg); color: var(--fg); }
.shell { max-width: 1100px; margin: 0 auto; padding: 12px 20px; }
header.shell { padding-top: 28px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
header.shell h1 { margin: 0; font-size: 20px; letter-spacing: 0.5px; }
header.shell h1 a { color: var(--fg); text-decoration: none; }
header.shell p { margin: 4px 0 0; }
header.shell h1 .site-name { font-size: 13px; font-weight: 400; letter-spacing: 0; }
.topnav { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.topnav a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--muted); font-size: 13px; }
.topnav a:hover { border-color: var(--accent); color: var(--accent); }
.topnav a.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.muted { color: var(--muted); }
footer.shell { padding: 24px 20px; border-top: 1px solid var(--line); margin-top: 32px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
tr:hover td { background: var(--row); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.pill.ok { background: rgba(110, 231, 183, 0.16); color: var(--accent); }
.pill.warn { background: rgba(245, 158, 11, 0.16); color: var(--warn); }
.pill.crit { background: rgba(239, 68, 68, 0.16); color: var(--crit); }
.pill.stale { background: rgba(138, 147, 158, 0.2); color: var(--muted); }
.card { background: var(--row); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 16px 0; }
h2 { margin: 24px 0 8px; font-size: 16px; }
a { color: var(--accent); }
.chart-wrap { height: 280px; position: relative; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.controls { display: flex; gap: 8px; margin-bottom: 12px; }
.controls a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; }
.controls a.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.link-card { display: block; text-decoration: none; color: var(--fg); }
.link-card:hover { border-color: var(--accent); }

.searchbar { display: flex; gap: 8px; margin: 12px 0; }
.searchbar input[type=text] { flex: 1; max-width: 360px; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 6px 10px; }
.searchbar button { background: transparent; border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.searchbar button:hover { border-color: var(--accent); color: var(--accent); }
table.kv { width: auto; }
table.kv th { width: 130px; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; vertical-align: top; }
.devices td:first-child { font-weight: 500; }
.devices td .mono { font-weight: 400; }
.topo-wrap { margin: 16px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.topo-wrap svg { display: block; }
.util-bar { display: inline-block; width: 160px; height: 8px; background: var(--row); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.util-fill { height: 100%; }
.util-fill.ok { background: var(--accent); }
.util-fill.warn { background: var(--warn); }
.util-fill.crit { background: var(--crit); }
details.listing { margin: 16px 0; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; }
details.listing > summary { cursor: pointer; padding: 12px 2px; font-weight: 500; list-style: none; }
details.listing > summary::-webkit-details-marker { display: none; }
details.listing > summary::before { content: "\25B8 "; color: var(--muted); }
details.listing[open] > summary::before { content: "\25BE "; }
details.listing[open] > summary { border-bottom: 1px solid var(--line); }
details.listing table { margin-bottom: 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.ap-fleet td:first-child { font-weight: 500; }
.ap-fleet .ap-clients-row td { padding: 0; border-bottom: none; }
.ap-clients-slot { padding: 0 10px; }
.ap-clients-slot:empty { display: none; }
.ap-clients-slot table.ap-clients { margin: 6px 0 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.ap-clients-slot table.ap-clients th { font-size: 11px; }
.ap-clients-slot table.ap-clients td { font-size: 13px; }

.expand-clients,
.expand-all,
.collapse-all {
  background: transparent; border: 1px solid var(--line); color: var(--fg);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.expand-clients:hover,
.expand-all:hover,
.collapse-all:hover { border-color: var(--accent); color: var(--accent); }

/* Loading-indicator: swap inner labels on htmx-request state */
.expand-clients .when-idle    { display: inline; }
.expand-clients .when-loading { display: none; }
.expand-clients.htmx-request .when-idle    { display: none; }
.expand-clients.htmx-request .when-loading { display: inline; }
.expand-clients.htmx-request { border-color: var(--accent); color: var(--accent); }

/* Optional: skeleton placeholder once a slot is loading. HTMX adds
   htmx-request to the *triggering element*; we mirror the visual cue
   by dimming the slot while it's being filled. */
.ap-clients-slot:has(table) { animation: none; }
