:root {
  --phi: 1.618;
  --space-1: 0.5rem;
  --space-2: 0.8125rem;
  --space-3: 1.3125rem;
  --space-4: 2.125rem;
  --space-5: 3.4375rem;
  --measure: 42rem;
  --radius: 1rem;
  --radius-sm: 0.75rem;

  --bg: #e7edf4;
  --bg-accent: #dfe8f1;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #5a6a7a;
  --brand: #0f5c52;
  --action: #127a6a;
  --action-ink: #ffffff;
  --danger: #c23b3b;
  --warn: #a67c00;
  --ok: #1f7a4d;
  --line: #d5dee8;
  --shadow: 0 1px 2px rgba(26, 35, 50, 0.04), 0 12px 32px rgba(26, 35, 50, 0.06);

  --font-body: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-display: "Fraunces", "IBM Plex Sans Arabic", serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

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

/* Any component that sets `display` on a class would otherwise defeat the
   `hidden` attribute — every JS-toggled element depends on this. */
[hidden] { display: none !important; }

html {
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(15, 92, 82, 0.08), transparent 55%),
    radial-gradient(700px 380px at 0% 100%, rgba(26, 35, 50, 0.05), transparent 50%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(18, 122, 106, 0.35);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(26, 35, 50, 0.03);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand span { color: var(--brand); }

.app-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.app-nav a {
  color: var(--muted);
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
}
.app-nav a:hover,
.app-nav a.is-active {
  color: var(--brand);
  background: rgba(15, 92, 82, 0.08);
  text-decoration: none;
}

.app-main {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: var(--space-4) 0 var(--space-5);
  flex: 1;
}

.page-head {
  margin-bottom: var(--space-4);
}
.page-title {
  margin: 0;
  font-size: clamp(1.6rem, 2.5vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--ink);
}
.page-help {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  max-width: var(--measure);
  line-height: 1.7;
  font-size: 1.02rem;
  text-wrap: pretty;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.card-title {
  margin: 0 0 var(--space-1);
  font-size: 1.15rem;
  font-weight: 650;
}

.card-help {
  margin: 0 0 var(--space-3);
  color: var(--muted);
  line-height: 1.6;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.stat {
  position: relative;
  padding: var(--space-3);
  overflow: hidden;
}
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: var(--space-1);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-3);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.7rem 1.15rem;
  border-radius: 0.9rem;
  font: inherit;
  font-weight: 650;
  background: var(--action);
  color: var(--action-ink);
  transition: transform 0.15s var(--ease), background-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  box-shadow: 0 8px 20px rgba(18, 122, 106, 0.18);
  text-decoration: none;
}
.btn:hover {
  background: #0f6a5c;
  text-decoration: none;
  color: var(--action-ink);
}
.btn:active { transform: scale(0.96); }
.btn.is-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.is-secondary:hover {
  background: #f7fafc;
  color: var(--ink);
}
.btn.is-block { width: 100%; }
.btn.is-small {
  min-height: 2.25rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
  box-shadow: none;
}

.field { margin-bottom: var(--space-3); }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 550;
  color: var(--ink);
}
.field .hint {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.field input,
.field select,
.field textarea,
.switcher select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field textarea { min-height: 7rem; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(18, 122, 106, 0.55);
  box-shadow: 0 0 0 4px rgba(18, 122, 106, 0.12);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.7rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 650;
  background: #eef3f7;
  color: var(--muted);
  border: 1px solid var(--line);
}
.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}
.badge.is-urgent { color: var(--danger); background: #fdeeee; border-color: #f3c6c6; }
.badge.is-important { color: var(--warn); background: #fff6de; border-color: #eed9a0; }
.badge.is-normal { color: var(--ok); background: #eaf6ef; border-color: #bfe0cb; }
.badge.is-neutral { color: var(--brand); background: #e7f4f1; border-color: #c5e2db; }

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table th,
.table td {
  text-align: right;
  padding: 0.95rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  color: var(--muted);
  font-weight: 550;
  font-size: 0.88rem;
}
.table tr:last-child td { border-bottom: 0; }
.table a { font-weight: 650; }

.case-list {
  display: grid;
  gap: var(--space-2);
}
.case-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), background-color 0.15s var(--ease);
}
.case-item:hover {
  border-color: rgba(15, 92, 82, 0.35);
  background: #fff;
  transform: translateY(-1px);
}
.case-item-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
}
.case-item-meta {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.actor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.actor-card {
  width: 100%;
  text-align: right;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: var(--radius);
  padding: var(--space-3);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.actor-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 92, 82, 0.4);
  background: #fff;
}
.actor-card:active { transform: scale(0.96); }
.actor-card strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 1.05rem;
}
.actor-card small { color: var(--muted); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 550;
}
.chip.is-on { color: var(--ok); border-color: #bfe0cb; background: #eaf6ef; }
.chip.is-off { color: var(--warn); border-color: #eed9a0; background: #fff6de; }

.flash {
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: #eaf6ef;
  border: 1px solid #bfe0cb;
  color: var(--ok);
  font-weight: 550;
}
.flash.is-error {
  background: #fdeeee;
  border-color: #f3c6c6;
  color: var(--danger);
}

.stack-between {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: end;
  flex-wrap: wrap;
}
.form-inline {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: end;
}
.form-inline .field {
  flex: 1;
  min-width: 220px;
  margin: 0;
}
.switcher select {
  width: auto;
  min-width: 190px;
  margin: 0;
  min-height: 2.25rem;
  padding: 0.4rem 0.7rem;
}

.muted { color: var(--muted); }
.list-plain {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-plain li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.list-plain li:last-child { border-bottom: 0; }

.welcome-panel {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--space-4);
  align-items: stretch;
}
.hero-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: var(--space-3);
  color: var(--brand);
  font-weight: 650;
}
.hero-mark i {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--brand);
  display: inline-block;
}

.empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--muted);
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

