:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-quiet: #edf1f7;
  --ink: #17202a;
  --muted: #637083;
  --line: #d8dee8;
  --blue: #255fbe;
  --green: #207a4c;
  --red: #b83232;
  --amber: #9b6400;
  --shadow: 0 10px 30px rgba(31, 45, 61, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
}

button.secondary {
  min-height: 30px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.status {
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-quiet);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 34px) 34px;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) repeat(6, minmax(130px, 1fr)) 90px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(37, 95, 190, 0.18);
  outline-offset: 1px;
}

.focus-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.focus-panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.timestamp {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.boundary-grid {
  display: grid;
  grid-template-columns: 1.15fr repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.boundary-card {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.boundary-card.read-only {
  border-top: 4px solid var(--blue);
}

.boundary-card.gated {
  border-top: 4px solid var(--red);
}

.boundary-card.evidence {
  border-top: 4px solid var(--green);
}

.boundary-card h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.boundary-body {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.boundary-stat {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.boundary-stat strong {
  color: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px;
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.brief-mode {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brief-head {
  align-items: flex-start;
}

.brief-head h2 {
  margin: 0;
  font-size: 17px;
}

.brief-lens-grid,
.brief-section-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.brief-lens-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.brief-section-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.brief-card,
.brief-section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.brief-card h3,
.brief-section h3 {
  margin: 0;
  font-size: 14px;
}

.brief-card .stack,
.brief-section .stack {
  padding: 0;
}

.scope-line,
.provenance-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.claim {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.claim strong {
  font-size: 13px;
}

.claim p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #e8eef9;
  color: var(--blue);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.pill.danger {
  background: #fae7e7;
  color: var(--red);
}

.stack,
.summary-list,
.row-list,
#next-decision {
  padding: 14px;
}

.item {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.item:first-child {
  padding-top: 0;
}

.item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.item h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.command {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.command code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1720;
  color: #f6f8fb;
  padding: 8px;
  font-size: 12px;
}

.payload-preview {
  display: grid;
  gap: 8px;
}

.payload-preview code {
  display: block;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1720;
  color: #f6f8fb;
  padding: 8px;
  font-size: 12px;
}

.action-route {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-list {
  display: grid;
  gap: 9px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
  color: var(--muted);
  font-size: 13px;
}

.summary-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary-row strong {
  color: var(--ink);
}

.report-drilldown-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 14px;
}

.drilldown-section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  border-top: 3px solid var(--line);
  padding-top: 10px;
}

.drilldown-section h3 {
  margin: 0;
  font-size: 14px;
}

.drilldown-section .item {
  padding: 9px 0;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
}

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

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 3px 7px;
  font-size: 12px;
}

.source-work_core {
  color: var(--green);
}

.source-studio {
  color: var(--blue);
}

.source-external_evidence,
.source-client_report {
  color: var(--amber);
}

.source-missing_data,
.source-blocked {
  color: var(--red);
}

.source-needs_review {
  color: var(--amber);
}

.source-ready,
.source-informational {
  color: var(--green);
}

@media (max-width: 1100px) {
  .control-panel,
  .boundary-grid,
  .metric-grid,
  .content-grid,
  .brief-lens-grid,
  .brief-section-grid,
  .report-drilldown-grid {
    grid-template-columns: 1fr 1fr;
  }

  .limit-control,
  .control-panel button {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .topbar,
  .focus-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .status,
  .timestamp {
    max-width: 100%;
    white-space: normal;
  }

  .control-panel,
  .boundary-grid,
  .metric-grid,
  .content-grid,
  .brief-lens-grid,
  .brief-section-grid,
  .report-drilldown-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }
}