/* agentguard dashboard — no framework, no build.
   Colors come from the validated data-viz palette: categorical slot 1 (blue) for
   latency, status-critical (red) for failures, neutral ink for the successful
   mass. Both modes are declared explicitly, never an automatic flip. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;      /* categorical slot 1 — latency */
  --status-critical: #d03b3b;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --neutral-mark: #c3c2b7;  /* the successful mass: present, not shouting */
  --shadow: 0 1px 2px rgba(11, 11, 11, .06), 0 8px 24px rgba(11, 11, 11, .06);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --neutral-mark: #4a4a46;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --neutral-mark: #4a4a46;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

/* An author `display` beats the UA stylesheet's [hidden] rule, so anything with
   a display of its own (the drawer, the table views) would ignore `hidden`. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--text-primary);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h2 { font-size: 14px; margin: 0 0 12px; letter-spacing: .01em; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 20px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand strong { letter-spacing: -.01em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.up { background: var(--status-good); }
.dot.down { background: var(--status-critical); }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 5px 11px; font: inherit; font-size: 12px; cursor: pointer;
}
.segmented button.on { background: var(--text-primary); color: var(--surface-1); }
.segmented button + button { border-left: 1px solid var(--border); }

button.ghost {
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  padding: 5px 11px; border-radius: 8px; font: inherit; font-size: 12px; cursor: pointer;
}
button.ghost:hover { color: var(--text-primary); }
.linkish {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px;
  cursor: pointer; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px;
}
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); }

/* ---- layout ---- */
main { padding: 16px 20px 64px; max-width: 1400px; margin: 0 auto; display: grid; gap: 16px; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px;
}
.tile-label { font-size: 12px; color: var(--text-secondary); }
.tile-value { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; }
.tile-sub { font-size: 12px; color: var(--muted); }
.tile-value.bad { color: var(--status-critical); }

.charts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.chart-card { margin: 0; }
.chart-card figcaption {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.card-title { font-size: 14px; font-weight: 600; }
.plot { position: relative; height: 190px; }
.plot svg { display: block; width: 100%; height: 100%; overflow: visible; }

.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-secondary); }
.key { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.swatch-ok { background: var(--neutral-mark); }
.swatch-failed { background: var(--status-critical); }

/* ---- tables ---- */
.scroll-x { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.selectable tbody tr { cursor: pointer; }
table.selectable tbody tr:hover td { background: var(--plane); }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ratebar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.ratebar .track { flex: 1; height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.ratebar .fill { height: 100%; background: var(--status-critical); border-radius: 3px; }
.ratebar span { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-secondary); }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px;
  border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap;
}
.pill.ok { color: var(--status-good); border-color: color-mix(in srgb, var(--status-good) 40%, transparent); }
.pill.bad { color: var(--status-critical); border-color: color-mix(in srgb, var(--status-critical) 40%, transparent); }
.pill.warn { color: var(--status-warning); border-color: color-mix(in srgb, var(--status-warning) 45%, transparent); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select {
  background: var(--plane); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; font: inherit; font-size: 12px;
}
.empty { padding: 12px 2px; }
.table-view table { width: 100%; margin-top: 8px; }

/* ---- alerts ---- */
#alert-strip { display: grid; gap: 8px; }
.alert {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1);
  border-left: 3px solid var(--status-warning);
}
.alert.page { border-left-color: var(--status-critical); }
.alert .icon { font-size: 14px; }
.alert .what { font-weight: 600; }

/* ---- drawer ---- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%);
  background: var(--surface-1); border-left: 1px solid var(--border);
  box-shadow: var(--shadow); z-index: 40; display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 10px;
}
.drawer-body { overflow-y: auto; padding: 16px; display: grid; gap: 16px; }
#scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; word-break: break-word; }

pre.json {
  margin: 0; padding: 10px 12px; background: var(--plane); border: 1px solid var(--border);
  border-radius: 8px; overflow-x: auto; font-size: 12px; line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 280px;
}
.section-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.attempt { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.attempt.failed { border-left: 3px solid var(--status-critical); }
.attempt.passed { border-left: 3px solid var(--status-good); }
.attempt-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.errlist { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--text-secondary); }
.errlist code { color: var(--text-primary); }

.replay-box { display: grid; gap: 8px; }
.replay-box textarea {
  width: 100%; min-height: 84px; background: var(--plane); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.replay-out { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.replay-out.reproduced { border-left: 3px solid var(--status-critical); }
.replay-out.clean { border-left: 3px solid var(--status-good); }

/* ---- tooltip ---- */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12px; min-width: 130px;
}
.tooltip .t-title { color: var(--muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .t-row b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- sign in ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; display: grid; gap: 6px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 18px; margin: 0 0 2px; letter-spacing: -.01em; }
.login-card label { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.login-card input {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--plane); color: var(--text-primary); font: inherit;
}
.login-card button {
  margin-top: 14px; border: 1px solid var(--border); background: var(--text-primary);
  color: var(--surface-1); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer;
}
.login-card button[disabled] { opacity: .6; cursor: progress; }
.login-error {
  margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; font-size: 12px;
  color: var(--status-critical);
  border: 1px solid color-mix(in srgb, var(--status-critical) 40%, transparent);
}
.small { font-size: 11px; line-height: 1.45; margin: 14px 0 0; }
.who { font-size: 12px; color: var(--text-secondary); }

/* SVG hover targets — a class, because a style="" attribute would violate the
   collector's content security policy. */
.hit { cursor: crosshair; }

@media (max-width: 640px) {
  .plot { height: 165px; }
  .tile-value { font-size: 24px; }
  main { padding: 12px 12px 48px; }
}