.scenario-card .scenario-id {
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.04em;
}

@media (max-width: 860px) {
  .stats,
  .grid-2,
  .grid-3,
  .actor-grid,
  .welcome-panel { grid-template-columns: 1fr; }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-2) var(--space-3);
  }
  .app-main { width: min(100% - 1.25rem, 1080px); }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .actor-card,
  .case-item { transition: none; }
  .btn:active,
  .actor-card:active { transform: none; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Case workspace: value-first —— */
.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.score-orb {
  position: relative;
  min-width: 5.75rem;
  min-height: 5.75rem;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 0.5rem;
  isolation: isolate;
}
.score-orb .orb-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  transform: rotate(-90deg);
}
.orb-track {
  fill: none;
  stroke: rgba(26, 35, 50, 0.08);
  stroke-width: 5;
}
.orb-progress {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 188.4;
  stroke-dashoffset: calc(188.4 - (188.4 * var(--score, 0) / 100));
}
.score-orb strong,
.score-orb span { position: relative; z-index: 1; }
.score-orb strong {
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-orb span {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
}
.score-orb.is-urgent { background: #fdeeee; border-color: #f3c6c6; color: var(--danger); }
.score-orb.is-important { background: #fff6de; border-color: #eed9a0; color: var(--warn); }
.score-orb.is-normal { background: #eaf6ef; border-color: #bfe0cb; color: var(--ok); }

.signal-stack {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.signal {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
}
.signal-icon {
  flex: 0 0 1.35rem;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.15rem;
  color: inherit;
}
.signal strong {
  display: block;
  font-weight: 750;
  margin-bottom: 0.15rem;
}
.signal span { color: var(--muted); }
.signal-danger { background: #fdeeee; border-color: #f3c6c6; color: var(--danger); }
.signal-danger strong { color: var(--danger); }
.signal-warn { background: #fff6de; border-color: #eed9a0; color: var(--warn); }
.signal-warn strong { color: var(--warn); }
.signal-smart { background: #e7f4f1; border-color: #c5e2db; color: var(--brand); }
.signal-smart strong { color: var(--brand); }

.workspace-twin {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  align-items: start;
}

.card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: var(--space-2);
  color: var(--brand);
  font-size: 0.88rem;
  font-weight: 750;
}
.smart-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 92, 82, 0.15);
}

.ai-canvas {
  border-color: rgba(15, 92, 82, 0.28);
  background:
    radial-gradient(500px 180px at 100% 0%, rgba(15, 92, 82, 0.08), transparent 60%),
    #fff;
}
.ai-summary {
  margin: 0 0 var(--space-3);
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--ink);
}

.ai-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.metric {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: #f4f8f7;
  border: 1px solid #d7e6e2;
}
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}
.metric-value {
  font-size: 1.02rem;
  font-weight: 750;
}

.confidence {
  height: 0.45rem;
  border-radius: 999px;
  background: #d9e5e2;
  overflow: hidden;
  margin: 0.35rem 0;
  position: relative;
}
.confidence::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: linear-gradient(90deg, #127a6a, #0f5c52);
  border-radius: inherit;
}

.ai-notes {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: #f8fbfa;
  border: 1px dashed #c5e2db;
}
.ai-notes h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.ai-notes ul {
  margin: 0;
  padding-inline-start: 1.1rem;
  color: var(--muted);
  line-height: 1.7;
}

.decision-canvas {
  border-color: rgba(26, 35, 50, 0.12);
}
.decision-canvas .is-override {
  border-color: var(--warn);
  box-shadow: 0 0 0 4px rgba(166, 124, 0, 0.12);
}
.inline-action { margin-bottom: var(--space-3); }

.select-smart {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--brand) 50%),
    linear-gradient(135deg, var(--brand) 50%, transparent 50%),
    linear-gradient(to right, transparent, transparent);
  background-position:
    calc(100% - 1.35rem) calc(50% - 0.18rem),
    calc(100% - 1.05rem) calc(50% - 0.18rem),
    100% 0;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem, 2.6rem 100%;
  background-repeat: no-repeat;
  padding-inline-end: 2.6rem;
  cursor: pointer;
}
[dir="rtl"] .select-smart,
html[lang="ar"] .select-smart {
  background-position:
    1.05rem calc(50% - 0.18rem),
    1.35rem calc(50% - 0.18rem),
    0 0;
  padding-inline-end: 0.9rem;
  padding-inline-start: 2.6rem;
}

.network-canvas { overflow: hidden; }
.network-canvas.is-empty-net { text-align: center; }
.spider-wrap {
  margin: 0;
  padding: var(--space-2);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 45%, rgba(15, 92, 82, 0.1), transparent 55%),
    linear-gradient(180deg, #f3f8f7, #eef3f7);
  border: 1px solid var(--line);
}
.spider-svg { width: min(100%, 440px); height: auto; display: block; margin-inline: auto; }
.spider-ring {
  fill: none;
  stroke: rgba(15, 92, 82, 0.18);
  stroke-width: 1.25;
  stroke-dasharray: 4 6;
}
.spider-hex {
  fill: rgba(15, 92, 82, 0.03);
  stroke: rgba(15, 92, 82, 0.22);
  stroke-width: 1.5;
}
.spider-guide {
  stroke: rgba(90, 106, 122, 0.22);
  stroke-width: 1;
}
.spider-link {
  stroke: #7a8b9a;
  stroke-width: 1.75;
  stroke-linecap: round;
}
.spider-hub {
  fill: rgba(15, 92, 82, 0.12);
  stroke: var(--brand);
  stroke-width: 2;
}
.spider-hub-core { fill: var(--brand); }
.spider-hub-label {
  fill: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
}
.spider-node {
  stroke: #fff;
  stroke-width: 2.5;
  cursor: pointer;
  transition: r 0.15s var(--ease);
}
.spider-node.is-urgent { fill: var(--danger); }
.spider-node.is-important { fill: var(--warn); }
.spider-node.is-normal { fill: var(--ok); }
.spider-node:hover { r: 26; }
.spider-node-label {
  fill: var(--ink);
  font-size: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  pointer-events: none;
}
.spider-caption {
  margin: var(--space-2) 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}
.spider-placeholder {
  width: min(100%, 280px);
  margin: var(--space-3) auto 0;
  display: block;
  opacity: 0.7;
}

.compare-grid {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.compare-row {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fbfcfd;
}
.compare-row.is-changed {
  background: #fff8e8;
  border-color: #eed9a0;
}
.compare-label {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.compare-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.mini-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}
.compare-values code {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.tag-investigator,
.tag-ai {
  display: inline-flex;
  align-items: center;
  min-height: 1.4rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.tag-investigator { background: #fff6de; color: var(--warn); border: 1px solid #eed9a0; }
.tag-ai { background: #e7f4f1; color: var(--brand); border: 1px solid #c5e2db; }

.edit-form { margin-top: var(--space-2); }
.audit-drawer summary {
  cursor: pointer;
  font-weight: 750;
  color: var(--ink);
}
.audit-drawer[open] summary { margin-bottom: var(--space-2); }

/* Case analytics + geometric markers */
.case-analytics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.analytic-chip {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}
.analytic-chip .stat-label {
  margin-bottom: 0.15rem;
  font-size: 0.8rem;
}
.analytic-chip strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.analytic-chip-text { font-size: 0.95rem !important; }

.geo-diamond,
.geo-hex,
.geo-tri,
.geo-circle {
  flex: 0 0 1.1rem;
  width: 1.1rem;
  height: 1.1rem;
  background: var(--brand);
  opacity: 0.85;
}
.geo-diamond { transform: rotate(45deg); border-radius: 0.15rem; }
.geo-hex {
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--action);
}
.geo-tri {
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  background: var(--warn);
}
.geo-circle {
  border-radius: 50%;
  background: var(--ok);
}
.geo-sm {
  position: absolute;
  top: 0.85rem;
  inset-inline-end: 0.85rem;
  opacity: 0.35;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.analytics-wide { grid-column: 1 / -1; }
.analytics-panel .card-title { margin-bottom: var(--space-2); }
.analytics-bars { width: 100%; height: auto; display: block; }
.analytics-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font-body);
}
.analytics-value {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
}

.fraud-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.fraud-bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}
.fraud-track {
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(15, 92, 82, 0.08);
  overflow: hidden;
}
.fraud-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #127a6a, #3ecf9a);
}

@media (max-width: 960px) {
  .workspace-twin,
  .ai-metrics,
  .compare-values,
  .analytics-grid,
  .case-analytics,
  .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .case-analytics,
  .stats { grid-template-columns: 1fr; }
}


/* ── Survey-style decision evaluation ─────────────────────────────── */

.survey-step {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-2);
}

.survey-q {
  font-weight: 600;
  padding: 0 var(--space-1);
  color: var(--brand);
}

.seg-control {
  display: flex;
  gap: var(--space-1);
  background: var(--bg-accent);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.seg-btn {
  flex: 1;
  border: 0;
  border-radius: calc(var(--radius-sm) - 4px);
  padding: var(--space-1) var(--space-2);
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow);
}

.decision-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: var(--space-1);
}

