:root {
  --bg: #071019;
  --surface: #0d1824;
  --surface-raised: #122131;
  --surface-soft: #17283a;
  --line: #24384b;
  --line-bright: #365169;
  --text: #e9f1f7;
  --muted: #8fa4b7;
  --cyan: #53d4c8;
  --cyan-soft: rgba(83, 212, 200, .14);
  --blue: #6da8ff;
  --violet: #a58bfa;
  --amber: #f0b35b;
  --red: #f27878;
  --green: #6ed39d;
  --shadow: 0 18px 60px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background:
  radial-gradient(circle at 85% -20%, rgba(83, 212, 200, .11), transparent 38rem),
  radial-gradient(circle at -10% 35%, rgba(109, 168, 255, .08), transparent 32rem), var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
code { color: var(--cyan); }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 60px; }
.topbar { min-height: 112px; display: grid; grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr); align-items: center; gap: 24px; border-bottom: 1px solid rgba(54, 81, 105, .55); }
.topbar-brand { justify-self: start; }
.topbar .dashboard-tabs-wrap { justify-self: center; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.15rem; letter-spacing: -.02em; }
h3 { font-size: .98rem; }
.eyebrow { margin-bottom: 6px; color: var(--cyan); font-size: .68rem; font-weight: 750; letter-spacing: .19em; }
.connection { justify-self: end; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .86rem; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px rgba(143, 164, 183, .08); }
.connection-dot.online { background: var(--green); box-shadow: 0 0 0 5px rgba(110, 211, 157, .1); }
.connection-dot.error { background: var(--red); box-shadow: 0 0 0 5px rgba(242, 120, 120, .1); }

.auth-panel { margin: 12vh auto 0; width: min(780px, 100%); padding: clamp(28px, 5vw, 52px); display: grid; grid-template-columns: 1.05fr .95fr; gap: 42px; align-items: center; background: linear-gradient(135deg, rgba(18, 33, 49, .96), rgba(13, 24, 36, .96)); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-panel p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); line-height: 1.65; }
.auth-form label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.input-row { display: flex; gap: 8px; }
input, select { min-height: 40px; color: var(--text); background: rgba(7, 16, 25, .68); border: 1px solid var(--line); border-radius: 8px; outline: 0; transition: border-color .15s, box-shadow .15s; }
input { width: 100%; padding: 0 12px; }
select { padding: 0 34px 0 12px; }
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(83, 212, 200, .12); }
.form-error { min-height: 20px; margin: 8px 0 0 !important; color: var(--red) !important; font-size: .77rem; }

