:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-navy: #1b2569;
  --color-text: #243964;
  --color-muted: #596583;
  --color-border: #e5e8ed;
  --color-action: #bf4a1c;
  --color-action-hover: #a63f16;
  --color-action-disabled: #e3cfc5;
  --color-accent: #ed6c3b;
  --color-success: #247a52;
  --color-warning: #8a5b10;
  --color-info: #2f568f;
  --font-display: "Playfair Display", Georgia, serif;
  --font-ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --color-danger: #a32b38;
  --color-danger-hover: #8c2430;
  --color-danger-accent: #e06c75;
  --color-danger-tint: #fdecee;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --shadow-card: 0 8px 24px rgb(27 37 105 / 7%);
}

* { box-sizing: border-box; }
html { background: var(--color-bg); color: var(--color-text); font-family: var(--font-ui); }
body { margin: 0; min-width: 320px; background: var(--color-bg); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 20; padding: 12px 16px; background: var(--color-navy); color: white; border-radius: 8px; }
.skip-link:focus { top: 16px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 256px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 32px; padding: 24px 20px; background: #f2f3f7; border-right: 1px solid var(--color-border); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--color-navy); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--color-navy); color: white; font-family: var(--font-display); font-size: 24px; }
.brand strong, .brand small, .actor-card strong, .actor-card small { display: block; }
.brand strong { font-family: var(--font-display); font-size: 20px; }
.brand small, .actor-card small { margin-top: 2px; color: var(--color-muted); font-size: 12px; }
.primary-nav { display: grid; gap: 6px; }
.primary-nav a, .nav-disabled { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 650; }
.primary-nav a:hover { background: white; }
.primary-nav a[aria-current="page"] { background: white; color: var(--color-navy); box-shadow: inset 3px 0 var(--color-action); }
.nav-disabled { color: #828a9d; }
.sidebar-boundary { margin-top: auto; padding: 16px; border: 1px solid #d7dbea; border-radius: 12px; background: rgb(255 255 255 / 65%); }
.sidebar-boundary strong { display: block; margin-top: 6px; font-size: 14px; }
.sidebar-boundary p { margin: 6px 0 0; color: var(--color-muted); font-size: 12px; line-height: 1.5; }
.actor-card { display: flex; align-items: center; gap: 10px; padding-top: 16px; border-top: 1px solid #d9dce5; font-size: 12px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--color-navy); color: white; font-size: 11px; font-weight: 750; }

.main-content { width: min(1184px, calc(100vw - 256px)); margin: 0 auto; padding: 48px 40px 80px; }
.page-header { margin-bottom: 40px; }
.split-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 32px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.eyebrow { color: var(--color-action); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--color-navy); font-family: var(--font-display); }
h1 { margin: 8px 0 10px; font-size: clamp(36px, 4vw, 54px); line-height: 1.05; letter-spacing: -.025em; }
h2 { margin: 4px 0 0; font-size: 25px; line-height: 1.2; }
h3 { margin-bottom: 8px; font-size: 19px; }
.page-header p, .section-copy { max-width: 720px; margin-bottom: 0; color: var(--color-muted); font-size: 15px; line-height: 1.65; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 0 18px; border: 1px solid transparent; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 750; cursor: pointer; }
.button-primary { background: var(--color-action); color: white; }
.button-primary:hover { background: var(--color-action-hover); }
.button-secondary { background: white; border-color: #cfd4df; color: var(--color-navy); }
.button-block { width: 100%; }
.button:disabled { background: var(--color-action-disabled); color: #745e55; cursor: not-allowed; }

.section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading { margin: 40px 0 16px; }
.panel-heading { padding-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.status, .count-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; text-transform: capitalize; white-space: nowrap; }
.status-neutral, .count-pill { background: #eef0f4; color: #4b5773; }
.status-info { background: #eaf1fb; color: var(--color-info); }
.status-warning { background: #fff4db; color: var(--color-warning); }
.status-success { background: #e5f5ed; color: var(--color-success); }
.status-required { background: #fbeae4; color: var(--color-action); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric, .panel { border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); box-shadow: var(--shadow-card); }
.metric { min-height: 152px; padding: 20px; }
.metric small, .metric span { display: block; color: var(--color-muted); }
.metric small { font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin: 16px 0 10px; color: var(--color-navy); font-family: var(--font-display); font-size: 38px; line-height: 1; }
.metric strong.metric-word { font-family: var(--font-ui); font-size: 17px; line-height: 1.25; text-transform: capitalize; }
.metric span { font-size: 11px; line-height: 1.45; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 24px; margin-top: 24px; }
.panel { padding: 24px; }
.campaign-list { display: grid; }
.campaign-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 4px; border-bottom: 1px solid var(--color-border); text-decoration: none; }
.campaign-row:hover strong { color: var(--color-action); }
.campaign-row:last-child { border-bottom: 0; padding-bottom: 4px; }
.campaign-main strong, .campaign-main small, .campaign-meta small { display: block; }
.campaign-main strong { color: var(--color-navy); font-family: var(--font-display); font-size: 18px; text-transform: capitalize; }
.campaign-main small, .campaign-meta small { margin-top: 6px; color: var(--color-muted); font-size: 11px; }
.campaign-meta { text-align: right; }
.decision-list { margin: 0; padding: 0; list-style: none; }
.decision-list li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 18px 0; border-bottom: 1px solid var(--color-border); }
.decision-list li .status { grid-column: 2; justify-self: start; }
.decision-list strong, .decision-list small { display: block; }
.decision-list small { margin-top: 5px; color: var(--color-muted); font-size: 11px; line-height: 1.4; }
.decision-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff4db; color: var(--color-warning); font-weight: 850; }
.empty-state { padding: 48px 24px 24px; text-align: center; }
.empty-state.compact { padding: 40px 12px 12px; }
.empty-state p { max-width: 470px; margin: 0 auto 20px; color: var(--color-muted); line-height: 1.55; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 12px; background: #fbeae4; color: var(--color-action); font-size: 22px; }
.principle-band, .notice { display: flex; gap: 16px; margin-top: 24px; padding: 20px 24px; border-radius: 12px; }
.principle-band { align-items: center; border: 1px solid #cfd7e7; background: #f1f5fb; }
.principle-band strong, .notice strong { color: var(--color-navy); }
.principle-band p, .notice p { margin: 4px 0 0; color: var(--color-muted); font-size: 13px; line-height: 1.5; }
.principle-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 8px; background: var(--color-navy); color: white; font-weight: 850; }

.notice { border-left: 4px solid var(--color-action); background: #fff8f5; }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); margin: 32px 0; padding: 0; list-style: none; }
.stepper li { position: relative; display: flex; align-items: center; gap: 10px; color: #80889a; font-size: 12px; }
.stepper li:not(:last-child)::after { content: ""; position: absolute; left: 38px; right: 10px; top: 15px; height: 1px; background: #d7dbe4; }
.stepper li span { z-index: 1; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #cdd2dc; border-radius: 50%; background: var(--color-bg); }
.stepper .current { color: var(--color-navy); }
.stepper .current span { border-color: var(--color-action); background: var(--color-action); color: white; }
.design-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 24px; }
.design-main, .panel { min-width: 0; }
.error-page { display: grid; min-height: 100vh; padding: var(--space-8); place-items: center; }
.error-summary { max-width: 42rem; width: 100%; }
.auth-page { background: white; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, .8fr) minmax(520px, 1.2fr); }
.auth-context { min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; gap: 48px; padding: 56px 64px; background: var(--color-navy); color: white; }
.auth-brand { display: inline-flex; align-items: center; gap: 14px; align-self: flex-start; color: white; font-family: var(--font-display); font-size: 24px; font-weight: 700; text-decoration: none; }
.auth-brand .brand-mark { background: white; color: var(--color-navy); }
.auth-context-copy { max-width: 520px; }
.auth-context-copy h1 { color: white; font-size: clamp(40px, 4vw, 60px); }
.auth-context-copy p { max-width: 500px; margin: 20px 0 0; color: #d7dbee; font-size: 16px; line-height: 1.65; }
.auth-boundary { max-width: 500px; padding: 18px 20px; border: 1px solid rgb(255 255 255 / 20%); border-radius: 12px; background: rgb(255 255 255 / 8%); }
.auth-boundary strong { color: white; font-size: 13px; }
.auth-boundary p { margin: 7px 0 0; color: #d7dbee; font-size: 12px; line-height: 1.55; }
.auth-clerk-region { display: grid; min-height: 100vh; place-items: center; padding: 56px 96px; background: white; }
.auth-clerk-content { width: min(100%, 420px); }
.auth-clerk-title { margin: 10px 0 8px; color: var(--color-navy); font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1.12; }
.auth-clerk-help { margin: 0 0 24px; color: var(--color-muted); font-size: 14px; line-height: 1.55; }
.auth-clerk-mount, .auth-clerk-root, .auth-clerk-box { width: 100%; }
.auth-clerk-card { width: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; }
.auth-access-denied { margin-top: 24px; padding: 18px 20px; border-left: 4px solid var(--color-action); border-radius: 8px; background: #fff8f5; }
.auth-access-denied strong { color: var(--color-navy); }
.auth-access-denied p { margin: 8px 0 0; color: var(--color-muted); font-size: 13px; line-height: 1.55; }
.auth-account-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.table-wrap { max-width: 100%; overflow-x: auto; }
.button-secondary:hover { background: var(--color-bg); border-color: var(--color-muted); }
.design-main { display: grid; gap: 24px; }
.form-section { padding: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 24px; }
.field { display: grid; gap: 8px; color: var(--color-navy); font-size: 12px; font-weight: 750; }
.field.wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #cfd4df; border-radius: 8px; background: #f7f8fa; color: var(--color-text); padding: 12px; font-size: 13px; font-weight: 450; line-height: 1.5; }
.field input:not(:disabled), .field select:not(:disabled), .field textarea:not(:disabled) { background: white; }
.field textarea { min-height: 104px; resize: vertical; }
.field textarea.message-field { min-height: 140px; }
.variant-grid, .choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 24px; }
.variant-card, .choice-card { padding: 18px; border: 1px solid var(--color-border); border-radius: 10px; background: #fbfbfc; }
.variant-card.selected { border: 2px solid var(--color-action); background: #fffaf8; }
.variant-card h3 { margin-top: 14px; }
.variant-card p, .variant-card li, .choice-card small { color: var(--color-muted); font-size: 12px; line-height: 1.55; }
.variant-card ul { margin-bottom: 0; padding-left: 18px; }
.risk-list { display: grid; grid-template-columns: max-content 1fr; align-items: start; gap: 8px 10px; margin: 16px 0; }
.risk-list small { color: var(--color-muted); font-size: 11px; line-height: 1.45; }
.retain-original { margin-top: 20px; }
.choice-card { display: flex; gap: 12px; }
.choice-form { display: grid; align-content: start; }
.choice-card strong, .choice-card small { display: block; }
.choice-card small { margin-top: 6px; }
.sticky-panel { position: sticky; top: 24px; }
.sticky-panel h2 { margin: 8px 0 24px; }
.summary-list { margin: 0; }
.summary-list div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--color-border); font-size: 12px; }
.summary-list dt { color: var(--color-muted); }
.summary-list dd { margin: 0; color: var(--color-navy); font-weight: 750; text-align: right; }
.manual-callout { margin: 20px 0; padding: 14px; border-radius: 8px; background: #f1f5fb; }
.manual-callout strong { color: var(--color-navy); }
.manual-callout p, .helper { margin: 5px 0 0; color: var(--color-muted); font-size: 11px; line-height: 1.5; }
.detail-list { margin: 20px 0 0; }
.detail-list div { padding: 14px 0; border-bottom: 1px solid var(--color-border); }
.detail-list dt { color: var(--color-muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.detail-list dd { margin: 6px 0 0; color: var(--color-text); font-size: 13px; line-height: 1.55; }
.command-hint { display: block; margin-top: 20px; padding: 14px; overflow-wrap: anywhere; border-radius: 8px; background: #f1f3f7; color: var(--color-navy); font-size: 11px; line-height: 1.55; }
.people-panel { margin-top: 24px; overflow-x: auto; }
.people-table { min-width: 700px; }
.people-row { display: grid; grid-template-columns: minmax(220px, 1.5fr) 1fr 1fr 1fr; align-items: center; gap: 16px; padding: 16px 4px; border-bottom: 1px solid var(--color-border); font-size: 12px; }
.route-segment-row { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, 1fr); align-items: center; gap: 16px; padding-inline: 4px; }
.people-row > span:first-child strong, .people-row > span:first-child small { display: block; }
.people-row small { margin-top: 4px; color: var(--color-muted); }
.people-head { color: var(--color-muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.breadcrumb { display: flex; gap: 8px; margin-bottom: 24px; color: var(--color-muted); font-size: 12px; }
.breadcrumb a { color: var(--color-action); }
.timeline { margin: 24px 0 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 26px 34px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 5px; width: 10px; height: 10px; border: 2px solid #b9c0ce; border-radius: 50%; background: white; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 19px; bottom: 2px; width: 1px; background: #d8dce4; }
.timeline .complete::before { border-color: var(--color-success); background: var(--color-success); }
.timeline .current::before { border-color: var(--color-action); background: var(--color-action); box-shadow: 0 0 0 4px #fbeae4; }
.timeline strong, .timeline small { display: block; }
.timeline small { margin-top: 5px; color: var(--color-muted); font-size: 11px; }
.boundary-list { display: grid; gap: 14px; margin: 24px 0; padding: 0; list-style: none; font-size: 13px; }
.boundary-list span { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 7px; border-radius: 50%; background: #fbeae4; color: var(--color-action); font-weight: 850; }
.learning-panel { margin-top: 24px; }
.outcome-flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 24px 0; }
.outcome-flow span { min-height: 100px; padding: 14px; border-radius: 8px; background: #eff5f2; color: var(--color-success); font-size: 11px; line-height: 1.4; }
.outcome-flow strong { display: block; margin-bottom: 10px; font-family: var(--font-display); font-size: 24px; }
.outcome-flow .diagnostic { background: #f1f3f7; color: var(--color-muted); }
.principle-band small { display: block; margin-top: 4px; }

/* --- Semantic feedback: danger and success ------------------------------- */
.status-danger { background: var(--color-danger-tint); color: var(--color-danger); }
.notice-danger { border-left-color: var(--color-danger-accent); background: var(--color-danger-tint); }
.notice-success { border-left-color: var(--color-success); background: #f2faf6; }

/* --- Button variants ------------------------------------------------------ */
.button-ghost { background: transparent; border-color: transparent; color: var(--color-navy); }
.button-ghost:hover { background: #eef0f4; }
.button-destructive { background: var(--color-danger); color: white; }
.button-destructive:hover { background: var(--color-danger-hover); }
.button[aria-busy="true"] { position: relative; color: transparent; pointer-events: none; }
.button[aria-busy="true"]::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentcolor; border-top-color: transparent; border-radius: 50%; color: white; animation: button-spin 700ms linear infinite; }
.button-secondary[aria-busy="true"]::after, .button-ghost[aria-busy="true"]::after { color: var(--color-navy); }
@keyframes button-spin { to { transform: rotate(1turn); } }

/* --- Layout primitives ---------------------------------------------------- */
.button-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.pagination .helper { margin: 0; }
.design-aside { display: grid; align-content: start; gap: var(--space-6); min-width: 0; }
.wide { grid-column: 1 / -1; }

/* --- Content primitives --------------------------------------------------- */
.metric-card { min-width: 0; padding: var(--space-5); border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); box-shadow: var(--shadow-card); }
.metric-card span, .metric-card small { display: block; color: var(--color-muted); }
.metric-card span { font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin: var(--space-3) 0 var(--space-2); overflow-wrap: anywhere; color: var(--color-navy); font-family: var(--font-display); font-size: 22px; line-height: 1.2; }
.metric-card small { font-size: 11px; line-height: 1.45; }
.message-preview { margin: var(--space-3) 0; padding: var(--space-3); border-radius: 8px; background: #f7f8fa; color: var(--color-text); font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 208px minmax(0, 1fr); }
  .main-content { width: min(100%, calc(100vw - 208px)); padding-inline: 24px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .design-layout { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .outcome-flow { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .auth-shell { display: block; }
  .auth-context { min-height: auto; gap: 28px; padding: 32px 24px; }
  .auth-context-copy h1 { font-size: 40px; }
  .auth-boundary { display: none; }
  .auth-clerk-region { min-height: auto; padding: 48px 24px 64px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; gap: 16px; padding: 16px; border-right: 0; border-bottom: 1px solid var(--color-border); }
  .primary-nav { display: flex; overflow-x: auto; }
  .primary-nav a, .nav-disabled { flex: 0 0 auto; }
  .sidebar-boundary { display: none; }
  .actor-card { position: absolute; right: 16px; top: 16px; border: 0; padding: 0; }
  .actor-card > span:last-child { display: none; }
  .main-content { width: 100%; padding: 32px 16px 64px; }
  .split-header, .section-heading { align-items: flex-start; flex-direction: column; }
  .content-grid, .detail-grid { grid-template-columns: 1fr; }
  .stepper strong { display: none; }
  .stepper li:not(:last-child)::after { left: 34px; }
  .form-grid, .variant-grid, .choice-grid { grid-template-columns: 1fr; }
  .wide, .field.wide { grid-column: auto; }
  .outcome-flow { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  h1 { font-size: 36px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .campaign-row { align-items: flex-start; flex-direction: column; }
  .campaign-meta { text-align: left; }
  .panel, .form-section { padding: 20px; }
  .outcome-flow { grid-template-columns: 1fr; }
  .principle-band { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
