:root {
  color-scheme: dark;
  --bg: #060a0d;
  --bg-2: #0a1115;
  --panel: #10171c;
  --panel-2: #151d23;
  --line: #28323a;
  --line-soft: #1c252c;
  --text: #eef5f6;
  --muted: #92a1a8;
  --soft: #c8d4d8;
  --cyan: #51c6dc;
  --cyan-soft: rgba(81, 198, 220, 0.14);
  --amber: #f2a30f;
  --amber-soft: rgba(242, 163, 15, 0.16);
  --red: #ff5c57;
  --red-soft: rgba(255, 92, 87, 0.13);
  --green: #7bcf5f;
  --green-soft: rgba(123, 207, 95, 0.12);
  --radius: 8px;
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(81, 198, 220, 0.05), transparent 34rem),
    radial-gradient(circle at 70% 0%, rgba(242, 163, 15, 0.06), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 10, 13, 0.92);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(81, 198, 220, 0.7);
  border-radius: 7px;
  background:
    linear-gradient(90deg, transparent 47%, rgba(81, 198, 220, 0.85) 47% 53%, transparent 53%),
    linear-gradient(0deg, transparent 47%, rgba(81, 198, 220, 0.85) 47% 53%, transparent 53%),
    var(--cyan-soft);
  box-shadow: 0 0 0 4px rgba(81, 198, 220, 0.04);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.05;
}

.brand p,
.panel-heading p,
.compact p,
.scene small,
.rail-note {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.text-link {
  color: var(--cyan);
  font-weight: 650;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.verdict-lock {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 650;
}

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

.scenario-rail,
.gate-rail {
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: rgba(10, 17, 21, 0.76);
}

.gate-rail {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.rail-title {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.scenario {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
  text-align: left;
}

.scenario:hover,
.scenario:focus-visible {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
  outline: none;
}

.scenario strong {
  min-width: 28px;
  padding: 3px 0;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  text-align: center;
}

.scenario.is-active {
  border-color: rgba(81, 198, 220, 0.35);
  background: linear-gradient(90deg, rgba(81, 198, 220, 0.18), rgba(81, 198, 220, 0.05));
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--cyan);
}

.rail-note {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
}

.primary-panel {
  min-width: 0;
  padding: 16px;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 23, 28, 0.78);
  box-shadow: var(--shadow);
}

.scene {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 9px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--panel);
}

.scene span {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--soft);
  font-weight: 800;
}

.scene strong {
  align-self: end;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.scene small {
  display: block;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.25;
}

.scene.is-done span {
  color: var(--green);
  background: var(--green-soft);
}

.scene.is-alert {
  border-color: rgba(255, 92, 87, 0.45);
}

.scene.is-alert span {
  color: var(--red);
  background: var(--red-soft);
}

.scene.is-review span {
  color: var(--amber);
  background: var(--amber-soft);
}

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0 12px;
}

.panel-heading h2 {
  font-size: 16px;
  line-height: 1.2;
}

.panel-heading p {
  margin-top: 3px;
  font-size: 12px;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--panel);
}

.mode-toggle button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mode-toggle button:last-child {
  border-right: 0;
}

.mode-toggle .is-selected {
  color: var(--text);
  background: rgba(81, 198, 220, 0.13);
}

.intake-form {
  display: grid;
  grid-template-columns: 1.05fr 150px 1.3fr 1.5fr 112px;
  gap: 10px;
  margin-bottom: 12px;
}

.intake-form label {
  min-width: 0;
}

.intake-form span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.intake-form input,
.intake-form textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  resize: vertical;
}

.intake-form textarea {
  min-height: 40px;
  max-height: 120px;
}

.intake-form input:focus,
.intake-form textarea:focus {
  outline: 2px solid rgba(81, 198, 220, 0.35);
  outline-offset: 1px;
}