.button, .icon-button { border: 1px solid transparent; border-radius: 8px; color: var(--text); background: var(--surface-soft); transition: transform .12s, border-color .12s, background .12s; }
.button { min-height: 38px; padding: 0 15px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.button:hover, .icon-button:hover { transform: translateY(-1px); border-color: var(--line-bright); }
.button.primary { color: #061512; background: var(--cyan); }
.button.primary:hover { background: #72e2d8; }
.button.subtle { border-color: var(--line); background: transparent; }
.button.danger { color: var(--red); border-color: rgba(242, 120, 120, .38); background: rgba(242, 120, 120, .08); }
.button.danger:hover { border-color: var(--red); background: rgba(242, 120, 120, .14); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }

.dashboard { padding-top: 18px; }
.dashboard-tabs-wrap { display: flex; align-items: center; justify-content: center; min-width: 0; }
.dashboard-tabs { display: inline-flex; gap: 3px; padding: 4px; background: rgba(13, 24, 36, .78); border: 1px solid rgba(54, 81, 105, .72); border-radius: 13px; box-shadow: 0 8px 26px rgba(0, 0, 0, .2); backdrop-filter: blur(14px); }
.dashboard-tab { min-width: 142px; min-height: 44px; padding: 6px 14px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 9px; transition: color .15s, background .15s, border-color .15s, transform .15s; }
.dashboard-tab span { font-size: .84rem; font-weight: 760; letter-spacing: .01em; }
.dashboard-tab small { color: inherit; font-size: .62rem; font-weight: 650; opacity: .72; white-space: nowrap; }
.dashboard-tab:hover { color: var(--text); background: rgba(255, 255, 255, .035); transform: translateY(-1px); }
.dashboard-tab.is-active { color: var(--text); background: linear-gradient(145deg, rgba(23, 40, 58, .98), rgba(18, 33, 49, .96)); border-color: var(--line-bright); box-shadow: inset 0 -2px 0 var(--cyan), 0 6px 16px rgba(0, 0, 0, .18); }
.dashboard-tab.is-active small { color: var(--cyan); opacity: .9; }
.dashboard-tab:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.dashboard-page { animation: dashboard-page-in .16s ease-out; }
@keyframes dashboard-page-in { from { opacity: .55; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.request-page .requests-panel { margin-top: 14px; }
.other-page > .panel:first-child { margin-top: 0; }
.other-page .aggregate-panel .aggregate-grid { margin-top: 18px; }
.other-page .audit-details { margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(54, 81, 105, .55); }
.audit-summary-secondary { margin-top: 3px; opacity: .85; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric-card { min-height: 132px; padding: 19px 20px; display: flex; flex-direction: column; background: linear-gradient(150deg, var(--surface-raised), var(--surface)); border: 1px solid var(--line); border-radius: 12px; }
.metric-card > span { color: var(--muted); font-size: .76rem; font-weight: 650; }
.metric-card strong { margin: auto 0 4px; font-size: clamp(1.65rem, 3vw, 2.35rem); font-weight: 680; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.metric-card strong i { color: var(--line-bright); font-style: normal; font-weight: 400; }
.metric-card small { color: var(--muted); font-size: .7rem; }
.runtime-controls-panel { margin-top: 14px; }
.runtime-controls-panel .panel-heading { align-items: flex-start; }
.runtime-intro { margin: 7px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.runtime-toolbar { min-width: 220px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.runtime-backend-picker { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.runtime-backend-picker label { color: var(--muted); font-size: .68rem; font-weight: 650; white-space: nowrap; }
.runtime-backend-picker select { min-width: 140px; }
.runtime-empty { margin: 18px 0 0; padding: 18px 20px; color: var(--muted); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 10px; font-size: .78rem; line-height: 1.5; }
.runtime-settings-status { max-width: 260px; margin: 3px 0 0; color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1.4; text-align: right; }
.runtime-state-good { color: var(--green); }
.runtime-state-neutral { color: var(--muted); }
.runtime-state-warn { color: var(--amber); }
.runtime-state-bad { color: var(--red); }
.runtime-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.runtime-card { min-width: 0; padding: 18px 20px 20px; background: linear-gradient(150deg, var(--surface-raised), var(--surface)); border: 1px solid var(--line); border-radius: 10px; }
.runtime-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.runtime-card-heading .eyebrow { margin-bottom: 4px; }
.runtime-card-heading h3 { margin: 0; font-size: .98rem; }
.runtime-card-state { flex: 0 0 auto; padding-top: 3px; color: var(--muted); font-size: .7rem; font-weight: 700; }
.runtime-card-state.runtime-state-good { color: var(--green); }
.runtime-card-state.runtime-state-warn { color: var(--amber); }
.runtime-card-state.runtime-state-bad { color: var(--red); }
.runtime-stat-line { margin-top: 18px; color: var(--muted); font-size: .82rem; }
.runtime-stat-line strong { color: var(--text); font-size: 1.3rem; font-weight: 680; font-variant-numeric: tabular-nums; }
.runtime-secondary { min-height: 21px; margin: 5px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.runtime-notice { margin: 10px 0 0; padding: 8px 10px; color: var(--amber); background: rgba(240, 179, 91, .08); border: 1px solid rgba(240, 179, 91, .28); border-radius: 7px; font-size: .7rem; line-height: 1.45; }
.runtime-actions { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.runtime-action-label { margin-right: 2px; color: var(--muted); font-size: .68rem; font-weight: 650; }
.runtime-target { min-width: 74px; min-height: 44px; }
.runtime-target[aria-pressed="true"] { color: #061512; background: var(--cyan); border-color: var(--cyan); }
.runtime-target[aria-pressed="true"]:hover { background: #72e2d8; }
.runtime-target:focus-visible, .runtime-controls-panel .button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.runtime-followup-message { margin-top: 18px; }
.runtime-followup-message-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .68rem; font-weight: 650; }
.runtime-followup-text-view { min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 13px; background: rgba(7, 16, 25, .42); border: 1px solid rgba(54, 81, 105, .66); border-radius: 9px; }
.runtime-followup-text-value { min-width: 0; flex: 1; overflow: hidden; color: var(--text); font-size: .8rem; font-weight: 620; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.runtime-followup-edit { min-height: 32px; padding: 0 12px; }
.runtime-followup-form { margin-top: 0; }
.runtime-followup-form input { min-height: 44px; }
.runtime-followup-edit-actions { margin-top: 9px; display: flex; gap: 8px; }
.runtime-followup-edit-actions .button { min-width: 78px; }
.runtime-followup-form .runtime-secondary { margin-top: 7px; }
.runtime-followup-form input:disabled { cursor: wait; opacity: .6; }
.button:focus-visible, .icon-button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.panel { margin-top: 14px; padding: 22px; background: rgba(13, 24, 36, .9); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .12); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.audit-summary { margin-top: 6px; color: var(--muted); font-size: .7rem; }

.request-heading { align-items: end; }
.filters { display: flex; gap: 8px; width: min(480px, 48%); }
.filters input { min-width: 180px; }
.table-wrap { position: relative; margin: 18px -22px -22px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1200px; }
.request-table { table-layout: fixed; }
.request-table td { text-align: center; }
.request-col-time { width: 12%; }
.request-col-id { width: 15%; }
.request-col-model { width: 16%; }
.request-col-status { width: 9%; }
.request-col-diagnostic { width: 14%; }
.request-col-tokens { width: 14%; }
.request-col-speed { width: 11%; }
.request-col-duration { width: 9%; }
th { padding: 10px 17px; color: var(--muted); background: rgba(7, 16, 25, .6); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .66rem; text-align: center; text-transform: uppercase; letter-spacing: .08em; }
td { padding: 14px 17px; border-bottom: 1px solid rgba(36, 56, 75, .55); color: #c8d5df; font-size: .76rem; vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(83, 212, 200, .035); }
tbody tr:last-child td { border-bottom: 0; }
.request-link { display: block; width: 100%; max-width: 100%; padding: 0; overflow: hidden; color: var(--cyan); background: transparent; border: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .73rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.request-link:hover { text-decoration: underline; }
.cell-main { display: block; color: var(--text); font-weight: 620; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: .68rem; }
.speed-cell .ttft-token, .speed-cell .speed-value.speed-token { color: var(--green); }
.speed-cell .ttft-http, .speed-cell .speed-value.speed-http { color: var(--amber); }
.truncation-badge { color: var(--amber); font-weight: 620; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid; border-radius: 999px; font-size: .67rem; font-weight: 700; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.processing { color: var(--blue); border-color: rgba(109, 168, 255, .28); background: rgba(109, 168, 255, .08); }
.status.succeeded { color: var(--green); border-color: rgba(110, 211, 157, .26); background: rgba(110, 211, 157, .07); }
.status.failed, .status.cancelled { color: var(--red); border-color: rgba(242, 120, 120, .26); background: rgba(242, 120, 120, .07); }
.empty-state { padding: 58px 20px; color: var(--muted); text-align: center; font-size: .8rem; }
.added-cell, .duration-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.duration-cell { white-space: nowrap; }
.duration-cell .cell-main { min-width: 8ch; }

/* Diagnostic pills — compact row-level badge for root cause inference */
.diagnostic-cell { min-width: 90px; max-width: 160px; white-space: normal; vertical-align: middle; }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2.5px 9px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
  font-size: .6rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill.good { color: var(--green); border-color: rgba(110, 211, 157, .26); background: rgba(110, 211, 157, .07); }
.pill.warn { color: var(--amber); border-color: rgba(240, 179, 91, .28); background: rgba(240, 179, 91, .07); }
.pill.bad { color: var(--red); border-color: rgba(242, 120, 120, .26); background: rgba(242, 120, 120, .07); }
.pill.neutral { color: var(--blue); border-color: rgba(109, 168, 255, .26); background: rgba(109, 168, 255, .07); }
.pill.pulse {
  animation: pillPulse 2s ease-in-out infinite;
}
@keyframes pillPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Inline preview row — Layer 2: expandable row preview */
.inline-preview td {
  padding: 10px 14px;
  background: rgba(7, 16, 25, .5);
  border-bottom: 1px solid var(--line);
  font-size: .72rem;
  line-height: 1.5;
  color: #b9c8d3;
}
.inline-preview-stat { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
.inline-preview-stat strong { color: var(--text); font-weight: 680; }
.inline-preview-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 16, 25, .4);
  color: var(--muted);
  font-size: .65rem;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.inline-preview-trigger:hover { border-color: var(--line-bright); background: rgba(7, 16, 25, .7); }
.inline-preview-trigger::before { content: "▸"; font-size: .6rem; transition: transform .15s; }
.inline-preview-trigger.expanded::before { transform: rotate(90deg); }
.inline-preview-body {
  display: none;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: rgba(7, 16, 25, .55);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .7rem;
  line-height: 1.55;
  color: #b9c8d3;
}
.inline-preview-body.open { display: block; }
.inline-preview-stat { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
.inline-preview-stat strong { color: var(--text); font-weight: 680; }

/* Root cause block in detail dialog */
.detail-root-cause {
  margin-top: 18px;
  padding: 14px 18px;
  background: rgba(242, 120, 120, .06);
  border: 1px solid rgba(242, 120, 120, .22);
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.detail-root-cause .root-cause-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
}
.detail-root-cause .root-cause-icon.error { background: rgba(242, 120, 120, .15); color: var(--red); }
.detail-root-cause .root-cause-icon.warn { background: rgba(240, 179, 91, .15); color: var(--amber); }
.detail-root-cause .root-cause-icon.info { background: rgba(109, 168, 255, .12); color: var(--blue); }
.detail-root-cause .root-cause-body { min-width: 0; }
.detail-root-cause .root-cause-body strong { font-size: .82rem; }
.detail-root-cause .root-cause-body p { margin: 3px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }

/* Payload on-demand cell */
.payload-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 16, 25, .4);
  color: var(--muted);
  font-size: .65rem;
  cursor: pointer;
  transition: background .12s;
}
.payload-toggle:hover { background: rgba(7, 16, 25, .7); border-color: var(--line-bright); }
.added-grid { display: flex; flex-direction: column; width: 100%; gap: 1px; line-height: 1.38; color: #c8d5df; }
.added-total { color: var(--text); font-weight: 720; white-space: nowrap; }
.added-pair { display: flex; gap: 8px; color: var(--muted); }
.added-pair > span { flex: 1 1 0; min-width: 0; white-space: nowrap; }
.added-grid .num { display: inline-block; min-width: 4.5ch; color: var(--text); text-align: right; }
.request-table .added-grid .num { text-align: center; }
.estimate-badge { margin-left: 5px; padding: 1px 3px; border-radius: 3px; font: 700 .55rem/1 ui-sans-serif, sans-serif; }
.estimate-badge.estimated { color: var(--amber); border: 1px solid rgba(240, 179, 91, .3); }
.estimate-badge.exact { color: var(--green); border: 1px solid rgba(110, 211, 157, .34); }
.detail-added-grid .added-grid { max-width: 240px; font-size: .86rem; }

.detail-dialog { width: min(1120px, calc(100% - 32px)); height: min(88vh, 920px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line-bright); border-radius: 15px; box-shadow: var(--shadow); }
.detail-dialog::backdrop { background: rgba(2, 8, 13, .78); backdrop-filter: blur(5px); }
.dialog-shell { min-height: 100%; display: flex; flex-direction: column; }
.dialog-header { padding: 21px 24px 17px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.detail-meta { margin: 6px 0 0; color: var(--muted); font-size: .73rem; }
.icon-button { width: 34px; height: 34px; font-size: 1.4rem; line-height: 1; }
.copy-actions { padding: 10px 24px; display: flex; justify-content: flex-end; gap: 8px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 25, .45); }
.detail-content { padding: 22px 24px 34px; overflow-y: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.detail-stat { padding: 13px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 8px; }
.detail-stat span { display: block; color: var(--muted); font-size: .66rem; }
.detail-stat strong { display: block; margin-top: 5px; font-size: 1rem; overflow-wrap: anywhere; }
.tooling-detail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.tooling-detail-heading h3 { margin: 0; font-size: .82rem; }
.tooling-detail-heading span { color: var(--muted); font-size: .65rem; }
.detail-grid.tooling-detail-grid { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.detail-section { margin-top: 18px; }
.detail-collapsible { background: rgba(7, 16, 25, .4); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.detail-collapsible > summary { list-style: none; cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 8px; transition: background .12s; }
.detail-collapsible > summary::-webkit-details-marker { display: none; }
.detail-collapsible > summary::before { content: "▸"; color: var(--muted); font-size: .7rem; transition: transform .15s; }
.detail-collapsible[open] > summary::before { transform: rotate(90deg); }
.detail-collapsible > summary:hover { background: rgba(83, 212, 200, .04); }
.detail-collapsible > summary h3 { margin: 0; font-size: .82rem; font-weight: 680; }
.detail-section-count { color: var(--muted); font-weight: 500; font-size: .72rem; }
.detail-collapsible .detail-list { padding: 8px 16px 14px; }
.diagnostic-body-view .detail-list { display: grid; gap: 10px; }
.body-view-description { margin: 0; color: var(--muted); font-size: .68rem; line-height: 1.45; }
.body-ref-list { display: grid; gap: 8px; }
.body-ref-card { padding: 12px; background: rgba(7, 16, 25, .55); border: 1px solid var(--line); border-radius: 8px; }
.body-ref-card.unavailable { border-color: rgba(240, 179, 91, .34); }
.body-ref-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.body-ref-head strong { color: var(--text); font-size: .75rem; }
.body-metadata { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; color: var(--muted); font-size: .65rem; line-height: 1.4; }
.body-metadata span { padding: 2px 6px; background: rgba(18, 33, 49, .72); border: 1px solid rgba(54, 81, 105, .72); border-radius: 4px; }
.body-metadata .body-flag { color: var(--amber); border-color: rgba(240, 179, 91, .32); }
.body-pane-message { margin: 10px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.body-pane-message.error { color: var(--red); }
.body-pane-message.unavailable { color: var(--amber); }
.body-pane-content { margin-top: 10px; }
.body-pane-notice { margin: 0 0 7px; color: var(--amber); font-size: .68rem; line-height: 1.45; }
.body-pane-content pre { margin: 0; padding: 10px; max-height: 320px; overflow: auto; color: #bad0df; background: #050b11; border: 1px solid var(--line); border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font: .69rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.body-expand[aria-expanded="true"] { color: var(--cyan); border-color: rgba(83, 212, 200, .42); }
.detail-exchange { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; background: rgba(7, 16, 25, .5); border: 1px solid var(--line-bright); border-radius: 12px; }
.exchange-side { min-width: 0; }
.exchange-role { margin: 0 0 8px; color: var(--cyan); font-size: .65rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.exchange-text { padding: 10px 12px; background: rgba(7, 16, 25, .55); border: 1px solid var(--line); border-radius: 8px; font-size: .74rem; line-height: 1.55; max-height: 240px; overflow: auto; overflow-wrap: anywhere; }
.exchange-text.muted { color: var(--muted); font-style: italic; }
.exchange-line { margin: 0 0 6px; color: #b9c8d3; }
.exchange-line:last-child { margin-bottom: 0; }
.exchange-line strong { color: var(--text); font-weight: 680; }
.exchange-fail { color: var(--red); font-weight: 620; }
.exchange-sub { color: var(--muted); font-size: .72rem; margin-left: 6px; font-weight: 400; }

.exchange-action { grid-column: 1 / -1; display: flex; justify-content: center; }
.exchange-banner { margin-top: 18px; padding: 12px 16px; border-radius: 10px; display: flex; gap: 12px; align-items: center; }
.exchange-banner.error { background: rgba(242, 120, 120, .08); border: 1px solid rgba(242, 120, 120, .28); }
.exchange-banner strong { color: var(--red); font-size: .8rem; }
.exchange-banner span { color: #b9c8d3; font-size: .74rem; }
.button.small { min-height: 30px; padding: 0 10px; font-size: .72rem; }
.detail-list { display: grid; gap: 8px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; }
.payload-block summary { cursor: pointer; padding: 8px 0; color: var(--text); }
.payload-block pre { margin: 8px 0 0; padding: 10px; max-height: 320px; overflow: auto; color: #bad0df; background: #050b11; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font: .69rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-entry { padding: 12px 14px; background: rgba(7, 16, 25, .55); border: 1px solid var(--line); border-radius: 8px; }
.detail-entry-head { display: flex; justify-content: space-between; gap: 16px; font-size: .72rem; }
.detail-entry-head strong { color: var(--text); }
.detail-entry-head time { color: var(--muted); }
.detail-entry p { margin: 7px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.detail-entry pre, .payload-preview { margin: 9px 0 0; padding: 10px; max-height: 210px; overflow: auto; color: #bad0df; background: #050b11; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font: .69rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.timeline { position: relative; display: grid; gap: 0; }
.timeline-entry { position: relative; padding: 0 0 17px 24px; }
.timeline-entry::before { content: ""; position: absolute; left: 5px; top: 7px; bottom: -7px; width: 1px; background: var(--line); }
.timeline-entry:last-child::before { display: none; }
.timeline-entry::after { content: ""; position: absolute; left: 1px; top: 5px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--blue); }
.timeline-entry.error::after { background: var(--red); }
.timeline-entry.warn::after { background: var(--amber); }
.timeline-entry header { display: flex; gap: 8px; align-items: baseline; }
.timeline-entry code { font-size: .7rem; }
.timeline-entry time { color: var(--muted); font-size: .65rem; }
.timeline-entry p { margin: 4px 0 0; color: #b9c8d3; font-size: .72rem; }
.empty-inline { color: var(--muted); font-size: .75rem; }
.models-panel { margin-top: 14px; }
.models-filters { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.model-filter { min-height: 34px; padding: 0 12px; }
.model-filter[aria-pressed="true"] { color: #061512; background: var(--cyan); border-color: var(--cyan); }
.model-filter[aria-pressed="true"]:hover { background: #72e2d8; }
.model-filter:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.models-list { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.model-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 999px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .73rem; }
.model-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); }
.models-empty { color: var(--muted); font-size: .8rem; }

/* Continuation / repair / failure badges — used in both request table and detail dialog */
.cont-badge { display: inline-flex; align-items: center; padding: 2px 7px; border: 1px solid; border-radius: 999px; font-size: .6rem; font-weight: 700; white-space: nowrap; }
.cont-ok { color: var(--green); border-color: rgba(110, 211, 157, .26); background: rgba(110, 211, 157, .07); }
.cont-fail { color: var(--red); border-color: rgba(242, 120, 120, .26); background: rgba(242, 120, 120, .07); }
.cont-warn { color: var(--amber); border-color: rgba(240, 179, 91, .28); background: rgba(240, 179, 91, .07); }
.cont-info { color: var(--blue); border-color: rgba(109, 168, 255, .26); background: rgba(109, 168, 255, .07); }
.detail-entry-head .cont-badge { margin-left: 6px; }
.detail-meta-line { margin: 5px 0 0; color: var(--muted); font-size: .66rem; }

/* Aggregate stats panel — compact inline cards below metrics */
.aggregate-panel { margin-top: 14px; }
.aggregate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.aggregate-card { padding: 14px 16px; background: linear-gradient(150deg, var(--surface-raised), var(--surface)); border: 1px solid var(--line); border-radius: 10px; }
.aggregate-card .agg-label { color: var(--muted); font-size: .68rem; font-weight: 650; letter-spacing: .04em; }
.aggregate-card .agg-value { margin-top: 6px; font-size: 1.35rem; font-weight: 680; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.aggregate-card .agg-sub { margin-top: 3px; color: var(--muted); font-size: .65rem; }

/* Compatibility audit details — expandable catalog within dashboard */
.audit-details { margin-top: 14px; }
.audit-catalog { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; }
.audit-item { padding: 10px 12px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 8px; }
.audit-item .ai-head { display: flex; align-items: center; gap: 8px; }
.audit-item .ai-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; color: var(--cyan); }
.audit-item .ai-name { font-size: .72rem; color: var(--text); font-weight: 620; }
.audit-item .ai-reason { margin-top: 4px; color: var(--muted); font-size: .66rem; line-height: 1.45; }
.audit-status { display: inline-flex; padding: 1px 6px; border: 1px solid; border-radius: 3px; font-size: .55rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.audit-status.active { color: var(--green); border-color: rgba(110, 211, 157, .3); }
.audit-status.retired { color: var(--muted); border-color: var(--line); }
.audit-status.deferred { color: var(--amber); border-color: rgba(240, 179, 91, .3); }
.audit-status.backend { color: var(--violet); border-color: rgba(165, 139, 250, .3); }
.copy-fallback { position: fixed; opacity: 0; pointer-events: none; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 18px); padding: 10px 15px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line-bright); border-radius: 8px; box-shadow: var(--shadow); font-size: .75rem; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 14px 20px; padding: 16px 0; }
  .topbar .dashboard-tabs-wrap { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .topbar .dashboard-tabs { width: min(100%, 440px); margin: 0 auto; }
  .topbar .dashboard-tab { flex: 1; min-width: 0; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-exchange { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 22px, 1480px); }
  .dashboard { padding-top: 12px; }
  .topbar { min-height: 86px; }
  .topbar .dashboard-tabs { width: 100%; }
  .dashboard-tab { padding-left: 10px; padding-right: 10px; }
  .dashboard-tab small { display: none; }
  .auth-panel { margin-top: 7vh; grid-template-columns: 1fr; gap: 24px; padding: 25px; }
  .input-row { flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .metric-card { min-height: 114px; }
  .panel { padding: 17px; }
  .runtime-controls-panel .panel-heading { flex-direction: column; gap: 8px; }
  .runtime-settings-status { max-width: none; margin-top: 0; text-align: left; }
  .runtime-toolbar { width: 100%; min-width: 0; align-items: stretch; }
  .runtime-backend-picker { justify-content: space-between; }
  .runtime-backend-picker select { flex: 1; min-width: 0; }
  .runtime-grid { grid-template-columns: 1fr; }
  .runtime-card { padding: 16px; }
  .runtime-actions .runtime-target { flex: 1; }
  .runtime-followup-edit-actions .button { flex: 1; }
  .request-heading { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; flex-direction: column; }
  .filters input { min-width: 0; }
  .table-wrap { margin-left: -17px; margin-right: -17px; }
  .copy-actions { padding: 10px 16px; justify-content: stretch; flex-wrap: wrap; }
  .copy-actions .button { flex: 1; }
  .dialog-header, .detail-content { padding-left: 16px; padding-right: 16px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-page { animation: none; }
  .dashboard-tab { transition: none; }
}