.decision-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  cursor: pointer;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.decision-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.decision-card input { position: absolute; opacity: 0; pointer-events: none; }

.decision-shape { width: 2.2rem; height: 2.2rem; }
.decision-shape svg { width: 100%; height: 100%; }

.decision-card.is-hold { color: var(--warn); }
.decision-card.is-block { color: var(--danger); }
.decision-card.is-clear { color: var(--ok); }
.decision-card.is-escalate { color: var(--brand); }

.decision-name { font-weight: 600; font-size: 0.85rem; color: var(--ink); }

.decision-card.is-selected { border-color: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.decision-card.is-suggested::after { content: ""; }

.decision-tag {
  font-size: 0.68rem;
  color: var(--brand);
  background: #e7f4f1;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

#decision-step[data-collapsed="1"] .decision-cards { opacity: 0.55; }

.reason-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}

.reason-chip { cursor: pointer; font: inherit; font-size: 0.8rem; }
.reason-chip.is-on {
  color: var(--brand);
  border-color: var(--brand);
  background: #e7f4f1;
  font-weight: 600;
}

/* Textareas outside .field (survey steps) must not fall back to browser monospace. */
.survey-step textarea {
  width: 100%;
  min-height: 7rem;
  resize: vertical;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.8;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.survey-step textarea:focus {
  border-color: rgba(18, 122, 106, 0.55);
  box-shadow: 0 0 0 4px rgba(18, 122, 106, 0.12);
}

/* ── Training indicators (admin/models) ───────────────────────────── */

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-2);
}

