/* ==========================================================================
   NarraSight Portal — Stage 2 Sandbox
   Design tokens matched to demo.html for product-surface continuity.
   WCAG 2.1 AA minimum on every text/background pair.
   ========================================================================== */

:root {
  /* Surfaces — navy palette matched to demo.html */
  --bg: #0a1628;
  --bg-deep: #060d18;
  --surface: #111b2e;
  --surface-2: #162236;
  --surface-3: #1a2940;
  --border: #1e2d45;
  --border-2: #243450;
  --border-strong: #2e4060;

  /* Text */
  --text: #f0f4f8;
  --text-secondary: #b3c2d3;   /* lightened from demo's #8899b0 to keep ≥4.5:1 on surface-2 */
  --text-muted: #8899b0;
  --text-on-accent: #052e1a;

  /* Brand accent */
  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-dim: rgba(16, 185, 129, 0.15);
  --accent-strong: #059669;

  /* Status */
  --error: #f87171;            /* lightened to maintain contrast on dark */
  --error-bg: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);
  --success: var(--accent);
  --success-bg: var(--accent-dim);

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Monaco, "Courier New", monospace;

  /* Motion — brand site's golden easing */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Focus */
  --focus-ring: 0 0 0 3px rgba(16, 185, 129, 0.6);
  --focus-ring-error: 0 0 0 3px rgba(248, 113, 113, 0.55);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);

  /* Layout */
  --nav-height: 64px;
  --sidebar-width: 240px;
  --content-max: 1280px;
}

/* ----- Reset / base ----- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* ----- Focus — visible 3px ring on EVERY interactive element ----- */
*:focus { outline: none; }
*:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  box-shadow: var(--focus-ring);
}

/* ----- Skip link ----- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 10px 16px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  z-index: 9999;
  transition: top var(--transition);
}
.skip-link:focus {
  top: 12px;
  text-decoration: none;
}

/* ----- Screen-reader only ----- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ----- Sandbox banner (visible on every page) ----- */
.sandbox-banner {
  background: var(--warning-bg);
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  letter-spacing: 0.01em;
}
.sandbox-banner strong { color: #fcd34d; font-weight: 700; }

/* ----- Top nav ----- */
.portal-nav {
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.portal-nav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}
.portal-nav .brand:hover { color: var(--text); }
.portal-nav .brand svg { color: var(--accent); }
.portal-nav .brand-name { font-size: 17px; letter-spacing: -0.01em; }
.portal-nav .brand-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.portal-nav nav { display: flex; gap: 4px; margin-left: 16px; }
.portal-nav nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}
.portal-nav nav a:hover { background: var(--surface-2); color: var(--text); }
.portal-nav nav a[aria-current="page"] {
  background: var(--accent-dim);
  color: var(--accent-hover);
}

.portal-nav .nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tenant-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}
.tenant-switcher select {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  padding-right: 4px;
}
.tenant-switcher .swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

/* ----- Layout ----- */
.portal-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100vh - var(--nav-height));
}
.portal-main {
  padding: 32px;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}
.portal-main--narrow { max-width: 800px; }

.page-header {
  margin-bottom: 32px;
}
.page-header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ----- Cards ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card + .card { margin-top: 20px; }
.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ----- Stat cards (dashboard) ----- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-card .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
}
.stat-card .value.accent { color: var(--accent-hover); }
.stat-card .delta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}
.stat-card .delta.positive { color: var(--accent-hover); }
.stat-card .delta.negative { color: var(--error); }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-on-accent);
}
.btn--ghost {
  background: transparent;
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border-2); }

.btn--danger {
  background: transparent;
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--error);
}
.btn--danger:hover { background: var(--error-bg); border-color: var(--error); }

