:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --border: #dbe3ef;
  --border-strong: #c3cfdd;
  --text: #172033;
  --muted: #64748b;
  --faint: #94a3b8;
  --blue: #2563eb;
  --green: #059669;
  --amber: #d97706;
  --orange: #ea580c;
  --red: #dc2626;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.brand,
.topbar-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.topbar-actions {
  gap: 12px;
}

.env-badge {
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  font-size: 11px;
  font-weight: 700;
}

.sync-status {
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.btn-secondary,
.btn-primary,
.scenario-button {
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  font-weight: 600;
  font-size: 13px;
}

.icon-button:hover,
.btn-secondary:hover,
.scenario-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.shell {
  padding: 22px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.kpi-card,
.insight-card,
.demo-toolbar,
.queue-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.kpi-card {
  padding: 16px;
  border-top: 3px solid var(--blue);
}

.kpi-card--green {
  border-top-color: var(--green);
}

.kpi-card--amber {
  border-top-color: var(--amber);
}

.kpi-card--red {
  border-top-color: var(--red);
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
  line-height: 1;
}

.kpi-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 14px;
}

.insight-card {
  min-height: 230px;
  padding: 16px;
}

.insight-card canvas {
  width: 100% !important;
  height: 170px !important;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading span {
  font-weight: 700;
}

.section-heading small,
.toolbar-subtitle,
.queue-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.trigger-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trigger-row__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.trigger-row__top strong {
  color: var(--text);
}

.mini-bar,
.score-track {
  height: 7px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.mini-bar div,
.score-track div {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.demo-toolbar {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 14px;
  align-items: center;
}

.toolbar-title {
  font-weight: 700;
}

.scenario-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scenario-button {
  background: var(--panel-soft);
  white-space: nowrap;
}

.trigger-msg {
  color: var(--muted);
  font-size: 12px;
  min-width: 120px;
}

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

.queue-panel,
.detail-panel {
  min-height: 560px;
  overflow: hidden;
}

.queue-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.queue-title {
  font-size: 15px;
  font-weight: 800;
}

.filter-row {
  display: flex;
  gap: 7px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.filter-chip {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.filter-chip--active {
  background: #eff6ff;
  color: var(--blue);
  border-color: #bfdbfe;
}

.alert-items {
  max-height: 720px;
  overflow-y: auto;
}

.alert-card {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: block;
}

.alert-card:hover {
  background: var(--panel-soft);
}

.alert-card--active {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.alert-card__top,
.alert-card__meta,
.score-line,
.label-row {
  display: flex;
  align-items: center;
}

.alert-card__top {
  justify-content: space-between;
  gap: 10px;
}

.alert-card__name {
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-card__meta {
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 7px;
  flex-wrap: wrap;
}

.score-line {
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.score-line .score-track {
  flex: 1;
}

.label-row {
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.label-chip,
.risk-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.label-chip {
  background: #f1f5f9;
  color: var(--muted);
  padding: 4px 7px;
}

.risk-pill {
  padding: 4px 8px;
  white-space: nowrap;
}

.risk-pill--critical {
  background: #fee2e2;
  color: var(--red);
}

.risk-pill--high {
  background: #ffedd5;
  color: var(--orange);
}

.risk-pill--medium {
  background: #fef3c7;
  color: var(--amber);
}

.risk-pill--low {
  background: #dcfce7;
  color: var(--green);
}

.detail-empty {
  min-height: 560px;
  display: grid;
  place-items: center;
  padding: 48px;
  text-align: center;
}

.empty-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.empty-copy {
  color: var(--muted);
  max-width: 430px;
}

.detail-content {
  padding: 20px;
  max-height: 760px;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-header h1 {
  margin: 5px 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

.detail-subtitle {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.score-badge {
  min-width: 112px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  background: var(--panel-soft);
}

.score-badge strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.score-badge span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

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

.summary-tile,
.evidence-card,
.triage-card,
.fp-card,
.review-card,
.info-item,
.dimension-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.summary-tile {
  padding: 14px;
}

.summary-tile__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-tile__value {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 800;
}

.detail-section {
  margin-bottom: 22px;
}

.evidence-card,
.triage-card,
.fp-card,
.review-card {
  padding: 14px;
}

.triage-card,
.fp-card,
.review-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.triage-card p,
.fp-card p,
.review-card p,
.dimension-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.triage-decision {
  font-size: 22px;
  font-weight: 900;
}

.triage-meta {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  min-width: 150px;
}

.fp-card__status {
  min-width: 96px;
  border-radius: 999px;
  padding: 6px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

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

.info-item {
  padding: 11px 12px;
  min-width: 0;
}

.info-item__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.info-item__value {
  margin-top: 5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dimension-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.dimension-card {
  padding: 12px;
}

.dimension-card__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.factor-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.review-card {
  align-items: center;
}

.tone-green {
  color: var(--green);
}

.tone-amber {
  color: var(--amber);
}

.tone-red {
  color: var(--red);
}

.tone-neutral {
  color: var(--muted);
}

.summary-tile.tone-green,
.summary-tile.tone-amber,
.summary-tile.tone-red,
.summary-tile.tone-neutral,
.fp-card__status.tone-green,
.fp-card__status.tone-amber,
.fp-card__status.tone-red,
.fp-card__status.tone-neutral {
  color: inherit;
}

.summary-tile.tone-green,
.fp-card__status.tone-green {
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.summary-tile.tone-amber,
.fp-card__status.tone-amber {
  background: #fffbeb;
  border-color: #fde68a;
}

.summary-tile.tone-red,
.fp-card__status.tone-red {
  background: #fef2f2;
  border-color: #fecaca;
}

.summary-tile.tone-neutral,
.fp-card__status.tone-neutral {
  background: #f8fafc;
  border-color: var(--border);
}

.muted-row,
.empty-state,
.loading-state,
.error-state {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.error-state {
  color: var(--red);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.45);
  z-index: 50;
  padding: 20px;
}

.modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.modal-header,
.modal-footer {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.modal-title {
  font-weight: 800;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.modal-body {
  padding: 18px;
}

.form-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.form-label--spaced {
  margin-top: 16px;
}

.decision-options {
  display: grid;
  gap: 10px;
}

.decision-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: start;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-soft);
}

.decision-option input {
  grid-row: span 2;
  margin-top: 3px;
}

.decision-option span {
  font-weight: 800;
}

.decision-option small {
  color: var(--muted);
}

.form-textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 96px;
  color: var(--text);
}

.form-textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: var(--blue);
}

@media (max-width: 1180px) {
  .kpi-grid,
  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

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

@media (max-width: 860px) {
  .topbar,
  .demo-toolbar,
  .detail-header,
  .triage-card,
  .fp-card,
  .review-card {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    height: auto;
    gap: 12px;
    padding: 14px 16px;
  }

  .shell {
    padding: 16px;
  }

  .kpi-grid,
  .insight-grid,
  .workspace,
  .detail-grid--three,
  .dimension-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .demo-toolbar {
    display: flex;
  }

  .triage-meta {
    text-align: left;
  }
}
