:root {
  color-scheme: dark;
  --shell: #061120;
  --shell-2: #0a182a;
  --sidebar: #071321;
  --sidebar-soft: #0d1b2d;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --line: #d9e2ee;
  --line-soft: #edf2f7;
  --text: #111827;
  --muted: #617089;
  --subtle: #8a98ac;
  --blue: #2563eb;
  --blue-2: #6ea4ff;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #dc2626;
  --burgundy: #991b1b;
  --navy: #0b1730;
  --shadow: 0 18px 44px rgba(6, 17, 32, 0.28);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; height: 100%; }
body {
  margin: 0;
  min-width: 1180px;
  background:
    radial-gradient(circle at 74% 8%, rgba(37, 99, 235, 0.18), transparent 25rem),
    linear-gradient(135deg, var(--shell) 0%, #071526 58%, #05101d 100%);
  color: var(--text);
  overflow: hidden;
}

button, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; font-weight: 700; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.triage-app {
  display: grid;
  grid-template-columns: 184px minmax(1000px, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(255,255,255,0.02), transparent 28%);
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(148, 163, 184, 0.22);
  background:
    radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.16), transparent 16rem),
    linear-gradient(180deg, #071321 0%, #06111f 100%);
  color: #d7e2f1;
}

.brand-mark {
  width: 38px;
  height: 48px;
  margin: 18px auto 18px 17px;
  position: relative;
}
.brand-mark span {
  position: absolute;
  left: 6px;
  width: 24px;
  height: 13px;
  border: 4px solid #2563eb;
  border-radius: 5px;
  transform: rotate(30deg) skewX(-22deg);
}
.brand-mark span:nth-child(1) { top: 0; }
.brand-mark span:nth-child(2) { top: 13px; border-color: #3b82f6; }
.brand-mark span:nth-child(3) { top: 26px; border-color: #60a5fa; }

.side-nav {
  display: grid;
  gap: 7px;
  padding: 0 8px;
}
.side-nav--bottom {
  margin-top: auto;
  padding-bottom: 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  padding-top: 18px;
}
.side-nav__item {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  color: #d7e2f1;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 750;
}
.side-nav__item.is-active {
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.08));
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.side-nav__icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #e9f1ff;
  font-weight: 900;
}

.dashboard {
  display: grid;
  grid-template-rows: 76px 70px 124px clamp(340px, 34vh, 420px) minmax(250px, 1fr);
  gap: 4px;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
  padding: 12px 18px 10px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  height: 76px; min-height: 0;
  color: #e9f1ff;
}
.topbar h1 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 850;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-chip, .select-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 5px;
  padding: 0 12px;
  color: #d7e2f1;
  background: rgba(11, 23, 43, 0.82);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.filter-chip--danger-dot::before,
