:root {
  color-scheme: dark;
  --ink: #e6edf3;
  --muted: #9fb0c3;
  --soft: #101923;
  --paper: #111c27;
  --line: #263747;
  --nav: #08111c;
  --nav-soft: #132233;
  --blue: #60a5fa;
  --teal: #2dd4bf;
  --green: #22c55e;
  --yellow: #facc15;
  --orange: #f97316;
  --red: #ef4444;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0b121c;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: linear-gradient(180deg, #041512 0%, #071f1a 55%, #06120f 100%);
  color: #f8fafc;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: #123f47;
  font-weight: 800;
}

.brand h1,
.page-head h2,
.panel-title h3,
.threat-key h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.05rem;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow,
.threat-key small {
  color: #8ba2b8;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.nav-tab {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: #c7d6e6;
  text-align: left;
}

.nav-tab:hover,
.nav-tab.active {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(20, 83, 74, 0.42);
  color: #ffffff;
}

.threat-key {
  margin-top: 34px;
  margin-bottom: 46px;
  padding-top: 24px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.app-footer {
  position: fixed;
  left: 24px;
  bottom: 18px;
  width: 236px;
  color: #7ea69f;
  font-size: 0.78rem;
  font-weight: 700;
}

.threat-key h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
}

.threat-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  align-items: center;
  gap: 11px;
  margin-top: 16px;
}

.threat-item span {
  width: 10px;
  height: 34px;
  border-radius: 4px;
}

.threat-item strong {
  display: block;
  font-size: 0.9rem;
}

.threat-item small {
  display: block;
  margin-top: 2px;
  line-height: 1.3;
}

.threat-item.low span {
  background: var(--green);
}

.threat-item.moderate span {
  background: var(--yellow);
}

.threat-item.elevated span {
  background: var(--orange);
}

.threat-item.flagged span {
  background: var(--red);
}

main {
  min-width: 0;
  padding: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.page-head h2 {
  font-size: clamp(1.8rem, 3vw, 2.65rem);
  line-height: 1.05;
}

.screening-grid,
.data-grid,
.policy-grid,
.help-grid {
  display: grid;
  gap: 18px;
  align-items: start;
}

.screening-grid {
  grid-template-columns: minmax(360px, 1.05fr) minmax(320px, 0.95fr);
}

.data-grid {
  grid-template-columns: minmax(520px, 1fr) 330px;
}

.policy-grid {
  grid-template-columns: minmax(420px, 0.92fr) minmax(360px, 1.08fr);
}

.help-grid {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
}

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

.intake-panel,
.results-panel,
.graph-panel,
.rules-panel,
.wide-panel,
.queue-panel,
.policy-editor-panel,
.policy-rules-panel,
.help-panel {
  padding: 20px;
}

.wide-panel {
  grid-row: span 2;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-title h3 {
  font-size: 1.05rem;
}

.status-pill,
.run-chip,
.risk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.run-chip,
.status-pill.neutral {
  border-color: #33485a;
  background: #142130;
  color: #b7c8d9;
}

.status-pill.low,
.risk-badge.low {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
}

.status-pill.moderate,
.risk-badge.moderate {
  border-color: rgba(250, 204, 21, 0.45);
  background: rgba(250, 204, 21, 0.12);
  color: var(--yellow);
}

.status-pill.elevated,
.risk-badge.elevated {
  border-color: rgba(249, 115, 22, 0.42);
  background: rgba(249, 115, 22, 0.13);
  color: var(--orange);
}

.status-pill.flagged,
.risk-badge.flagged {
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.13);
  color: var(--red);
}

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

label span,
.preview-head,
th {
  color: #a9bacb;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #33485a;
  border-radius: 8px;
  background: #0c1520;
  color: var(--ink);
}

select,
input {
  height: 44px;
  margin-top: 7px;
  padding: 0 12px;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(96, 165, 250, 0.24);
  outline-offset: 2px;
}

.llm-config {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(160px, 0.55fr) minmax(240px, 1fr);
  gap: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.wide-label {
  min-width: 0;
}

.protocol-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 16px;
  align-items: stretch;
}

.upload-zone {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  border: 1px dashed #426070;
  border-radius: 8px;
  padding: 16px;
  background: var(--soft);
}

.upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-zone strong,
.upload-zone small {
  display: block;
  grid-column: 2;
}

.upload-zone small {
  margin-top: -8px;
  color: var(--muted);
}

.upload-icon {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.12);
  color: var(--teal);
  font-size: 1.5rem;
  font-weight: 700;
}

.secondary-action,
.primary-action,
.text-action,
.icon-action {
  border-radius: 8px;
  font-weight: 800;
}

.secondary-action {
  border: 1px solid #33485a;
  background: #0c1520;
  color: #d8e3ef;
  padding: 0 16px;
}

.secondary-action:hover,
.text-action:hover,
.icon-action:hover {
  background: #162536;
}

