:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --panel: #121722;
  --inset: #0e1219;
  --border: #232b3a;
  --text: #e8ecf3;
  --muted: #8b94a7;
  --accent: #53c7f0;
  --ok: #3fb968;
  --warn: #d9a03f;
  --down: #e5534b;
  --info: #5b9dd9;
  --radius: 10px;
  --sidebar: 200px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  overflow-x: hidden;
}

body {
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
}

img,
svg,
pre,
code {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: var(--sidebar);
  border-right: 1px solid var(--border);
  background: #090c12;
  padding: 18px 12px;
}

.mobile-nav {
  display: none;
}

.wordmark {
  margin: 0 8px 18px;
  color: var(--text);
  font-weight: 650;
  font-size: 20px;
  letter-spacing: 0;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-group {
  min-width: 0;
}

.nav-group summary {
  display: flex;
  align-items: center;
  min-height: 36px;
  margin: 8px 0 2px;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.nav-group summary:hover,
.nav-group summary:focus-visible {
  color: var(--text);
  background: rgba(83, 199, 240, 0.08);
}

.nav-group .nav-link {
  margin-left: 10px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  padding: 8px 10px;
  color: var(--muted);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--text);
  background: rgba(83, 199, 240, 0.08);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(83, 199, 240, 0.12);
}

main {
  width: min(100% - var(--sidebar), 1200px);
  max-width: 1200px;
  min-width: 0;
  margin-left: var(--sidebar);
  padding: 24px;
  overflow-x: hidden;
}

.page-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #151b27, var(--panel));
  padding: 16px 20px;
}

.page-strip h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 650;
}

.page-strip p {
  max-width: 820px;
  margin: 4px 0 0;
  color: var(--muted);
}

.panel {
  min-width: 0;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

.narrative-lede {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #151b27, var(--panel));
  padding: 20px;
}

.narrative-lede p {
  max-width: 980px;
  margin: 0;
  color: var(--text);
  font-size: clamp(1.05rem, 4.5vw, 1.45rem);
  line-height: 1.35;
  font-weight: 560;
  overflow-wrap: anywhere;
}

.narrative-lede a {
  overflow-wrap: anywhere;
}

.sentence-list,
.evidence-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.narrative-lines p,
.answer-lines p {
  margin: 0 0 10px;
}

.narrative-lines p:last-child,
.answer-lines p:last-child {
  margin-bottom: 0;
}

.ask-panel {
  display: grid;
  gap: 12px;
}

.ask-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.ask-form input {
  min-height: 48px;
  font-size: 16px;
}

.example-chips a:hover {
  text-decoration: none;
}

.answer-panel {
  border-left: 3px solid var(--accent);
}

.needs-list,
.job-grid {
  display: grid;
  gap: 12px;
}

.need-item,
.job-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--inset);
  padding: 14px;
}

.need-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}

.need-copy {
  min-width: 0;
}

.need-item h2,
.job-card h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.need-item p,
.job-card p {
  margin: 0 0 8px;
}

.clarity-card {
  align-items: start;
}

.clarity-sections {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.clarity-section {
  min-width: 0;
  border-left: 3px solid rgba(83, 199, 240, 0.45);
  border-radius: 6px;
  background: rgba(83, 199, 240, 0.05);
  padding: 10px 12px;
}

.clarity-section.why {
  border-left-color: rgba(217, 160, 63, 0.55);
  background: rgba(217, 160, 63, 0.06);
}

.clarity-section.next {
  border-left-color: rgba(63, 185, 104, 0.55);
  background: rgba(63, 185, 104, 0.06);
}

.clarity-section h3 {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.clarity-section p {
  margin: 0;
  overflow-wrap: anywhere;
}

.need-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
}

.need-meta span,
.need-meta a {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.job-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.job-status.good { color: var(--ok); }
.job-status.bad { color: var(--down); }

.verdict {
  margin-top: 0;
  font-size: 18px;
  font-weight: 700;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
}

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

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2,
.panel-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

.gauge {
  background:
    radial-gradient(circle at 100% 0, rgba(83, 199, 240, 0.12), transparent 34%),
    var(--panel);
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 6px;
  font: 700 26px/1.1 var(--mono);
  color: var(--text);
}

.metric-context {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.status-readout {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gate-list {
  display: grid;
  gap: 8px;
}

.gate-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--inset);
  padding: 8px 10px;
}

.gate-name {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--inset);
  padding: 4px 9px;
  color: var(--muted);
  font-size: 13px;
  white-space: normal;
}

.chip.good { color: var(--ok); border-color: rgba(63, 185, 104, 0.45); }
.chip.warn { color: var(--warn); border-color: rgba(217, 160, 63, 0.45); }
.chip.bad { color: var(--down); border-color: rgba(229, 83, 75, 0.45); }

.led {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 999px;
  background: var(--info);
  box-shadow: 0 0 0 3px rgba(91, 157, 217, 0.12);
}

.good .led,
.health-healthy .led,
.health-ok .led,
.health-pass .led,
.led-pass { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 104, 0.12); }