.intake-form button,
.panel-heading button,
dialog button {
  min-height: 40px;
  align-self: end;
  border: 1px solid rgba(81, 198, 220, 0.45);
  border-radius: 7px;
  padding: 0 14px;
  background: var(--cyan-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.intake-form button:hover,
.panel-heading button:hover,
dialog button:hover {
  background: rgba(81, 198, 220, 0.22);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 23, 28, 0.82);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 15%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 7%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 17%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 22%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 12%;
}

th:nth-child(6),
td:nth-child(6) {
  width: 8%;
}

th:nth-child(7),
td:nth-child(7) {
  width: 10%;
}

th:nth-child(8),
td:nth-child(8) {
  width: 9%;
}

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

th:last-child,
td:last-child {
  border-right: 0;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #131b20;
  color: var(--text);
  font-size: 12px;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

td {
  color: var(--soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.source-name {
  display: block;
  color: var(--text);
  font-weight: 750;
}

.source-url {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.evidence-quote {
  color: var(--text);
}

.is-flagged td {
  background: var(--red-soft);
  box-shadow: inset 3px 0 0 var(--red);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--soft);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.tag::before {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  content: "";
  background: currentColor;
}

.tag.pass {
  color: var(--green);
  border-color: rgba(123, 207, 95, 0.3);
  background: var(--green-soft);
}

.tag.warn {
  color: var(--amber);
  border-color: rgba(242, 163, 15, 0.35);
  background: var(--amber-soft);
}

.tag.fail {
  color: var(--red);
  border-color: rgba(255, 92, 87, 0.35);
  background: var(--red-soft);
}

.gate-card,
.routing-card {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

.gate-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.gate-card h3 {
  margin: 0;
  font-size: 14px;
}

.gate-card p,
.gate-card li,
.routing-card {
  color: var(--muted);
  font-size: 12px;
}

.gate-status {
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.gate-status.pass {
  color: var(--green);
}

.gate-status.warn {
  color: var(--amber);
}

.gate-status.fail {
  color: var(--red);
}

.gate-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.routing-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--soft);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.routing-card strong {
  color: var(--amber);
  font-size: 13px;
}

.review-band {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 16px;
  padding: 0 16px 18px;
}

.review-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(16, 23, 28, 0.78);
  box-shadow: var(--shadow);
}

.compact {
  align-items: center;
  margin: 0 0 12px;
}

.queue-table {
  overflow: auto;
}

.queue-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1.15fr) minmax(0, 1fr) 92px;
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--line-soft);
  color: var(--soft);
  font-size: 12px;
}

.queue-row strong {
  color: var(--text);
}

.empty-state {
  display: none;
  min-height: 72px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state.is-visible {
  display: grid;
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}

.timeline li::before {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  content: "";
  background: var(--green);
}

.timeline .warn::before {
  background: var(--amber);
}

.timeline .fail::before {
  background: var(--red);
}

.timeline strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

.timeline time {
  color: var(--muted);
  white-space: nowrap;
}

dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.55);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

dialog form {
  margin: 0;
  padding: 18px;
}

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

.dialog-head h2 {
  font-size: 18px;
}

.dialog-head button {
  min-width: 38px;
  padding: 0;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

dialog dl {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
  color: var(--soft);
}

dialog dt {
  color: var(--muted);
  font-weight: 800;
}

dialog dd {
  margin: 0;
}

dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .gate-rail {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .gate-rail .rail-title {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }
}

@media (max-width: 880px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    white-space: normal;
  }

  .workspace,
  .review-band {
    display: block;
  }

  .scenario-rail,
  .gate-rail,
  .primary-panel,
  .review-band {
    border: 0;
    padding: 14px;
  }

  .workflow-strip,
  .gate-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intake-form {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .review-panel {
    margin-bottom: 14px;
  }

  .queue-row {
    grid-template-columns: 1fr;
  }

  .timeline li {
    grid-template-columns: 16px minmax(0, 1fr);
  }

  .timeline time {
    grid-column: 2;
  }
}

@media (max-width: 480px) {
  .workflow-strip,
  .gate-rail {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .verdict-lock,
  .text-link {
    width: 100%;
  }
}
