/* ─────────────────────────────────────────
   Reptst — Design System
   WKL Blue accent on near-black surface
   (accent vars overridden per-user via base.html inline style)
───────────────────────────────────────── */

:root {
  --bg:            #0d0f17;
  --surface:       #13161f;
  --surface-2:     #1a1e2e;
  --surface-3:     #222638;
  --border:        #252a3d;
  --border-bright: #353b55;

  --accent:        #355e91;
  --accent-dim:    rgba(53, 94, 145, 0.12);
  --accent-glow:   rgba(53, 94, 145, 0.25);

  --text:          #e2e8f6;
  --text-muted:    #6b7494;
  --text-dim:      #9ba3c2;

  /* Severity */
  --sev-critical:      #ff88d8;
  --sev-critical-bg:   rgba(255, 136, 216, 0.12);
  --sev-high:          #ff989c;
  --sev-high-bg:       rgba(255, 152, 156, 0.12);
  --sev-medium:        #ffaf66;
  --sev-medium-bg:     rgba(255, 175, 102, 0.12);
  --sev-low:           #ffed99;
  --sev-low-bg:        rgba(255, 237, 153, 0.12);
  --sev-info:          #b7e1f5;
  --sev-info-bg:       rgba(183, 225, 245, 0.12);

  --success:       #4ade80;
  --success-bg:    rgba(74, 222, 128, 0.10);
  --danger:        #f87171;
  --danger-bg:     rgba(248, 113, 113, 0.12);
  --warning:       #fbbf24;

  --sidebar-w:     240px;
  --radius:        8px;
  --radius-lg:     12px;
  --transition:    180ms ease;
}

[data-theme="light"] {
  --bg:            #f5f6fa;
  --surface:       #ffffff;
  --surface-2:     #f0f2f8;
  --surface-3:     #e8ebf4;
  --border:        #dde1ee;
  --border-bright: #c8cede;

  --text:          #1a1e2e;
  --text-muted:    #7a82a0;
  --text-dim:      #4a5278;

  --sev-critical:    #b5166e;
  --sev-critical-bg: rgba(181,22,110,0.08);
  --sev-high:        #c01c22;
  --sev-high-bg:     rgba(192,28,34,0.08);
  --sev-medium:      #a04f00;
  --sev-medium-bg:   rgba(160,79,0,0.08);
  --sev-low:         #7a6400;
  --sev-low-bg:      rgba(122,100,0,0.08);
  --sev-info:        #1060a0;
  --sev-info-bg:     rgba(16,96,160,0.08);

  --success:       #16a34a;
  --success-bg:    rgba(22,163,74,0.10);
  --danger:        #dc2626;
  --danger-bg:     rgba(220,38,38,0.10);
  --warning:       #d97706;
}

/* ── Reset / Base ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #ffaa55; }

::selection { background: var(--accent-glow); }

/* ── Layout ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-mark {
  /* Real brand mark: drop the old letter-tile chrome so the shield reads cleanly. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
}
.sidebar-logo .logo-mark img {
  display: block;
  width: 32px;
  height: auto;
}

/* Login and other standalone uses of the mark. */
img.logo-mark {
  display: block;
  width: 44px;
  height: auto;
  background: transparent;
  border-radius: 0;
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.sidebar-logo .logo-text span {
  color: var(--accent);
}

.sidebar-section {
  padding: 16px 10px 4px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 4px;
}

.sidebar-nav { list-style: none; margin: 0; padding: 0; }

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.sidebar-nav li a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-nav li a.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-nav li a .nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
  flex-shrink: 0;
}
.sidebar-nav li a .nav-icon .icon {
  width: 16px;
  height: 16px;
}
.sidebar-nav li a.active .nav-icon { opacity: 1; }
.sidebar-nav li a .nav-badge {
  margin-left: auto;
  background: var(--danger, #c44);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  line-height: 16px;
  min-width: 18px;
  text-align: center;
}

/* Monochrome line icons — inherit text colour via currentColor */
.icon {
  display: inline-block;
  vertical-align: -0.2em;
  flex-shrink: 0;
}
@keyframes icon-spin {
  to { transform: rotate(360deg); }
}
.icon-spin {
  animation: icon-spin 0.9s linear infinite;
}
.icon-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.icon-label .icon { vertical-align: 0; }

.section-nav-item .nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.section-nav-item.active .nav-icon,
.section-nav-item:hover .nav-icon { opacity: 1; }

.card-title .icon { opacity: 0.85; flex-shrink: 0; }

.btn .icon {
  margin-right: 6px;
  vertical-align: -0.25em;
}
.btn.btn-icon .icon,
.btn-icon-only .icon {
  margin-right: 0;
}
.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 8px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.theme-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  margin-bottom: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
}
.theme-toggle-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.theme-toggle-btn .t-icon {
  width: 16px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.user-pill .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-pill .user-info { flex: 1; min-width: 0; }
.user-pill .user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-pill .user-role {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.user-pill .logout-btn {
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
  transition: color var(--transition);
}
.user-pill .logout-btn:hover { color: var(--danger); }

.view-as-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px 10px;
}
.view-as-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.view-as-select {
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}
.view-as-select:focus {
  outline: none;
  border-color: var(--accent);
}
.view-as-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px;
  background: rgba(251, 191, 36, 0.12);
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--text);
  font-size: 13px;
}
.view-as-banner strong { color: var(--warning); }
.view-as-banner .icon { color: var(--warning); margin-right: 4px; }

