:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-soft: #f2f5f8;
  --text: #1a1f24;
  --muted: #5c6b7a;
  --line: #d9dee4;
  --accent: #1f5fa8;
  --accent-strong: #0e2438;
  --warning: #8a5a00;
  --warning-bg: #fff4d6;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
  --ok: #1c7c43;
  --ok-bg: #e5f4ea;
  --shadow: 0 10px 28px rgb(14 36 56 / 8%);
  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;
  color: var(--text);
  background: var(--bg);
}

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

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  color: #f8fbf8;
  background: #0e2438;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #17221c;
  background: #dbe6f0;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #b8c8be;
  font-size: 0.85rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: #dfe8e2;
}

.nav-item.active {
  color: #0e2438;
  background: #dbe6f0;
  font-weight: 700;
}

.nav-item.disabled {
  color: #87958d;
}

.guardrail {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 14px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 8px;
  color: #b8c8be;
  font-size: 0.85rem;
}

.guardrail strong {
  color: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 18px;
  max-width: 1360px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.3rem, 2.3rem);
  line-height: 1.1;
}

.topbar-copy {
  max-width: 680px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.topbar-actions,
.badge-list,
.filter-group,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill,
.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill.private,
.badge.neutral {
  color: var(--accent-strong);
  background: #e5f4ee;
  border-color: #bddbcf;
}

.status-pill.draft {
  color: #6d4b07;
  background: var(--warning-bg);
  border-color: #f3d491;
}

.status-pill.locked {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #efb2aa;
}

.toast,
.kill-banner {
  max-width: 1360px;
  margin: 0 auto 14px;
  border: 1px solid #f3d491;
  border-radius: 8px;
  padding: 12px 14px;
  color: #6d4b07;
  background: var(--warning-bg);
  font-size: 0.9rem;
  font-weight: 700;
}

.kill-banner {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #efb2aa;
}

.kill-banner span {
  color: #6c302c;
  font-weight: 600;
}

.badge.warn {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: #f3d491;
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #f0b4ad;
}

.badge.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: #bfe2c9;
}

.dashboard-stack {
  display: grid;
  gap: 14px;
  max-width: 1360px;
  margin: 0 auto;
}

.panel,
.metric-card,
.provider-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.scenario-panel,
.toolbar-panel,
.provider-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.toolbar-panel {
  flex-wrap: wrap;
}

.panel-label,
.cell-note,
.muted,
.provider-strip span {
  color: var(--muted);
  font-size: 0.82rem;
}

.panel-label,
.cell-note {
  display: block;
}

.scenario-button,
.filter-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
}

.bucket-filter {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.bucket-filter select {
  min-height: 36px;
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

.scenario-button.active,
.filter-button.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

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

.metric-card {
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.75rem;
}

.provider-strip {
  align-items: flex-start;
}

.provider-strip div {
  display: grid;
  gap: 4px;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

td strong {
  display: block;
  margin-bottom: 4px;
}

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

.evidence-links {
  display: grid;
  gap: 5px;
  min-width: 190px;
}

.evidence-links span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.snippet-link {
  max-width: 300px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.filtered-empty {
  margin: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #fbfcfe;
  text-align: center;
}

.state-panel {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 32px;
  text-align: center;
}

.state-panel p {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
}

.split-header,
.section-heading,
.kill-switch-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.section-heading {
  border-bottom: 1px solid var(--line);
}

.section-heading h2,
.split-header h2,
.kill-switch-panel h2 {
  margin: 4px 0 0;
}

.queue-list,
.timeline {
  display: grid;
  gap: 12px;
}

.queue-item {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.queue-main {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
  gap: 18px;
}

.queue-main h2 {
  margin: 4px 0 6px;
}

.queue-main p,
.audit-event p,
.kill-switch-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.queue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.compact {
  display: grid;
  align-items: start;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.action-button,
.danger-button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
}

.action-button:disabled,
.danger-button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.text-link {
  font-weight: 800;
}

.resolution-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(280px, 1fr) minmax(260px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.detail-panel,
.candidate-card,
.field-card {
  display: grid;
  gap: 12px;
}

.detail-panel {
  padding: 16px;
}

.candidate-card,
.field-card,
.confirmation-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.field-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.field-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.candidate-list,
.evidence-list {
  display: grid;
  gap: 8px;
}

.evidence-list span {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-card label,
td label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input {
  min-height: 34px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

input[type="checkbox"] {
  width: 20px;
}

.draft-preview {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--muted);
}

.audit-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 14px;
}

.audit-event code {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  color: var(--accent-strong);
  background: var(--surface-soft);
  font-size: 0.76rem;
}

.kill-switch-panel.engaged {
  border-color: #efb2aa;
  background: #fff8f7;
}

.spinner {
  width: 36px;
  height: 36px;
  margin-bottom: 18px;
  border: 3px solid #c9d6ce;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

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

  .guardrail {
    margin-top: 0;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .scenario-panel,
  .toolbar-panel,
  .provider-strip,
  .split-header,
  .section-heading,
  .kill-switch-panel,
  .kill-banner {
    flex-direction: column;
    align-items: stretch;
  }

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

  .queue-main,
  .queue-grid,
  .resolution-grid,
  .audit-event {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .nav-list,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .segmented,
  .filter-group,
  .bucket-filter {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .scenario-button,
  .filter-button,
  .status-pill,
  .bucket-filter select {
    justify-content: center;
    width: 100%;
    max-width: none;
  }
}