.filter-chip--warning-dot::before,
.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
}
.filter-chip--warning-dot::before { background: var(--amber); box-shadow: -10px 0 0 #ef4444; margin-left: 10px; }
.select-chip { padding: 0 9px; }
.select-chip select {
  min-width: 190px;
  border: 0;
  color: #d7e2f1;
  background: transparent;
  outline: 0;
  font-size: 12px;
  font-weight: 750;
}
.select-chip option { background: #0b1730; color: #fff; }
.top-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.language-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 5px;
  background: rgba(17, 31, 54, 0.74);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.lang-button {
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  padding: 0 10px;
  color: #c5d2e4;
  background: transparent;
  font-size: 12px;
  font-weight: 850;
}
.lang-button.is-active {
  color: #0b1730;
  background: #eaf2ff;
}
.confidence-card {
  min-width: 282px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 5px;
  padding: 0 18px;
  background: rgba(17, 31, 54, 0.74);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.confidence-card span { color: #c5d2e4; font-size: 12px; font-weight: 650; }
.confidence-card strong { color: #4ade80; font-size: 26px; line-height: 1; }

.incident-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.incident-card {
  display: grid;
  grid-template-columns: 48px minmax(270px, 1.55fr) auto repeat(5, minmax(118px, 0.58fr)) 122px;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 10px;
  margin-bottom: 0;
}
.incident-alert {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: linear-gradient(135deg, #ef4444, #e11d48);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
}
.incident-kicker {
  display: block;
  margin-bottom: 7px;
  color: #ef4444;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  font-weight: 900;
}
.incident-title h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.severity-pill {
  justify-self: start;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 5px 8px;
  color: #dc2626;
  background: #fff5f5;
  font-size: 11px;
  font-weight: 900;
}
.metric-block {
  min-height: 44px;
  border-left: 1px solid var(--line-soft);
  padding-left: 18px;
  display: grid;
  align-content: center;
  gap: 2px;
}
.metric-block span {
  color: #526077;
  font-size: 11px;
  font-weight: 700;
}
.metric-block strong {
  color: #0f172a;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.metric-block a, .metric-block em, .metric-block small {
  color: var(--blue);
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}
.metric-block em { color: #ef4444; }
.metric-block small {
  justify-self: start;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 2px 5px;
  color: #dc2626;
  background: #fff5f5;
}
.status-dot { display: inline-flex; align-items: center; gap: 8px; font-size: 13px !important; font-weight: 750 !important; }
.outline-button, .secondary-button {
  min-height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: var(--blue);
  background: #fff;
  font-size: 12px;
  font-weight: 850;
}

.history-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(420px, 1.3fr) minmax(300px, 1.1fr);
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  padding: 10px 12px;
}
.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.history-head h3 {
  margin: 0 0 5px;
  color: #0f172a;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.history-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.history-state {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
}
.history-state--worse { color: #dc2626; background: #fff5f5; border: 1px solid #fca5a5; }
.history-state--critical { color: #fff; background: #dc2626; border: 1px solid #b91c1c; }
.history-state--alert { color: #b45309; background: #fffbeb; border: 1px solid #fbbf24; }
.history-state--recovering { color: #15803d; background: #f0fdf4; border: 1px solid #86efac; }
.history-state--stable { color: #2563eb; background: #eff6ff; border: 1px solid #bfdbfe; }
.history-state--recovered { color: #15803d; background: #f0fdf4; border: 1px solid #86efac; }
.decision-copy {
  display: grid;
  gap: 2px;
  margin-top: 7px;
}
.decision-copy strong {
  color: #334155;
  font-size: 10px;
  font-weight: 900;
}
.decision-copy span {
  color: #475569;
  font-size: 10px;
  line-height: 1.35;
}
.history-source-note {
  color: #64748b;
  font-size: 10px;
  font-style: normal;
  line-height: 1.35;
}
.history-source-note--fallback { color: #b45309; }
.history-source-note--collector { color: #2563eb; }
.decision-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.decision-rules span {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 2px 6px;
  color: #475569;
  background: #f8fafc;
  font-size: 9px;
  font-weight: 800;
}
.decision-stack {
  display: grid;
  justify-items: end;
  gap: 5px;
}
.decision-stack small {
  color: var(--blue);
  font-size: 10px;
  font-weight: 850;
}
.history-source-badge {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 4px 8px;
  color: #475569;
  background: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}
.history-source-badge--collector {
  border-color: #bfdbfe;
  color: #1d4ed8;
  background: #eff6ff;
}
.history-source-badge--fallback {
  border-color: #fbbf24;
  color: #92400e;
  background: #fffbeb;
}
.history-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.history-metric {
  display: grid;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 8px 10px;
  background: #fbfdff;
}
.history-metric span {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}
.history-metric strong {
  color: #0f172a;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.history-metric em {
  color: #ef4444;
  font-size: 10px;
  font-style: normal;
  font-weight: 850;
}
.history-spark {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  min-width: 0;
}
.history-run {
  display: grid;
  grid-template-rows: 15px 1fr 14px;
  align-items: end;
  justify-items: center;
  min-width: 0;
  height: 78px;
  border-left: 1px solid var(--line-soft);
}
.history-run span,
.history-run b {
  max-width: 100%;
  overflow: hidden;
  color: #64748b;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 800;
}
.history-run i {
  display: block;
  width: 60%;
  min-height: 12px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #93c5fd, #2563eb);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.18);
}
.history-run.is-current i {
  background: linear-gradient(180deg, #f59e0b, #ef4444);
}
.history-run.is-current b {
  color: #dc2626;
}

.main-grid {
  display: grid;
  grid-template-columns: 35% 41% 24%;
  gap: 4px;
  height: 100%;
  min-height: 0;
}
.bottom-grid {
  display: grid;
  grid-template-columns: 31% 26% 17% 26%;
  gap: 4px;
  margin-top: 4px;
  height: 100%;
  min-height: 0;
}
.bottom-grid > .panel { height: 100%; }
.panel {
  min-width: 0;
  overflow: hidden;
  border-radius: 5px;
}
.panel-head {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 {
  margin: 0 0 3px;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.panel-head--controls { align-items: flex-start; }
.info-dot {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1px solid #94a3b8;
  border-radius: 50%;
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}
.beta {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 4px;
  color: #64748b;
  font-size: 9px;
  letter-spacing: 0.05em;
}
.search-box, .control-pair span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid #d6dfeb;
  border-radius: 4px;
  padding: 0 10px;
  color: #64748b;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
}
.control-pair { display: inline-flex; gap: 7px; align-items: center; }
.icon-actions { color: #64748b; font-weight: 900; }

.trace-table { font-size: 11px; }
.trace-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.8fr) 58px 72px minmax(160px, 1.15fr) 62px minmax(100px, 0.8fr);
  align-items: center;
  min-height: 37px;
  border-bottom: 1px solid var(--line-soft);
  padding: 0 8px 0 12px;
  color: #334155;
}
.trace-row--head {
  min-height: 30px;
  color: #64748b;
  background: #f8fafc;
  font-size: 10px;
  font-weight: 850;
}
.trace-row.is-selected {
  background: #eff6ff;
  outline: 1px solid #93c5fd;
  outline-offset: -1px;
}
.trace-row.is-highlight {
  background: #fff7f7;
  outline: 1px solid #fca5a5;
  outline-offset: -1px;
}
.trace-row--total { font-weight: 850; background: #fff; }
.trace-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.trace-name--level-1 { padding-left: 16px; }
.trace-name--level-2 { padding-left: 36px; }
.trace-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 760; }
.trace-name small { color: #64748b; display: block; font-size: 9px; }
.trace-name i { color: #64748b; font-style: normal; flex: 0 0 auto; }
.status {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: #fff;
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
}
.status--success { background: var(--green); }
.status--warning { color: #fff; background: var(--amber); }
.status--error { background: var(--red); }
.status--progress { background: var(--blue-2); }
.status--skipped { background: #94a3b8; }
.duration.is-bad, .retry.is-bad { color: #dc2626; font-weight: 900; }

.timeline-scale {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 0 24px 0 88px;
  color: #64748b;
  font-size: 10px;
}
.timeline-scale span { border-top: 1px solid #cbd5e1; padding-top: 7px; }
.waterfall-body { padding: 4px 18px 10px 12px; }
.span-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  min-height: 38px;
  align-items: center;
}
.span-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}
.span-track {
  position: relative;
  min-height: 38px;
  background-image: linear-gradient(90deg, rgba(226,232,240,0.72) 1px, transparent 1px);
  background-size: 20% 100%;
}
.span-bar {
  position: absolute;
  top: 10px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-radius: 3px;
  padding: 0 7px;
  color: #fff;
  font-size: 10px;
  font-weight: 850;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.18);
}
.span-bar--progress { background: linear-gradient(90deg, #74a8ff, #3b82f6); }
.span-bar--warning { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.span-bar--error { background: linear-gradient(90deg, #ef4444, #991b1b); }
.span-bar--skipped { background: linear-gradient(90deg, #94a3b8, #64748b); }
.span-annotation {
  position: absolute;
  top: 9px;
  border: 1px solid #fbbf24;
  border-radius: 3px;
  padding: 3px 7px;
  color: #92400e;
  background: #fff7ed;
  font-style: normal;
  font-size: 10px;
  white-space: nowrap;
}
.retry-badge {
  position: absolute;
  top: 31px;
  border: 1px solid #f59e0b;
  border-radius: 3px;
  padding: 3px 5px;
  color: #92400e;
  background: #fff7ed;
  font-size: 9px;
  white-space: nowrap;
}
.legend-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  border-top: 1px solid var(--line-soft);
  padding: 10px 12px;
  color: #475569;
  font-size: 10px;
  font-weight: 750;
}
.legend-row span { display: inline-flex; align-items: center; gap: 7px; }
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #94a3b8;
}
.legend-dot--success { background: var(--green); }
.legend-dot--warning { background: var(--amber); }
.legend-dot--error { background: var(--red); }
.legend-dot--progress { background: var(--blue-2); }
.legend-dot--skipped { background: #94a3b8; }
.dependency-line {
  width: 32px;
  border-top: 1px dashed #64748b;
}

.rca-panel { padding-bottom: 10px; }
.rca-panel h4 {
  margin: 4px 14px 8px;
  font-size: 11px;
  color: #334155;
}
.hypothesis-list {
  display: grid;
  gap: 8px;
  padding: 0 14px;
}
.hypothesis {
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  padding: 10px 10px 8px;
  background: #f8fbff;
}
.hypothesis--danger { border-color: #fca5a5; background: #fff7f7; }
.hypothesis--warning { border-color: #fbbf24; background: #fffbeb; }
.hypothesis__top {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.hypothesis__top span { font-weight: 900; color: #334155; }
.hypothesis__top strong { font-size: 12px; }
.hypothesis__top b { color: #dc2626; }
.hypothesis ul { margin: 8px 0 0 22px; padding: 0; color: #334155; font-size: 11px; line-height: 1.65; }
.mini-link {
  display: inline-flex;
  margin: 10px 14px 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
}
.recommended-action {
  margin: 10px 14px 0;
  border: 1px solid #86efac;
  border-radius: 5px;
  background: #f0fdf4;
  padding: 10px;
}
.recommended-action span, .recommended-action p, .why-line { color: #475569; font-size: 11px; }
.recommended-action strong { display: block; margin-top: 4px; color: #0f172a; font-size: 12px; }
.recommended-action p { margin: 5px 0 8px; line-height: 1.55; }
.recommended-action button {
  float: right;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  color: var(--blue);
  background: #fff;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 850;
}
.why-line { margin: 8px 14px 0; }

.payload-layout {
  display: grid;
  grid-template-columns: 1fr 128px;
  gap: 14px;
  padding: 0 14px 8px;
}
.code-block {
  height: 178px;
  min-height: 0;
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 10px 0;
  color: #334155;
  background: #fbfdff;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.55;
}
.code-block span { display: block; white-space: pre; }
.code-block i { display: inline-block; width: 34px; color: #94a3b8; font-style: normal; text-align: right; margin-right: 12px; }
.redaction-card {
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 14px 12px;
  color: #334155;
  font-size: 11px;
}
.redaction-card strong { font-size: 12px; }
.redaction-card span { color: #15803d; }
.redaction-card button {
  margin-top: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  color: var(--blue);
  min-height: 28px;
  font-weight: 850;
}
.panel-footnote {
  margin: 0 14px 12px;
  color: #64748b;
  font-size: 11px;
}

.eval-table { padding: 0 12px; font-size: 11px; }
.eval-row {
  display: grid;
  grid-template-columns: 1fr 54px 70px 78px 48px;
  align-items: center;
  min-height: 25px;
  border-bottom: 1px solid var(--line-soft);
  color: #334155;
}
.eval-row--head { color: #64748b; font-weight: 850; }
.delta { color: #ef4444; font-weight: 800; }
.delta i {
  display: inline-block;
  height: 2px;
  background: #ef4444;
  margin-right: 6px;
  vertical-align: middle;
}
.impact { font-weight: 850; }
.impact--danger { color: #dc2626; }
.impact--warning { color: #f59e0b; }
.impact--info { color: #2563eb; }

.replay-panel { padding-bottom: 14px; }
.replay-panel p { margin: 0 16px 12px; color: #475569; font-size: 11px; }
.form-grid { display: grid; gap: 6px; padding: 0 16px 8px; }
.form-grid label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  color: #475569;
  font-size: 11px;
}
.form-grid b {
  min-width: 144px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 5px 9px;
  color: #334155;
  background: #fff;
  font-weight: 700;
}
.toggle-row { min-height: 28px !important; }
.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #cbd5e1;
}
.toggle.is-on { background: var(--blue); }
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}
.toggle.is-on::after { left: 17px; }
.primary-button, .secondary-button {
  display: block;
  width: calc(100% - 32px);
  margin: 7px 16px 0;
  min-height: 31px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 850;
}
.primary-button { border: 0; color: #fff; background: linear-gradient(180deg, #2563eb, #1d4ed8); }
.secondary-button { color: var(--blue); background: #fff; }

.tabs {
  display: flex;
  gap: 20px;
  padding: 0 16px;
  color: #64748b;
  font-size: 11px;
  font-weight: 850;
}
.tabs span { padding: 0 0 10px; }
.tabs .is-active { color: var(--blue); border-bottom: 2px solid var(--blue); }
.log-table { padding: 0 12px; font-size: 11px; }
.log-row {
  display: grid;
  grid-template-columns: 88px 70px 98px 1fr;
  align-items: center;
  min-height: 26px;
  border-bottom: 1px solid var(--line-soft);
  color: #334155;
}
.log-row--head { color: #64748b; font-weight: 850; }
.log-level {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 6px;
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
}
.log-level--error { color: #dc2626; background: #fff5f5; border: 1px solid #fca5a5; }
.log-level--warn { color: #b45309; background: #fffbeb; border: 1px solid #fbbf24; }
.log-level--info { color: #2563eb; background: #eff6ff; border: 1px solid #bfdbfe; }

.dashboard--error { min-height: 100vh; display: grid; place-items: center; }
.error-panel { width: min(720px, 90vw); padding: 24px; }
.error-panel h1 { margin: 0 0 12px; color: #0f172a; }

@media (max-width: 1400px) {
  body { min-width: 1060px; }
  .triage-app { grid-template-columns: 168px minmax(890px, 1fr); }
  .dashboard { grid-template-rows: 76px 70px 124px clamp(320px, 32vh, 400px) minmax(245px, 1fr); }
  .incident-card { grid-template-columns: 48px minmax(250px, 1.3fr) auto repeat(3, minmax(106px, 0.52fr)) 112px; }
  .incident-card .metric-block:nth-of-type(n+5) { display: none; }
  .history-panel { grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.25fr) minmax(260px, 1fr); }
  .main-grid { grid-template-columns: 34% 40% 26%; }
  .bottom-grid { grid-template-columns: 34% 27% 0 39%; }
.bottom-grid > .panel { height: 100%; }
  .replay-panel { display: none; }
}




/* Maximize-view fit tuning: keep the right RCA card readable without page-level clipping. */
.rca-panel .panel-head {
  min-height: 42px;
  padding: 8px 14px 6px;
}
.rca-panel h4 {
  margin: 3px 14px 6px;
}
.hypothesis-list {
  gap: 5px;
}
.hypothesis {
  padding: 6px 9px 5px;
}
.hypothesis__top {
  font-size: 11px;
}
.hypothesis__top strong {
  font-size: 11px;
}
.hypothesis ul {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.35;
}
.rca-panel .mini-link {
  margin-top: 6px;
}
.recommended-action {
  margin-top: 6px;
  padding: 7px 9px;
}
.recommended-action p {
  margin: 3px 0 5px;
  line-height: 1.35;
}
.why-line {
  margin-top: 5px;
  line-height: 1.35;
}

/* Compact-window mode:
   - keep the maximized v2-style composition above this breakpoint
   - switch to vertical page flow when the viewport cannot responsibly fit every panel
   - keep dense data grids in their own scroll containers instead of clipping the page */
@media (max-width: 1500px), (max-height: 900px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  body {
    min-width: 0;
    overflow: auto;
  }

  .triage-app {
    grid-template-columns: 72px minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 100vh;
  }

  .brand-mark {
    margin: 14px auto 18px;
    transform: scale(0.82);
    transform-origin: top center;
  }

  .side-nav {
    gap: 6px;
    padding: 0 7px;
  }

  .side-nav--bottom {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .side-nav__item {
    justify-content: center;
    gap: 0;
    min-height: 40px;
    padding: 0;
  }

  .side-nav__item span:not(.side-nav__icon) {
    display: none;
  }

  .side-nav__icon {
    width: 34px;
    height: 34px;
  }

  .dashboard {
    grid-template-rows: auto auto auto auto;
    gap: 8px;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 10px;
  }

  .topbar {
    flex-wrap: wrap;
    align-items: stretch;
    height: auto;
    gap: 8px;
  }

  .topbar h1 {
    margin-bottom: 8px;
    font-size: 20px;
  }

  .filter-row {
    gap: 6px;
  }

  .filter-chip,
  .select-chip {
    flex: 0 0 auto;
    min-height: 28px;
    padding-inline: 10px;
  }

  .select-chip select {
    min-width: 170px;
  }

  .top-actions {
    margin-left: auto;
  }

  .confidence-card {
    min-width: 210px;
    height: 42px;
  }

  .incident-card {
    grid-template-columns: 44px minmax(0, 1fr) auto repeat(2, minmax(104px, 0.42fr)) 112px;
    gap: 10px;
    min-height: 60px;
    padding: 8px;
  }

  .incident-title h2 {
    font-size: 14px;
  }

  .incident-card .metric-block:nth-of-type(n+5) {
    display: none;
  }

  .metric-block {
    min-height: 40px;
    padding-left: 12px;
  }

  .metric-block strong {
    font-size: 18px;
  }

  .history-panel {
    grid-template-columns: minmax(240px, 0.9fr) minmax(420px, 1.3fr);
    grid-template-areas:
      "head metrics"
      "spark spark";
  }

  .history-head { grid-area: head; }
  .history-metrics { grid-area: metrics; }
  .history-spark { grid-area: spark; height: 78px; }

  .main-grid,
  .bottom-grid {
    display: grid;
    gap: 8px;
    height: auto;
    min-height: 0;
    margin-top: 0;
  }

  .main-grid {
    grid-template-columns: minmax(560px, 1.3fr) minmax(330px, 0.75fr);
    grid-template-areas:
      "trace rca"
      "waterfall waterfall";
  }

  .trace-tree-panel { grid-area: trace; }
  .waterfall-panel { grid-area: waterfall; }
  .rca-panel { grid-area: rca; }

  .bottom-grid {
    grid-template-columns: minmax(430px, 1fr) minmax(360px, 0.92fr);
    grid-template-areas:
      "payload eval"
      "replay logs";
  }

  .payload-panel { grid-area: payload; }
  .eval-panel { grid-area: eval; }
  .replay-panel { grid-area: replay; }
  .logs-panel { grid-area: logs; }

  .bottom-grid > .panel {
    height: auto;
  }

  .replay-panel {
    display: block;
  }

  .panel {
    min-height: 0;
  }

  .trace-tree-panel,
  .waterfall-panel,
  .rca-panel,
  .payload-panel,
  .eval-panel,
  .replay-panel,
  .logs-panel {
    min-height: 260px;
  }

  .panel-head {
    min-height: 44px;
    padding: 8px 12px 7px;
  }

  .trace-table,
  .eval-table,
  .log-table {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .trace-row {
    min-width: 780px;
  }

  .eval-row {
    min-width: 480px;
  }

  .log-row {
    min-width: 620px;
  }

  .waterfall-panel {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .waterfall-panel .panel-head,
  .timeline-scale,
  .waterfall-body,
  .legend-row {
    min-width: 660px;
  }

  .waterfall-body {
    padding-bottom: 12px;
  }

  .legend-row {
    justify-content: flex-start;
    padding-left: 180px;
  }

  .payload-layout {
    grid-template-columns: minmax(430px, 1fr) 128px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .code-block {
    height: 178px;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid label {
    align-items: stretch;
    flex-direction: column;
    gap: 5px;
  }

  .form-grid b {
    min-width: 0;
  }

  .toggle-row {
    flex-direction: row !important;
    align-items: center !important;
  }
}

@media (max-width: 1180px) {
  .main-grid,
  .bottom-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: none;
  }

  .trace-tree-panel,
  .waterfall-panel,
  .rca-panel,
  .payload-panel,
  .eval-panel,
  .replay-panel,
  .logs-panel {
    grid-area: auto;
  }
}

@media (max-width: 760px) {
  .triage-app {
    display: block;
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    width: auto;
    height: calc(64px + env(safe-area-inset-bottom));
    min-height: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.28);
    border-right: 0;
    box-shadow: 0 -14px 32px rgba(2, 8, 23, 0.34);
  }

  .brand-mark,
  .side-nav--bottom {
    display: none;
  }

  .sidebar > .side-nav:not(.side-nav--bottom) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    height: 100%;
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  }

  .sidebar > .side-nav:not(.side-nav--bottom) .side-nav__item:nth-child(n+6) {
    display: none;
  }

  .side-nav__item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    border-radius: 8px;
  }

  .side-nav__item span:not(.side-nav__icon) {
    display: block;
    max-width: 68px;
    overflow: hidden;
    color: #d7e2f1;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
    line-height: 1.1;
    font-weight: 800;
  }

  .side-nav__icon {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .dashboard {
    padding: 8px 8px 12px;
  }

  .dashboard > * {
    min-width: 0;
    max-width: 100%;
  }

  .top-actions {
    width: 100%;
    margin-left: 0;
  }

  .language-switch,
  .confidence-card {
    flex: 1 1 auto;
  }

  .confidence-card {
    min-width: 0;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar > div:first-child {
    min-width: 0;
    width: 100%;
  }

  .filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .filter-chip,
  .select-chip,
  .outline-button,
  .secondary-button,
  .primary-button,
  .control-pair span,
  .search-box {
    min-height: 44px;
  }

  .select-chip select {
    min-height: 40px;
  }

  .lang-button {
    min-height: 44px;
    flex: 1 1 auto;
  }

  .select-chip select {
    min-width: 160px;
  }

  .incident-card {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
  }

  .incident-alert {
    width: 42px;
    height: 42px;
  }

  .incident-title h2 {
    line-height: 1.35;
  }

  .severity-pill {
    align-self: center;
  }

  .incident-card .metric-block {
    display: grid;
    grid-column: 1 / -1;
    min-height: 0;
    border-top: 1px solid var(--line-soft);
    border-left: 0;
    padding: 8px 0 0;
  }

  .incident-card .metric-block:nth-of-type(n+5) {
    display: none;
  }

  .incident-card .outline-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .trace-tree-panel { order: 1; }
  .rca-panel { order: 2; }
  .waterfall-panel { order: 3; }

  .history-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "metrics"
      "spark";
  }

  .history-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .decision-stack {
    grid-auto-flow: column;
    justify-content: start;
    justify-items: start;
    align-items: center;
    width: 100%;
  }

  .history-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-spark {
    overflow-x: auto;
    min-width: 0;
    scrollbar-width: thin;
  }

  .history-run {
    min-width: 80px;
  }

  .trace-tree-panel,
  .waterfall-panel,
  .rca-panel,
  .payload-panel,
  .eval-panel,
  .replay-panel,
  .logs-panel {
    min-height: 0;
  }

  .panel-head {
    gap: 8px;
  }

  .panel-head--controls {
    flex-wrap: wrap;
  }

  .control-pair {
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: thin;
  }

  .payload-layout,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .payload-layout {
    overflow-x: visible;
  }

  .code-block {
    overflow: auto;
  }

  .recommended-action button,
  .redaction-card button {
    min-height: 44px;
  }

  .redaction-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .redaction-card strong,
  .redaction-card button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 420px) {
  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .language-switch,
  .confidence-card {
    width: 100%;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .language-switch {
    min-width: 132px;
  }

  .confidence-card {
    flex-basis: 148px;
    padding-inline: 12px;
  }

  .confidence-card strong {
    font-size: 22px;
  }

  .incident-title h2 {
    font-size: 13px;
  }

  .panel-head h3 {
    font-size: 13px;
  }
}