/* ── Sidebar collapse ── */
.sidebar {
  transition: width var(--transition), min-width var(--transition);
}

.sidebar.nav-collapsed {
  width: 52px;
  min-width: 52px;
}

.sidebar.nav-collapsed .sidebar-section,
.sidebar.nav-collapsed .sidebar-section-label,
.sidebar.nav-collapsed .sidebar-footer {
  display: none;
}

.sidebar.nav-collapsed .sidebar-logo .logo-text {
  display: none;
}

.sidebar.nav-collapsed .sidebar-logo {
  justify-content: center;
  padding: 14px 8px;
}

.sidebar.nav-collapsed .sidebar-collapse-btn {
  display: none;
}

/* Brand mark is the image itself — no accent tile behind it when collapsed. */
.sidebar.nav-collapsed .logo-mark {
  background: transparent;
  box-shadow: none;
}

/* Expand button shown in topbar when collapsed */
.sidebar-expand-btn {
  display: none;
}

.sidebar.nav-collapsed ~ .main-content .sidebar-expand-btn {
  display: inline-flex;
}

/* ── Main content area ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

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

.download-menu { position: relative; display: inline-block; }
.download-menu > summary {
  list-style: none;
  cursor: pointer;
}
.download-menu > summary::-webkit-details-marker { display: none; }
.download-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  padding: 6px;
  z-index: 40;
}
.download-menu-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}
.download-menu-label:first-child { padding-top: 4px; }
.download-menu-list a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.download-menu-list a:hover { background: var(--surface-3); }
.download-menu-list .download-menu-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.download-menu-list .download-menu-btn:hover { background: var(--surface-3); }

.secure-zip-password-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.qa-mark-quote {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  white-space: pre-wrap;
}
.editor-preview-split {
  display: flex;
  flex: 1;
  min-height: 0;
}
.editor-preview-split .editor-preview-body {
  flex: 1;
  min-width: 0;
}
.preview-toolbar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.qa-marks-panel {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  padding: 12px;
  overflow-y: auto;
}
.qa-marks-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.qa-marks-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.qa-marks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qa-mark-card {
  background: rgba(255,121,0,0.06);
  border: 1px solid rgba(255,121,0,0.25);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.qa-mark-card.done { border-left-color: #355e91; }
.qa-mark-card.resolved { opacity: 0.7; border-left-color: var(--success); }
.qa-mark-card .quote {
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 6px;
  white-space: pre-wrap;
}
.qa-mark-card .actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.ai-writing-quote {
  margin-top: 4px;
  font-style: italic;
  color: var(--text-muted);
}
.ai-writing-suggest {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(99,140,255,0.08);
  border-radius: 4px;
}

.sample-report-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(99,140,255,0.35);
  background: rgba(99,140,255,0.08);
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
}
.sample-report-banner strong {
  color: var(--accent);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.page-body {
  padding: 28px;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: #e86d00;
  border-color: #e86d00;
  color: #fff;
  box-shadow: 0 0 14px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-dim);
  border-color: var(--border-bright);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-bright);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.25);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.25);
}
.btn-success:hover:not(:disabled) {
  background: var(--success);
  color: #0d0f17;
  border-color: var(--success);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-icon { padding: 7px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}

.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder { color: var(--text-muted); }

select option { background: var(--surface-2); color: var(--text); }

textarea { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* A hint written inside its <label> inherits the label's uppercase and bold, so
   the field name and its explanation run together as one shouty sentence. It also
   needs to be a block for the margin above to apply at all. */