.indicator-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--space-2);
  text-align: center;
}

.ring { width: 6.5rem; height: 6.5rem; transform: rotate(-90deg); }
.ring text { transform: rotate(90deg); transform-origin: 50px 50px; }

.ring-track { fill: none; stroke: var(--bg-accent); stroke-width: 9; }
.ring-value {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s var(--ease);
}
.ring-value.is-ok { stroke: var(--ok); }
.ring-value.is-warn { stroke: var(--warn); }

.ring-num { font-size: 1.15rem; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.ring-sub { font-size: 0.6rem; fill: var(--muted); text-anchor: middle; }

.indicator-name { font-weight: 700; margin-top: 0.4rem; }
.indicator-help { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }

.balance-bar {
  height: 1.1rem;
  border-radius: 999px;
  background: #eaf6ef;
  overflow: hidden;
  margin: var(--space-3) 0 var(--space-1);
  border: 1px solid var(--line);
}
.balance-pos { height: 100%; background: var(--danger); opacity: 0.75; border-radius: 999px 0 0 999px; }
.balance-legend { display: flex; justify-content: center; gap: var(--space-1); margin-bottom: var(--space-1); }

.indicator-meta { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-2); }

.badge.is-ok { color: var(--ok); background: #eaf6ef; border-color: #bfe0cb; }
.badge.is-warn { color: var(--warn); background: #fff6de; border-color: #eed9a0; }

.alert {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #eaf6ef;
  color: var(--ok);
  padding: var(--space-1) var(--space-2);
  margin: var(--space-1) 0;
}
.alert.is-error { background: #fdeeee; color: var(--danger); border-color: #f3c6c6; }

/* ── Layout polish: value-order + gap closure ─────────────────────── */

.workspace-col {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}

.compliance-canvas .btn { margin-top: var(--space-1); }

.network-note {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 var(--space-3);
  padding: var(--space-1) var(--space-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.55);
}
.network-note svg { width: 1.2rem; height: 1.2rem; flex: none; color: var(--brand); opacity: 0.7; }

.intake-drawer summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.intake-drawer summary::after {
  content: "+";
  font-size: 1.4rem;
  color: var(--brand);
  line-height: 1;
}
.intake-drawer[open] summary { margin-bottom: var(--space-2); }
.intake-drawer[open] summary::after { content: "−"; }

/* ── Mailbox ──────────────────────────────────────────────────────── */

.mail-list { display: grid; gap: var(--space-1); }

.mail-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.mail-item summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  cursor: pointer;
  list-style: none;
}
.mail-item summary::-webkit-details-marker { display: none; }

.mail-status { width: 1.6rem; height: 1.6rem; flex: none; color: var(--muted); }
.mail-status svg { width: 100%; height: 100%; }
.mail-item.is-replied .mail-status { color: var(--ok); }
.mail-item.is-failed .mail-status { color: var(--danger); }

.mail-main { flex: 1; min-width: 0; display: grid; gap: 0.15rem; }
.mail-subject { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-meta { color: var(--muted); font-size: 0.8rem; }

.mail-item[open] { box-shadow: var(--shadow); }
.mail-item[open] summary { border-bottom: 1px solid var(--line); }

.mail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}
.mail-pane h3 { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--brand); }
.mail-pane p { margin: 0 0 var(--space-1); font-size: 0.88rem; line-height: 1.8; white-space: pre-line; }
.mail-error { color: var(--danger); }

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

/* ── Role walkthrough bar ─────────────────────────────────────────── */

.impersonation-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-1) var(--space-4);
  background: #fff6de;
  border-bottom: 1px solid #eed9a0;
  color: #7a5c00;
  font-size: 0.88rem;
}
.impersonation-bar strong { color: var(--warn); }
.impersonation-bar form { margin: 0; }