.warn .led,
.health-degraded .led,
.led-run,
.led-unknown { background: var(--warn); box-shadow: 0 0 0 3px rgba(217, 160, 63, 0.12); }

.bad .led,
.health-down .led,
.health-fail .led,
.health-error .led,
.led-fail { background: var(--down); box-shadow: 0 0 0 3px rgba(229, 83, 75, 0.12); }

.health {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  font-size: 13px;
}

.section-row > td {
  padding: 0;
}

.section-row details {
  padding: 10px 12px;
}

.section-row summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

th,
td {
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  padding: 10px 9px;
  text-align: left;
}

tbody tr:nth-child(even) td { background: var(--inset); }

tbody tr:hover td { background: rgba(83, 199, 240, 0.07); }

tr:last-child td { border-bottom: 0; }

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #171d2a;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.subject {
  max-width: 520px;
  overflow-wrap: anywhere;
}

.muted { color: var(--muted); }

.mono,
pre,
td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
  font-family: var(--mono);
}

pre {
  max-width: 100%;
  max-height: 70vh;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--inset);
  color: var(--text);
  padding: 14px;
  font-size: 12.5px;
}

form.inline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

input,
select,
textarea,
button {
  min-height: 36px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--inset);
  color: var(--text);
  font: inherit;
  padding: 7px 10px;
}

.touch {
  min-width: 44px;
  min-height: 44px;
}

.chip.touch {
  min-height: 44px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

button:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(83, 199, 240, 0.08);
}

button.primary {
  color: #061119;
  border-color: var(--accent);
  background: var(--accent);
}

button.secondary {
  color: var(--muted);
  background: transparent;
}

button.danger {
  color: #fff;
  border-color: rgba(229, 83, 75, 0.55);
  background: rgba(229, 83, 75, 0.18);
}

button.promoted {
  border-color: var(--warn);
  background: rgba(217, 160, 63, 0.18);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.result {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--inset);
  padding: 10px;
}

.tip {
  position: relative;
  cursor: help;
  text-decoration: underline dotted rgba(139, 148, 167, 0.7);
  text-underline-offset: 3px;
}

.tip-glyph {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
  font-size: .92em;
  text-decoration: none;
}

.tip::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 100;
  width: max-content;
  max-width: 280px;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
  color: var(--text);
  content: attr(data-tip);
  font: 12.5px/1.35 var(--sans);
  letter-spacing: 0;
  opacity: 0;
  padding: 9px 10px;
  pointer-events: none;
  text-align: left;
  text-transform: none;
  transition: opacity 120ms ease;
  visibility: hidden;
  white-space: normal;
}

.tip:hover::after,
.tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.tip-right::after {
  top: 50%;
  bottom: auto;
  left: calc(100% + 10px);
  transform: translateY(-50%);
}

.tip-left::after {
  right: 0;
  left: auto;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 20;
    display: block;
    border-bottom: 1px solid var(--border);
    background: #090c12;
  }

  .mobile-nav > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 8px 12px;
    cursor: pointer;
    list-style: none;
  }

  .mobile-nav > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-wordmark {
    color: var(--accent);
    font: 800 18px/1 var(--mono);
  }

  .hamburger,
  .hamburger::before,
  .hamburger::after {
    display: block;
    width: 24px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
  }

  .hamburger {
    position: relative;
  }

  .hamburger::before,
  .hamburger::after {
    position: absolute;
    left: 0;
    content: "";
  }

  .hamburger::before { top: -7px; }
  .hamburger::after { top: 7px; }

  .mobile-nav nav {
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    border-top: 1px solid var(--border);
    padding: 8px 12px 14px;
  }

  .mobile-nav:not([open]) nav {
    display: none;
  }

  .mobile-nav .nav-link,
  .mobile-nav .nav-group summary {
    min-height: 44px;
  }

  .mobile-nav .nav-group .nav-link {
    margin-left: 0;
  }

  .tip-right::after {
    top: auto;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
  }

  main {
    width: 100%;
    max-width: none;
    margin-left: 0;
    padding: 68px 16px 16px;
  }

  .page-strip {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .toolbar,
  form.inline,
  .touch-form,
  .actions {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    width: 100%;
  }

  .toolbar label,
  .toolbar input,
  .toolbar select,
  .toolbar button,
  .touch-form input:not([type="hidden"]),
  .touch-form select,
  .touch-form button,
  .ask-form input,
  .ask-form button {
    width: 100%;
  }

  .chips {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chip {
    width: 100%;
  }

  .need-item .actions {
    min-width: 0;
  }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .job-grid,
  .need-item { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
  .sidebar {
    display: block;
  }

  .mobile-nav {
    display: none;
  }
}

@media (max-width: 620px) {
  main {
    padding: 16px;
    padding-top: 68px;
  }
  .page-strip,
  .panel,
  .metric { padding: 12px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .toolbar label { width: 100%; }
  .toolbar input { width: 100%; }
  .ask-form { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 1fr; }
}
