:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #16202b;
  --muted: #5d6b7a;
  --line: #dde2e8;
  --grid: #e9edf1;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --series: #2f6fd0;
  --ok: #17794a;
  --ok-bg: #e3f4ea;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --warn: #7a5600;
  --warn-bg: #fff4d6;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --panel: #1a212a;
    --text: #e6ebf0;
    --muted: #9aa7b5;
    --line: #2c3642;
    --grid: #232c36;
    --accent: #6ea8ff;
    --accent-text: #0c1320;
    --series: #6ea8ff;
    --ok: #6fd3a0;
    --ok-bg: #173527;
    --bad: #ff9d94;
    --bad-bg: #3d1c19;
    --warn: #f2cf78;
    --warn-bg: #3a3016;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 13px; }
h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

/* shell */
.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 0 8px; }
nav { display: grid; gap: 2px; }
nav a { padding: 8px 10px; border-radius: 7px; color: var(--text); text-decoration: none; }
nav a:hover { background: var(--bg); }
nav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.who { margin-top: auto; display: grid; gap: 4px; padding: 0 8px; }
.who-name { font-weight: 600; overflow-wrap: anywhere; }
main { padding: 24px; min-width: 0; outline: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  nav { display: flex; flex-wrap: wrap; }
  .who { margin: 0 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 0; }
  .who-role { display: none; }
  main { padding: 16px; }
}

/* controls */
button, select, input { font: inherit; }
button { padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
input, select { width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
select { width: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--bad); margin: 0; min-height: 1.2em; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* panels, tiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tile .label { font-size: 12.5px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .note { font-size: 12.5px; color: var(--muted); }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 980px) { .cols { grid-template-columns: 1fr; } }

/* chips */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.chip.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
td.wrap { white-space: normal; min-width: 220px; }
td.num, th.num { text-align: right; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg); }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }

/* bar chart: one series, one hue; recessive grid; value on hover and in the table view */
.chart { position: relative; height: 200px; display: flex; align-items: flex-end; gap: 2px; padding: 8px 0 0; border-bottom: 1px solid var(--line); background: linear-gradient(to top, transparent calc(50% - 1px), var(--grid) calc(50% - 1px), var(--grid) 50%, transparent 50%); }
.bar-slot { flex: 1 1 0; min-width: 4px; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: min(100%, 28px); min-height: 2px; background: var(--series); border-radius: 4px 4px 0 0; }
.bar-slot:hover .bar, .bar-slot:focus-visible .bar { filter: brightness(1.15); }
.axis { display: flex; gap: 2px; margin-top: 4px; }
.axis span { flex: 1 1 0; min-width: 4px; text-align: center; font-size: 11px; color: var(--muted); overflow: hidden; white-space: nowrap; }
.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 9px; border-radius: 6px; font-size: 12.5px; white-space: nowrap; }

/* call detail */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.turns { display: grid; gap: 10px; }
.turn { display: grid; grid-template-columns: 64px 1fr; gap: 10px; }
.turn .t { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 3px; }
.bubble { padding: 8px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); max-width: 760px; }
.turn.agent .bubble { background: var(--panel); }
.who-tag { font-size: 12px; font-weight: 600; color: var(--muted); display: block; }
pre.prompt { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-family: var(--mono); font-size: 12.5px; max-height: 360px; overflow: auto; margin: 8px 0 0; }
details > summary { cursor: pointer; color: var(--accent); }
.meter { height: 8px; border-radius: 999px; background: var(--grid); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--series); border-radius: 999px; }

/* forms */
.form { display: grid; gap: 14px; max-width: 860px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .form .row2 { grid-template-columns: 1fr; } }
textarea { font: inherit; width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--text); resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.form select { width: 100%; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.checks input { width: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notice { padding: 8px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--muted); }
/* line chart (single series) */
.line { width: 100%; height: 200px; display: block; }
.line .grid { stroke: var(--grid); stroke-width: 1; }
.line .path { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line .dot { fill: var(--series); stroke: var(--panel); stroke-width: 2; }
.line .hit { fill: transparent; }
.line .target { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