/* ── Live mail listener (radar) ───────────────────────────────────── */

.listener {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f7fbfa);
  box-shadow: var(--shadow);
}

.listener-radar { width: 4.5rem; height: 4.5rem; flex: none; }
.listener-radar svg { width: 100%; height: 100%; overflow: visible; }

.radar-ring {
  fill: none;
  stroke: var(--brand);
  stroke-width: 1;
  opacity: 0.18;
}
.radar-ring.r1 { animation: radar-breathe 3.2s var(--ease) infinite; }
.radar-ring.r2 { animation: radar-breathe 3.2s var(--ease) 0.4s infinite; }
.radar-ring.r3 { animation: radar-breathe 3.2s var(--ease) 0.8s infinite; }

@keyframes radar-breathe {
  0%, 100% { opacity: 0.12; transform: scale(0.97); }
  50%      { opacity: 0.34; transform: scale(1); }
}
.radar-ring { transform-origin: 60px 60px; }

.radar-sweep {
  transform-origin: 60px 60px;
  animation: radar-spin 4s linear infinite;
}
.radar-sweep path { fill: var(--brand); opacity: 0.14; }
@keyframes radar-spin { to { transform: rotate(360deg); } }

.radar-core { fill: var(--brand); opacity: 0.85; }

.radar-blip { fill: var(--ok); opacity: 0; transform-origin: 60px 60px; }

