:root {
  --page: #eef2f5;
  --surface: #ffffff;
  --surface-muted: #f7f9fb;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: #d9e0e7;
  --line-strong: #c5ced8;
  --brand: #006b75;
  --brand-strong: #054e58;
  --brand-soft: #e2f4f4;
  --success: #127245;
  --success-soft: #e5f5ed;
  --warning: #9a6200;
  --warning-soft: #fff4d8;
  --info: #285f9f;
  --info-soft: #e8f1fb;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Avenir Next", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(0, 107, 117, 0.12) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, #f8fafc 0%, var(--page) 100%);
  background-size: 24px 24px, 100% 100%;
}

button,
input {
  font: inherit;
}

.app-frame {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 16px 20px;
  background: #12202f;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-block,
.topbar-actions,
.case-tags,
.panel-heading {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #0c7782;
  color: #ffffff;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.overline,
.section-label,
.metric-label,
.evidence-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar .overline {
  color: #a9bacb;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 700;
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.environment,
.operator {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
}

.environment {
  background: rgba(255, 255, 255, 0.11);
  color: #d8e7f1;
}

.operator {
  background: #ffffff;
  color: #12202f;
}

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

.metric-card,
.panel,
.case-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.05);
}

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 16px;
}

.metric-card strong {
  font-size: 1.45rem;
  line-height: 1;
}

.metric-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-warn {
  color: var(--warning);
}

.metric-info {
  color: var(--info);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.side-stack,
.main-stack {
  display: grid;
  gap: 16px;
}

.panel,
.case-header {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #334155;
  font-size: 0.84rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 107, 117, 0.16);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--brand-strong);
  border-radius: 6px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.primary-action:hover:not(:disabled) {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  box-shadow: 0 8px 18px rgba(0, 107, 117, 0.2);
}

.primary-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.status-block {
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.status.good {
  color: var(--success);
  border-color: rgba(18, 114, 69, 0.22);
  background: var(--success-soft);
}

.status.warn {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.24);
  background: #fff1f0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill.success {
  background: var(--success-soft);
  border-color: rgba(18, 114, 69, 0.18);
  color: var(--success);
}

.pill.warning {
  background: var(--warning-soft);
  border-color: rgba(154, 98, 0, 0.18);
  color: var(--warning);
}

.pill.info {
  background: var(--info-soft);
  border-color: rgba(40, 95, 159, 0.18);
  color: var(--info);
}

.pill.neutral {
  background: #edf2f7;
  border-color: var(--line);
  color: #435365;
}

.timeline {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  position: relative;
}

.timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 22px;
  left: 8px;
  width: 1px;
  height: calc(100% + 4px);
  background: var(--line);
}

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.timeline li.active .timeline-dot {
  background: var(--success);
}

.timeline strong {
  display: block;
  font-size: 0.92rem;
}

.timeline p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.case-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.case-tags {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.case-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.case-card,
.decision-card {
  min-height: 100%;
}

.risk-score {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(40, 95, 159, 0.22);
  border-radius: 6px;
  background: var(--info-soft);
  color: var(--info);
  font-weight: 700;
}

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

.details-grid div {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.details-grid dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.details-grid dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.evidence-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.evidence-label {
  display: block;
  margin-bottom: 4px;
}

.decision-copy {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.5;
}

.dispatch-action {
  width: 100%;
}

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

.queue table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #ffffff;
}

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

.queue th {
  background: #f3f6f9;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.queue tbody tr:last-child td {
  border-bottom: none;
}

.queue td strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.9rem;
}

.queue td span {
  color: var(--muted);
}

.table-action-copy {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

@media (max-width: 1040px) {
  .summary-strip,
  .workspace-grid,
  .case-layout {
    grid-template-columns: 1fr 1fr;
  }

  .side-stack {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-stack {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-frame {
    width: min(100% - 20px, 1280px);
    padding-top: 10px;
  }

  .topbar,
  .case-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .case-tags {
    justify-content: flex-start;
  }

  .summary-strip,
  .side-stack,
  .case-layout {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 92px;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    border: none;
    overflow: visible;
  }

  .queue table,
  .queue thead,
  .queue tbody,
  .queue tr,
  .queue th,
  .queue td {
    display: block;
    min-width: 0;
  }

  .queue thead {
    display: none;
  }

  .queue tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
  }

  .queue td {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }

  .queue td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
}
