/* The vocabulary every admin page shares. Pages keep an inline <style>
   only for what they genuinely do differently; anything that appeared in
   more than one page lives here. Served as a static asset off
   /assets/admin.css, content-hashed for cache-busting. */

/* Palette and page frame */
:root { color-scheme: light; --bg: #f4f6fb; --panel: #ffffff; --border: #d9e0ef; --text: #152033; --muted: #5f6b82; --accent: #3657d6; --good: #1c7c54; --danger: #b42318; }
body { margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: linear-gradient(180deg, #eef3ff 0%, var(--bg) 100%); color: var(--text); }
main { max-width: 1280px; margin: 0 auto; padding: 40px 24px 56px; }
header { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 28px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 34px; letter-spacing: -0.03em; }
h2 { margin: 0 0 12px; font-size: 18px; }
.subtitle { margin-top: 8px; color: var(--muted); font-size: 15px; }
.shell { display: grid; gap: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 18px; box-shadow: 0 8px 32px rgba(21, 32, 51, 0.06); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
code { background: #f3f6ff; padding: 2px 6px; border-radius: 8px; }
.muted { color: var(--muted); }
.meta { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 8px 0; }

/* Stat tiles. auto-fit already lands four tiles on one row at desktop
   width and wraps them gracefully below it, so no page needs a fixed
   column count. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: #f8faff; border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.stat .value { display: block; font-size: 22px; font-weight: 650; }
.stat .label { color: var(--muted); font-size: 12px; }

/* Range chips */
.range-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; background: #f8faff; color: var(--muted); cursor: pointer; text-decoration: none; }
.chip.chip-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Severity badges. The edge-group and fleet-version pages keep their own
   .badge variants; those override this one from the page's <style>. */
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #e8f4ef; color: var(--good); font-size: 12px; font-weight: 600; }
.severity-low { background: #e8f4ef; color: #1c7c54; }
.severity-medium { background: #fef3cd; color: #92400e; }
.severity-high { background: #fee2e2; color: #991b1b; }

/* Connection status pills and the transport-differential row that lays
   them out. Without this the pills collapse into an unspaced run of words. */
.conn-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.conn-good { background: #e8f4ef; color: #1c7c54; }
.conn-warn { background: #fef3cd; color: #92400e; }
.conn-bad { background: #fee2e2; color: #991b1b; }
.conn-none { background: #f1f5f9; color: var(--muted); }
.transport-diff { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 5px; font-size: 12px; }

/* "Attention" card banding */
.attention { border-left: 5px solid var(--border); }
.attention h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.attention-alert { border-left-color: var(--danger); background: #fef2f2; }
.attention-alert h2, .attention-alert > div > h2 { color: var(--danger); }
.attention-warn { border-left-color: #f0b429; background: #fffdf3; }
.attention-calm { border-left-color: var(--good); }

/* Agent liveness dots */
.status-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-online { background: #1c7c54; }
.dot-stale { background: #b45309; }
.dot-offline { background: #dc2626; }
.dot-never { background: transparent; border: 2px solid #9ca3af; }

/* Open-findings banner */
.findings-banner { background: #fef2f2; border: 1px solid #fecaca; border-radius: 18px; padding: 18px; }
.findings-banner h2 { margin: 0 0 10px; font-size: 18px; color: var(--danger); }
.findings-banner table { width: 100%; border-collapse: collapse; }
.findings-banner th, .findings-banner td { border-bottom: 1px solid #fecaca; }

/* Health / link-quality strips */
.hg-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hg-label { flex: 0 0 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.hg-label-child { padding-left: 18px; color: var(--muted); }
.hg-kids .hg-cell { height: 14px; }
.hg-twisty { all: unset; cursor: pointer; color: var(--muted); font-size: 11px; padding: 0 4px 0 0; }
.hg-twisty[aria-expanded="true"] { transform: rotate(90deg); display: inline-block; }
.hg-strip { display: flex; gap: 2px; flex: 1; min-width: 0; position: relative; z-index: 1; }
.hg-cell { flex: 1; height: 22px; border-radius: 2px; min-width: 2px; }
.hg-strip-wrap { position: relative; flex: 1; min-width: 0; }
.hg-band { position: absolute; top: -3px; bottom: -3px; border-radius: 3px; opacity: 0.30; pointer-events: none; z-index: 0; }
.hg-band-finding { opacity: 0.5; outline: 1px dashed rgba(20,32,51,0.6); outline-offset: -1px; }
.hg-healthy { background: #2da160; }
.hg-degraded, .hg-degraded_latency, .hg-degraded_loss { background: #f0b429; }
.hg-dns_issue { background: #38bdf8; }
.hg-restricted { background: #ef4444; }
.hg-severe, .hg-severe_latency, .hg-severe_loss { background: #991b1b; }
.hg-none { background: #e9edf5; }
.lq-solid { background: #2da160; }
.lq-fair { background: #a3c245; }
.lq-lossy { background: #f0b429; }
.lq-poor { background: #ef4444; }
.lq-none { background: #e9edf5; }
.hg-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); align-items: center; }
.hg-legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Definition tiles and stacks */
.definition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.definition { background: #f8faff; border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.definition .label { color: var(--muted); font-size: 12px; }
.definition .value { display: block; margin-top: 4px; font-weight: 650; }
.stack { display: grid; gap: 8px; }

/* Filter bar */
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-top: 12px; }
.filters label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.filters select { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: #f8faff; color: var(--text); font: inherit; min-width: 160px; }
.filters button { border: 0; border-radius: 10px; padding: 9px 14px; background: var(--accent); color: #fff; font: inherit; cursor: pointer; }

/* A fix offered inline in prose, sized to sit on the same line as it */
.inline-action { border: 1px solid var(--border); border-radius: 8px; padding: 1px 8px; background: #f8faff; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; }
.inline-action:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.inline-action.htmx-request { opacity: 0.5; pointer-events: none; }

/* Interactive latency chart (/webapp/latencychart.js builds the controls) */
.latency-chart { margin-top: 8px; }
.lc-controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.lc-controls label { display: inline-flex; gap: 5px; align-items: center; }
.lc-controls select { border: 1px solid var(--border); border-radius: 8px; padding: 2px 6px; background: #f8faff; color: var(--text); font: inherit; font-size: 12px; }
.lc-status { margin-left: auto; }
.lc-plot { width: 100%; }

/* Tap-to-inspect tooltips */
.tip-btn { all: unset; display: inline-flex; align-items: center; cursor: pointer; vertical-align: middle; }
.tip-wrap-btn { all: unset; cursor: pointer; }
.tip-icon { color: var(--muted); font-size: 11px; line-height: 1; margin-left: 3px; }
[popover].tip-body { position: fixed; margin: 0; background: #1e293b; color: #f8fafc; padding: 7px 11px; border-radius: 9px; border: none; font-size: 12px; font-weight: normal; font-family: inherit; text-transform: none; letter-spacing: normal; width: max-content; max-width: 280px; white-space: normal; box-shadow: 0 4px 16px rgba(0,0,0,0.18); line-height: 1.5; }

/* Phone. Last, so a page's own h1 size still wins over it — that was true
   when this lived at the end of the inlined base sheet and pages append
   after it. */
@media (max-width: 640px) {
  main { padding: 16px 8px 32px; }
  h1 { font-size: 24px; }
  /* A wide table used to widen the whole document, because main is a grid
     and a grid item won't shrink below its content. Everything else on the
     page then stretched to that width — including the strips, which ran off
     the right edge. Scrolling the table inside its own box keeps the page
     the width of the screen. */
  main > * { min-width: 0; }
  table { display: block; overflow-x: auto; }
  /* 96 slots at a 2px floor need 382px before the card's padding, which is
     already past a phone. The cells stay legible at 1px of separation. */
  .hg-strip { gap: 1px; }
  .hg-cell { min-width: 1px; }
}