.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 12px 24px; font-size: 15px; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ----- Forms ----- */
.field {
  margin-bottom: 22px;
}
.field label,
.field .field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field .required {
  color: var(--accent-hover);
  font-weight: 700;
  margin-left: 2px;
}
.field .why,
.field .lawful-basis {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
}
.field .lawful-basis {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 6px;
  font-family: var(--font-mono);
}
.field .lawful-basis::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--border-strong);
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.field textarea { resize: vertical; min-height: 84px; font-family: var(--font-sans); }
.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--error);
}
.field input[aria-invalid="true"]:focus-visible { box-shadow: var(--focus-ring-error); }

.field .error-msg {
  color: var(--error);
  font-size: 13px;
  margin-top: 6px;
  display: block;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

/* Checkbox + radio */
.checkbox, .radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.checkbox:hover, .radio:hover { border-color: var(--border-strong); background: var(--surface-2); }
.checkbox input, .radio input { margin-top: 3px; accent-color: var(--accent); }
.checkbox-text, .radio-text { flex: 1; font-size: 14px; }
.checkbox-help, .radio-help { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.checkbox input:focus-visible + .checkbox-text,
.radio input:focus-visible + .radio-text {
  outline: var(--focus-ring);
}
.checkbox:has(input:checked), .radio:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.checkbox-list, .radio-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Range slider */
.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.range-value {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-mono);
  color: var(--accent-hover);
  font-weight: 600;
}

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
}
.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-2);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .row-checkbox { width: 32px; }
.data-table .thumb-cell { width: 64px; }
.data-table .thumb-cell .thumb {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.data-table .thumb img { width: 100%; height: 100%; object-fit: cover; }
.data-table .alt-cell { max-width: 480px; font-size: 13px; color: var(--text-secondary); }
.data-table code { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* ----- Status badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-sans);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge--draft { color: var(--text-secondary); background: var(--surface-2); border-color: var(--border-2); }
.badge--review { color: var(--warning); background: var(--warning-bg); border-color: rgba(251, 191, 36, 0.3); }
.badge--approved { color: var(--accent-hover); background: var(--accent-dim); border-color: rgba(16, 185, 129, 0.35); }
.badge--published { color: var(--info); background: var(--info-bg); border-color: rgba(96, 165, 250, 0.3); }
.badge--rejected { color: var(--error); background: var(--error-bg); border-color: rgba(248, 113, 113, 0.3); }
.badge--missing { color: var(--error); background: var(--error-bg); border-color: rgba(248, 113, 113, 0.3); }
.badge--offline { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }

.confidence-bar {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px;
}
.confidence-bar .bar {
  width: 56px; height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.confidence-bar .fill {
  height: 100%;
  background: var(--accent);
  transition: width var(--transition);
}

/* ----- Wizard steps ----- */
.wizard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
}
.wizard-progress {
  display: flex;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  gap: 8px;
  overflow-x: auto;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.wizard-step .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.wizard-step .label-text { overflow: hidden; text-overflow: ellipsis; }
.wizard-step--active { color: var(--text); font-weight: 600; }
.wizard-step--active .num { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.wizard-step--done { color: var(--text-secondary); }
.wizard-step--done .num { background: var(--accent-dim); color: var(--accent-hover); border-color: var(--accent); }

.wizard-body { padding: 32px; }
.wizard-body h2 { margin-bottom: 6px; font-size: 22px; }
.wizard-body .step-intro {
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.wizard-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 32px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ----- Why panel ----- */
details.why-panel {
  margin-top: 4px;
  margin-bottom: 8px;
}
details.why-panel summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}
details.why-panel summary::-webkit-details-marker { display: none; }
details.why-panel summary::before {
  content: "▸";
  display: inline-block;
  transition: transform var(--transition);
  font-size: 10px;
}
details.why-panel[open] summary::before { transform: rotate(90deg); }
details.why-panel summary:hover { color: var(--accent-hover); }
details.why-panel .why-body {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ----- Toast / aria-live ----- */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 12px);
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: toast-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
  border-left-width: 4px;
}
.toast--success { border-left-color: var(--accent); }
.toast--error { border-left-color: var(--error); }
.toast--info { border-left-color: var(--info); }
.toast--warning { border-left-color: var(--warning); }
.toast .toast-msg { flex: 1; }
.toast .toast-title { font-weight: 600; margin-bottom: 2px; }
.toast .toast-body { color: var(--text-secondary); font-size: 13px; }
.toast .toast-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.toast .toast-close:hover { color: var(--text); background: var(--surface-3); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----- Diff view ----- */
.diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
.diff-pane {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.diff-pane .diff-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.diff-pane .diff-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  font-family: var(--font-sans);
  white-space: pre-wrap;
}
.diff-pane .diff-empty { color: var(--text-muted); font-style: italic; }
.diff-pane--current { border-color: rgba(248, 113, 113, 0.3); }
.diff-pane--current .diff-label { color: var(--error); }
.diff-pane--generated { border-color: var(--accent); }
.diff-pane--generated .diff-label { color: var(--accent-hover); }

.char-counter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.char-counter--warn { color: var(--warning); }
.char-counter--error { color: var(--error); }

/* ----- Review actions ----- */
.review-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius);
  margin-top: 16px;
  flex-wrap: wrap;
}
.kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0 2px;
}