label .form-hint {
  display: block;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  margin-top: 3px;
  line-height: 1.45;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* For rows of short selects, where the 200px minimum above wraps three controls
   into two columns and leaves the third stranded on a half-width row. */
.form-row-compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  /* Hints wrap to different line counts, which would otherwise leave the controls
     sitting at ragged heights across the row. */
  align-items: end;
}

/* ── Toggle / checkbox ── */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--surface-3);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: #fff;
}

.toggle-label { font-size: 13px; font-weight: 500; color: var(--text-dim); }

/* ── Report feature toggles ── */
.feature-group + .feature-group { margin-top: 22px; }
.feature-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.feature-row { padding: 7px 0; }
.feature-row + .feature-row { border-top: 1px solid var(--border-subtle, var(--border)); }
.feature-row-child {
  margin-left: 28px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.feature-row-child .feature-help { margin-left: 46px; }
.feature-row.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.feature-help {
  margin: 3px 0 0 46px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}
/* An off section reads as inactive, so the panel scans at a glance. */
.feature-row:has(input:not(:checked)) .toggle-label { opacity: 0.65; }
.feature-row:has(input:not(:checked)) .feature-help { opacity: 0.55; }

/* ── Badges / Severity pills ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-critical { background: var(--sev-critical-bg); color: var(--sev-critical); border: 1px solid rgba(255,136,216,0.3); }
.badge-high     { background: var(--sev-high-bg);     color: var(--sev-high);     border: 1px solid rgba(255,152,156,0.3); }
.badge-medium   { background: var(--sev-medium-bg);   color: var(--sev-medium);   border: 1px solid rgba(255,175,102,0.3); }
.badge-low      { background: var(--sev-low-bg);      color: var(--sev-low);      border: 1px solid rgba(255,237,153,0.3); }
.badge-info     { background: var(--sev-info-bg);     color: var(--sev-info);     border: 1px solid rgba(183,225,245,0.3); }

.badge-success  { background: var(--success-bg);      color: var(--success);      border: 1px solid rgba(74,222,128,0.25); }
.badge-danger   { background: var(--danger-bg);       color: var(--danger);       border: 1px solid rgba(248,113,113,0.25); }
.badge-neutral  { background: var(--surface-3);       color: var(--text-muted);   border: 1px solid var(--border-bright); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td { padding: 11px 14px; color: var(--text-dim); vertical-align: middle; }

/* ── Alerts ── */
.alert {
  padding: 11px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-success { background: var(--success-bg); border-color: rgba(74,222,128,0.25); color: var(--success); }
.alert-danger  { background: var(--danger-bg);  border-color: rgba(248,113,113,0.25); color: var(--danger); }
.alert-warning { background: rgba(251,191,36,0.10); border-color: rgba(251,191,36,0.25); color: var(--warning); }
.alert-info    { background: var(--sev-info-bg); border-color: rgba(183,225,245,0.25); color: var(--sev-info); }

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  margin-bottom: 16px;
  opacity: 0.35;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
}
.empty-state .empty-icon .icon {
  width: 40px;
  height: 40px;
}
.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 8px;
}
.empty-state p { font-size: 13px; margin: 0 0 20px; }

/* ── Modals ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  animation: modal-in 180ms ease;
}

.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Code / editor ── */
.code-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}

.code-toolbar .toolbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
  font-weight: 600;
}

.code-toolbar .toolbar-btn:hover {
  background: var(--border);
  color: var(--text);
}