.listener.is-scanning .radar-sweep { animation-duration: 1.1s; }
.listener.is-scanning .radar-core { animation: core-pulse 1.1s var(--ease) infinite; }
@keyframes core-pulse {
  0%, 100% { r: 7; opacity: 0.85; }
  50%      { r: 9; opacity: 1; }
}

.listener.is-hit { border-color: #bfe0cb; background: linear-gradient(180deg, #ffffff, #eaf6ef); }
.listener.is-hit .radar-blip { animation: blip 1.4s var(--ease) infinite; }
@keyframes blip {
  0%   { opacity: 0.9; transform: scale(1); }
  70%  { opacity: 0; transform: scale(5.5); }
  100% { opacity: 0; transform: scale(5.5); }
}
.listener.is-hit .listener-state { color: var(--ok); }

.listener.is-offline { border-color: #f3c6c6; background: #fdf7f7; }
.listener.is-offline .radar-sweep { animation-play-state: paused; }
.listener.is-offline .radar-core { fill: var(--danger); }
.listener.is-offline .listener-state { color: var(--danger); }

.listener-text { flex: 1; min-width: 0; display: grid; gap: 0.2rem; }
.listener-state { font-size: 1rem; color: var(--brand); }
.listener-meta { color: var(--muted); font-size: 0.82rem; }

.listener-counts {
  display: flex;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.listener-counts b {
  display: block;
  font-size: 1.35rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

@media (prefers-reduced-motion: reduce) {
  .radar-ring, .radar-sweep, .radar-core, .radar-blip { animation: none !important; }
}

/* ── Mailbox list refinements ─────────────────────────────────────── */

.mail-head { margin-bottom: var(--space-2); }
.mail-head .card-title { margin: 0; }

.mail-subject {
  font-size: 0.95rem;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46ch;
}

.mail-item.is-ignored { opacity: 0.72; }
.mail-item.is-ignored .mail-subject { font-weight: 500; }

/* Long machine bodies were creating page-height gaps: clamp them. */
.mail-excerpt,
.mail-reply {
  white-space: pre-line;
  max-height: 11rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: #f7fafc;
  border: 1px solid var(--line);
  font-size: 0.86rem;
  line-height: 1.75;
}
.mail-reply { background: #eaf6ef; border-color: #bfe0cb; }

.mail-body { align-items: start; }
.mail-pane { min-width: 0; }

/* ── Case page: header facts + unified data panel ─────────────────── */

.case-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.case-identity { min-width: 0; flex: 1; }

.case-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: 0.88rem;
}
.case-facts b { color: var(--ink); font-variant-numeric: tabular-nums; }

.data-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.data-row { display: grid; gap: 0.3rem; min-width: 0; }
.data-row.is-wide { grid-column: 1 / -1; }
.data-row label { font-size: 0.85rem; font-weight: 550; color: var(--ink); }
.data-row input,
.data-row textarea {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.data-row textarea { min-height: 5.5rem; resize: vertical; line-height: 1.75; }
.data-row input:focus,
.data-row textarea:focus {
  border-color: rgba(18, 122, 106, 0.55);
  box-shadow: 0 0 0 4px rgba(18, 122, 106, 0.12);
  outline: none;
}

.data-origin {
  font-size: 0.75rem;
  color: var(--warn);
}
.data-origin code {
  background: #fff6de;
  border: 1px solid #eed9a0;
  border-radius: 6px;
  padding: 0.05rem 0.35rem;
  font-size: 0.72rem;
}

.audit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.audit-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.audit-list li:last-child { border-bottom: 0; }
.audit-event { color: var(--ink); }

/* ── Segmented evaluation control: distinct agree / override paths ── */

.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.seg-btn svg { width: 1.05rem; height: 1.05rem; opacity: 0; transition: opacity 0.15s var(--ease); }
.seg-btn.is-active svg { opacity: 1; }
.seg-btn[data-mode="agree"].is-active { color: var(--ok); }
.seg-btn[data-mode="override"].is-active { color: var(--danger); }

#decision-form[data-mode="agree"] .decision-card.is-suggested {
  border-color: var(--ok);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.14);
}
#decision-form[data-mode="override"] .decision-cards { --override-tint: 1; }

.btn.is-danger { background: var(--danger); box-shadow: 0 8px 20px rgba(194, 59, 59, 0.2); }
.btn.is-danger:hover { background: #ad3434; }

/* ── Choice cards (radio groups that are not decisions) ───────────── */

.choice-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.choice-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
.choice-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 92, 82, 0.12);
}

.choice-icon { width: 2rem; height: 2rem; flex: none; color: var(--brand); }
.choice-icon svg { width: 100%; height: 100%; }
.choice-body { display: grid; gap: 0.2rem; min-width: 0; }
.choice-body strong { font-size: 0.94rem; }
.choice-body span { color: var(--muted); font-size: 0.78rem; line-height: 1.6; }

/* ── Dropzone ─────────────────────────────────────────────────────── */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-3);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f8fbfa);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.dropzone:hover { border-color: rgba(15, 92, 82, 0.4); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.dropzone-art { width: 3.4rem; height: 2.6rem; color: var(--brand); opacity: 0.75; }
.dropzone-art svg { width: 100%; height: 100%; }
.dz-arrow { transition: transform 0.25s var(--ease); }

.dropzone-text { display: grid; gap: 0.2rem; }
.dropzone-text strong { font-size: 0.98rem; }
.dropzone-text span { color: var(--muted); font-size: 0.82rem; }

.dropzone.is-over {
  border-color: var(--action);
  border-style: solid;
  background: #eaf6f3;
}
.dropzone.is-over .dropzone-art { opacity: 1; }
.dropzone.is-over .dz-arrow { transform: translateY(-4px); }

/* ── Selected file list ───────────────────────────────────────────── */

.file-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: grid; gap: 0.4rem; }