.protocol-preview {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.preview-head,
.panel-actions,
.sample-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-head {
  padding: 10px 12px;
  background: #0d1722;
}

.sample-actions {
  justify-content: flex-end;
}

.sample-actions select {
  width: min(240px, 45vw);
  height: 34px;
  margin-top: 0;
  font-size: 0.82rem;
  text-transform: none;
}

.panel-actions {
  justify-content: flex-end;
}

.text-action {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 4px 0;
}

pre {
  min-height: 180px;
  max-height: 300px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  background: #09111b;
  color: #d8e3ef;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.validation-summary {
  display: none;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d1722;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.validation-summary.active {
  display: block;
}

.validation-summary strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.validation-summary ul {
  margin: 0;
  padding-left: 18px;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.primary-action {
  border: 1px solid #2563eb;
  background: #1d4ed8;
  color: #ffffff;
  padding: 11px 16px;
}

.primary-action:hover {
  background: #2563eb;
}

.primary-action:disabled {
  border-color: #263747;
  background: #182332;
  color: #6c7e90;
  cursor: not-allowed;
}

.primary-action.screen {
  background: #0f766e;
  border-color: #14b8a6;
}

.primary-action.screen:hover {
  background: #0d9488;
}

.primary-action.graph-action {
  background: #263747;
  border-color: #41586c;
}

.primary-action.graph-action:hover {
  background: #33485a;
}

.primary-action.compact {
  min-height: 40px;
  padding: 9px 14px;
}

.hidden {
  display: none !important;
}

.score-row {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 18px;
  align-items: center;
}

.confidence-meter svg {
  width: 116px;
  height: 116px;
}

.meter-bg,
.meter-fg {
  fill: none;
  stroke-width: 12;
}

.meter-bg {
  stroke: #253343;
}

.meter-fg {
  stroke: var(--orange);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-dasharray: 302;
  stroke-dashoffset: 54;
}

.confidence-meter text {
  fill: var(--ink);
  font-size: 1.1rem;
  font-weight: 900;
}

.result-label {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 900;
}

.score-row h4 {
  margin: 0;
  font-size: 1.25rem;
}

.score-row p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.result-context,
.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 0;
}

.result-context {
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
}

.result-context div,
.result-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d1722;
}

.result-context dt,
.result-metrics dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-context dd,
.result-metrics dd {
  margin: 6px 0 0;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.workflow-graph {
  min-height: 310px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #09111b;
}

.workflow-graph svg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: 310px;
}

.graph-node rect {
  fill: #111c27;
  stroke: #426070;
  stroke-width: 1.4;
}

.graph-node text {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
}

.graph-node.flagged rect {
  fill: rgba(239, 68, 68, 0.12);
  stroke: var(--red);
}

.graph-node.elevated rect {
  fill: rgba(249, 115, 22, 0.12);
  stroke: var(--orange);
}

.graph-node.moderate rect {
  fill: rgba(250, 204, 21, 0.12);
  stroke: var(--yellow);
}

.graph-line {
  stroke: #6d8799;
  stroke-width: 2;
  marker-end: url("#arrow");
}

.trigger-list,
.queue-list,
.domain-checklist {
  display: grid;
  gap: 10px;
}

.domain-checklist {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.domain-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d1722;
}

.domain-option input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 auto;
}

.domain-option strong,
.help-panel h3 {
  display: block;
  margin: 0 0 5px;
}

.domain-option p,
.help-panel p,
.help-panel li {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.help-panel ol {
  margin: 0;
  padding-left: 20px;
}

.help-panel li + li {
  margin-top: 8px;
}

.trigger-item,
.queue-item {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 12px;
  background: #0d1722;
}

.trigger-item.low,
.queue-item.low {
  border-left-color: var(--green);
}

.trigger-item.moderate,
.queue-item.moderate {
  border-left-color: var(--yellow);
}

.trigger-item.elevated,
.queue-item.elevated {
  border-left-color: var(--orange);
}

.trigger-item.flagged,
.queue-item.flagged {
  border-left-color: var(--red);
}

.trigger-item.low {
  background: rgba(34, 197, 94, 0.08);
}

.trigger-item.moderate {
  background: rgba(250, 204, 21, 0.1);
}

.trigger-item.elevated {
  background: rgba(249, 115, 22, 0.1);
}

.trigger-item.flagged {
  background: rgba(239, 68, 68, 0.1);
}

.trigger-item strong,
.queue-item strong {
  display: block;
  margin-bottom: 5px;
}

.trigger-item p,
.queue-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

thead {
  background: #0d1722;
}

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

td {
  color: #d3dfeb;
  font-size: 0.92rem;
}

.confidence-cell {
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 18, 0.72);
  z-index: 10;
}

.modal {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.icon-action {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #33485a;
  background: #0c1520;
  color: #d8e3ef;
}

textarea {
  min-height: 320px;
  resize: vertical;
  padding: 14px;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

.modal-actions {
  margin-top: 14px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .app-footer {
    position: static;
    width: auto;
    padding: 0 18px 18px;
    background: #06120f;
  }

  .screening-grid,
  .data-grid,
  .policy-grid,
  .help-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  main,
  .sidebar {
    padding: 18px;
  }

  .page-head,
  .panel-title,
  .preview-head,
  .panel-actions,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .llm-config,
  .result-context,
  .domain-checklist,
  .protocol-inputs,
  .result-metrics,
  .score-row {
    grid-template-columns: 1fr;
  }

  .secondary-action,
  .primary-action {
    width: 100%;
    min-height: 44px;
  }

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

  .sample-actions select {
    width: 100%;
  }
}