.code-toolbar .toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border-bright);
  margin: 0 2px;
}

.editor-wrap .form-control {
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: "Inconsolata", "Consolas", monospace;
  font-size: 13px;
  min-height: 180px;
}

/* ── Severity dot ── */
.sev-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sev-dot.critical { background: var(--sev-critical); }
.sev-dot.high     { background: var(--sev-high); }
.sev-dot.medium   { background: var(--sev-medium); }
.sev-dot.low      { background: var(--sev-low); }
.sev-dot.info     { background: var(--sev-info); }

/* ── Finding card (in editor) ── */
.finding-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color var(--transition);
}

.finding-card:hover { border-color: var(--border-bright); }

.finding-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}

.finding-card-header .drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 14px;
  flex-shrink: 0;
}

.finding-card-header .finding-title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finding-card-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
  display: none;
}

.finding-card.expanded .finding-card-body { display: block; }
.finding-card.expanded { border-color: var(--accent); }

.finding-field-guide {
  margin: 4px 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.finding-field-guide > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
}
.finding-field-guide > summary::-webkit-details-marker { display: none; }
.finding-field-guide > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}
.finding-field-guide[open] > summary::before { transform: rotate(90deg); }
.finding-field-guide-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 18px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}
.finding-field-guide-col h4 {
  margin: 10px 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.finding-field-guide-intro {
  margin: 0 0 8px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-dim);
}
.finding-field-guide-col dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.finding-field-guide-col dt {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.finding-field-guide-col dd {
  margin: 2px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* ── Preview pane ── */
.preview-pane {
  background: #fff;
  color: #222;
  border-radius: var(--radius-lg);
  overflow: auto;
  padding: 40px 48px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.6;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.preview-pane h1, .preview-pane h2, .preview-pane h3 {
  color: var(--accent);
  font-weight: 700;
}

.preview-finding-header {
  border-top: 3px solid #ccc;
  padding: 10px 0 0;
  margin-bottom: 16px;
}

/* ── Git log ── */
.git-commit {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.git-commit:last-child { border-bottom: none; }

.git-commit-hash {
  font-family: monospace;
  font-size: 11.5px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.git-commit-msg {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.git-commit-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ── Search bar ── */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 340px;
}
.search-bar input {
  padding-left: 34px;
  background: var(--surface-2);
}
.search-bar .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

/* ── Report list card ── */
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.report-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.report-card:hover {
  border-color: var(--border-bright);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.report-card:hover::before { opacity: 1; }

.report-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.report-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.report-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.report-card-findings {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.report-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Severity count pill ── */
.sev-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}

/* ── Split pane editor layout ── */
.editor-shell {
  display: flex;
  height: calc(100vh - 57px);
  overflow: hidden;
}

.editor-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.editor-main {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.editor-preview {
  width: 45%;
  min-width: 380px;
  border-left: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
}

.editor-preview-toolbar {
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.preview-tabs { display: flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; }
.preview-tab {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.preview-tab:hover { color: var(--text); background: var(--surface-3); }
.preview-tab.active {
  background: var(--surface-3);
  color: var(--text);
}

.editor-preview-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.section-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent;
}

.section-nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.section-nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
}

.section-nav-group-label {
  padding: 14px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* ── Evidence guidance box ── */
.evidence-guidance {
  background: rgba(183,225,245,0.06);
  border: 1px solid rgba(183,225,245,0.18);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 12px;
}

.evidence-guidance-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sev-info);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.evidence-guidance-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 200ms ease;
  max-width: 340px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.danger  { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--sev-info); }

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

/* ── AI Review Annotations ── */
:root {
  --ai-accent:     #7c6aff;
  --ai-accent-dim: rgba(124, 106, 255, 0.12);
}

.toolbar-btn-ai {
  color: var(--ai-accent) !important;
  border-color: rgba(124, 106, 255, 0.35) !important;
}
.toolbar-btn-ai:hover {
  background: var(--ai-accent-dim) !important;
}
.toolbar-btn-ai:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Review All button — dim when disabled */
#ai-review-all-btn:disabled,
#ai-review-all-btn.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Per-field annotations */
.ai-annotations {
  margin-top: 6px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(124, 106, 255, 0.25);
}

.ai-review-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(124, 106, 255, 0.08);
  font-size: 11.5px;
}

.ai-review-label {
  font-weight: 700;
  color: var(--ai-accent);
}

.ai-review-model,
.ai-review-time {
  color: var(--text-muted);
  font-size: 10.5px;
}

.ai-review-summary {
  padding: 6px 10px;
  background: rgba(124, 106, 255, 0.04);
  font-size: 12.5px;
  color: var(--text-dim);
  font-style: italic;
  border-top: 1px solid rgba(124, 106, 255, 0.15);
}

.ai-review-error {
  color: var(--danger);
  font-style: normal;
}

.ai-issue {
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(124, 106, 255, 0.03);
  border-top: 1px solid rgba(124, 106, 255, 0.1);
  font-size: 12px;
  align-items: baseline;
}

.ai-issue-category {
  font-weight: 700;
  font-size: 10px;
  color: var(--ai-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 90px;
  flex-shrink: 0;
}

.ai-issue-text {
  color: var(--text-dim);
  line-height: 1.5;
}

/* Severity overrides */
.ai-issue-warning .ai-issue-category { color: var(--warning); }
.ai-issue-error   .ai-issue-category { color: var(--danger); }

.ai-finding-ref {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  margin-right: 4px;
}

.ai-dismiss-btn {
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  cursor: pointer;
  margin-left: auto;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.ai-dismiss-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}

/* Spinner */
.ai-spinner-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--ai-accent);
}

.ai-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(124, 106, 255, 0.25);
  border-top-color: var(--ai-accent);
  border-radius: 50%;
  animation: ai-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

/* Alignment banner */
.ai-alignment-banner {
  border: 1px solid;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.ai-alignment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.15);
  font-size: 12px;
}

.ai-alignment-summary {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-alignment-issues {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-companion-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-companion-field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.ai-companion-field-body {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.ai-companion-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 14px;
  flex-wrap: wrap;
}

.ai-finding-assist-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-finding-rewrite { margin-bottom: 10px; }
.ai-finding-class-row { margin-bottom: 10px; font-size: 12.5px; }
.ai-finding-class-proposed {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-3);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.ai-finding-class-changes {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 12px;
}
.ai-class-action {
  display: inline-block;
  min-width: 52px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.ai-class-add { color: var(--success); }
.ai-class-remove { color: var(--danger); }
.ai-class-keep { color: var(--text-muted); }
.ai-finding-sources {
  margin: 0;
  padding-left: 18px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ── QA Annotations ── */
.toolbar-btn-qa {
  color: var(--accent) !important;
  border-color: rgba(255,121,0,0.35) !important;
}
.toolbar-btn-qa:hover {
  background: rgba(255,121,0,0.12) !important;
}

.qa-annotations {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qa-comment {
  background: rgba(255,121,0,0.06);
  border: 1px solid rgba(255,121,0,0.25);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
}

.qa-comment.qa-done {
  background: rgba(53,94,145,0.06);
  border-color: rgba(53,94,145,0.25);
  border-left-color: var(--accent);
}

.qa-comment.qa-resolved {
  background: rgba(74,222,128,0.05);
  border-color: rgba(74,222,128,0.2);
  border-left-color: var(--success);
  opacity: 0.75;
}

.qa-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.qa-author {
  font-weight: 700;
  color: var(--accent);
  font-size: 11.5px;
}

.qa-date {
  color: var(--text-muted);
  font-size: 11px;
}

.qa-resolved-badge {
  font-size: 10.5px;
  color: var(--success);
  background: rgba(74,222,128,0.1);
  border: 1px solid rgba(74,222,128,0.25);
  border-radius: 4px;
  padding: 1px 6px;
}

.qa-done-badge {
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(53,94,145,0.3);
  border-radius: 4px;
  padding: 1px 6px;
}

.qa-text {
  color: var(--text-dim);
  line-height: 1.5;
  white-space: pre-wrap;
}

.qa-resolve-btn,
.qa-done-btn {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  background: transparent;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background var(--transition);
}
.qa-resolve-btn {
  color: var(--success);
  border: 1px solid rgba(74,222,128,0.3);
}
.qa-resolve-btn:hover { background: rgba(74,222,128,0.1); }

.qa-done-btn {
  color: var(--accent);
  border: 1px solid rgba(53,94,145,0.3);
  margin-right: 6px;
}
.qa-done-btn:hover { background: var(--accent-dim); }

/* ── Utilities ── */
.text-muted   { color: var(--text-muted) !important; }
.text-accent  { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-sm      { font-size: 12px !important; }
.text-xs      { font-size: 11px !important; }
.fw-bold      { font-weight: 700 !important; }
.d-flex       { display: flex !important; }
.align-center { align-items: center !important; }
.gap-8        { gap: 8px !important; }
.gap-12       { gap: 12px !important; }
.ms-auto      { margin-left: auto !important; }
.mt-0         { margin-top: 0 !important; }
.mb-0         { margin-bottom: 0 !important; }
.mb-16        { margin-bottom: 16px !important; }
.mb-24        { margin-bottom: 24px !important; }
.w-100        { width: 100% !important; }

/* ── QA field flash (highlight on "Go To" navigation) ── */
@keyframes qa-field-flash {
  0%          { outline: 3px solid transparent; box-shadow: none; }
  12%, 38%    { outline: 3px solid #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,0.22); }
  25%, 50%    { outline: 3px solid transparent; box-shadow: none; }
  62%, 88%    { outline: 3px solid #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,0.22); }
  75%, 100%   { outline: 3px solid transparent; box-shadow: none; }
}
.qa-field-flash {
  animation: qa-field-flash 1.6s ease forwards;
  border-radius: 4px;
}

/* ── Audit log ── */
.audit-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.audit-stat { padding: 16px 16px 14px; text-align: center; }
.audit-stat-n {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}
.audit-stat-l {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 6px;
}
.audit-filters { padding: 16px 18px 14px; margin-bottom: 16px; }
.audit-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 12px;
}
.audit-filters-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}
.audit-filters-grid input,
.audit-filters-grid select {
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  width: 100%;
}
.audit-filters-grid input:focus,
.audit-filters-grid select:focus {
  outline: none;
  border-color: var(--accent);
}
.audit-filters-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.audit-table { width: 100%; }
.audit-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.audit-table td { vertical-align: top; padding: 10px 12px; }
.audit-ts { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-dim); }
.audit-ip { font-size: 12px; color: var(--text-dim); }
.audit-ua { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-cat { font-size: 10px; margin-bottom: 3px; }
.audit-action { font-size: 13px; font-weight: 600; }
.audit-report { font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.audit-detail { font-size: 12px; color: var(--text-muted); max-width: 280px; word-break: break-word; }
.audit-result {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.audit-result-ok { color: var(--success); }
.audit-result-fail { color: var(--danger); }
.audit-result-denied { color: var(--warning); }
.audit-row-denied { background: rgba(248, 113, 113, 0.04); }
.audit-row-failure { background: rgba(251, 191, 36, 0.04); }
.audit-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.access-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 400;
}
.access-toggle input {
  width: 15px;
  height: 15px;
  margin-top: 3px;
  flex-shrink: 0;
}
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 8px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--input-bg);
}
.country-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
}
.country-opt:hover { background: var(--bg); }
.country-opt input { width: 14px; height: 14px; flex-shrink: 0; }
.country-opt span { flex: 1; min-width: 0; }
.country-opt code {
  font-size: 10px;
  color: var(--text-muted);
  background: none;
}

/* ── Role picker (create / edit user) ── */
.role-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 1fr);
  gap: 14px;
  margin-top: 6px;
  align-items: stretch;
}
@media (max-width: 720px) {
  .role-picker { grid-template-columns: 1fr; }
}
.role-pick-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.role-pick {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 400;
}
.role-pick:hover,
.role-pick:focus-within {
  border-color: var(--border-bright);
  background: var(--bg);
}
.role-pick.is-on {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.role-pick input {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  flex-shrink: 0;
}
.role-pick-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role-pick-label { font-size: 13px; font-weight: 600; color: var(--text); }
.role-pick-sum { font-size: 11px; color: var(--text-muted); line-height: 1.35; }
.role-guide-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg);
  font-size: 12px;
}
.role-guide-title { font-size: 13px; font-weight: 700; color: var(--text); }
.role-guide-summary { color: var(--text-muted); margin: 4px 0 10px; line-height: 1.4; }
.role-guide-empty { color: var(--text-muted); margin: 0; }
.role-guide-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.role-guide-panel h4 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.role-guide-panel ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  line-height: 1.35;
}

/* ── HTTP error pages ── */
.error-screen {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.error-screen.is-standalone {
  min-height: 100vh;
  background: var(--bg);
}
.error-panel {
  width: 100%;
  max-width: 440px;
  text-align: center;
}
.error-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  text-align: left;
}
.error-wordmark {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.error-wordmark span { color: var(--accent); }
.error-company {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.error-card .card-body { padding: 32px 28px 28px; }
.error-code {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 8px;
}
.error-icon {
  color: var(--accent);
  opacity: 0.7;
  margin: 4px 0 12px;
  display: flex;
  justify-content: center;
}
.error-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}
.error-copy {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 22px;
}
.error-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.error-foot {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 20px;
}
.error-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0 0 8px;
}

/* ── API docs ── */
.api-docs { max-width: 920px; }
.api-once {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.api-once-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}
.api-once-row code {
  flex: 1;
  min-width: 0;
  word-break: break-all;
  font-size: 12px;
  padding: 8px 10px;
  background: var(--input-bg);
  border-radius: 6px;
}
.api-key-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  font-size: 13px;
}
.api-example {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  margin: 0 0 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.api-endpoint-list { padding-top: 4px; }
.api-endpoint {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}
.api-endpoint:last-child { border-bottom: none; }
.api-endpoint summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  flex-wrap: wrap;
}
.api-endpoint summary::-webkit-details-marker { display: none; }
.api-endpoint-body { padding: 10px 0 6px 0; }
.api-method {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  min-width: 52px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.api-method-get { background: rgba(76,175,130,0.18); color: #4caf82; }
.api-method-post { background: var(--accent-dim); color: var(--accent); }
.api-method-patch { background: rgba(255,183,77,0.18); color: #ffb74d; }
.api-method-put { background: rgba(124,106,255,0.18); color: #7c6aff; }
.api-method-delete { background: rgba(255,121,121,0.18); color: #ff7979; }
.api-path { font-size: 12.5px; color: var(--text); }
.api-sum { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.api-workflow {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.api-workflow li { padding-left: 4px; }
.api-workflow-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.api-workflow-call {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 8px;
  border-radius: 4px;
}

/* ── Help / guide ── */
.help-docs { max-width: 820px; }
.help-hero .card-body { padding-top: 20px; padding-bottom: 18px; }
.help-hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.help-hero-lead {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 62ch;
}
.help-docs .help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}
.help-docs .help-toc a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
}
.help-docs .help-toc a:hover {
  color: var(--text);
  border-color: var(--accent);
}
.help-prose {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
}
.help-prose p { margin: 0 0 12px; }
.help-ol, .help-ul {
  margin: 0 0 12px;
  padding-left: 1.25rem;
}
.help-ol li, .help-ul li { margin-bottom: 6px; }
.help-callout {
  background: var(--accent-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.55;
}
.help-callout-muted {
  background: var(--surface-2);
  border-color: var(--border);
}
.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.help-table th,
.help-table td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.help-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-2);
}
.help-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
  width: 28%;
}
.help-group-label {
  font-size: 11px;
  margin: 18px 0 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.help-feature {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.help-feature:last-child { border-bottom: none; }
.help-feature-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.help-feature-title { font-weight: 700; font-size: 13px; }
.help-feature-help {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 4px 0 0;
  line-height: 1.5;
}
.help-feature-child { padding-left: 16px; }
.help-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
}
.help-pill-muted {
  background: var(--surface-3);
  color: var(--text-muted);
}
.help-status-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  font-size: 13px;
}
.help-status-flow code {
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: 4px;
}