.file-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.55rem var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.file-row.is-invalid { border-color: #f3c6c6; background: #fdf7f7; }

.file-kind {
  flex: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--brand);
  background: #e7f4f1;
  border: 1px solid #c5e2db;
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
}
.file-row.is-invalid .file-kind { color: var(--danger); background: #fdeeee; border-color: #f3c6c6; }

.file-meta { flex: 1; min-width: 0; display: grid; gap: 0.1rem; }
.file-meta strong { font-size: 0.87rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { color: var(--muted); font-size: 0.76rem; }
.file-row.is-invalid .file-meta span { color: var(--danger); }

.file-remove {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.file-remove:hover { color: var(--danger); border-color: #f3c6c6; }

/* ── Upload progress ──────────────────────────────────────────────── */

.upload-progress { margin-top: var(--space-2); display: grid; gap: 0.4rem; }

.progress-track {
  height: 0.55rem;
  border-radius: 999px;
  background: var(--bg-accent);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--action), var(--brand));
  background-size: 1.6rem 100%;
  transition: width 0.2s var(--ease);
  animation: progress-stripe 0.9s linear infinite;
}
@keyframes progress-stripe { to { background-position: 1.6rem 0; } }

.upload-progress.is-done .progress-fill { animation: none; background: var(--ok); }
.progress-label { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* ── Import result ────────────────────────────────────────────────── */

.import-result {
  margin-top: var(--space-2);
  padding: var(--space-2);
  border: 1px solid #bfe0cb;
  border-radius: var(--radius-sm);
  background: #eaf6ef;
}
.result-head { margin: 0 0 var(--space-1); font-weight: 600; }
.result-list { list-style: none; margin: 0 0 var(--space-2); padding: 0; display: grid; gap: 0.25rem; font-size: 0.85rem; }
.result-list .ok { color: var(--ok); font-weight: 700; }
.result-list .bad { color: var(--danger); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .progress-fill { animation: none; }
}