/* ----- Login page ----- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, var(--surface) 0%, var(--bg-deep) 60%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.login-card .login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card .subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 14px; }
.login-card .demo-hint {
  background: var(--accent-dim);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 20px;
}
.login-card .demo-hint strong { color: var(--accent-hover); }

/* ----- Audit log ----- */
.audit-list { list-style: none; padding: 0; }
.audit-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.audit-item:last-child { border-bottom: none; }
.audit-item .audit-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.audit-item .audit-actor {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 2px;
}
.audit-item .audit-action {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.audit-item .audit-diff {
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 6px;
}
.audit-item .audit-diff .diff-before {
  color: var(--error);
  text-decoration: line-through;
  display: block;
  margin-bottom: 2px;
}
.audit-item .audit-diff .diff-after {
  color: var(--accent-hover);
  display: block;
}

/* ----- Empty / loading states ----- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; }
.empty-state .empty-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  color: var(--text-muted);
  opacity: 0.6;
}

.loading-shimmer {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: -100% 0; }
  to { background-position: 100% 0; }
}

/* ----- Footer ----- */
.portal-footer {
  border-top: 1px solid var(--border);
  padding: 24px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 48px;
}
.portal-footer a { color: var(--text-secondary); text-decoration: none; }
.portal-footer a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ----- Responsive ----- */
@media (max-width: 900px) {
  .portal-nav { padding: 0 16px; gap: 12px; }
  .portal-nav nav { display: none; }   /* sub-nav handled via in-page tabs on mobile */
  .portal-nav .brand-tag { display: none; }
  .portal-main { padding: 24px 16px; }
  .diff-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .wizard-body { padding: 20px; }
  .wizard-footer { padding: 14px 20px; flex-direction: column-reverse; }
  .wizard-footer .btn { width: 100%; }
  .audit-item { grid-template-columns: 1fr; }
}

/* ----- prefers-reduced-motion ----- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ----- High contrast ----- */
@media (prefers-contrast: more) {
  :root {
    --border: #4a5568;
    --border-2: #5a6678;
    --text-secondary: #d4dae3;
  }
}

/* ----- Section head + chip ----- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--surface-2, #f4f6fa); color: var(--text-secondary); }
.chip--connected { background: #e8f5ee; border-color: #b9dcc5; color: #1a6b3b; }
.chip--connected::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2ea25a; }
@media (prefers-contrast: more) { .chip--connected { background: #d4ebdb; border-color: #1a6b3b; color: #0c4423; } }

/* ----- a11y patch: search inputs (used outside .field) ----- */
input[type="search"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input[type="search"]:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}
input[type="search"]::placeholder { color: var(--text-muted); }

/* ----- a11y patch: footer links must be distinguishable from surrounding text ----- */
.portal-footer a, .portal-footer a:visited {
  color: #d6e0ec;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.portal-footer a:hover, .portal-footer a:focus-visible {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
}
