/* ============ THEME SYSTEM ============ */
:root {
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --transition: all .2s cubic-bezier(.4, 0, .2, 1);
  --transition-slow: all .3s cubic-bezier(.4, 0, .2, 1);
  --success: #10b981;
  --success-light: #34d399;
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --danger: #ef4444;
  --danger-light: #f87171;
  --info: #3b82f6;
  --info-light: #60a5fa;
}

[data-theme="sunset"] {
  --primary: #fb7185;
  --primary-dark: #f43f5e;
  --primary-light: #ffe4e6;
  --primary-glow: rgba(244, 63, 94, .28);
  --bg-base: #fff7ed;
  --bg-elevated: #fff;
  --bg-card: #fff;
  --bg-hover: #fffbeb;
  --bg-active: #fed7aa;
  --bg-input: #fff;
  --text-primary: #3b0f1f;
  --text-secondary: #7c2d12;
  --text-muted: #9a3412;
  --text-dim: #f97316;
  --border: #fed7aa;
  --border-light: #ffedd5;
  --border-focus: #f97316;
  --shadow-sm: 0 1px 3px rgba(124, 45, 18, .08);
  --shadow-md: 0 4px 12px rgba(124, 45, 18, .1);
  --shadow-lg: 0 10px 25px rgba(124, 45, 18, .12);
  --shadow-glow: 0 0 30px var(--primary-glow);
  --gradient-bg: radial-gradient(ellipse at 10% 0%, rgba(248, 113, 113, .14) 0%, transparent 55%), radial-gradient(ellipse at 90% 100%, rgba(251, 191, 36, .12) 0%, transparent 55%);
}

[data-theme="ocean"] {
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --primary-light: #e0f2fe;
  --primary-glow: rgba(56, 189, 248, .3);
  --bg-base: #f0f9ff;
  --bg-elevated: #fff;
  --bg-card: #fff;
  --bg-hover: #e0f2fe;
  --bg-active: #bae6fd;
  --bg-input: #fff;
  --text-primary: #0f172a;
  --text-secondary: #0e7490;
  --text-muted: #0369a1;
  --text-dim: #38bdf8;
  --border: #bae6fd;
  --border-light: #7dd3fc;
  --border-focus: #0ea5e9;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .1);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .12);
  --shadow-glow: 0 0 30px var(--primary-glow);
  --gradient-bg: radial-gradient(ellipse at 15% 0%, rgba(56, 189, 248, .16) 0%, transparent 55%), radial-gradient(ellipse at 85% 100%, rgba(37, 99, 235, .1) 0%, transparent 55%);
}

[data-theme="vibrant"] {
  --primary: #a855f7;
  --primary-dark: #7c3aed;
  --primary-light: #e9d5ff;
  --primary-glow: rgba(168, 85, 247, .3);
  --bg-base: #faf5ff;
  --bg-elevated: #fff;
  --bg-card: #fff;
  --bg-hover: #f3e8ff;
  --bg-active: #e9d5ff;
  --bg-input: #fff;
  --text-primary: #2e1065;
  --text-secondary: #4c1d95;
  --text-muted: #6b21a8;
  --text-dim: #a855f7;
  --border: #ddd6fe;
  --border-light: #e9d5ff;
  --border-focus: #a855f7;
  --shadow-sm: 0 1px 3px rgba(46, 16, 101, .08);
  --shadow-md: 0 4px 12px rgba(46, 16, 101, .1);
  --shadow-lg: 0 10px 25px rgba(46, 16, 101, .12);
  --shadow-glow: 0 0 30px var(--primary-glow);
  --gradient-bg: radial-gradient(ellipse at 20% 0%, rgba(168, 85, 247, .18) 0%, transparent 55%), radial-gradient(ellipse at 80% 100%, rgba(45, 212, 191, .12) 0%, transparent 55%);
}

[data-theme="light"] {
  --primary: #0ea5e9;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --primary-glow: rgba(14, 165, 233, .25);
  --bg-base: #f9fafb;
  --bg-elevated: #fff;
  --bg-card: #fff;
  --bg-hover: #f3f4f6;
  --bg-active: #e5e7eb;
  --bg-input: #fff;
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #4b5563;
  --text-dim: #6b7280;
  --border: #e5e7eb;
  --border-light: #d1d5db;
  --border-focus: #0ea5e9;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .1);
  --shadow-glow: 0 0 30px var(--primary-glow);
  --gradient-bg: radial-gradient(ellipse at 15% 0%, rgba(148, 163, 184, .12) 0%, transparent 55%), radial-gradient(ellipse at 85% 100%, rgba(14, 165, 233, .12) 0%, transparent 55%);
}

[data-theme="dark"] {
  --primary: #2dd4bf;
  --primary-dark: #14b8a6;
  --primary-light: #5eead4;
  --primary-glow: rgba(45, 212, 191, .45);
  --bg-base: #020617;
  --bg-elevated: #02071f;
  --bg-card: #020b27;
  --bg-hover: #031022;
  --bg-active: #041326;
  --bg-input: #020a20;
  --text-primary: #f3f4f6;
  --text-secondary: #e5e7eb;
  --text-muted: #9ca3af;
  --text-dim: #22c55e;
  --border: #1f2937;
  --border-light: #334155;
  --border-focus: #2dd4bf;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .7);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, .85);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .85);
  --shadow-glow: 0 0 40px var(--primary-glow);
  --gradient-bg: radial-gradient(ellipse at 0% 0%, rgba(45, 212, 191, .2) 0%, transparent 55%), radial-gradient(ellipse at 100% 100%, rgba(88, 28, 135, .35) 0%, transparent 55%);
}

[data-theme="mint"] {
  --primary: #2dd4bf;
  --primary-dark: #14b8a6;
  --primary-light: #5eead4;
  --primary-glow: rgba(45, 212, 191, .3);
  --bg-base: #f0fdfa;
  --bg-elevated: #fff;
  --bg-card: #fff;
  --bg-hover: #e6fffa;
  --bg-active: #ccfbf1;
  --bg-input: #fff;
  --text-primary: #0d3331;
  --text-secondary: #115e59;
  --text-muted: #0f766e;
  --text-dim: #14b8a6;
  --border: #99f6e4;
  --border-light: #5eead4;
  --border-focus: #14b8a6;
  --shadow-sm: 0 1px 3px rgba(13, 51, 49, .08);
  --shadow-md: 0 4px 12px rgba(13, 51, 49, .1);
  --shadow-lg: 0 10px 25px rgba(13, 51, 49, .12);
  --shadow-glow: 0 0 30px var(--primary-glow);
  --gradient-bg: radial-gradient(ellipse at 20% 0%, rgba(45, 212, 191, .1) 0%, transparent 50%), radial-gradient(ellipse at 80% 100%, rgba(147, 51, 234, .05) 0%, transparent 50%);
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Manrope', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background .35s, color .35s;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--gradient-bg);
  pointer-events: none;
  z-index: 0;
}

/* ============ ANIMATIONS ============ */
@keyframes fadeSlide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes shimmer { 0% { left: -100%; } 100% { left: 100%; } }

/* ============ LAYOUT ============ */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: 250px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 20;
  transition: background .35s, border-color .35s, width .25s ease;
}
.sidebar-brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); transition: padding .25s ease; }
.sidebar-brand img, .sidebar-logo { max-width: 150px; height: auto; display: block; transition: max-width .25s ease; }
.sidebar-brand span {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 2px; display: block; margin-top: 5px;
  transition: opacity .2s ease;
}
.sidebar-nav { flex: 1; padding: 8px 10px; overflow-y: auto; transition: padding .25s ease; }
.nav-group {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 2px; color: var(--text-muted); padding: 16px 12px 6px; opacity: .6;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: var(--transition); margin-bottom: 1px; position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-active); color: var(--primary); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; background: var(--primary); border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .65; }
.nav-item.active svg { opacity: 1; color: var(--primary); }
.nav-badge {
  margin-left: auto; background: var(--primary); color: var(--bg-base);
  font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: var(--radius-full);
}

/* ============ MAIN ============ */
.main { flex: 1; min-width: 0; margin-left: 250px; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left .25s ease; }

/* ============ TOP BAR ============ */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px; border-bottom: 1px solid var(--border);
  background: var(--bg-elevated); position: sticky; top: 0; z-index: 15;
  transition: background .35s;
}
.top-bar-left { display: flex; align-items: center; gap: 12px; }
.breadcrumb { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.breadcrumb .bc-link { color: var(--primary); cursor: pointer; font-weight: 600; }
.breadcrumb .bc-link:hover { text-decoration: underline; }
.breadcrumb .bc-sep { opacity: .4; }
.breadcrumb .bc-current { color: var(--text-primary); font-weight: 700; }
.top-bar-right { display: flex; align-items: center; gap: 10px; }
.skin-picker {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 5px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-full);
}
.skin-picker label {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); padding: 0 5px;
}
.skin-btn {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; transition: var(--transition);
}
.skin-btn:hover { transform: scale(1.2); }
.skin-btn.active { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--bg-base); }
.skin-btn[data-t="sunset"] { background: linear-gradient(135deg, #fb7185, #f59e0b); }
.skin-btn[data-t="ocean"] { background: linear-gradient(135deg, #38bdf8, #3b82f6); }
.skin-btn[data-t="vibrant"] { background: linear-gradient(135deg, #a855f7, #2dd4bf); }
.skin-btn[data-t="light"] { background: linear-gradient(135deg, #e5e7eb, #0ea5e9); }
.skin-btn[data-t="dark"] { background: linear-gradient(135deg, #020617, #2dd4bf); }
.skin-btn[data-t="mint"] { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }

.content { padding: 24px 28px; flex: 1; min-width: 0; }

/* ============ VIEWS ============ */
.view { display: none; }
.view.active { display: block; animation: fadeSlide .3s ease; }

/* ============ STAT CARDS ============ */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  transition: var(--transition); position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--primary); opacity: 0; transition: opacity .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card:hover::after { opacity: 1; }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.stat-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; background: var(--bg-hover);
}
.stat-icon svg { width: 15px; height: 15px; color: var(--primary); }
.stat-change { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: var(--radius-full); white-space: nowrap; }
.stat-change.up { background: rgba(16, 185, 129, .12); color: var(--success); }
.stat-change.down { background: rgba(239, 68, 68, .12); color: var(--danger); }
.stat-value {
  font-family: 'Outfit', sans-serif; font-size: 26px; font-weight: 800;
  color: var(--text-primary); letter-spacing: -1px; line-height: 1;
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-top: 3px; }

/* ============ QUOTA STRIP ============ */
/* Slim full-width meter showing AI-Reviews usage and reset date.
   Sits below the stats grid on both scan-tier and workflow-tier dashboards. */
.quota-strip {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 20px;
  margin-bottom: 22px; position: relative; overflow: hidden;
  transition: var(--transition); cursor: pointer;
}
.quota-strip::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent, var(--primary)));
  opacity: .55; transition: opacity .2s;
}
.quota-strip:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.quota-strip:hover::before { opacity: 1; }
.quota-strip-icon {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover); flex-shrink: 0;
}
.quota-strip-icon svg { width: 18px; height: 18px; color: var(--primary); }
.quota-strip-body { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.quota-strip-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.quota-strip-label {
  font-size: 12.5px; color: var(--text-muted); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quota-strip-label strong { color: var(--text-primary); font-weight: 800; }
.quota-strip-reset {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap; flex-shrink: 0;
}
.quota-strip-bar {
  height: 8px; background: var(--bg-hover); border-radius: var(--radius-full);
  overflow: hidden; position: relative;
}
.quota-strip-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent, var(--primary)));
  border-radius: var(--radius-full);
  transition: width .4s cubic-bezier(.2, .8, .25, 1);
}
.quota-strip-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.quota-strip-fill.danger {
  background: linear-gradient(90deg, var(--danger), #f87171);
}
.quota-strip-buy {
  flex-shrink: 0;
  font-size: 12px; font-weight: 700;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.quota-strip-buy:hover { background: var(--primary-dark, var(--primary)); transform: translateY(-1px); }
.quota-strip-buy:disabled { opacity: .6; cursor: wait; transform: none; }
.quota-strip.unlimited .quota-strip-bar { display: none; }
.quota-strip.unlimited .quota-strip-row { flex: 1; }

/* ============ FILTER BAR ============ */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  margin-bottom: 16px; flex-wrap: nowrap; overflow-x: auto;
}
.filter-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); white-space: nowrap;
}
.filter-select, .filter-date {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-primary); cursor: pointer;
  transition: var(--transition); outline: none;
}
.filter-search {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 500;
  padding: 6px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-primary);
  transition: var(--transition); outline: none; min-width: 200px;
}
.filter-search::placeholder { color: var(--text-muted); font-weight: 500; }
.filter-search:focus {
  border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-glow);
}
.filter-select:focus, .filter-date:focus {
  border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-glow);
}
.filter-sep { width: 1px; height: 22px; background: var(--border); }
.chip {
  font-family: 'Manrope', sans-serif; font-size: 11px; font-weight: 700;
  padding: 5px 13px; border-radius: var(--radius-full);
  border: 1.5px solid var(--border); background: transparent;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: var(--bg-base); border-color: var(--primary); }
.filter-clear {
  font-family: 'Manrope', sans-serif; font-size: 10px; font-weight: 700;
  padding: 5px 10px; border: none; background: transparent;
  color: var(--danger-light); cursor: pointer; margin-left: auto;
}
.filter-clear:hover { background: rgba(239, 68, 68, .08); border-radius: var(--radius-sm); }

/* ============ TABLE ============ */
.tbl-wrap {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.tbl-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.tbl-head h3 { font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
table th {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); padding: 9px 18px;
  text-align: left; background: var(--bg-hover); border-bottom: 1px solid var(--border);
}
table td {
  font-size: 12.5px; font-weight: 500; padding: 12px 18px;
  border-bottom: 1px solid var(--border); color: var(--text-secondary);
}
table tr:last-child td { border-bottom: none; }
table tr { cursor: pointer; transition: var(--transition); }
table tr:hover td { background: var(--bg-hover); }
table tr.row-active td { background: var(--bg-active); }
.td-id { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--primary); font-size: 12px; }
.td-bold { font-weight: 700; color: var(--text-primary); }
.pill {
  font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  padding: 4px 10px; border-radius: 6px; display: inline-block;
  white-space: nowrap; line-height: 1.4;
}
.pill-pending { background: rgba(245, 158, 11, .10); color: var(--warning); }
.pill-approved { background: rgba(16, 185, 129, .10); color: var(--success); }
.pill-revision { background: rgba(239, 68, 68, .10); color: var(--danger); }
.pill-review { background: rgba(59, 130, 246, .10); color: var(--info); }

/* ============ SUBMISSION DETAIL VIEW ============ */
.detail-back {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--primary);
  cursor: pointer; margin-bottom: 16px; padding: 5px 0; transition: var(--transition);
}
.detail-back:hover { opacity: .7; }
.detail-back svg { width: 16px; height: 16px; }

.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 24px; }
.detail-header-left { flex: 1; min-width: 0; }
.detail-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-title { font-family: 'Outfit', sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.detail-type-badge {
  font-size: 11px; font-weight: 700; padding: 4px 14px;
  border-radius: var(--radius-full); background: var(--bg-active);
  color: var(--primary); border: 1px solid var(--border);
  white-space: nowrap;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 8px; }
.detail-meta-item { font-size: 12px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.detail-meta-item.detail-meta-study { white-space: normal; flex-basis: 100%; }
.detail-meta-item b { font-weight: 700; color: var(--text-secondary); }
.detail-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.detail-actions .ai-scan-btn {
  margin: 0; padding: 10px 26px;
  font-size: 13.5px; border-radius: var(--radius-full);
  height: auto; letter-spacing: 0.01em;
  box-shadow: 0 0 20px var(--primary-glow), 0 2px 8px rgba(0,0,0,.06);
}
.detail-actions .ai-scan-btn svg { width: 16px; height: 16px; }
.detail-actions .ai-scan-btn:hover {
  box-shadow: 0 0 32px var(--primary-glow), 0 4px 16px rgba(0,0,0,.1);
  transform: translateY(-2px);
}
.detail-actions .ai-scan-wrap {
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

/* Wrapper so the AI disclaimer sits directly under the Run AI-Review button
   without affecting the vertical alignment of sibling action buttons. */
.ai-scan-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.ai-scan-disclaimer {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 600;
  font-style: italic;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--primary);
  opacity: 0.72;
  user-select: none;
  pointer-events: none;
}
.ai-scan-disclaimer svg {
  width: 10px;
  height: 10px;
  stroke-width: 2.2;
  flex-shrink: 0;
}

/* ============ TABS ============ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
  font-family: 'Manrope', sans-serif; font-size: 12.5px; font-weight: 700;
  padding: 10px 20px; cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-badge {
  background: var(--primary); color: var(--bg-base);
  font-size: 9px; font-weight: 800; padding: 1px 6px;
  border-radius: 10px; margin-left: 5px;
}
.tab-panel { display: none; animation: fadeSlide .25s ease; }
.tab-panel.active { display: block; }

/* ============ DOC LIST ============ */
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  transition: var(--transition); cursor: pointer;
}
.doc-row:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doc-row.doc-clickable:hover { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.doc-row.doc-disabled { opacity: .55; cursor: default; }
.doc-row.doc-disabled:hover { border-color: var(--border); box-shadow: none; transform: none; }
/* doc-ready: uploaded, awaiting an AI review. Full opacity (the file is real and ready),
   but no clickable affordance — the doc viewer needs sections produced by a scan. */
.doc-row.doc-ready { cursor: default; }
.doc-row.doc-ready:hover { border-color: var(--border); box-shadow: none; transform: none; }
.doc-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.doc-icon svg { width: 20px; height: 20px; }
.doc-icon-pdf { background: rgba(239, 68, 68, .1); color: var(--danger); }
.doc-icon-doc { background: rgba(59, 130, 246, .1); color: var(--info); }
.doc-icon-xls { background: rgba(16, 185, 129, .1); color: var(--success); }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.doc-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.doc-row-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.doc-size { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }
.doc-review-status { display: flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; }
.doc-review-status.needs-review { color: var(--warning); }
.doc-review-status.reviewed { color: var(--success); }
.doc-review-status.issues { color: var(--danger); }
.doc-review-status svg { width: 13px; height: 13px; }
.doc-open-arrow { color: var(--text-muted); opacity: .4; transition: var(--transition); }
.doc-row:hover .doc-open-arrow { opacity: 1; color: var(--primary); }

/* ============ METADATA GRID ============ */
.meta-panel-header { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.edit-meta-form { max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.meta-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px 18px;
}
.meta-card-title {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 10px;
}
.meta-row {
  display: flex; justify-content: space-between; padding: 5px 0;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.meta-row:last-child { border-bottom: none; }
.meta-label { color: var(--text-muted); font-weight: 600; }
.meta-value { color: var(--text-primary); font-weight: 700; text-align: right; }

/* ============ ACTIVITY LOG ============ */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border); position: relative;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.activity-dot.dot-submit { background: var(--info); }
.activity-dot.dot-review { background: var(--warning); }
.activity-dot.dot-approve { background: var(--success); }
.activity-dot.dot-upload { background: var(--primary); }
.activity-dot.dot-comment { background: var(--text-muted); }
.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 12.5px; color: var(--text-primary); font-weight: 500; }
.activity-text b { font-weight: 700; }
.activity-time { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* ============ REVIEWER CARDS ============ */
.reviewer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.reviewer-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px;
  display: flex; align-items: center; gap: 12px;
}
.reviewer-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: white; flex-shrink: 0;
}
.reviewer-info { flex: 1; min-width: 0; }
.reviewer-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.reviewer-role { font-size: 10.5px; color: var(--text-muted); font-weight: 500; }
.reviewer-status {
  font-size: 10px; font-weight: 700; padding: 3px 9px;
  border-radius: var(--radius-full); margin-top: 4px; display: inline-block;
}

/* ============ BUTTONS ============ */
.btn {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 700;
  padding: 8px 18px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; transition: var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--primary); color: var(--bg-base); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-hover); }
.btn-accent { background: var(--success); color: #fff; }
.btn-accent:hover { background: #059669; box-shadow: var(--shadow-md); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; box-shadow: var(--shadow-md); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; box-shadow: var(--shadow-md); }
.btn-warn { background: var(--warning); color: white; }
.btn-warn:hover { background: #d97706; }
.btn-sm { padding: 6px 12px; font-size: 11px; }

/* ============ SUBMISSION TYPE CARDS ============ */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.type-card {
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px; cursor: pointer;
  transition: var(--transition-slow); position: relative; overflow: hidden;
}
.type-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: transparent; transition: background .25s;
}
.type-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.type-card:hover::before, .type-card.selected::before { background: var(--primary); }
.type-card.selected { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.type-card-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--bg-hover); display: flex; align-items: center;
  justify-content: center; margin-bottom: 14px; transition: var(--transition);
}
.type-card:hover .type-card-icon, .type-card.selected .type-card-icon { background: var(--primary); }
.type-card-icon svg { width: 20px; height: 20px; color: var(--primary); transition: color .2s; }
.type-card:hover .type-card-icon svg, .type-card.selected .type-card-icon svg { color: var(--bg-base); }
.type-card h3 {
  font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 5px;
}
.type-card p { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.type-tag {
  display: inline-block; font-size: 9.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .8px;
  padding: 3px 9px; border-radius: 6px; margin-top: 12px;
}
.type-tag-full { background: rgba(239, 68, 68, .1); color: var(--danger); }
.type-tag-exp { background: rgba(16, 185, 129, .1); color: var(--success); }
.type-tag-req { background: rgba(245, 158, 11, .1); color: var(--warning); }
.type-tag-urgent { background: rgba(239, 68, 68, .15); color: var(--danger-light); }

/* ============ DYNAMIC FORM ============ */
.form-panel { display: none; margin-top: 24px; animation: fadeSlide .3s ease; }
.form-panel.active { display: block; }
.form-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 28px; box-shadow: var(--shadow-sm);
}
.form-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.form-header h3 { font-family: 'Outfit', sans-serif; font-size: 17px; font-weight: 700; }
.form-type-badge {
  font-size: 11px; font-weight: 700; padding: 4px 14px;
  border-radius: var(--radius-full); background: var(--bg-hover);
  color: var(--primary); border: 1px solid var(--border);
}
.form-section { margin-bottom: 22px; }
.form-section-label {
  font-family: 'Outfit', sans-serif; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); margin-bottom: 14px; opacity: .7;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.full { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-primary); margin-bottom: 5px; }
.field label .req { color: var(--danger); }
.field .field-hint { display: block; font-size: 11px; color: var(--text-muted); font-style: italic; margin-top: 4px; }
.file-count-label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-muted); margin-top: 8px; text-align: right;
}
.field input, .field select, .field textarea {
  font-family: 'Manrope', sans-serif; font-size: 13px; font-weight: 500;
  padding: 9px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-primary);
  transition: var(--transition); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-glow);
}
.field textarea { resize: vertical; min-height: 72px; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-muted); opacity: .5; }

/* Upload */
.upload-drop {
  border: 2px dashed var(--border); border-radius: var(--radius-md);
  padding: 28px; text-align: center; cursor: pointer;
  transition: var(--transition); background: var(--bg-hover);
}
.upload-drop:hover { border-color: var(--primary); background: var(--bg-active); }
.upload-drop svg { width: 32px; height: 32px; color: var(--text-muted); margin-bottom: 8px; }
.upload-drop p { font-size: 12.5px; color: var(--text-muted); }
.upload-drop .accent { color: var(--primary); font-weight: 700; }
.upload-drop .hint { font-size: 11px; color: var(--text-muted); opacity: .6; margin-top: 3px; }
.upload-drop .upload-types {
  display: flex; justify-content: center; gap: 8px; margin-top: 10px;
}
.upload-drop .upload-type-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  padding: 4px 11px; border-radius: 6px; display: inline-block;
  border: 1px solid transparent;
}
.upload-drop .upload-type-pdf {
  background: rgba(239, 68, 68, .10); color: var(--danger);
  border-color: rgba(239, 68, 68, .25);
}
.upload-drop .upload-type-docx {
  background: rgba(59, 130, 246, .10); color: var(--info);
  border-color: rgba(59, 130, 246, .25);
}
.upload-drop .upload-type-xls {
  background: rgba(34, 139, 87, .10); color: #228b57;
  border-color: rgba(34, 139, 87, .30);
}
.upload-drop .upload-type-csv {
  background: rgba(13, 148, 136, .10); color: #0d9488;
  border-color: rgba(13, 148, 136, .30);
}
.upload-drop .upload-exclusion {
  font-size: 11.5px; color: var(--text-muted); margin-top: 10px; line-height: 1.5;
}
.upload-drop .upload-exclusion strong { color: var(--text-primary); font-weight: 700; }
.uploaded-list { margin-top: 10px; }
.uploaded-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-top: 6px; font-size: 12.5px; animation: fadeSlide .2s;
}
.uploaded-item svg { width: 15px; height: 15px; color: var(--success); flex-shrink: 0; }
.uploaded-item .fname { flex: 1; font-weight: 600; color: var(--text-primary); }
.uploaded-item .fsize { color: var(--text-muted); font-size: 11px; }
.uploaded-item .fremove {
  width: 18px; height: 18px; border-radius: 50%; border: none;
  background: rgba(239, 68, 68, .1); color: var(--danger);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; transition: var(--transition);
}
.uploaded-item .fremove:hover { background: var(--danger); color: white; }
.form-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border);
}

/* ============ TOAST ============ */
/* ============ TOAST SYSTEM ============ */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px 11px 14px; border-radius: var(--radius-md);
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg);
  transform: translateX(120%); opacity: 0;
  transition: all .35s cubic-bezier(.4, 0, .2, 1);
  pointer-events: auto; cursor: default;
  max-width: 400px; min-width: 240px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.exit { transform: translateX(120%); opacity: 0; }
.toast svg { width: 15px; height: 15px; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  font-size: 16px; line-height: 1; cursor: pointer; opacity: 0.5;
  padding: 0 2px; transition: opacity .15s;
}
.toast-close:hover { opacity: 1; }

/* Toast types */
.toast-success { background: #065f46; color: #d1fae5; border: 1px solid rgba(16,185,129,.3); }
.toast-success svg { color: #34d399; }
.toast-error { background: #7f1d1d; color: #fee2e2; border: 1px solid rgba(239,68,68,.3); }
.toast-error svg { color: #f87171; }
.toast-warning { background: #78350f; color: #fef3c7; border: 1px solid rgba(245,158,11,.3); }
.toast-warning svg { color: #fbbf24; }
.toast-info { background: #1e3a5f; color: #dbeafe; border: 1px solid rgba(59,130,246,.3); }
.toast-info svg { color: #60a5fa; }

/* ============================================================
   DOC REVIEW VIEW — Split Pane Layout
   ============================================================ */

/* Doc Info Bar (inside doc-review view) */
.doc-info-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.doc-info-bar .doc-id {
  font-family: 'Outfit', sans-serif; font-weight: 800;
  color: var(--primary); font-size: 13px;
}
.doc-info-bar .doc-meta { color: var(--text-muted); font-weight: 500; }
.doc-info-bar .doc-meta b { color: var(--text-secondary); font-weight: 700; }
.doc-info-bar .pill {
  font-size: 10px; font-weight: 700; padding: 3px 10px;
  border-radius: var(--radius-full); background: rgba(59, 130, 246, .12); color: var(--info);
}
.doc-info-bar .doc-actions { margin-left: auto; display: flex; gap: 6px; }

/* Split Pane */
.split-pane {
  display: flex; height: calc(100vh - 140px);
  position: relative; z-index: 1;
  overflow: hidden; /* clip any horizontal overflow from children */
  min-width: 0;
}

/* PDF Pane (Left) */
.pdf-pane {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  overflow: hidden; /* clip the PDF when the pane shrinks below its width */
}
.pdf-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-card); flex-shrink: 0;
}
.pdf-tool {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg-input);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); position: relative;
}
.pdf-tool:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-hover); }
.pdf-tool.active {
  border-color: var(--primary); color: var(--primary);
  background: var(--bg-active); box-shadow: 0 0 0 2px var(--primary-glow);
}
.pdf-tool svg { width: 16px; height: 16px; }
.pdf-tool-sep { width: 1px; height: 22px; background: var(--border); }

/* Document / Original PDF tab switcher */
.pdf-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg-input);
  color: var(--text-muted); cursor: pointer;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  transition: var(--transition);
}
.pdf-tab svg { width: 14px; height: 14px; flex-shrink: 0; }
.pdf-tab:hover { border-color: var(--primary); color: var(--primary); background: var(--bg-hover); }
.pdf-tab.active {
  border-color: var(--primary); color: var(--primary);
  background: var(--bg-active); box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Spreadsheet viewer (rendered by SheetJS) */
.xlsx-viewer { width: 100%; height: 100%; display: flex; flex-direction: column; background: #fff; }
.xlsx-tabs {
  display: flex; gap: 4px; padding: 8px 12px;
  border-bottom: 1.5px solid var(--border); background: var(--bg-input);
  overflow-x: auto; flex-shrink: 0;
}
.xlsx-tab {
  padding: 6px 14px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1.5px solid var(--border); border-bottom: none;
  background: #fff; color: var(--text-muted); cursor: pointer;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  transition: var(--transition);
}
.xlsx-tab:hover { color: var(--primary); border-color: var(--primary); }
.xlsx-tab.active { color: var(--primary); border-color: var(--primary); background: var(--bg-active); }
.xlsx-sheet-host { flex: 1; overflow: auto; padding: 16px; }
.xlsx-sheet-host table {
  border-collapse: collapse; font-family: var(--font-mono, monospace);
  font-size: 12px;
}
.xlsx-sheet-host th, .xlsx-sheet-host td {
  border: 1px solid #d0d7de; padding: 4px 8px; text-align: left;
  vertical-align: top; white-space: nowrap;
}
.xlsx-sheet-host th { background: #f6f8fa; font-weight: 600; }
.xlsx-sheet-host tr:nth-child(even) td { background: #fafbfc; }
.pdf-tool-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
}
.pdf-page-nav {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; font-size: 12px; color: var(--text-muted); font-weight: 600;
}
.pdf-page-nav input {
  width: 36px; text-align: center; font-family: 'JetBrains Mono', monospace;
  font-size: 11px; padding: 3px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--bg-input); color: var(--text-primary);
}
.pdf-viewport {
  flex: 1; min-width: 0;
  overflow-x: hidden; overflow-y: auto; /* clip horizontally; scroll pages vertically */
  padding: 20px;
  display: flex;
  /* `safe center` centers when the PDF fits, but falls back to `start` (left)
     when the pane shrinks below the PDF's width — so the PDF anchors to the
     left and gets visually clipped on the right (same visual as the slider
     sliding over it). */
  justify-content: safe center;
  position: relative;
}
.pdf-pages-container { display: flex; flex-direction: column; align-items: center; gap: 24px; padding-bottom: 20px; }
.pdf-mock-page {
  width: 680px; background: white;
  box-shadow: 0 2px 20px rgba(0, 0, 0, .12); border-radius: 2px;
  padding: 60px 65px 80px; position: relative;
  color: #1a1a2e; line-height: 1.75; font-size: 13.5px;
  min-height: 880px;
}
[data-theme="dark"] .pdf-mock-page { background: #f8f9fa; color: #1a1a2e; }
.pdf-mock-page h1 {
  font-family: 'Outfit', sans-serif; font-size: 18px; font-weight: 800;
  text-align: center; margin-bottom: 4px; color: #111;
}
.pdf-mock-page h2 {
  font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 700;
  text-align: center; margin-bottom: 20px; color: #333;
}
.pdf-mock-page h3 {
  font-family: 'Outfit', sans-serif; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px;
  margin: 22px 0 8px; color: #111; padding-bottom: 4px;
  border-bottom: 1px solid #e5e7eb;
}
.pdf-mock-page p { margin-bottom: 10px; text-align: justify; }
.pdf-mock-page .page-num { position: absolute; bottom: 30px; right: 40px; font-size: 10px; color: #999; }

/* Highlight Zones */
.hl-zone {
  position: relative; cursor: pointer; transition: background .2s, border-color .2s;
  border-radius: 4px; padding: 4px 6px 4px 14px; margin: 2px 0;
  border-left: 3px solid transparent;
}
.hl-zone:hover { background: rgba(0, 0, 0, .03); }

/* Passive status strip (worst result) */
.hl-zone.hl-pass { border-left-color: var(--success); background: rgba(16, 185, 129, .04); }
.hl-zone.hl-fail { border-left-color: var(--danger); background: rgba(239, 68, 68, .05); }
.hl-zone.hl-warn { border-left-color: var(--warning); background: rgba(245, 158, 11, .05); }
.hl-zone.hl-pend { border-left-color: #d1d5db; }

/* Mini status dots — shows all statuses for this zone */
.hl-zone::after {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  display: none; /* shown via JS data attribute */
}
.hl-zone[data-has-mixed="true"]::after {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid white;
  left: -5px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.hl-zone[data-has-mixed="true"][data-worst="fail"]::after { background: var(--danger); }
.hl-zone[data-has-mixed="true"][data-worst="warn"]::after { background: var(--warning); }

/* Active state — clicked rule's zone */
.hl-zone.hl-active {
  border-left-width: 5px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
  z-index: 1;
}
.hl-zone.hl-active.hl-pass {
  border-left-color: var(--success);
  background: rgba(16, 185, 129, .10);
}
.hl-zone.hl-active.hl-fail {
  border-left-color: var(--danger);
  background: rgba(239, 68, 68, .12);
}
.hl-zone.hl-active.hl-warn {
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, .12);
}
.hl-zone.hl-active.hl-pend {
  border-left-color: #9ca3af;
  background: rgba(156, 163, 175, .08);
}

/* Dimmed state — zones NOT related to clicked rule fade */
.hl-zone.hl-dimmed {
  opacity: .4;
  transition: opacity .2s;
}

/* Annotation Pins */
.anno-pin {
  position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: var(--warning); color: white;
  font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
  z-index: 5; transform: translate(-50%, -50%); transition: transform .15s;
}
.anno-pin:hover { transform: translate(-50%, -50%) scale(1.2); }
.anno-pin.pin-danger { background: var(--danger); }
.anno-pin.pin-info { background: var(--info); }

/* Annotation Popover */
.anno-popover {
  position: absolute; width: 280px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 14px; z-index: 10; display: none; animation: fadeSlide .2s ease;
}
.anno-popover.show { display: block; }
.anno-popover textarea {
  font-family: 'Manrope', sans-serif; width: 100%; font-size: 12px;
  padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-primary);
  resize: vertical; min-height: 60px; outline: none; transition: var(--transition);
}
.anno-popover textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-glow); }
.anno-popover .anno-actions { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; }

/* ============ SPLIT PANE RESIZER ============ */
.split-resizer {
  flex: 0 0 6px;
  position: relative;
  background: var(--border);
  cursor: col-resize;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
  touch-action: none;
  user-select: none;
  z-index: 5;
}
.split-resizer::before {
  content: ''; position: absolute; top: 0; bottom: 0;
  left: -6px; right: -6px; /* widen the hit target without widening the visual */
}
.split-resizer:hover { background: var(--primary); }
.split-resizer.dragging { background: var(--primary); }
.split-resizer-grabber {
  position: relative;
  width: 16px; height: 44px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  display: grid;
  grid-template-columns: 3px 3px;
  grid-auto-rows: 3px;
  gap: 3px;
  align-content: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  transition: var(--transition);
}
.split-resizer-grabber .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-muted);
  transition: background .15s ease;
}
.split-resizer:hover .split-resizer-grabber,
.split-resizer.dragging .split-resizer-grabber {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 2px 8px rgba(0,0,0,.12);
}
.split-resizer:hover .split-resizer-grabber .dot,
.split-resizer.dragging .split-resizer-grabber .dot {
  background: var(--primary);
}
/* While resizing, kill text selection and force the cursor everywhere so
   the user gets continuous feedback even if the pointer leaves the handle. */
body.split-resizing { cursor: col-resize !important; user-select: none; }
body.split-resizing * { cursor: col-resize !important; user-select: none !important; }

/* ============ CHECKLIST PANE (Right) ============ */
.checklist-pane {
  flex: 0 0 420px; /* basis is overridden inline via style.width by JS */
  width: 420px;   /* explicit width — kept in sync with flex-basis by JS */
  min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  overflow: hidden;
  border-left: 1px solid var(--border);
}
.checklist-header {
  position: relative; /* anchor for the kebab menu popover */
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-card); flex-shrink: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px;
}
.checklist-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 14px; font-weight: 800; letter-spacing: -.2px; line-height: 1.35;
  margin: 0; flex: 1; min-width: 0;
  word-break: break-word;
}
.checklist-header .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Clickable cross-doc count inside the title — feels like a quiet link */
.scan-title-other-link {
  color: var(--primary);
  cursor: pointer;
  font-weight: 800;
  border-bottom: 1px dashed var(--primary);
  transition: var(--transition);
}
.scan-title-other-link:hover { opacity: .75; }

/* Kebab menu wrapper + popover */
.checklist-menu-wrap { position: relative; flex-shrink: 0; }
.checklist-menu-btn.active {
  background: var(--bg-active);
  border-color: var(--border-focus);
  color: var(--primary);
}
.checklist-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  padding: 4px;
  z-index: 30;
  animation: fadeSlide .15s ease;
}
.checklist-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px; font-weight: 700;
  color: var(--text-primary);
  transition: var(--transition);
  white-space: nowrap;
}
.checklist-menu-item:hover {
  background: var(--bg-hover);
  color: var(--primary);
}
.checklist-menu-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.checklist-menu-item-label { flex: 1; }

.checklist-progress {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-card); flex-shrink: 0;
}
.progress-bar { flex: 1; height: 6px; background: var(--bg-active); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; background: var(--success); border-radius: var(--radius-full); transition: width .4s ease; }
.progress-text { font-size: 11px; font-weight: 800; color: var(--text-muted); white-space: nowrap; }

/* Compact stat pills — click toggles the corresponding findings group.
   Inside the scan-meta-row, `margin-left: auto` pushes the pills to the
   right edge after the run selector + FULL/QUICK badge. */
.checklist-stats {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.cl-stat {
  flex: 0 0 auto;
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 4px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
}
.cl-stat:hover {
  border-color: var(--border-focus);
  transform: translateY(-1px);
}
.cl-stat.active {
  background: var(--bg-active);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}
.cl-stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 13px; font-weight: 800; line-height: 1;
}
.cl-stat-label {
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-top: 0;
}
.cl-stat.s-pass .cl-stat-num { color: var(--success); }
.cl-stat.s-fail .cl-stat-num { color: var(--danger); }
.cl-stat.s-warn .cl-stat-num { color: var(--warning); }
.cl-stat.s-na   .cl-stat-num { color: #6b7280; }
.cl-stat.s-pend .cl-stat-num { color: var(--text-muted); }

.checklist-body { flex: 1; overflow-y: auto; padding: 10px 0; }

/* Checklist Section */
.cl-section { margin-bottom: 4px; }
.cl-section-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; cursor: pointer;
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  transition: var(--transition); user-select: none;
}
.cl-section-head:hover { background: var(--bg-hover); color: var(--text-primary); }
.cl-section-head svg { width: 12px; height: 12px; transition: transform .2s; }
.cl-section-head.open svg { transform: rotate(90deg); }
.cl-section-head .sec-count {
  margin-left: auto; font-size: 10px; font-weight: 700;
  color: var(--text-dim); opacity: .6;
}
.cl-section-body { display: none; padding: 0 10px 6px 10px; }
.cl-section-head.open + .cl-section-body { display: block; }

/* Checklist Item */
.cl-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  margin-bottom: 2px;
  border: 1.5px solid transparent;
  border-left: 3px solid transparent;
}

/* Status-based left accent + subtle background tint */
.cl-item[data-status="fail"] { 
  border-left-color: var(--danger); 
  background: rgba(239, 68, 68, .03);
}
.cl-item[data-status="warn"] { 
  border-left-color: var(--warning); 
  background: rgba(245, 158, 11, .03);
}
.cl-item[data-status="pass"] { border-left-color: transparent; }
.cl-item[data-status="pend"] { border-left-color: transparent; }

/* Hover */
.cl-item[data-status="fail"]:hover { background: rgba(239, 68, 68, .07); }
.cl-item[data-status="warn"]:hover { background: rgba(245, 158, 11, .06); }
.cl-item[data-status="pass"]:hover { background: rgba(16, 185, 129, .05); }
.cl-item[data-status="pend"]:hover { background: var(--bg-hover); }

/* Focused (clicked) */
.cl-item.focused { background: var(--bg-active); border-color: var(--primary); }
.cl-item[data-status="fail"].focused { 
  background: rgba(239, 68, 68, .06); 
  border-color: var(--danger); border-left-color: var(--danger); 
}
.cl-item[data-status="warn"].focused { 
  background: rgba(245, 158, 11, .06); 
  border-color: var(--warning); border-left-color: var(--warning); 
}
.cl-item[data-status="pass"].focused { 
  background: rgba(16, 185, 129, .05); 
  border-color: var(--success); border-left-color: var(--success); 
}

/* Deleted finding */
.cl-item-deleted {
  opacity: 0.45;
  border-left-color: var(--border) !important;
  background: var(--bg-subtle);
  position: relative;
}
.cl-item-deleted::after {
  content: 'Removed';
  position: absolute; top: 8px; right: 10px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 1px 6px; border-radius: 4px;
}
.cl-item-deleted:hover { opacity: 0.65; }
.cl-item-deleted .cl-detail,
.cl-item-deleted .cl-excerpt,
.cl-item-deleted .cl-ref { display: none; }

/* Deleted toggle */
.scan-deleted-toggle {
  padding: 4px 12px 8px;
}
.deleted-toggle-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.deleted-toggle-label input[type="checkbox"] {
  accent-color: var(--primary);
}

/* Status icon circle */
.cl-status {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.cl-status svg { width: 12px; height: 12px; }
.cl-status.st-pass { background: rgba(16, 185, 129, .15); color: var(--success); }
.cl-status.st-fail { background: rgba(239, 68, 68, .15); color: var(--danger); }
.cl-status.st-warn { background: rgba(245, 158, 11, .15); color: var(--warning); }
.cl-status.st-pend { background: var(--bg-active); color: var(--text-muted); }
.cl-status.st-scan { background: rgba(59, 130, 246, .15); color: var(--info); animation: pulse 1.5s infinite; }

/* Content */
.cl-content { flex: 1; min-width: 0; }
.cl-title { font-size: 12.5px; font-weight: 700; color: var(--text-primary); line-height: 1.4; }
.cl-ref {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px;
  font-weight: 600; color: var(--text-dim); margin-top: 2px;
}
.cl-detail {
  font-size: 11.5px; color: var(--text-muted); margin-top: 4px;
  line-height: 1.5; display: none;
}
.cl-item.focused .cl-detail { display: block; }

/* AI reasoning narrative — color matches item status */
.cl-narrative {
  margin-top: 8px; padding: 8px 10px;
  background: var(--bg-hover); border-radius: var(--radius-sm);
  border-left: 3px solid var(--text-muted);
  font-size: 11px; color: var(--text-secondary);
  line-height: 1.5; display: none;
}
.cl-item[data-status="fail"] .cl-narrative { border-left-color: var(--danger); background: rgba(239, 68, 68, .04); }
.cl-item[data-status="warn"] .cl-narrative { border-left-color: var(--warning); background: rgba(245, 158, 11, .04); }
.cl-item[data-status="pass"] .cl-narrative { border-left-color: var(--success); background: rgba(16, 185, 129, .04); }
.cl-item.focused .cl-narrative { display: block; }

/* Actions */
.cl-item-actions { display: none; margin-top: 8px; gap: 6px; }
.cl-item.focused .cl-item-actions { display: flex; }

.scanning .cl-status { animation: pulse 1s infinite; }
/* ============ AI SCAN BUTTON ============ */
.ai-scan-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin: 10px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg-base); border: none; border-radius: var(--radius-md);
  font-family: 'Manrope', sans-serif; font-size: 12.5px; font-weight: 700;
  cursor: pointer; transition: var(--transition);
  position: relative; overflow: hidden;
}
.ai-scan-btn:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.ai-scan-btn svg { width: 18px; height: 18px; }
.ai-scan-btn .shimmer {
  position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
  animation: shimmer 2s infinite;
}

/* ============ AI SCAN PROGRESS ============ */
.scan-progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

/* Status line */
.scan-status-row {
  display: flex; align-items: center; gap: 10px;
}
.scan-status-text {
  font-family: 'Outfit', sans-serif;
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
}

/* Progress bar */
.scan-prog-wrap { display: flex; flex-direction: column; gap: 6px; }
.scan-prog-bar {
  height: 6px; background: var(--bg-active);
  border-radius: var(--radius-full); overflow: hidden;
}
.scan-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-full);
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
  width: 0%;
}
.scan-prog-indeterminate {
  width: 40% !important;
  animation: scanShimmer 1.5s ease-in-out infinite;
}
@keyframes scanShimmer {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.scan-prog-complete {
  background: linear-gradient(90deg, var(--success), var(--success-light)) !important;
  width: 100% !important;
}
.scan-prog-error {
  background: linear-gradient(90deg, var(--danger), var(--danger-light)) !important;
  width: 100% !important;
}
.scan-prog-text {
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
}

/* Live stats row */
.scan-stats-row {
  display: flex; gap: 12px;
}
.scan-stat {
  display: flex; flex-direction: column; align-items: center;
  min-width: 56px;
  padding: 6px 10px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.scan-stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 18px; font-weight: 800; line-height: 1.2;
  transition: transform .15s ease;
}
.scan-stat-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
}
.scan-stat-pass .scan-stat-num { color: var(--success); }
.scan-stat-fail .scan-stat-num { color: var(--danger); }
.scan-stat-warn .scan-stat-num { color: var(--warning); }
.scan-stat-na .scan-stat-num { color: #6b7280; }

/* Live result feed */
.scan-feed {
  max-height: 200px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
}
.scan-feed-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  opacity: 0; transform: translateY(4px);
  transition: opacity .2s ease, transform .2s ease;
}
.scan-feed-item.visible { opacity: 1; transform: translateY(0); }
.scan-feed-badge {
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.scan-feed-badge svg { width: 14px; height: 14px; }
.scan-feed-pass .scan-feed-badge { color: var(--success); }
.scan-feed-fail .scan-feed-badge { color: var(--danger); }
.scan-feed-warn .scan-feed-badge { color: var(--warning); }
.scan-feed-name {
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Note */
.scan-note {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  font-style: italic;
}

/* View Results actions (post-completion) */
.scan-results-actions {
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 12px;
}
.scan-results-msg {
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}

/* Scanning state on button — pulse */
.ai-scan-btn.scanning {
  animation: scanPulse 1.5s ease-in-out infinite;
}
@keyframes scanPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50% { box-shadow: 0 0 16px 4px var(--primary-glow); }
}

/* ============ ROUTE MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5);
  z-index: 100; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }

.modal {
  width: 520px; max-height: 80vh;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  padding: 28px; overflow-y: auto; animation: fadeSlide .25s ease;
}
.modal h3 { font-family: 'Outfit', sans-serif; font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.modal .modal-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; }
.modal .field { margin-bottom: 14px; }
.modal .field label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 4px;
}
.modal .field label .req { color: var(--danger); }
.modal .field input, .modal .field select, .modal .field textarea {
  font-family: 'Manrope', sans-serif; width: 100%; font-size: 12.5px;
  font-weight: 500; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-input);
  color: var(--text-primary); outline: none; transition: var(--transition);
}
.modal .field input:focus, .modal .field select:focus, .modal .field textarea:focus {
  border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-glow);
}
.modal .field textarea { resize: vertical; min-height: 80px; }
.modal .issue-summary {
  padding: 10px 12px; background: var(--bg-hover);
  border-radius: var(--radius-sm); border-left: 3px solid var(--danger);
  font-size: 11.5px; color: var(--text-secondary);
  line-height: 1.5; margin-bottom: 14px;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* ============ AUDIT LOG ============ */

/* Dashboard Row Action Menu */
.td-actions-cell { position: relative; width: 40px; text-align: center; padding: 0 !important; }
.row-menu { position: relative; display: inline-block; }
.row-menu-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; font-weight: 700; color: var(--text-muted);
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.row-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.row-menu-dropdown {
  display: none; position: fixed; z-index: 200;
  min-width: 190px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 4px 0;
}
.row-menu-dropdown.show { display: block; }
.row-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: var(--transition);
}
.row-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.row-menu-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.row-menu-primary { color: var(--primary); }
.row-menu-primary:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.row-menu-success { color: var(--success); }
.row-menu-success:hover { background: color-mix(in srgb, var(--success) 8%, transparent); }
.row-menu-warn { color: var(--warning); }
.row-menu-warn:hover { background: color-mix(in srgb, var(--warning) 8%, transparent); }
.row-menu-danger { color: var(--danger); }
.row-menu-danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.row-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Assign Reviewer Modal */
.assign-reviewer-list {
  display: flex; flex-direction: column; gap: 4px;
  margin: 12px 0 18px; max-height: 320px; overflow-y: auto;
}
.assign-reviewer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid transparent; cursor: pointer;
  transition: var(--transition);
}
.assign-reviewer-row:hover { background: var(--bg-hover); }
.assign-reviewer-row.already-assigned {
  background: color-mix(in srgb, var(--primary) 4%, transparent);
  border-color: color-mix(in srgb, var(--primary) 15%, transparent);
}
.assign-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.assign-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.assign-name { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.assign-role-label { font-size: 10.5px; color: var(--text-muted); font-weight: 500; }
.assign-role-select { font-size: 11px; padding: 4px 8px; flex-shrink: 0; }
.assign-remove-btn {
  background: none; border: none; cursor: pointer;
  width: 24px; height: 24px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  flex-shrink: 0; transition: var(--transition); margin-left: 4px;
}
.assign-remove-btn:hover { background: rgba(239,68,68,.12); color: var(--danger); }

/* Status Transition Modal */
.status-options { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 12px; }
.status-option-card {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); cursor: pointer;
  transition: var(--transition);
}
.status-option-card:hover { border-color: var(--primary); background: var(--bg-hover); }
.status-option-card.selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.status-option-label { display: flex; align-items: center; gap: 8px; flex: 1; }
.status-option-text { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.status-note-hint { font-size: 10.5px; color: var(--text-muted); margin-left: auto; font-style: italic; }
.status-notes {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12.5px; font-family: inherit;
  resize: vertical; background: var(--bg-primary); color: var(--text-primary);
  margin-bottom: 4px;
}
.status-notes:focus { outline: none; border-color: var(--primary); }
.modal-sub strong.pill { display: inline; padding: 2px 8px; }

/* Page badge on checklist items */
.cl-page-badge {
  display: inline-block; font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; font-weight: 700; padding: 1px 6px;
  border-radius: var(--radius-full); background: var(--bg-hover);
  color: var(--text-muted); margin-left: 8px; vertical-align: middle;
}

/* Routed badge on checklist items */
.cl-routed-badge {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
  font-size: 11px; color: var(--text-secondary);
}
.cl-routed-badge svg { width: 12px; height: 12px; color: var(--warning); flex-shrink: 0; }
.cl-routed-badge strong { color: var(--text-primary); font-weight: 700; }

/* Comment thread */
.cl-actions {
  margin-top: 8px;
}

.cl-actions .btn + .btn {
  margin-left: 6px;
}
.cl-comment-thread { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.cl-comment-thread:empty { display: none; }
.cl-removal-reason {
  margin-top: 8px; padding: 10px 12px;
  background: var(--bg-hover); border: 1px dashed var(--border);
  border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 4px;
}
.cl-removal-reason-header {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.cl-removal-reason-body {
  font-size: 13px; color: var(--text-primary); line-height: 1.5; white-space: pre-wrap;
}
.cl-comment-bubble {
  display: flex; gap: 8px; padding: 7px 10px;
  background: var(--bg-hover); border-radius: var(--radius-sm);
}
.cl-comment-avatar {
  width: 24px; height: 24px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.cl-comment-body { flex: 1; min-width: 0; }
.cl-comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.cl-comment-author { font-size: 11px; font-weight: 700; color: var(--text-primary); }
.cl-comment-time { font-size: 10px; color: var(--text-muted); }
.cl-comment-text { font-size: 11.5px; color: var(--text-secondary); line-height: 1.5; }

/* Comment delete/restore action */
.cl-comment-action {
  margin-left: auto; padding: 0 4px; opacity: 0;
  transition: opacity .15s; font-size: 10px;
}
.cl-comment-action svg { width: 11px; height: 11px; }
.cl-comment-bubble:hover .cl-comment-action { opacity: 0.6; }
.cl-comment-bubble:hover .cl-comment-action:hover { opacity: 1; }

/* Deleted comment */
.cl-comment-deleted { opacity: 0.5; }
.cl-comment-deleted .cl-comment-action { opacity: 0.7; }

/* Comment input */
.cl-comment-input-row { margin-top: 6px; }
.cl-comment-input {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; font-family: inherit;
  resize: none; background: var(--bg-primary); color: var(--text-primary);
}
.cl-comment-input:focus { outline: none; border-color: var(--primary); }
.cl-comment-input-actions {
  display: flex; gap: 6px; justify-content: flex-end; margin-top: 5px;
}
.btn-xs { font-size: 11px; padding: 3px 10px; border-radius: var(--radius-sm); }

/* PDF.js canvas viewer */
.pdf-page-nav-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 6px 12px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.pdf-page-label {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  font-weight: 700; color: var(--text-primary); min-width: 60px; text-align: center;
}
.pdf-canvas-container {
  flex: 1; min-width: 0;
  overflow-x: hidden; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column;
  align-items: safe center;
  background: var(--bg-hover);
}
.pdf-canvas-container canvas {
  box-shadow: var(--shadow-md); border-radius: 2px;
  max-width: 100%;
}

/* Search input in filter bar */
.audit-search {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-primary); outline: none;
  transition: var(--transition); min-width: 200px;
}
.audit-search:focus {
  border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-glow);
}
.audit-search::placeholder { color: var(--text-dim); font-weight: 500; }

/* Count badge next to title */
.audit-count {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--bg-hover); padding: 2px 10px;
  border-radius: var(--radius-full);
}

/* Table overrides */
.audit-table { width: 100%; border-collapse: collapse; }
.audit-table td { vertical-align: top; padding: 11px 18px; }
.audit-table tr { cursor: default; }
.audit-table tr:hover td { background: var(--bg-hover); }

/* Timestamp cell */
.audit-ts { white-space: nowrap; }
.audit-ts .ts-date {
  display: block; font-size: 12px; font-weight: 700; color: var(--text-primary);
}
.audit-ts .ts-time {
  display: block; font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; color: var(--text-muted); font-weight: 500; margin-top: 1px;
}

/* User cell */
.audit-user { display: flex; align-items: center; gap: 9px; }
.audit-avatar {
  width: 28px; height: 28px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff; flex-shrink: 0;
  letter-spacing: .5px;
}
.audit-user-text { display: flex; flex-direction: column; min-width: 0; }
.audit-user-name { font-size: 12px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.audit-user-role { font-size: 10.5px; color: var(--text-dim); font-weight: 500; margin-top: 1px; }

/* Action pill */
.audit-action-pill {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  padding: 3px 10px; border-radius: var(--radius-full); white-space: nowrap;
}
.action-status { background: rgba(99,102,241,.12); color: #6366f1; }
.action-created { background: rgba(16,185,129,.12); color: var(--success); }
.action-assigned { background: rgba(59,130,246,.12); color: #3b82f6; }
.action-upload { background: rgba(139,92,246,.12); color: #8b5cf6; }
.action-download { background: rgba(107,114,128,.12); color: var(--text-muted); }
.action-review { background: rgba(245,158,11,.12); color: #f59e0b; }
.action-comment { background: rgba(20,184,166,.12); color: #14b8a6; }
.action-approved { background: rgba(16,185,129,.18); color: var(--success); }
.action-warning { background: rgba(239,68,68,.12); color: var(--danger); }

/* Target cell */
.audit-target-id {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
  font-weight: 700; color: var(--primary); cursor: pointer;
}
.audit-target-id:hover { text-decoration: underline; }
.audit-target-type { display: block; font-size: 10.5px; color: var(--text-dim); font-weight: 500; margin-top: 1px; }

/* Detail cell */
.audit-detail { font-size: 12px; color: var(--text-secondary); line-height: 1.5; max-width: 340px; }

/* IP cell */
.audit-ip { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--text-dim); white-space: nowrap; }

/* Empty state */
.audit-empty { text-align: center; padding: 48px 18px !important; color: var(--text-muted); font-size: 13px; }

/* ============ RESPONSIVE ============ */
/* Hamburger toggle — hidden on desktop, shown on mobile via media query */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  padding: 0; margin-right: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-hover); border-color: var(--primary); color: var(--primary); }
.sidebar-toggle svg { width: 20px; height: 20px; display: block; }

/* Backdrop for mobile drawer */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 90;
  opacity: 0;
  transition: opacity .2s ease;
}
body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }

/* Filter bar toggle — desktop hides it; mobile media query reveals it. */
.filter-bar-toggle { display: none; }

/* Floating action button — mobile-only quick access to "New Review Package".
   Replaces the bulky .scan-quick-action card on small screens. */
.dash-fab {
  display: none;
  position: fixed; right: 18px; bottom: 22px;
  width: 56px; height: 56px;
  align-items: center; justify-content: center;
  background: var(--primary); color: #fff;
  border: none; border-radius: 50%;
  box-shadow: 0 8px 22px rgba(124, 58, 237, .4), 0 2px 6px rgba(0,0,0,.2);
  cursor: pointer; z-index: 60;
  transition: transform .15s ease, box-shadow .2s ease;
}
.dash-fab:active { transform: scale(.94); }
.dash-fab svg { width: 26px; height: 26px; }

@media (max-width: 960px) {
  .sidebar-toggle { display: inline-flex; }

  .sidebar {
    display: flex;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  .main { margin-left: 0; }
  .sidebar.compact ~ .main { margin-left: 0; }

  .meta-grid { grid-template-columns: 1fr; }

  .top-bar { padding: 10px 16px; gap: 6px; }
  .top-bar-left { min-width: 0; flex: 1 1 auto; }
  /* Breadcrumb: single line with ellipsis. The current page label can grow
     long (e.g. "Protocol Review — [study title]") so we let it shrink
     while keeping the back-links visible for tap-navigation. */
  .breadcrumb {
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
    font-size: 11.5px;
  }
  .breadcrumb > * {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .breadcrumb .bc-sep { flex-shrink: 0; }
  .breadcrumb .bc-link { flex-shrink: 1; min-width: 0; max-width: 90px; }
  .breadcrumb .bc-link[data-nav="dashboard"] { flex-shrink: 0; max-width: none; }
  .breadcrumb .bc-current { flex-shrink: 1; min-width: 0; }

  .content { padding: 14px !important; }

  /* Stats: horizontal scrollable chip strip — keeps urgency signals
     (overdue badges) visible without consuming the whole viewport. */
  .stats-grid,
  .stats-grid:has(.stat-card:nth-child(4):last-child),
  .stats-grid:has(.stat-card:nth-child(2):last-child) {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .stats-grid::-webkit-scrollbar { display: none; }
  .stat-card {
    flex: 0 0 auto;
    min-width: 130px;
    padding: 10px 12px;
    scroll-snap-align: start;
  }
  .stat-card .stat-top { margin-bottom: 4px; gap: 6px; }
  .stat-card .stat-icon { width: 24px; height: 24px; }
  .stat-card .stat-icon svg { width: 13px; height: 13px; }
  .stat-card .stat-change { font-size: 9px; padding: 1px 5px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 10.5px; margin-top: 2px; }

  /* When the stats grid has exactly 3 cards (e.g., Site Management:
     Total/Active/Inactive), fit them onscreen as a 3-col grid instead
     of scrolling horizontally. */
  .stats-grid:has(.stat-card:nth-child(3):last-child) {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
    gap: 6px;
    scroll-snap-type: none;
  }
  .stats-grid:has(.stat-card:nth-child(3):last-child) .stat-card {
    min-width: 0;
    padding: 8px 6px;
  }
  .stats-grid:has(.stat-card:nth-child(3):last-child) .stat-card .stat-value {
    font-size: 18px;
  }
  .stats-grid:has(.stat-card:nth-child(3):last-child) .stat-card .stat-label {
    font-size: 9.5px;
  }

  /* Quota strip: tighter padding, no reset pill, single-line label. */
  .quota-strip { padding: 10px 12px; gap: 10px; margin-bottom: 14px; }
  .quota-strip-icon { width: 30px; height: 30px; }
  .quota-strip-icon svg { width: 15px; height: 15px; }
  .quota-strip-body { gap: 5px; }
  .quota-strip-row { gap: 8px; }
  .quota-strip-label { font-size: 11.5px; }
  .quota-strip-reset { display: none; }
  .quota-strip-bar { height: 5px; }
  .quota-strip-buy { font-size: 11px; padding: 6px 10px; }

  /* Bulky CTA card — replaced by the FAB on mobile. */
  .scan-quick-action { display: none; }

  /* Show the FAB. */
  .dash-fab { display: inline-flex; }

  /* ---------- FILTER BAR (collapsed by default) ---------- */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
    padding: 8px;
    gap: 8px;
  }
  /* Scope the filter-bar collapse to ONLY bars that actually have the
     toggle button. Other reuses of .filter-bar (e.g., the action bar in
     Site Management that just holds a "New Site" button) keep their
     children visible. */
  .filter-bar:has(.filter-bar-toggle) > *:not(.filter-bar-toggle) { display: none; }
  .filter-bar:has(.filter-bar-toggle).expanded > * { display: flex; }
  .filter-bar:has(.filter-bar-toggle).expanded > .filter-label,
  .filter-bar:has(.filter-bar-toggle).expanded > .filter-select,
  .filter-bar:has(.filter-bar-toggle).expanded > .filter-date,
  .filter-bar:has(.filter-bar-toggle).expanded > .chip,
  .filter-bar:has(.filter-bar-toggle).expanded > .filter-clear,
  .filter-bar:has(.filter-bar-toggle).expanded > span { display: block; }
  .filter-bar:has(.filter-bar-toggle).expanded > .filter-sep { display: none; }
  .filter-bar:has(.filter-bar-toggle).expanded .filter-select,
  .filter-bar:has(.filter-bar-toggle).expanded .filter-date { width: 100%; padding: 9px 12px; font-size: 13px; }
  .filter-bar:has(.filter-bar-toggle).expanded .filter-label {
    margin-top: 4px;
  }
  .filter-bar:has(.filter-bar-toggle).expanded .filter-clear {
    align-self: flex-end; margin-left: 0; padding: 8px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
  }

  .filter-bar-toggle {
    display: inline-flex;
    align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 10px 14px;
    background: var(--bg-card); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: 'Manrope', sans-serif; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: var(--transition);
  }
  .filter-bar-toggle:hover { border-color: var(--primary); color: var(--primary); }
  .filter-bar-toggle svg { width: 16px; height: 16px; }
  .filter-bar.expanded .filter-bar-toggle { color: var(--primary); border-color: var(--primary); }

  /* ---------- TABLE HEAD (stack title above search/controls) ---------- */
  .tbl-head {
    flex-direction: column; align-items: stretch; gap: 10px;
    padding: 12px 14px;
  }
  .tbl-head h3 { font-size: 13px; }
  .tbl-head-right { width: 100%; gap: 8px; }
  .tbl-head-right .tbl-search-wrap { flex: 1; min-width: 0; }
  .tbl-head-right .tbl-search { width: 100%; min-width: 0; }
  /* "+ New" button is replaced by the FAB on mobile */
  .tbl-head-right .btn.btn-primary { display: none; }

  /* ---------- TABLE → CARDS ---------- */
  .tbl-wrap table,
  .tbl-wrap tbody {
    display: block;
    width: 100%;
  }
  .tbl-wrap thead { display: none; }

  .tbl-wrap tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id      status"
      "study   study"
      "meta    actions";
    column-gap: 10px;
    row-gap: 6px;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .tbl-wrap tbody tr:last-child { border-bottom: none; }
  .tbl-wrap tbody tr:hover td { background: transparent; }
  .tbl-wrap tbody tr td {
    display: block;
    padding: 0;
    border: none;
    background: transparent !important;
  }

  /* Hide low-value columns in card layout — study title carries the context,
     so Type/PI/Submitted/Docs are dropped to keep cards skimmable. */
  .tbl-wrap tbody tr .td-cb,
  .tbl-wrap tbody tr .td-type,
  .tbl-wrap tbody tr .td-pi,
  .tbl-wrap tbody tr .td-submitted,
  .tbl-wrap tbody tr .td-docs { display: none; }

  /* Position cells into the card grid */
  .tbl-wrap tbody tr .td-id {
    grid-area: id;
    font-size: 11.5px;
    align-self: center;
  }
  .tbl-wrap tbody tr .td-status {
    grid-area: status;
    justify-self: end; align-self: center;
  }
  .tbl-wrap tbody tr .td-study {
    grid-area: study;
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    line-height: 1.3;
  }
  .tbl-wrap tbody tr .td-study-protocol { display: block; margin-top: 2px; }
  .tbl-wrap tbody tr .td-due {
    grid-area: meta;
    font-size: 11.5px; color: var(--text-muted);
    align-self: center;
  }
  .tbl-wrap tbody tr .td-actions-cell {
    grid-area: actions;
    justify-self: end; align-self: center;
  }

  /* Empty-state row should span the whole card area */
  .tbl-wrap tbody tr:has(.empty-state) {
    display: block;
    padding: 24px 14px;
  }
  .tbl-wrap tbody tr:has(.empty-state) td { display: block; }

  /* Hide bulk-action bar on mobile — multi-select isn't a phone interaction */
  .bulk-bar { display: none !important; }

  /* Pagination compact */
  .pagination-bar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }

  /* ============ DETAIL VIEW ============ */

  /* Header — stack title above actions so the ID can't be overlapped. */
  .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .detail-title { font-size: 18px; }
  .detail-title-row { gap: 8px; }
  .detail-meta { gap: 4px 14px; }

  /* Action row: wrap onto multiple lines. Primary "Run AI Review" sits
     full-width on the first row; secondary buttons wrap below. */
  .detail-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .detail-actions .ai-scan-wrap {
    order: -1;
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  .detail-actions .ai-scan-wrap .ai-scan-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 13px;
  }
  /* Disclaimer goes static on mobile so it pushes the secondary buttons
     down instead of overlapping them. Slightly larger text too. */
  .detail-actions .ai-scan-wrap .ai-scan-disclaimer {
    position: static;
    transform: none;
    width: 100%;
    margin-top: 6px;
    text-align: center;
    justify-content: center;
    font-size: 10.5px;
    pointer-events: auto;
  }
  .detail-actions .btn:not(.ai-scan-btn) {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    justify-content: center;
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Tabs — single horizontal scroll line, no wrapping or clipping. */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* "Add Documents" sits flush right on desktop; on mobile make it full-width
     so it doesn't float in the middle of nothing. */
  .meta-panel-header {
    justify-content: stretch;
  }
  .meta-panel-header .btn {
    flex: 1; justify-content: center;
  }

  /* Doc rows — let the action buttons wrap onto a second line under the
     filename instead of cramming into a tiny right column. */
  .doc-row {
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 14px;
    gap: 10px 12px;
  }
  .doc-info { flex: 1 1 calc(100% - 54px); min-width: 0; }
  .doc-name { word-break: break-word; }
  .doc-row-meta {
    flex-basis: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 2px;
  }
  .doc-row-meta .btn {
    flex: 0 0 auto;
    padding: 6px 12px; font-size: 12px;
    white-space: nowrap;
  }
}

/* ============ VERSION HISTORY ============ */
.version-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.version-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--bg-hover);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; transition: var(--transition);
}
.version-item:first-child { border-color: var(--primary); background: var(--bg-active); }
.version-item .ver-tag {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 800;
  padding: 2px 8px; border-radius: var(--radius-full);
  background: var(--primary); color: var(--bg-base);
}
.version-item:not(:first-child) .ver-tag {
  background: var(--bg-active); color: var(--text-muted);
}
.version-item .ver-name { font-weight: 700; color: var(--text-primary); flex: 1; min-width: 0; }
.version-item .ver-date { font-size: 11px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.version-item .ver-uploader { font-size: 11px; color: var(--text-dim); font-weight: 600; white-space: nowrap; }

/* Upload New Version area inside modal */
.upload-version-drop {
  border: 2px dashed var(--border); border-radius: var(--radius-md);
  padding: 22px; text-align: center; cursor: pointer;
  transition: var(--transition); background: var(--bg-hover); margin-bottom: 14px;
}
.upload-version-drop:hover { border-color: var(--primary); background: var(--bg-active); }
.upload-version-drop svg { width: 28px; height: 28px; color: var(--text-muted); margin-bottom: 6px; }
.upload-version-drop p { font-size: 12px; color: var(--text-muted); }
.upload-version-drop .accent { color: var(--primary); font-weight: 700; }
.upload-version-drop .hint { font-size: 10.5px; color: var(--text-muted); opacity: .6; margin-top: 2px; }
.upload-selected-file {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; background: var(--bg-elevated);
  border: 1px solid var(--success); border-radius: var(--radius-sm);
  margin-bottom: 14px; font-size: 12px;
}
.upload-selected-file svg { width: 15px; height: 15px; color: var(--success); flex-shrink: 0; }
.upload-selected-file .fname { flex: 1; font-weight: 600; color: var(--text-primary); }
.upload-selected-file .fsize { color: var(--text-muted); font-size: 11px; }

/* ============ USER MANAGEMENT ============ */
.user-mgmt-view { max-width: 1100px; }
.user-mgmt-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.user-mgmt-header h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.user-mgmt-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Stats row */
.user-stats-row { display: flex; gap: 16px; margin-bottom: 20px; }
.user-stat-card {
  flex: 1; display: flex; align-items: center; gap: 12px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.user-stat-icon { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.user-stat-icon svg { width: 18px; height: 18px; }
.user-stat-value { font-size: 20px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.user-stat-label { font-size: 12px; color: var(--text-muted); }

/* Table tweaks */
.user-table .th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.user-cell-info { display: flex; flex-direction: column; gap: 1px; }
.user-cell-name { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.user-cell-email { font-size: 11px; color: var(--text-muted); }
.user-last-active { font-size: 12px; color: var(--text-muted); }
.user-perm-count { font-size: 12px; color: var(--text-secondary); }
.user-actions-cell { display: flex; gap: 4px; }
.row-inactive { opacity: 0.6; }
.row-inactive:hover { opacity: 0.85; }

/* Role badges */
.role-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.role-chair { background: #f3e8ff; color: #7c3aed; }
.role-admin { background: #fce7f3; color: #db2777; }
.role-coordinator { background: #dbeafe; color: #2563eb; }
.role-reviewer { background: #fef3c7; color: #d97706; }
.role-medical { background: #d1fae5; color: #059669; }
.role-statistical { background: #ffedd5; color: #ea580c; }
.role-pi { background: #fee2e2; color: #dc2626; }
.role-research { background: #e0f2fe; color: #0284c7; }

/* User form modal */
.user-form { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.user-form-field { display: flex; flex-direction: column; gap: 4px; }
.user-form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.user-form-section { margin-top: 8px; }
.user-form-section-label { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; }
.form-input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--card-bg); color: var(--text-primary);
  box-sizing: border-box;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(16,185,129,0.15); }

/* Permissions grid */
.perm-grid { display: flex; flex-direction: column; gap: 6px; }
.perm-row { padding: 6px 8px; border-radius: 6px; transition: background 0.15s; }
.perm-row:hover { background: var(--hover-bg); }
.perm-label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-primary); }
.perm-label input[type="checkbox"] { margin-top: 3px; accent-color: var(--accent); }
.perm-desc { font-size: 11px; color: var(--text-muted); font-weight: 400; }

/* ============ SETTINGS ============ */
.settings-view { max-width: 1000px; }
.settings-header { margin-bottom: 24px; }
.settings-header h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.settings-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Two-column layout */
.settings-layout { display: flex; gap: 24px; min-height: 500px; }
.settings-nav {
  width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 8px; align-self: flex-start; position: sticky; top: 80px;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  transition: var(--transition);
}
.settings-nav-item:hover { background: var(--hover-bg); color: var(--text-primary); }
.settings-nav-item.active { background: var(--primary-glow); color: var(--accent); font-weight: 700; }
.settings-nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.settings-nav-icon svg { width: 16px; height: 16px; }

/* Panel area */
.settings-panel-area { flex: 1; min-width: 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeSlide .25s ease; }

/* Section headings */
.settings-section-title { margin-bottom: 24px; }
.settings-section-title h3 { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 0 0 4px; }
.settings-section-desc { font-size: 13px; color: var(--text-muted); }

/* Profile card */
.settings-profile-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: 24px;
}
.settings-avatar {
  width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.settings-profile-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.settings-profile-role { font-size: 13px; color: var(--text-secondary); }
.settings-profile-email { font-size: 12px; color: var(--text-muted); }

/* Form */
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-form-row { display: flex; gap: 16px; }
.settings-form-row > * { flex: 1; }
.settings-field { display: flex; flex-direction: column; gap: 4px; }
.settings-field-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.settings-actions { margin-top: 20px; display: flex; gap: 10px; }

/* Groups */
.settings-group { margin-bottom: 20px; }
.settings-group-label { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.settings-group .form-input { max-width: 260px; }
.settings-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* Toggle rows */
.settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 16px; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 10px;
}
.settings-toggle-text { flex: 1; }
.settings-toggle-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.settings-toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 22px;
  transition: .25s;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 16px; width: 16px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
  transition: .25s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Theme grid */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.theme-card {
  padding: 12px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition); text-align: center;
}
.theme-card:hover { border-color: var(--text-muted); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--primary-glow); }
.theme-swatch {
  width: 100%; height: 32px; border-radius: 6px; margin-bottom: 8px;
}
.theme-swatch[data-swatch="mint"] { background: linear-gradient(135deg, #10b981, #14b8a6); }
.theme-swatch[data-swatch="ocean"] { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.theme-swatch[data-swatch="sunset"] { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.theme-swatch[data-swatch="vibrant"] { background: linear-gradient(135deg, #a855f7, #ec4899); }
.theme-swatch[data-swatch="light"] { background: linear-gradient(135deg, #e5e7eb, #f9fafb); }
.theme-swatch[data-swatch="dark"] { background: linear-gradient(135deg, #1f2937, #374151); }
.theme-card-label { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.theme-card-desc { font-size: 11px; color: var(--text-muted); }

/* System info */
.settings-info-grid {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 24px;
}
.settings-info-row {
  display: flex; padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.settings-info-row:last-child { border-bottom: none; }
.settings-info-key { width: 140px; font-size: 12px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.settings-info-val { font-size: 13px; color: var(--text-primary); }

/* Danger zone */
.settings-danger {
  margin-top: 24px; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 10px;
}

/* ============ COMPACT SIDEBAR ============ */
.nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-label { white-space: nowrap; overflow: hidden; }

.sidebar.compact { width: 64px; overflow: hidden; }
.sidebar.compact .sidebar-brand span { display: none; }
.sidebar.compact .sidebar-brand img, .sidebar.compact .sidebar-logo { max-width: 36px; height: auto; }
.sidebar.compact .sidebar-brand { padding: 16px 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sidebar.compact .sidebar-nav { padding: 8px 6px; }
.sidebar.compact .nav-group { height: 0; overflow: hidden; padding: 0; margin: 8px 0 0; border-top: 1px solid var(--border); }
.sidebar.compact .nav-group:first-child { border-top: none; margin-top: 0; }
.sidebar.compact .nav-item {
  justify-content: center; padding: 10px; gap: 0;
}
.sidebar.compact .nav-item .nav-label { display: none; }
.sidebar.compact .nav-item .nav-icon svg { width: 20px; height: 20px; }
.sidebar.compact .nav-item.active::before { display: none; }
.sidebar.compact ~ .main { margin-left: 64px; }

/* Tooltip on hover in compact mode */
.sidebar.compact .nav-item { position: relative; }
.sidebar.compact .nav-item::after {
  content: attr(data-tip); position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  background: var(--text-primary); color: var(--bg-base); padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s; margin-left: 8px; z-index: 100;
}
.sidebar.compact .nav-item:hover::after { opacity: 1; }

/* ============ COMPACT ROWS ============ */
.compact-rows table td { padding: 4px 14px; font-size: 11px; line-height: 1.3; }
.compact-rows table th { padding: 5px 14px; font-size: 9px; }
.compact-rows .audit-table td { padding: 5px 14px; font-size: 11px; }
.compact-rows .user-table .user-cell { padding: 5px 10px; }
.compact-rows .user-table .th { padding: 5px 10px; font-size: 9px; }
.compact-rows .user-avatar { width: 26px; height: 26px; font-size: 10px; }
.compact-rows .status-pill { font-size: 9px; padding: 1px 8px; }
.compact-rows .td-id { font-size: 10px; }
.compact-rows .role-badge { font-size: 9px; padding: 1px 7px; }

/* ============ REPORTS & ANALYTICS ============ */
.reports-view .view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

.reports-filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.reports-chip-group { display: flex; gap: 4px; background: var(--bg-hover); border-radius: var(--radius-sm); padding: 3px; }
.reports-chip {
  padding: 5px 14px; border-radius: var(--radius-sm); border: none; background: transparent;
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: var(--transition);
}
.reports-chip:hover { color: var(--text-primary); }
.reports-chip.active { background: var(--bg-base); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.reports-kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 24px; }
.reports-kpi-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 16px; text-align: center; transition: var(--transition);
}
.reports-kpi-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px var(--primary-glow); }
.reports-kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.reports-kpi-icon svg { width: 18px; height: 18px; }
.reports-kpi-value { font-size: 24px; font-weight: 800; color: var(--text-primary); line-height: 1; margin-bottom: 4px; }
.reports-kpi-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.reports-chart-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 18px; }
.reports-chart-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 20px; transition: var(--transition);
}
.reports-chart-card:hover { border-color: var(--primary); }
.reports-chart-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; }
.reports-chart-body { position: relative; }
.reports-empty { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; font-weight: 600; }

/* Donut */
.reports-donut-layout { display: flex; align-items: center; gap: 24px; justify-content: center; }
.reports-legend { display: flex; flex-direction: column; gap: 8px; }
.reports-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.reports-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.reports-legend-val { color: var(--text-muted); margin-left: auto; font-variant-numeric: tabular-nums; }

/* Horizontal bars */
.reports-hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.reports-hbar-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); min-width: 80px; text-align: right; }
.reports-hbar-track { flex: 1; height: 18px; background: var(--bg-hover); border-radius: 9px; overflow: hidden; }
.reports-hbar-fill { height: 100%; background: var(--primary); border-radius: 9px; transition: width .5s ease; min-width: 4px; }
.reports-hbar-val { font-size: 11px; font-weight: 700; color: var(--text-muted); min-width: 50px; font-variant-numeric: tabular-nums; }

/* Gauges */
.reports-gauges { display: flex; flex-direction: column; gap: 16px; }
.reports-gauge-row { display: flex; align-items: center; gap: 14px; }
.reports-gauge-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

/* Tab Bar */
.reports-tab-bar {
  display: flex; gap: 0; margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.reports-tab {
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); background: none; border: none;
  cursor: pointer; position: relative; transition: var(--transition);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.reports-tab:hover { color: var(--text-primary); }
.reports-tab.active {
  color: var(--primary); border-bottom-color: var(--primary);
}

/* Insights — Regulatory Reference Tag */
.insights-reg-ref {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  background: var(--bg-hover); border-radius: 3px;
  padding: 1px 5px; margin-left: 6px; white-space: nowrap;
}

/* Insights — Training Recommendations */
.insights-rec-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.insights-rec-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px 20px;
  transition: var(--transition);
}
.insights-rec-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.insights-rec-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; margin-bottom: 10px;
}
.insights-rec-topic {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 6px; line-height: 1.4;
}
.insights-rec-stat {
  font-size: 12px; color: var(--text-muted); line-height: 1.4;
}

/* Responsive */
@media (max-width: 1100px) {
  .reports-kpi-row { grid-template-columns: repeat(3, 1fr); }
  .reports-chart-row { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .reports-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* ============ REPORTS PRINT-TO-PDF ============ */
/* The "Export PDF" button in reports_view.dart builds a self-contained
   .reports-print-portal at body level, then calls window.print(). On screen
   the portal is hidden; on print it's the only thing the browser sees.

   We deliberately set @page margin to 0 and bake the page margins into
   each .reports-print-page wrapper as padding. This is the only approach
   that survives Chrome's "Margins: None" dropdown setting — when the user
   has that selected (and it's sticky across sessions), @page margin is
   ignored entirely. Padding inside the content always works. */
@page {
  size: letter;
  margin: 0;
}

.reports-print-portal { display: none; }

@media print {
  /* Hide every top-level body child except our portal */
  body > *:not(.reports-print-portal) { display: none !important; }

  html, body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .reports-print-portal {
    display: block !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    background: #ffffff !important;
    color: #111827 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 11px;
    line-height: 1.4;
    /* Override theme variables so the cloned charts/cards print with a
       light, high-contrast palette regardless of the user's active theme. */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --primary-glow: rgba(79, 70, 229, 0.18);
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --border: #d1d5db;
    --border-light: #e5e7eb;
    --bg-base: #ffffff;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f3f4f6;
    --bg-active: #e5e7eb;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --shadow-glow: none;
  }

  /* ----- Per-page wrapper -----
     Each page of the report is wrapped in one of these. The padding here
     IS the page margin — this is the only mechanism that survives Chrome's
     "Margins: None" print-dialog setting. page-break-after forces a fresh
     page after each wrapper; page-break-inside: avoid asks the browser to
     keep each wrapper intact. */
  .reports-print-page {
    box-sizing: border-box;
    width: 100%;
    padding: 0.6in 0.55in 0.55in 0.55in;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
    /* Ensure the bottom footer sits near the page bottom even on a short
       page — content + auto top, footer pushed down. */
    display: flex;
    flex-direction: column;
  }
  .reports-print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  .reports-print-page > .reports-print-footer {
    margin-top: auto;
  }

  /* ----- Print header ----- */
  .reports-print-header {
    border-bottom: 2px solid #4f46e5;
    padding-bottom: 12px;
    margin-bottom: 18px;
  }
  .reports-print-org {
    font-size: 11px;
    font-weight: 700;
    color: #4f46e5;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
  }
  .reports-print-title {
    margin: 0 0 10px 0;
    font-size: 22px;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.01em;
  }
  .reports-print-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 10px;
    color: #374151;
  }
  .reports-print-meta-k {
    display: inline-block;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 5px;
  }
  .reports-print-meta-v {
    color: #111827;
    font-weight: 700;
  }

  /* ----- Print footer ----- */
  .reports-print-footer {
    margin-top: 20px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
    font-size: 9px;
    color: #9ca3af;
    text-align: center;
  }

  /* ----- KPI cards: 3 per row, no hover/shadow chrome ----- */
  .reports-print-portal .reports-kpi-row {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .reports-print-portal .reports-kpi-card {
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    padding: 10px 12px !important;
    box-shadow: none !important;
    transform: none !important;
  }
  .reports-print-portal .reports-kpi-icon {
    width: 22px !important;
    height: 22px !important;
    margin-bottom: 4px !important;
  }
  .reports-print-portal .reports-kpi-icon svg {
    width: 14px !important;
    height: 14px !important;
  }
  .reports-print-portal .reports-kpi-value {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: #111827 !important;
  }
  .reports-print-portal .reports-kpi-label {
    font-size: 9px !important;
    color: #6b7280 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* ----- Chart rows: equal halves, never split across pages ----- */
  .reports-print-portal .reports-chart-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
    margin-bottom: 14px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .reports-print-portal .reports-chart-card {
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    padding: 10px !important;
    box-shadow: none !important;
    transform: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .reports-print-portal .reports-chart-title {
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #111827 !important;
    margin-bottom: 8px !important;
  }
  .reports-print-portal .reports-chart-body {
    overflow: visible !important;
  }
  .reports-print-portal svg {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Donut/legend, horizontal bars, gauges — keep compact and printable */
  .reports-print-portal .reports-donut-layout {
    gap: 14px !important;
  }
  .reports-print-portal .reports-legend-item { font-size: 9px !important; }
  .reports-print-portal .reports-hbar-row { margin-bottom: 6px !important; }
  .reports-print-portal .reports-hbar-label { font-size: 9px !important; }
  .reports-print-portal .reports-hbar-val { font-size: 9px !important; }
  .reports-print-portal .reports-gauge-row { gap: 10px !important; }
  .reports-print-portal .reports-gauge-label { font-size: 10px !important; }

  /* ----- Insights tab content ----- */
  .reports-print-portal .insights-content { background: #ffffff !important; }
  .reports-print-portal .insights-content > * {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Strip any animations/transitions during print so charts render
     in their final state without partial frames. */
  .reports-print-portal *,
  .reports-print-portal *::before,
  .reports-print-portal *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ============ NOTIFICATION BELL ============ */
.notif-wrapper { position: relative; }
.notif-bell {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; transition: var(--transition); color: var(--text-muted);
}
.notif-bell:hover { background: var(--bg-hover); color: var(--text-primary); }
.notif-bell svg { width: 18px; height: 18px; }
.notif-bell.has-unread svg { animation: bellShake 0.5s ease-in-out; }
@keyframes bellShake {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(12deg); }
  30% { transform: rotate(-10deg); }
  45% { transform: rotate(8deg); }
  60% { transform: rotate(-6deg); }
  75% { transform: rotate(3deg); }
}
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: #ef4444; color: white; font-size: 9px; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
}

/* Dropdown */
.notif-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 8px;
  width: 380px; max-height: 480px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0,0,0,.15); z-index: 200; overflow: hidden;
}
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.notif-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.notif-mark-all {
  font-size: 11px; font-weight: 600; color: var(--primary); background: none; border: none;
  cursor: pointer; font-family: 'Manrope', sans-serif;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px;
  cursor: pointer; transition: var(--transition); border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--primary-glow); }
.notif-item.unread:hover { background: var(--bg-hover); }
.notif-icon { flex-shrink: 0; margin-top: 2px; }
.notif-icon svg { width: 16px; height: 16px; }
.notif-content { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.notif-item-body { font-size: 12px; color: var(--text-secondary); line-height: 1.4; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-item-meta { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.notif-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }
.notif-empty { padding: 40px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ============ @MENTION AUTOCOMPLETE ============ */
.mention-dropdown {
  position: absolute; 
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 -4px 20px rgba(0,0,0,.12); z-index: 50; max-height: 240px; overflow-y: auto;
  z-index: 10000;
}
.mention-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  cursor: pointer; transition: var(--transition);
}
.mention-item:hover, .mention-item.active { background: var(--bg-hover); }
.mention-avatar {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: white; flex-shrink: 0;
}
.mention-info { display: flex; flex-direction: column; }
.mention-name { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.mention-role { font-size: 10px; color: var(--text-muted); font-weight: 600; }

/* ============ VERSION SELECTOR ============ */
.version-selector {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-primary); cursor: pointer;
}
.version-selector:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow); }

/* Version read-only banner */
.version-readonly-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin-bottom: 12px;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25);
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  color: #b45309;
}
.version-readonly-banner svg { width: 14px; height: 14px; flex-shrink: 0; }
.run-doc-banner svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.version-back-link { color: var(--primary); cursor: pointer; text-decoration: underline; margin-left: auto; }

/* Checklist diff indicators */
.cl-item-changed { border-left: 3px solid var(--primary); }
.cl-diff-badge {
  position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 4px;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.cl-diff-arrow { color: var(--text-muted); }
.cl-diff-prior, .cl-diff-new { padding: 1px 6px; border-radius: 9999px; }
.cl-st-pass { background: rgba(16,185,129,.12); color: #059669; }
.cl-st-fail { background: rgba(239,68,68,.12); color: #dc2626; }
.cl-st-warn { background: rgba(245,158,11,.12); color: #d97706; }
.cl-st-pend { background: rgba(148,163,184,.12); color: #64748b; }

/* Comment version tag */
.cl-comment-version {
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 9999px;
  background: rgba(99,102,241,.1); color: #6366f1; margin-left: 4px;
}

/* @mention highlight in comments */
.mention-highlight { color: var(--primary); font-weight: 700; }

/* ============ LOADING SPINNER ============ */
.loading-spinner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 20px; color: var(--text-muted);
}
.spinner-ring {
  width: 20px; height: 20px; border: 2.5px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spinRing 0.7s linear infinite;
}
@keyframes spinRing { to { transform: rotate(360deg); } }
.spinner-text { font-size: 12px; font-weight: 600; }

/* ============ PAGINATION ============ */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted); flex-wrap: wrap;
}
.page-info { font-weight: 600; }
.page-controls { display: flex; align-items: center; gap: 4px; }
.page-btn {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-primary); cursor: pointer;
  transition: var(--transition);
}
.page-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-ellipsis { padding: 0 6px; color: var(--text-muted); font-weight: 700; }
.page-size-select {
  font-family: 'Manrope', sans-serif; font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer;
}

/* ============ TABLE HEADER SEARCH ============ */
.tbl-head-right { display: flex; align-items: center; gap: 10px; }
.deleted-toggle svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.deleted-toggle.active { color: var(--danger); border-color: var(--danger); }
.tbl-search-wrap {
  position: relative; display: flex; align-items: center;
}
.tbl-search-icon {
  position: absolute; left: 10px; pointer-events: none;
  color: var(--text-muted); display: flex; align-items: center;
}
.tbl-search-icon svg { width: 14px; height: 14px; }
.tbl-search {
  font-family: 'Manrope', sans-serif; font-size: 12px; font-weight: 500;
  padding: 7px 12px 7px 32px; border-radius: var(--radius-full); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary); width: 160px;
  transition: all .2s ease;
}
.tbl-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); width: 220px; }
.tbl-search::placeholder { color: var(--text-muted); font-weight: 500; }
.td-empty { padding: 40px 16px !important; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ============ EMPTY STATES ============ */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center;
}
.empty-state-icon {
  width: 100px; height: 84px; color: var(--text-muted); margin-bottom: 16px;
  opacity: 0.7;
}
.empty-state-icon svg { width: 100%; height: 100%; }
.empty-state-title {
  font-family: 'Outfit', sans-serif; font-size: 15px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 6px;
}
.empty-state-desc {
  font-size: 12.5px; color: var(--text-muted); line-height: 1.5;
  max-width: 300px; margin-bottom: 16px;
}
.empty-state .btn { font-size: 12px; }
.empty-state-desc a { color: var(--primary); font-weight: 600; text-decoration: none; }
.empty-state-desc a:hover { text-decoration: underline; }

/* ============ CONFIRM DIALOG ============ */
.confirm-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 24px 20px;
  width: 380px; max-width: 90vw; text-align: center;
  box-shadow: var(--shadow-xl);
  animation: confirmEnter .2s ease;
}
@keyframes confirmEnter {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.confirm-icon {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
}
.confirm-icon svg { width: 22px; height: 22px; }
.confirm-icon-danger { background: rgba(239,68,68,.1); color: #ef4444; }
.confirm-icon-warning { background: rgba(245,158,11,.1); color: #f59e0b; }
.confirm-icon-primary { background: rgba(99,102,241,.1); color: #6366f1; }
.confirm-title {
  font-family: 'Outfit', sans-serif; font-size: 16px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 8px;
}
.confirm-message {
  font-size: 13px; color: var(--text-muted); line-height: 1.55; margin-bottom: 20px;
}
.confirm-actions {
  display: flex; gap: 10px; justify-content: center;
}
.confirm-actions .btn { min-width: 100px; font-size: 12.5px; }
.confirm-actions .btn:disabled { opacity: .5; cursor: not-allowed; }
.confirm-modal-input { width: 460px; text-align: left; }
.confirm-modal-input .confirm-icon,
.confirm-modal-input .confirm-title,
.confirm-modal-input .confirm-message { text-align: center; }
.confirm-modal-input .confirm-actions { margin-top: 16px; }
.confirm-input-wrap { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.confirm-input-label {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .04em;
}
.confirm-input {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; font-size: 13px; font-family: inherit; line-height: 1.5;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  resize: vertical; min-height: 84px;
  transition: border-color .15s, box-shadow .15s;
}
.confirm-input:focus {
  outline: none; border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.confirm-checkbox-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 4px;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer;
  font-size: 13px; color: var(--text-primary);
  transition: border-color .15s, background .15s;
}
.confirm-checkbox-row:hover { border-color: var(--border-focus); }
.confirm-checkbox-row input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}
.btn-danger {
  background: #ef4444; color: white; border: 1px solid #ef4444;
}
.btn-danger:hover { background: #dc2626; }
.btn-warning {
  background: #f59e0b; color: white; border: 1px solid #f59e0b;
}
.btn-warning:hover { background: #d97706; }

/* ============ BULK ACTIONS ============ */
.bulk-cb {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary);
}
.td-cb { padding-left: 12px !important; width: 36px; }
.td-cb .bulk-cb { pointer-events: auto; }
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--primary-glow);
  border-bottom: 1px solid var(--primary);
  animation: bulkSlide .2s ease;
}
@keyframes bulkSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.bulk-count {
  font-size: 12.5px; font-weight: 700; color: var(--primary);
}
.bulk-actions {
  display: flex; align-items: center; gap: 6px;
}
.bulk-actions .btn svg { width: 13px; height: 13px; }
.bulk-clear {
  color: var(--text-muted) !important; font-size: 11px !important;
}
.bulk-hint {
  font-size: 11px; color: var(--text-muted); font-style: italic; padding: 0 8px;
}

/* ============ SIDEBAR SHORTCUT HINT ============ */
.sidebar-shortcut-hint {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin: 8px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  transition: var(--transition); background: rgba(255,255,255,.02);
}
.sidebar-shortcut-hint:hover {
  border-color: var(--primary); color: var(--text-secondary);
  background: var(--primary-glow);
}
.sidebar-shortcut-hint svg { width: 13px; height: 13px; flex-shrink: 0; }
.sidebar-shortcut-hint span { flex: 1; }
.sidebar-shortcut-hint kbd {
  font-family: 'Manrope', sans-serif; font-size: 10px; font-weight: 800;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-active); border: 1px solid var(--border);
  color: var(--text-muted); line-height: 1;
}
.sidebar.compact .sidebar-shortcut-hint { justify-content: center; padding: 8px; margin: 8px 6px; }
.sidebar.compact .sidebar-shortcut-hint span,
.sidebar.compact .sidebar-shortcut-hint kbd { display: none; }

/* ============ COMMAND PALETTE ============ */
.cmd-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
}
.cmd-overlay.show { opacity: 1; pointer-events: auto; }
.cmd-modal {
  width: 520px; max-width: 90vw; max-height: 70vh;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 24px 48px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
  animation: cmdEnter .15s ease;
  overflow: hidden;
}
@keyframes cmdEnter {
  from { transform: scale(0.96) translateY(-8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.cmd-search-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.cmd-search-icon { display: flex; color: var(--text-muted); }
.cmd-search-icon svg { width: 16px; height: 16px; }
.cmd-input {
  flex: 1; border: none; background: transparent; outline: none;
  font-family: 'Manrope', sans-serif; font-size: 14px; font-weight: 500;
  color: var(--text-primary);
}
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-esc-hint {
  font-size: 9px; font-weight: 700; padding: 3px 6px; border-radius: 4px;
  background: var(--bg-active); border: 1px solid var(--border);
  color: var(--text-muted);
}
.cmd-results {
  flex: 1; overflow-y: auto; padding: 6px 0;
  max-height: calc(70vh - 110px);
}
.cmd-section {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text-muted);
  padding: 10px 16px 4px;
}
.cmd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; cursor: pointer;
  transition: background .1s;
}
.cmd-item:hover, .cmd-item.active {
  background: var(--primary-glow);
}
.cmd-item.active { border-left: 2px solid var(--primary); }
.cmd-item-icon { display: flex; color: var(--text-muted); flex-shrink: 0; }
.cmd-item-icon svg { width: 15px; height: 15px; }
.cmd-item-text { display: flex; flex-direction: column; min-width: 0; }
.cmd-item-label {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmd-item-sub {
  font-size: 11px; color: var(--text-muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmd-empty {
  padding: 28px 16px; text-align: center;
  font-size: 13px; color: var(--text-muted);
}
.cmd-footer {
  display: flex; gap: 16px; padding: 8px 16px;
  border-top: 1px solid var(--border);
}
.cmd-foot-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--text-muted);
}
.cmd-foot-item kbd {
  font-family: 'Manrope', sans-serif; font-size: 9px; font-weight: 800;
  padding: 1px 5px; border-radius: 3px;
  background: var(--bg-active); border: 1px solid var(--border);
}

/* ============ SHORTCUTS HELP MODAL ============ */
.shortcuts-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  width: 460px; max-width: 90vw; box-shadow: var(--shadow-xl);
  text-align: center;
}
.shortcuts-modal h3 {
  font-family: 'Outfit', sans-serif; font-size: 16px; font-weight: 700;
  margin-bottom: 20px;
}
.shortcuts-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  text-align: left; margin-bottom: 20px;
}
.shortcut-group-title {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text-muted); margin-bottom: 10px;
}
.shortcut-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; font-size: 12.5px; color: var(--text-secondary);
}
.shortcut-row kbd {
  font-family: 'Manrope', sans-serif; font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 4px; min-width: 28px; text-align: center;
  background: var(--bg-active); border: 1px solid var(--border);
  color: var(--text-muted);
}
.shortcut-row span { flex: 1; }

/* ============ CHECKLIST ACTION ROW ============ */
.checklist-action-row {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; margin-bottom: 2px;
}
/* scan button no longer in action row */
.checklist-action-row .btn svg { width: 13px; height: 13px; }

/* ============ AI REVIEW RULES ============ */
.airules-stats {
  display: flex; gap: 12px; margin-bottom: 16px;
}
.airules-stat {
  flex: 1; padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); text-align: center;
  background: var(--bg-active);
}
.airules-stat-val {
  display: block; font-family: 'Outfit', sans-serif;
  font-size: 22px; font-weight: 800; color: var(--primary);
}
.airules-stat-lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
}
.airules-add-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.airules-add-row .btn svg { width: 13px; height: 13px; }
.airules-list { display: flex; flex-direction: column; gap: 10px; }
.airule-card {
  padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  transition: var(--transition);
}
.airule-card:hover { border-color: var(--primary); }
.airule-disabled { opacity: 0.55; }
.airule-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.airule-name-wrap { display: flex; align-items: center; gap: 8px; }
.airule-name {
  font-size: 13px; font-weight: 700; color: var(--text-primary);
}
.airule-priority {
  font-size: 9px; font-weight: 800; padding: 2px 8px; border-radius: 9999px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.airule-priority-req { background: rgba(239,68,68,.1); color: #ef4444; }
.airule-priority-rec { background: rgba(245,158,11,.1); color: #d97706; }
.airule-prompt {
  font-size: 12px; color: var(--text-secondary); line-height: 1.55;
  padding: 8px 10px; background: var(--bg-active); border-radius: var(--radius-xs);
  margin-bottom: 8px;
}
.airule-actions { display: flex; gap: 6px; }
.airule-actions .btn { font-size: 11px; }

/* Rule modal */
.airule-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; width: 480px;
  max-width: 90vw; box-shadow: var(--shadow-xl);
}
.airule-modal h3 {
  font-family: 'Outfit', sans-serif; font-size: 16px;
  font-weight: 700; margin-bottom: 4px;
}
.airule-textarea {
  min-height: 100px; resize: vertical; font-family: 'Manrope', sans-serif;
  font-size: 12.5px; line-height: 1.55;
}
.airule-char-count {
  font-size: 10px; color: var(--text-muted); text-align: right; margin-top: 4px;
}

/* ============ AI SCAN ANIMATION ============ */
.cl-scanning {
  background: var(--primary-glow) !important;
  transition: background .15s;
}

/* ============ CONTEXT SWITCHER ============ */
.ctx-switcher {
  margin: 4px 12px 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.ctx-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.ctx-row:hover {
  background: var(--bg-active);
}
.ctx-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .6;
}
.ctx-icon svg {
  width: 14px;
  height: 14px;
}
.ctx-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.ctx-chevron {
  font-size: 10px;
  opacity: .5;
}

/* Compact sidebar: hide labels */
.sidebar.compact .ctx-switcher {
  margin: 4px 6px 8px;
}
.sidebar.compact .ctx-label,
.sidebar.compact .ctx-chevron {
  display: none;
}
.sidebar.compact .ctx-row {
  justify-content: center;
  padding: 5px;
}

/* Context picker modal */
.ctx-picker-modal {
  max-width: 340px !important;
  padding: 24px 28px !important;
}
.ctx-picker-modal h3 {
  margin: 0 0 14px;
  font-size: 15px;
  text-align: center;
}
.ctx-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}
.ctx-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.ctx-picker-item:hover {
  background: var(--bg-active);
}
.ctx-picker-active {
  background: var(--primary-glow);
  cursor: default;
}
.ctx-picker-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}
.ctx-picker-check {
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
}
.ctx-picker-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
}
.ctx-badge-inactive {
  background: #fef2f2;
  color: #dc2626;
}
.ctx-picker-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}
.ctx-picker-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 4px;
  text-align: center;
}
.ctx-picker-empty-icon {
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  margin-bottom: 16px;
}
.ctx-picker-empty-icon svg { width: 100%; height: 100%; }
.ctx-picker-empty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.ctx-picker-empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 240px;
}
.ctx-picker-cta {
  margin-top: 20px;
  padding: 9px 28px;
}
.ctx-picker-dismiss {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
}
.ctx-picker-dismiss:hover {
  color: var(--text-primary);
}

/* ============ SITE CARDS ============ */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  padding: 0 2px;
}
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  transition: border-color .15s, box-shadow .15s;
}
.site-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}
.site-inactive {
  opacity: .6;
}
.site-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.site-card-name {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}
.site-card-status {
  font-size: 11px;
}
.site-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.site-card-detail {
  font-size: 11.5px;
  color: var(--text-secondary);
}
.site-label {
  font-weight: 600;
  color: var(--text-muted);
  display: inline-block;
  min-width: 52px;
}
.site-card-actions {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ============ ORG TABLE ENHANCEMENTS ============ */
.clickable-row {
  cursor: pointer;
  transition: background .12s;
}
.clickable-row:hover {
  background: var(--bg-active);
}
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 9999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge-purple {
  background: #f3e8ff;
  color: #7c3aed;
}
.badge-blue {
  background: #dbeafe;
  color: #2563eb;
}
.badge-gray {
  background: #f3f4f6;
  color: #6b7280;
}
.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: -8px 0 14px;
}

/* ============ RULES UI (three-tier) ============ */
.rules-header {
  margin-bottom: 16px;
}
.rules-title {
  font-size: 16px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  margin-bottom: 4px;
}
.rules-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.rules-add-area {
  margin-bottom: 18px;
}
.rules-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 8px 18px;
}
.rules-add-btn svg {
  width: 14px;
  height: 14px;
}
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.rules-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--primary);
  padding: 14px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.rules-group-std {
  color: var(--text-muted);
  margin-top: 8px;
}

/* Rule card */
.rule-card {
  padding: 14px 16px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.rule-card:hover {
  background: var(--bg-active);
}
.rule-org {
  border-left-color: var(--primary);
}
.rule-std {
  border-left-color: #d1d5db;
}
.rule-disabled {
  opacity: .5;
}
.rule-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.rule-name {
  font-size: 13.5px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  line-height: 1.3;
}
.rule-chips {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.rule-chip {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: 2px 7px;
  border-radius: 9999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.rule-chip svg {
  width: 10px;
  height: 10px;
}
.rule-chip-org {
  background: var(--primary-glow);
  color: var(--primary);
}
.rule-chip-std {
  background: #f3f4f6;
  color: #6b7280;
}
.rule-chip-req {
  background: #fef2f2;
  color: #dc2626;
}
.rule-chip-rec {
  background: #fffbeb;
  color: #d97706;
}
.rule-chip-lock {
  background: #f0fdf4;
  color: #16a34a;
}
.rule-chip-pending {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.rule-chip-rejected {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Rule cards in non-live states */
.rule-card.rule-pending {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 60%);
}
.rule-card.rule-rejected {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fef2f2 0%, #ffffff 60%);
}

/* Banner shown above the prompt for pending_new rules */
.rule-pending-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 4px 0 10px;
}

/* Rejection callout (used for rejected rules and for last-edit-rejected on live rules) */
.rule-rejection-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 8px 0 4px;
}
.rule-rejection-headline {
  font-size: 12.5px;
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 4px;
}
.rule-rejection-reason {
  font-size: 12.5px;
  color: #7f1d1d;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-bottom: 6px;
}
.rule-rejection-hint {
  font-size: 11.5px;
  color: #b91c1c;
  font-style: italic;
}

/* Pending-edit diff: shows live vs proposed values side-by-side */
.rule-pending-diff {
  margin: 10px 0 4px;
  padding: 12px 14px;
  border: 1px dashed #fcd34d;
  background: #fffbeb;
  border-radius: 8px;
}
.rule-pending-diff-header {
  font-size: 12px;
  font-weight: 700;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.rule-pending-diff-hint {
  font-size: 11.5px;
  color: #92400e;
  margin-bottom: 10px;
  line-height: 1.5;
}
.rule-pending-diff-row {
  margin-bottom: 10px;
}
.rule-pending-diff-row:last-of-type {
  margin-bottom: 4px;
}
.rule-pending-diff-label {
  font-size: 11px;
  font-weight: 700;
  color: #78350f;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.rule-pending-diff-old, .rule-pending-diff-new {
  font-size: 12.5px;
  line-height: 1.55;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}
.rule-pending-diff-old {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.rule-pending-diff-new {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.rule-pending-diff-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #cbd5e1;
  color: #1e293b;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}
.rule-pending-diff-tag-new {
  background: #6ee7b7;
  color: #064e3b;
}
.rule-pending-diff-meta {
  font-size: 11px;
  color: #92400e;
  margin-top: 6px;
  font-style: italic;
}

/* Locked-tier state on the Add Rule buttons + inline notice */
.rules-add-btn-locked {
  opacity: 0.7;
}
.rules-add-btn-locked:hover {
  opacity: 1;
}
.rules-tier-locked-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(217, 119, 6, 0.08) 100%);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 8px 0 16px;
  font-size: 13px;
  color: #78350f;
  line-height: 1.55;
}
.rules-tier-locked-notice strong {
  color: #92400e;
  font-weight: 700;
}
.rules-tier-locked-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  background: #fef3c7;
  color: #b45309;
  border-radius: 50%;
  flex: 0 0 28px;
}
.rules-tier-locked-icon svg {
  width: 14px;
  height: 14px;
}
.rules-tier-locked-cta {
  margin-left: auto;
  flex-shrink: 0;
  color: #b45309 !important;
  font-weight: 600;
}
.rules-tier-locked-cta:hover {
  background: #fef3c7 !important;
}

/* Pending Approvals tab (Internal Admin) */
.pending-approvals-summary {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.07) 0%, rgba(13, 148, 136, 0.07) 100%);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: #115e59;
  line-height: 1.55;
  margin-bottom: 16px;
}
.pending-approvals-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pending-approval-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: box-shadow 150ms ease, border-color 150ms ease;
}
.pending-approval-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.pending-approval-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.pending-approval-kind {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 8px;
  border-radius: 4px;
  align-self: start;
  margin-top: 2px;
}
.pending-approval-kind-new {
  background: #ecfdf5;
  color: #047857;
}
.pending-approval-kind-edit {
  background: #fef3c7;
  color: #92400e;
}
.pending-approval-title .pending-approval-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
}
.pending-approval-title .pending-approval-scope {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.pending-approval-title .dot { margin: 0 4px; color: #cbd5e1; }
.pending-approval-meta {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.pending-approval-meta .pending-approval-by {
  color: #1e293b;
  font-weight: 600;
}
.pending-approval-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.pending-approval-prompt {
  font-size: 13px;
  color: #0f172a;
  line-height: 1.6;
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}
.pending-approval-ref, .pending-approval-prio {
  font-size: 12px;
  color: #334155;
}
.pending-approval-diff {
  background: #fffbeb;
  border: 1px dashed #fcd34d;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 4px;
}
.pending-approval-empty-diff {
  font-size: 12px;
  color: #92400e;
  font-style: italic;
}
.pending-approval-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}
.pending-approval-reject {
  color: #b91c1c !important;
}
.pending-approval-reject:hover {
  background: #fef2f2 !important;
}

/* Approval-flow notice inside the rule editor modal */
.rule-modal-approval-notice {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.08) 0%, rgba(13, 148, 136, 0.08) 100%);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.rule-modal-approval-headline {
  font-size: 13px;
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 4px;
}
.rule-modal-approval-body {
  font-size: 12.5px;
  color: #115e59;
  line-height: 1.55;
}
.rule-prompt {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 4px;
}
.rule-ref {
  font-size: 10.5px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 4px;
}
.rule-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.rule-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rule-toggle-label {
  font-size: 11px;
  color: var(--text-muted);
}
.rule-actions {
  display: flex;
  gap: 4px;
}
.rule-delete-btn {
  color: #ef4444 !important;
}
.rule-lock-note {
  font-size: 11px;
  color: #16a34a;
  font-style: italic;
}

/* Rule modal */
.rule-modal {
  max-width: 520px !important;
}
.rule-modal h3 {
  margin: 0 0 4px;
  font-size: 17px;
}
.rule-modal-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}
.rule-field {
  margin-bottom: 16px;
}
.rule-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-secondary);
}
.rule-prompt-input {
  min-height: 90px;
  resize: vertical;
  font-size: 12.5px !important;
  line-height: 1.5;
}
.rule-prio-pills {
  display: flex;
  gap: 8px;
}
.rule-prio-pill {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
.rule-prio-pill strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}
.rule-prio-pill span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
}
.rule-prio-pill:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}
.rule-prio-active {
  border-color: var(--primary) !important;
  background: var(--primary-glow) !important;
}
.rule-prio-active strong {
  color: var(--primary);
}
.rule-ref-toggle {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 0;
}
.rule-ref-toggle:hover {
  text-decoration: underline;
}
.rule-ref-input {
  margin-top: 6px;
}

/* ============ RULES CONTEXT BANNER ============ */
.rules-ctx {
  background: var(--bg-active);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.rules-ctx-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}
.rules-ctx-icon {
  width: 14px;
  height: 14px;
  opacity: .6;
}
.rules-ctx-icon svg {
  width: 14px;
  height: 14px;
}
.rules-ctx-site {
  font-family: 'Outfit', sans-serif;
  color: var(--primary);
}
.rules-ctx-sep {
  color: var(--text-muted);
}
.rules-ctx-org {
  color: var(--text-secondary);
  font-weight: 500;
}
.rules-ctx-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}
.rules-summary {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.rules-summary-count {
  font-size: 18px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--primary);
  margin-right: 4px;
}
.rules-add-area {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.btn-outline:hover {
  background: var(--primary-glow);
}
.rules-group-count {
  font-weight: 400;
  opacity: .7;
}
.rules-tier-site {
  color: var(--primary) !important;
}
.rules-tier-org {
  color: #7c3aed !important;
}
.rules-tier-std {
  color: var(--text-muted) !important;
}
.rule-tier-site { border-left-color: var(--primary); }
.rule-tier-org  { border-left-color: #7c3aed; }
.rule-tier-standard { border-left-color: #d1d5db; }
.rule-chip-site {
  background: var(--primary-glow);
  color: var(--primary);
}
.rule-disabled-reason {
  font-size: 10.5px;
  color: #ef4444;
  font-style: italic;
  padding: 2px 0 4px;
}
.rule-muted-btn {
  color: var(--text-muted) !important;
  font-size: 11px !important;
}

/* ============ MEMBERS LIST (org/site views) ============ */
.members-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px 0;
  max-height: 400px;
  overflow-y: auto;
}
.member-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background .12s;
}
.member-row:hover {
  background: var(--bg-active);
}
.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.member-info {
  flex: 1;
  min-width: 0;
}
.member-name {
  font-size: 13px;
  font-weight: 600;
}
.member-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.member-email {
  font-size: 11px;
  color: var(--text-muted);
}
.member-perm-count {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
.member-sites {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.member-site-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  background: var(--bg-active);
  border-radius: 6px;
  padding: 3px 8px;
}
.msc-site {
  font-weight: 600;
}
.msc-role {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: 1px 6px;
  border-radius: 9999px;
}
.role-admin { background: #fef2f2; color: #dc2626; }
.role-sadmin { background: #f3e8ff; color: #7c3aed; }
.role-reviewer { background: #dbeafe; color: #2563eb; }
.role-user { background: #f3f4f6; color: #6b7280; }

/* ============ USER ACCESS SECTION (user edit modal) ============ */
.user-access-section {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 14px;
}
.user-access-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.user-access-title {
  font-size: 13px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}
.user-access-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.user-access-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px;
  text-align: center;
}
.user-access-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-active);
  border-radius: 8px;
  font-size: 12px;
}
.ua-info {
  flex: 1;
  min-width: 0;
}
.ua-site {
  font-weight: 600;
  font-size: 12.5px;
}
.ua-org {
  font-size: 10.5px;
  color: var(--text-muted);
}
.ua-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ua-perms {
  font-size: 10px;
  color: var(--text-muted);
}
.ua-remove {
  font-size: 16px !important;
  padding: 0 4px !important;
  color: #ef4444 !important;
  line-height: 1;
}

/* ============ ACCESS PERMISSION GRID ============ */
.access-perm-grid {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.access-perm-group {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 6px 0 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.access-perm-group:first-child {
  padding-top: 0;
}
.access-perm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}
.access-perm-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

/* ============ SITE ACCESS LIST (user edit) ============ */
.user-access-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.site-access-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.site-access-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  transition: background .12s;
}
.site-access-row:hover {
  background: var(--bg-active);
}
.site-access-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.site-access-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}
.site-access-role {
  width: 140px;
  font-size: 12px !important;
  padding: 4px 8px !important;
  flex-shrink: 0;
}
.site-inactive {
  opacity: .45;
}

/* Members modal search + pagination */
.members-search-wrap {
  margin-bottom: 10px;
}
.members-pag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  justify-content: center;
}
.pag-info {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============ USER MANAGEMENT — REWRITE ============ */
.um-layout {
  display: flex;
  gap: 0;
  min-height: 500px;
}
.um-table-wrap {
  flex: 1;
  min-width: 0;
}
.um-detail-container {
  width: 0;
  overflow: hidden;
  transition: width .25s ease;
  border-left: 0 solid var(--border);
}
.um-detail-container.open {
  width: 380px;
  min-width: 380px;
  border-left-width: 1px;
}
.um-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.um-search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.um-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  opacity: .4;
}
.um-search-icon svg {
  width: 14px;
  height: 14px;
}
.um-search-input {
  padding-left: 32px !important;
  font-size: 12.5px !important;
}
.um-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Table cells */
.um-user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.um-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.um-name {
  font-size: 12.5px;
  font-weight: 600;
}
.um-email-cell {
  font-size: 12px;
  color: var(--text-secondary);
}
.um-site-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.um-site-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  background: var(--bg-active);
  border-radius: 5px;
  padding: 2px 7px;
}
.um-chip-name {
  font-weight: 600;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.um-chip-role {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0 4px;
  border-radius: 3px;
}
.um-role-reviewer { background: #dbeafe; color: #2563eb; }
.um-role-coordinator { background: #f3e8ff; color: #7c3aed; }
.um-role-chair { background: #fef2f2; color: #dc2626; }
.um-role-pi { background: #ecfdf5; color: #059669; }
.um-role-admin { background: #fef3c7; color: #d97706; }
.um-no-sites {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.um-site-more {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ============ DETAIL PANEL ============ */
.um-detail {
  padding: 18px;
  position: relative;
}
.um-detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-active);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.um-detail-close:hover {
  background: var(--border);
}
.um-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-right: 32px;
}
.um-detail-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.um-detail-name-block {
  min-width: 0;
}
.um-detail-name {
  font-size: 15px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}
.um-detail-email {
  font-size: 12px;
  color: var(--text-muted);
}

/* Sections */
.um-section {
  margin-bottom: 20px;
}
.um-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.um-section-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Site rows */
.um-site-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.um-site-row:last-child {
  border-bottom: none;
}
.um-site-inactive {
  opacity: .45;
}
.um-site-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.um-site-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.um-site-name {
  font-size: 12.5px;
  font-weight: 600;
}
.um-site-tag-inactive {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: #ef4444;
  background: #fef2f2;
  padding: 1px 5px;
  border-radius: 3px;
}
.um-role-select {
  width: 140px;
  flex-shrink: 0;
  font-size: 12px !important;
  padding: 5px 8px !important;
}

/* Permission grid */
.um-perm-grid {
  max-height: 280px;
  overflow-y: auto;
}
.um-perm-group {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 8px 0 2px;
}
.um-perm-group:first-child {
  padding-top: 0;
}
.um-perm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}
.um-perm-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
}
.um-inline-select {
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 4px;
  background: var(--surface, #fff);
  color: var(--text-primary, #1f2937);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.um-inline-select:hover { border-color: var(--primary, #6366f1); }
.um-inline-select:focus { border-color: var(--primary, #6366f1); box-shadow: 0 0 0 2px rgba(99,102,241,.15); }

/* Members modal (site view) */
.members-search-wrap {
  margin-bottom: 10px;
}
.members-pag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 0;
}
.pag-info {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}
.badge-green {
  background: #ecfdf5;
  color: #059669;
}

/* ============ QUOTA BADGE ============ */
.view-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.quota-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 9999px;
  white-space: nowrap;
}
.quota-ok {
  background: #f0fdf4;
  color: #16a34a;
}
.quota-warn {
  background: #fffbeb;
  color: #d97706;
}
.quota-full {
  background: #fef2f2;
  color: #dc2626;
}

/* ============ VIEW HEADER (shared across views) ============ */
.user-mgmt-view .view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.user-mgmt-view .view-header h2 {
  font-size: 22px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
  margin: 0;
}
.view-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.view-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.user-mgmt-view .um-search-bar {
  margin-bottom: 16px;
}

/* ============ STATUS FILTER PILLS ============ */
.um-status-pills {
  display: flex;
  gap: 2px;
  background: var(--bg-active);
  border-radius: 8px;
  padding: 2px;
}
.um-status-pill {
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.um-status-pill:hover {
  color: var(--text-primary);
}
.um-pill-active {
  background: #fff;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Deactivated row */
.um-row-deactivated {
  opacity: .5;
}
.um-row-deactivated:hover {
  opacity: .75;
}

/* Detail panel status bar */
.um-detail-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.btn-danger-ghost {
  background: transparent !important;
  color: #dc2626 !important;
  border: 1px solid #fecaca !important;
  font-size: 11.5px;
}
.btn-danger-ghost:hover {
  background: #fef2f2 !important;
}

/* Badge red */
.badge-red {
  background: #fef2f2;
  color: #dc2626;
}

/* ============ SCAN RUN TOOLBAR ============ */
.scan-run-row {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
.scan-run-select {
  flex: 1;
  min-width: 0;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  padding: 0 8px !important;
  height: 30px;
  border-radius: 6px !important;
  background: var(--bg-active) !important;
  border: 1px solid transparent !important;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}
.scan-run-select:hover { border-color: var(--border) !important; }
.scan-run-select:focus { border-color: var(--primary) !important; outline: none; }
.scan-run-row .ai-scan-btn {
  margin: 0 !important;
  padding: 0 12px !important;
  font-size: 11px !important;
  height: 30px;
  border-radius: 6px !important;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 5px !important;
}
.scan-run-row .ai-scan-btn svg { width: 13px !important; height: 13px !important; }
.scan-export-btn {
  padding: 0 !important;
  width: 30px; height: 30px; min-width: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px !important;
  border: none !important;
  background: var(--bg-active) !important;
  color: var(--text-muted) !important;
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--transition);
}
.scan-export-btn:hover { background: var(--bg-hover) !important; color: var(--primary) !important; }
.scan-export-btn svg { width: 13px; height: 13px; }

/* Stale banner */
.scan-stale-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px;
  background: #fffbeb; border-bottom: 1px solid #fde68a;
  color: #92400e; font-size: 11px; font-weight: 500; flex-shrink: 0;
}
.scan-stale-banner svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Provenance */
.scan-provenance {
  display: flex; flex-wrap: wrap; gap: 3px 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card); flex-shrink: 0;
}

/* Combined row in doc-review: run selector + provenance side-by-side.
   Wraps to two lines when the panel is narrow. Children inherit the row's
   padding/border so we strip their own. */
.scan-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
.scan-meta-row .scan-run-row {
  padding: 0;
  border-bottom: 0;
  background: transparent;
  flex: 0 0 auto;
  min-width: 160px;
  max-width: 240px;
}
.scan-meta-row .scan-provenance {
  padding: 0;
  border-bottom: 0;
  background: transparent;
  flex: 0 0 auto;
}
.prov-item {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; color: var(--text-muted); white-space: nowrap; font-weight: 500;
}
.prov-item svg { width: 10px; height: 10px; opacity: .4; }

/* ============ TRIGGER TAGS ============ */
.scan-trigger-tags {
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.trigger-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.trigger-label {
  font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
}
.btn-trigger-edit {
  display: inline-flex; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  font-size: 10.5px; color: var(--primary); padding: 1px 6px;
  border-radius: 4px; transition: background .15s;
}
.btn-trigger-edit:hover { background: rgba(99,102,241,.08); }
.btn-trigger-edit svg { width: 11px; height: 11px; }
.trigger-empty {
  font-size: 12px; color: var(--text-muted); font-style: italic;
  display: inline-block; margin-right: 8px;
}
.trigger-chips {
  display: flex; flex-wrap: wrap; gap: 5px;
  animation: triggerChipsFadeIn .18s ease-out;
}
@keyframes triggerChipsFadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.trigger-chip {
  display: inline-block; font-size: 11px; font-weight: 500;
  padding: 2px 9px; border-radius: 10px;
  cursor: default; transition: all .15s;
}
.trigger-chip.active {
  background: rgba(99,102,241,.1); color: var(--primary);
  border: 1px solid rgba(99,102,241,.25);
}
.trigger-chip.inactive {
  background: transparent; color: var(--text-muted);
  border: 1px dashed var(--border);
}
.trigger-chip.editable { cursor: pointer; }
.trigger-chip.active.editable:hover {
  background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.3);
  color: #dc2626; text-decoration: line-through;
}
.trigger-chip.inactive.editable:hover {
  background: rgba(99,102,241,.06); border-color: rgba(99,102,241,.3);
  color: var(--primary); border-style: solid;
}
.trigger-add-section { margin-top: 6px; }
.trigger-add-toggle {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted); cursor: pointer;
  padding: 2px 0; user-select: none;
}
.trigger-add-toggle:hover { color: var(--text); }
.trigger-add-chevron { font-size: 9px; transition: transform .15s; }
.trigger-chips.inactive { margin-top: 5px; }
.trigger-actions {
  display: flex; gap: 8px; margin-top: 8px;
}
.trigger-loading {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); padding: 4px 0;
}
.trigger-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ SCAN RESULT ITEMS ============ */
/* Section group headers */
.scan-grp-std { font-weight: 600; color: #374151; }
.scan-grp-org { font-weight: 600; color: #7c3aed; }
.scan-grp-site { font-weight: 600; color: #4f46e5; }
.sec-fail { font-size: 9.5px; font-weight: 600; background: #fef2f2; color: #dc2626; padding: 2px 6px; border-radius: 4px; margin-left: 6px; }
.sec-warn { font-size: 9.5px; font-weight: 600; background: #fffbeb; color: #d97706; padding: 2px 6px; border-radius: 4px; margin-left: 6px; }

/* Title row with priority chip */
.cl-title-row { display: flex; align-items: center; gap: 6px; }
.scan-pri-chip {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 2px 6px; border-radius: 3px;
  flex-shrink: 0; line-height: 1;
}
.pri-required { background: #fef2f2; color: #dc2626; }
.pri-warning { background: #fffbeb; color: #d97706; }
.scan-general-chip {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 2px 6px; border-radius: 3px;
  flex-shrink: 0; line-height: 1;
  background: var(--bg-hover); color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: help;
}

/* AI reasoning block */
.scan-reasoning {
  display: flex; align-items: flex-start; gap: 6px;
  font-style: italic; color: var(--text-secondary);
  font-size: 11.5px; line-height: 1.55; margin-top: 6px;
  padding: 8px 10px; background: #f9fafb; border-radius: 6px;
  border-left: 3px solid var(--primary);
}
.scan-reasoning svg {
  width: 13px; height: 13px; min-width: 13px;
  flex-shrink: 0; margin-top: 2px; opacity: .35;
}

/* Excerpt from document */
.cl-excerpt {
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
  margin-top: 5px;
  padding: 3px 0 3px 10px;
  border-left: 2px solid #d1d5db;
  line-height: 1.5;
}

/* Scan button disabled state — nothing changed since last run */
.scan-run-row .ai-scan-btn.scan-btn-disabled {
  opacity: .4;
  cursor: not-allowed;
  background: var(--bg-active) !important;
  color: var(--text-muted) !important;
}
.scan-run-row .ai-scan-btn.scan-btn-disabled:hover {
  box-shadow: none !important;
  transform: none !important;
}
.scan-run-row .ai-scan-btn.scan-btn-disabled .shimmer {
  display: none;
}


/* ============ PROTOCOL AUTOCOMPLETE ============ */
.proto-ac {
  position: relative;
  width: 100%;
}
.proto-ac-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.proto-ac-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.proto-ac-search-icon svg { width: 14px; height: 14px; }
.proto-ac-input {
  width: 100%; padding: 9px 12px 9px 32px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px; font-family: 'Manrope', sans-serif;
  background: var(--bg-base); color: var(--text-primary);
  transition: var(--transition);
}
.proto-ac-input:focus {
  border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 99,102,241), .1);
}
.proto-ac-input::placeholder { color: var(--text-muted); }
.proto-ac-hint {
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
  line-height: 1.4;
}

/* Dropdown */
.proto-ac-dropdown {
  display: none;
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto; margin-top: 4px;
}
.proto-ac-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border-light, rgba(0,0,0,.04));
  transition: background .15s;
}
.proto-ac-item:last-child { border-bottom: none; }
.proto-ac-item:hover, .proto-ac-item.active {
  background: var(--bg-hover);
}
.proto-ac-item-main {
  display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
}
.proto-ac-item-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11.5px; font-weight: 700; color: var(--primary);
  white-space: nowrap;
}
.proto-ac-item-study {
  font-size: 12.5px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proto-ac-item-meta {
  font-size: 11px; color: var(--text-muted);
}
.proto-ac-empty {
  padding: 20px 14px; text-align: center;
  color: var(--text-muted); font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.proto-ac-empty svg { width: 28px; height: 28px; opacity: .4; }

/* Selected card */
.proto-ac-selected { margin-top: 0; }
.proto-ac-card {
  background: var(--bg-hover); border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm); padding: 12px 14px;
  position: relative;
  animation: protoCardEnter .2s ease;
}
@keyframes protoCardEnter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.proto-ac-card-top {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.proto-ac-card-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px; font-weight: 700; color: var(--primary);
}
.proto-ac-card-study {
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  line-height: 1.4;
}
.proto-ac-card-meta {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.pill-sm {
  font-size: 9.5px; padding: 1px 7px; border-radius: 9999px;
}
.proto-ac-clear {
  position: absolute; top: 10px; right: 10px;
  background: none; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 10px;
  font-size: 11px; font-weight: 700; font-family: 'Manrope', sans-serif;
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: var(--transition);
}
.proto-ac-clear svg { width: 12px; height: 12px; }
.proto-ac-clear:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--bg-hover);
}

/* ============ PROTOCOL AUTOCOMPLETE — ADDITIONS ============ */

/* Loading state */
.proto-ac-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 14px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

/* Error state */
.proto-ac-error {
  color: var(--danger) !important;
}
.proto-ac-error svg {
  color: var(--danger);
  opacity: .7;
}

/* Empty state — structured layout */
.proto-ac-empty-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.proto-ac-empty-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}
.proto-ac-empty-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Result count footer */
.proto-ac-footer {
  padding: 6px 14px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-hover);
  text-align: center;
}

/* Read-only fields (auto-filled from selected protocol) */
.field-readonly input,
.field-readonly select,
.field-readonly textarea {
  background: var(--bg-hover); color: var(--text-muted);
  pointer-events: none; opacity: .7;
  border-color: var(--border);
}
.field-readonly label::after {
  content: ' (auto-filled)';
  font-size: 10px; font-weight: 400; color: var(--text-muted);
  font-style: italic;
}


/* ============ FIELD VALIDATION ============ */
.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--danger) !important;
}
.field-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  line-height: 1.3;
  animation: fieldErrorEnter .2s ease;
}
@keyframes fieldErrorEnter {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}



/* ============ SUBMISSION PROGRESS PANEL ============ */
.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding: 4px 0;
}

/* Vertical connector line — sits behind icons */
.progress-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 0 0 24px 0;
  position: relative;
  margin-left: 10px;
}
.progress-step:last-child { padding-bottom: 0; }

/* The connecting line between steps */
.progress-step::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 22px;
  bottom: 0;
  width: 2px;
  background: var(--border);
  transition: background .3s;
}
.progress-step:last-child::before { display: none; }
.progress-complete::before { background: var(--success); }
.progress-active::before { background: var(--border); }
.progress-error::before { background: var(--danger); }

/* Icon circle — sits on top of the line */
.progress-step-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-card);
  position: relative;
  z-index: 1;
}
.progress-step-icon svg {
  width: 18px;
  height: 18px;
}

/* Label */
.progress-step-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 20px;
  padding-top: 0;
}

/* ── State: Pending ── */
.progress-pending .progress-step-icon {
  color: var(--text-muted);
  opacity: .5;
  font-size: 11px;
}
.progress-pending .progress-step-label {
  color: var(--text-muted);
  opacity: .5;
}

/* ── State: Active (parsing) ── */
.progress-active .progress-step-icon .spinner-ring {
  width: 16px;
  height: 16px;
  border-width: 2px;
  border-color: var(--border);
  border-top-color: var(--primary);
}
.progress-active .progress-step-label {
  color: var(--primary);
  font-weight: 700;
}

/* ── State: Complete ── */
.progress-complete .progress-step-icon {
  color: var(--success);
}
.progress-complete .progress-step-label {
  color: var(--text-primary);
}

/* ── State: Error ── */
.progress-error .progress-step-icon {
  color: var(--danger);
}
.progress-error .progress-step-label {
  color: var(--danger);
}

/* ============ PROGRESS INFO BOXES ============ */
.progress-estimate {
  margin: 20px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}
.progress-estimate b {
  font-weight: 700;
  color: var(--text-secondary);
}

.progress-notice {
  margin: 14px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  background: rgba(99, 102, 241, .05);
  border: 1px solid rgba(99, 102, 241, .12);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.progress-notice svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--primary);
  opacity: .6;
}
.progress-notice b {
  font-weight: 700;
  color: var(--text-primary);
}

/* Fade out animation for removing notice */
.progress-notice.fade-out {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .3s, transform .3s;
}

/* ============ SUCCESS / ERROR CARDS ============ */
.progress-result {
  margin: 24px 0 0;
  padding: 24px;
  border-radius: var(--radius-md);
  text-align: center;
  animation: fadeSlide .35s ease;
}
.progress-result-success {
  background: rgba(16, 185, 129, .05);
  border: 1px solid rgba(16, 185, 129, .15);
}
.progress-result-error {
  background: rgba(239, 68, 68, .05);
  border: 1px solid rgba(239, 68, 68, .15);
}
.progress-result-warning {
  background: rgba(245, 158, 11, .05);
  border: 1px solid rgba(245, 158, 11, .18);
}
.progress-result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}
.progress-result-icon svg {
  width: 18px;
  height: 18px;
}
.progress-result-success .progress-result-icon {
  color: var(--success);
}
.progress-result-error .progress-result-icon {
  color: var(--danger);
}
.progress-result-warning .progress-result-icon {
  color: var(--warning, #f59e0b);
}
.progress-result-failed-list {
  list-style: none;
  margin: 12px auto 18px;
  padding: 12px 16px;
  max-width: 460px;
  text-align: left;
  background: rgba(245, 158, 11, .07);
  border: 1px solid rgba(245, 158, 11, .18);
  border-radius: var(--radius-sm, 8px);
  font-size: 12.5px;
  color: var(--text-muted);
}
.progress-result-failed-list li {
  padding: 4px 0;
}
.progress-result-failed-list li + li {
  border-top: 1px dashed rgba(245, 158, 11, .25);
}
.progress-result-failed-list b {
  color: var(--text);
  font-weight: 600;
}
.progress-result-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.progress-result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.progress-result-actions .btn svg {
  width: 14px;
  height: 14px;
}

/* ============ DOCUMENT PARSE STATUS (detail view) ============ */
.doc-row.doc-parsing {
  opacity: 1;
  cursor: default;
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
  background: color-mix(in srgb, var(--primary) 3%, var(--bg-card));
}
.doc-row.doc-parsing:hover {
  transform: none;
  box-shadow: none;
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
}
.doc-row.doc-error {
  opacity: 1;
  cursor: default;
  border-color: color-mix(in srgb, var(--danger) 20%, var(--border));
  background: color-mix(in srgb, var(--danger) 2%, var(--bg-card));
}
.doc-row.doc-error:hover {
  transform: none;
  box-shadow: none;
  border-color: color-mix(in srgb, var(--danger) 20%, var(--border));
}

/* Parse status banner in detail view doc tab */
.doc-parse-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 16px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, .05);
  border: 1px solid rgba(99, 102, 241, .12);
}
.doc-parse-banner svg {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex-shrink: 0;
  color: var(--primary);
  margin-top: 1px;
}
.doc-parse-banner-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.doc-parse-banner-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.doc-parse-banner-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-style: italic;
}

.doc-table-wrap { margin: 8px 0; overflow-x: auto; }
.doc-table-wrap table { width: 100%; border-collapse: collapse; font-size: 11px; line-height: 1.4; }
.doc-table-wrap th, .doc-table-wrap td { border: 1px solid #d1d5db; padding: 4px 8px; text-align: left; }
.doc-table-wrap th { background: #f3f4f6; font-weight: 700; font-size: 10px; }
.doc-table-wrap tr:nth-child(even) td { background: #f9fafb; }


/* ============ ADD USER MODAL — SITE PICKER ============ */
.um-modal-site-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin-top: 6px;
}
.um-modal-site-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  transition: background .12s;
}
.um-modal-site-row:hover {
  background: var(--bg-active);
}
.um-modal-site-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}
.um-modal-site-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.um-modal-site-row .um-role-select {
  width: 140px !important;
  min-width: 140px;
  flex-shrink: 0;
  font-size: 12px !important;
  padding: 4px 8px !important;
}
.um-no-sites-msg {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

/* ============ SCAN-TIER DASHBOARD ============ */

/* Stats grid auto-adjusts to 4 columns when scan-tier has 4 cards */
.stats-grid:has(.stat-card:nth-child(4):last-child) {
  grid-template-columns: repeat(4, 1fr);
}

/* Stats grid auto-adjusts to 2 columns when scan-tier has 2 cards */
.stats-grid:has(.stat-card:nth-child(2):last-child) {
  grid-template-columns: repeat(2, 1fr);
}

/* Quick-action hero card */
.scan-quick-action {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  margin-bottom: 22px; cursor: pointer;
  transition: var(--transition); position: relative; overflow: hidden;
}
.scan-quick-action::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent, var(--primary)));
  opacity: .6; transition: opacity .2s;
}
.scan-quick-action:hover {
  box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.scan-quick-action:hover::before { opacity: 1; }

.scan-qa-content { display: flex; align-items: center; gap: 16px; }
.scan-qa-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover); flex-shrink: 0;
}
.scan-qa-icon svg { width: 22px; height: 22px; color: var(--primary); }
.scan-qa-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 2px;
}
.scan-qa-desc {
  font-size: 12px; color: var(--text-muted); line-height: 1.4;
  max-width: 520px;
}

@media (max-width: 960px) {
  .scan-quick-action { flex-direction: column; gap: 14px; text-align: center; }
  .scan-qa-content { flex-direction: column; }
  .stats-grid:has(.stat-card:nth-child(4):last-child) {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============ TIER HINT (upsell nudge) ============ */

.tier-hint {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; padding: 12px 16px; margin-top: 16px;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); opacity: 0;
  transform: translateY(6px);
  transition: opacity .3s ease, transform .3s ease;
}
.tier-hint-show { opacity: 1; transform: translateY(0); }
.tier-hint-exit { opacity: 0; transform: translateY(-4px); transition: opacity .25s ease, transform .25s ease; }

.tier-hint-body { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }

.tier-hint-icon {
  flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px;
  color: var(--text-dim); opacity: .5;
}
.tier-hint-icon svg { width: 16px; height: 16px; }

.tier-hint-content {
  font-size: 12px; line-height: 1.5; color: var(--text-muted);
}
.tier-hint-ctx { color: var(--text-secondary); }
.tier-hint-text { color: var(--text-muted); }

.tier-hint-link {
  color: var(--primary); text-decoration: none; font-weight: 600;
  opacity: .7; transition: opacity .15s;
}
.tier-hint-link:hover { opacity: 1; text-decoration: underline; }

.tier-hint-dismiss {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 16px; line-height: 1;
  padding: 0 2px; opacity: .3; transition: opacity .15s;
}
.tier-hint-dismiss:hover { opacity: .7; }


/* ============ SUBSCRIPTION VIEW ============ */

.sub-view { padding: 0; }

.sub-header { margin-bottom: 24px; }
.sub-header h2 {
  font-size: 28px; font-weight: 800; color: var(--text-primary);
  letter-spacing: -.02em; margin: 0 0 6px;
  font-family: 'Outfit', sans-serif;
}
.sub-subheading { color: var(--text-muted); font-size: 15px; }

/* Cards */
.sub-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; margin-bottom: 24px;
  backdrop-filter: blur(10px);
}
.sub-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px;
}
.sub-card-title {
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .08em; margin: 0;
  font-family: 'Outfit', sans-serif;
}

/* Status badges */
.sub-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em;
}
.sub-status-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
}
.sub-status-active { background: rgba(16,185,129,.12); color: var(--success-light); }
.sub-status-active::before { background: var(--success-light); animation: sub-pulse 2s ease-in-out infinite; }
.sub-status-trialing { background: rgba(245,158,11,.12); color: var(--warning-light); }
.sub-status-trialing::before { background: var(--warning-light); }
.sub-status-past_due { background: rgba(239,68,68,.12); color: var(--danger-light); }
.sub-status-past_due::before { background: var(--danger-light); animation: sub-pulse 1s ease-in-out infinite; }
.sub-status-cancelling { background: rgba(245,158,11,.12); color: var(--warning-light); }
.sub-status-cancelling::before { background: var(--warning-light); }
.sub-status-cancelled { background: rgba(148,163,184,.12); color: var(--text-muted); }
.sub-status-cancelled::before { background: var(--text-muted); }
.sub-status-suspended { background: rgba(239,68,68,.12); color: var(--danger-light); }
.sub-status-suspended::before { background: var(--danger-light); }

@keyframes sub-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* Plan info */
.sub-plan-info { display: flex; align-items: baseline; gap: 14px; margin-bottom: 4px; }
.sub-plan-name {
  font-size: 26px; font-weight: 800; color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
}
.sub-plan-price { font-size: 17px; color: var(--primary); font-weight: 700; }
.sub-plan-price span { font-size: 13px; color: var(--text-dim); font-weight: 400; }

.sub-billing-info { color: var(--text-muted); font-size: 14px; margin-top: 10px; }
.sub-billing-info strong { color: var(--text-secondary); }

/* Quota bar */
.sub-quota-row { margin-top: 20px; }
.sub-quota-label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.sub-quota-label strong { color: var(--text-secondary); }
.sub-quota-bar {
  height: 8px; background: var(--bg-hover); border-radius: var(--radius-full);
  overflow: hidden;
}
.sub-quota-fill {
  height: 100%; background: var(--primary); border-radius: var(--radius-full);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.sub-quota-fill.warning { background: var(--warning); }
.sub-quota-fill.danger { background: var(--danger); }

/* Notices */
.sub-notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px; border-radius: var(--radius-md); margin-top: 16px;
  font-size: 13px; line-height: 1.5;
}
.sub-notice svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.sub-notice.warning {
  background: rgba(245,158,11,.08); color: var(--warning-light);
  border: 1px solid rgba(245,158,11,.15);
}
.sub-notice.danger {
  background: rgba(239,68,68,.08); color: var(--danger-light);
  border: 1px solid rgba(239,68,68,.15);
}
.sub-notice strong { color: inherit; }

/* Buttons */
.sub-btn-group { display: flex; gap: 12px; margin-top: 24px; }

.sub-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; font-size: 13px; font-weight: 600;
  border-radius: var(--radius-sm); border: none; cursor: pointer;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  font-family: 'Outfit', sans-serif;
}
.sub-btn:disabled { opacity: .5; cursor: not-allowed; }
.sub-btn svg { width: 16px; height: 16px; }

.sub-btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 0 20px var(--primary-glow);
}
.sub-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px); box-shadow: 0 4px 20px var(--primary-glow);
}

.sub-btn-secondary {
  background: var(--bg-hover); color: var(--text-muted);
  border: 1px solid var(--border);
}
.sub-btn-secondary:hover:not(:disabled) {
  background: var(--bg-active); color: var(--text-primary);
}

.sub-btn-danger {
  background: rgba(239,68,68,.08); color: var(--danger-light);
  border: 1px solid rgba(239,68,68,.18);
}
.sub-btn-danger:hover:not(:disabled) {
  background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.3);
}

.sub-btn-sm { padding: 7px 14px; font-size: 12px; }

/* Payment Method */
.sub-payment-method {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.sub-card-brand {
  width: 48px; height: 32px;
  background: linear-gradient(135deg, #1a1f36, #252d4a);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  text-transform: uppercase; letter-spacing: .05em;
}
.sub-card-details { flex: 1; }
.sub-card-number {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace; letter-spacing: .04em;
}
.sub-card-expiry { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Invoice Table */
.sub-invoice-table { width: 100%; border-collapse: collapse; }
.sub-invoice-table .sub-th {
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.sub-invoice-table .sub-td {
  padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 13px;
}
.sub-invoice-table tr:last-child .sub-td { border-bottom: none; }
.sub-td-date { color: var(--text-muted); }
.sub-td-desc { color: var(--text-primary); font-weight: 500; }
.sub-td-amount {
  color: var(--text-secondary); font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.sub-invoice-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.sub-invoice-succeeded { background: rgba(16,185,129,.1); color: var(--success-light); }
.sub-invoice-failed { background: rgba(239,68,68,.1); color: var(--danger-light); }

.sub-invoice-link {
  color: var(--primary); text-decoration: none; font-weight: 600;
  font-size: 12px; transition: color .15s;
}
.sub-invoice-link:hover { text-decoration: underline; }

.sub-invoice-loading {
  padding: 32px 0; text-align: center; color: var(--text-dim); font-size: 14px;
}

/* Pagination */
.sub-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sub-page-label { font-size: 13px; color: var(--text-muted); }

/* Empty state */
.sub-empty-state { padding: 24px 0; text-align: center; }
.sub-empty-state p { color: var(--text-dim); font-size: 14px; margin: 0; }

/* Error banner */
.sub-error-banner {
  padding: 16px 20px; border-radius: var(--radius-md);
  background: rgba(239,68,68,.08); color: var(--danger-light);
  border: 1px solid rgba(239,68,68,.15);
  font-size: 14px; line-height: 1.5; text-align: center;
}

/* ──── Scan History Card ──── */

.sh-cycle-label {
  font-size: 12px; color: var(--text-dim); font-weight: 500;
  padding: 4px 10px; background: var(--bg-hover); border-radius: var(--radius-full);
}

/* Summary stats row */
.sh-summary {
  display: flex; gap: 32px; margin-bottom: 16px;
}
.sh-stat {
  display: flex; flex-direction: column; gap: 2px;
}
.sh-stat-number {
  font-size: 28px; font-weight: 800; color: var(--text-primary);
  font-family: 'Outfit', sans-serif; line-height: 1;
}
.sh-stat-number.sh-warning { color: var(--warning); }
.sh-stat-number.sh-danger { color: var(--danger-light); }
.sh-stat-label {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
}

/* Quota bar */
.sh-bar {
  height: 6px; background: var(--bg-hover); border-radius: var(--radius-full);
  overflow: hidden; margin-bottom: 24px;
}
.sh-bar-fill {
  height: 100%; background: var(--primary); border-radius: var(--radius-full);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.sh-bar-fill.warning { background: var(--warning); }
.sh-bar-fill.danger { background: var(--danger); }

/* Loading */
.sh-loading {
  padding: 32px 0; text-align: center; color: var(--text-dim); font-size: 14px;
}

/* Empty state */
.sh-empty { text-align: center; padding: 40px 20px; }
.sh-empty-icon {
  width: 48px; height: 48px; margin: 0 auto 16px;
  color: var(--text-dim); opacity: .4;
}
.sh-empty-icon svg { width: 100%; height: 100%; }
.sh-empty-title {
  font-size: 15px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 6px;
}
.sh-empty-desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; }

/* Table */
.sh-table { width: 100%; border-collapse: collapse; }
.sh-th {
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border);
}
.sh-td {
  padding: 14px 12px 14px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.sh-row:last-child .sh-td { border-bottom: none; }
.sh-row { transition: background .15s; }
.sh-row:hover { background: var(--bg-hover); }

/* Date cell */
.sh-td-date { white-space: nowrap; }
.sh-ts-date { display: block; color: var(--text-secondary); font-weight: 500; font-size: 13px; }
.sh-ts-time { display: block; color: var(--text-dim); font-size: 11px; margin-top: 2px; }

/* Submission cell */
.sh-sub-link { cursor: pointer; transition: opacity .15s; }
.sh-sub-link:hover { opacity: .8; }
.sh-sub-code {
  display: block; color: var(--primary); font-weight: 600; font-size: 13px;
  font-family: 'JetBrains Mono', monospace; letter-spacing: .01em;
}
.sh-sub-study {
  display: block; color: var(--text-dim); font-size: 11px; margin-top: 2px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Findings badges */
.sh-td-findings { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.sh-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.sh-badge-fail { background: rgba(239,68,68,.12); color: #f87171; }
.sh-badge-warn { background: rgba(245,158,11,.12); color: #fbbf24; }
.sh-badge-pass { background: rgba(16,185,129,.12); color: #34d399; }
.sh-badge-none { color: var(--text-dim); background: none; }

/* Duration */
.sh-td-duration {
  color: var(--text-muted); font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* Status badges */
.sh-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.sh-status-completed { background: rgba(16,185,129,.1); color: var(--success-light); }
.sh-status-running { background: rgba(99,102,241,.12); color: #818cf8; }
.sh-status-failed { background: rgba(239,68,68,.1); color: var(--danger-light); }
.sh-status-pending { background: rgba(148,163,184,.1); color: var(--text-dim); }

/* Pagination */
.sh-pagination {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
.sh-page-info { font-size: 12px; color: var(--text-dim); }
.sh-page-controls { display: flex; align-items: center; gap: 12px; }
.sh-page-label { font-size: 13px; color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
  .sh-summary { gap: 20px; }
  .sh-stat-number { font-size: 22px; }
  .sh-th-hide-sm, .sh-td-hide-sm { display: none; }
  .sh-sub-study { max-width: 140px; }
}

/* ──── Modals ──── */

/* Overlay that also works for subscription modals */
.sub-view .modal-overlay,
.sub-confirm-modal ~ .modal-overlay {
  /* inherits from global .modal-overlay */
}

.sub-confirm-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 32px;
  max-width: 440px; width: 90%;
  transform: scale(.95) translateY(20px);
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.show .sub-confirm-modal {
  transform: scale(1) translateY(0);
}

.sub-modal-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin: 0 auto 16px;
}
.sub-modal-icon.success { background: rgba(16,185,129,.1); }
.sub-modal-icon.warning { background: rgba(239,68,68,.1); }

.sub-confirm-modal h3 {
  margin: 0 0 10px; font-size: 19px; font-weight: 700;
  color: var(--text-primary); text-align: center;
  font-family: 'Outfit', sans-serif;
}
.sub-confirm-modal p {
  margin: 0 0 24px; color: var(--text-muted); text-align: center;
  font-size: 14px; line-height: 1.6;
}
.sub-confirm-modal strong { color: var(--text-secondary); }

.sub-modal-buttons { display: flex; gap: 12px; }
.sub-modal-buttons .sub-btn { flex: 1; }

.sub-modal-close {
  position: absolute; top: 20px; right: 20px;
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 8px; border-radius: var(--radius-sm);
  transition: all .15s;
}
.sub-modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ──── Change Plan Modal ──── */
.sub-plan-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); max-width: 900px; width: 95%;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column;
  transform: scale(.95) translateY(20px);
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.show .sub-plan-modal {
  transform: scale(1) translateY(0);
}

.sub-plan-modal-header {
  padding: 20px 28px 14px; border-bottom: 1px solid var(--border);
  position: relative;
}
.sub-plan-modal-header h3 {
  margin: 0 0 4px; font-size: 19px; font-weight: 700;
  color: var(--text-primary); text-align: left;
  font-family: 'Outfit', sans-serif;
}
.sub-plan-modal-header p {
  margin: 0; color: var(--text-muted); font-size: 13px; text-align: left;
}

.sub-plan-options {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; padding: 20px 24px;
}

.sub-plan-option {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  position: relative; transition: all .2s;
  display: flex; flex-direction: column;
}
.sub-plan-option:hover { border-color: var(--border-light); background: var(--bg-hover); }
.sub-plan-option.current {
  border-color: var(--primary); background: var(--primary-glow);
}
.sub-plan-option.featured {
  border-color: var(--primary); box-shadow: 0 0 30px var(--primary-glow);
}

.sub-current-badge, .sub-featured-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  padding: 3px 12px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; white-space: nowrap;
}
.sub-current-badge { background: var(--primary); color: #fff; }
.sub-featured-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
}

.sub-plan-option-header { margin-bottom: 14px; padding-top: 6px; }
.sub-plan-option-name {
  display: block; font-size: 15px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 4px;
  font-family: 'Outfit', sans-serif;
}
.sub-plan-option-price {
  font-size: 26px; font-weight: 800; color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
}
.sub-plan-option-price span {
  font-size: 12px; font-weight: 400; color: var(--text-dim);
}

.sub-plan-features {
  list-style: none; padding: 0; margin: 0 0 18px; flex: 1;
}
.sub-plan-features li {
  padding: 4px 0; font-size: 12px; color: var(--text-muted);
  display: flex; align-items: flex-start; gap: 8px; line-height: 1.3;
}
.sub-plan-features li::before {
  content: '\2713'; color: var(--primary); font-weight: 700;
  font-size: 11px; margin-top: 1px;
}

.sub-plan-select-btn { width: 100%; margin-top: auto; }

.sub-plan-modal-footer {
  padding: 12px 28px; border-top: 1px solid var(--border); text-align: center;
}
.sub-plan-modal-footer p {
  margin: 0; font-size: 13px; color: var(--text-dim);
}
.sub-plan-modal-footer a {
  color: var(--primary); text-decoration: none;
}
.sub-plan-modal-footer a:hover { text-decoration: underline; }

/* ──── Payment Modal ──── */
.sub-payment-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); max-width: 480px; width: 95%;
  max-height: 90vh; display: flex; flex-direction: column;
  transform: scale(.95) translateY(20px);
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.show .sub-payment-modal {
  transform: scale(1) translateY(0);
}

.sub-payment-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}

.sub-card-error {
  color: var(--danger-light); font-size: 13px; margin-top: 12px;
  min-height: 18px;
}

/* ──── Invoice Detail Modal ──── */
.sub-invoice-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); max-width: 600px; width: 95%;
  max-height: 90vh; overflow-y: auto; position: relative;
  transform: scale(.95) translateY(20px);
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.show .sub-invoice-modal {
  transform: scale(1) translateY(0);
}

.sub-invoice-close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,.9); border: 1px solid #e2e8f0;
  color: #64748b; z-index: 10;
}

.sub-invoice-document {
  background: #fff; color: #1a1a1a; padding: 36px;
}

.sub-inv-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 28px; padding-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
}
.sub-inv-title-block { text-align: right; }
.sub-inv-title {
  font-size: 24px; font-weight: 800; color: #14b8a6;
  letter-spacing: .05em;
}
.sub-inv-number {
  font-size: 12px; color: #64748b; margin-top: 3px;
  font-family: 'JetBrains Mono', monospace;
}

.sub-inv-info-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 18px; margin-bottom: 28px;
}
.sub-inv-info-label {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px;
}
.sub-inv-info-value { font-size: 13px; color: #334155; line-height: 1.5; }
.sub-inv-info-value strong { color: #0f172a; }

.sub-inv-paid-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
  background: rgba(16,185,129,.1); color: #16a34a;
}
.sub-inv-paid-badge::before { content: '\2713'; font-size: 10px; }
.sub-inv-failed-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
  background: rgba(239,68,68,.1); color: #dc2626;
}
.sub-inv-failed-badge::before { content: '\2715'; font-size: 10px; }

.sub-inv-items-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.sub-inv-items-table .sub-th {
  text-align: left; font-size: 10px; font-weight: 700;
  color: #64748b; text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 0; border-bottom: 2px solid #e2e8f0;
}
.sub-inv-items-table td {
  padding: 14px 0; font-size: 13px; color: #334155;
  border-bottom: 1px solid #f1f5f9;
}
.text-right { text-align: right; }

.sub-inv-totals { margin-left: auto; width: 200px; margin-bottom: 28px; }
.sub-inv-total-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 13px; color: #64748b;
}
.sub-inv-total-row.total {
  border-top: 2px solid #e2e8f0; margin-top: 6px; padding-top: 12px;
  font-size: 16px; font-weight: 700; color: #0f172a;
}

.sub-inv-pm-info {
  background: #f8fafc; border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 20px;
}
.sub-inv-pm-label {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px;
}
.sub-inv-pm-value { font-size: 13px; color: #334155; }

.sub-inv-footer {
  text-align: center; padding-top: 20px; border-top: 1px solid #f1f5f9;
}
.sub-inv-footer p { margin: 0; font-size: 13px; color: #64748b; }
.sub-inv-contact { margin-top: 6px !important; font-size: 11px !important; color: #94a3b8 !important; }

.sub-inv-actions {
  display: flex; gap: 12px; padding: 16px 20px;
  background: var(--bg-card); border-top: 1px solid var(--border);
}
.sub-inv-actions .sub-btn { flex: 1; }

/* ──── Responsive ──── */
@media (max-width: 768px) {
  .sub-plan-options { grid-template-columns: 1fr; }
  .sub-plan-info { flex-direction: column; gap: 4px; }
  .sub-payment-method { flex-direction: column; text-align: center; }
  .sub-btn-group { flex-direction: column; }
  .sub-inv-info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sub-card { padding: 20px; }
  .sub-card-header { flex-direction: column; gap: 10px; }
  .sub-invoice-table .sub-th:nth-child(2),
  .sub-invoice-table .sub-td:nth-child(2) { display: none; }
}

/* ============ TAB BAR ============ */

.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--bg-active);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.tab-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-item.active {
  color: var(--text-primary);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.tab-icon {
  display: inline-flex;
  align-items: center;
  width: 16px;
  height: 16px;
}
.tab-icon svg {
  width: 16px;
  height: 16px;
}

.tab-content {
  min-height: 200px;
}

/* ============ STATUS PILL (inline badges) ============ */

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.status-approved {
  background: rgba(16, 185, 129, .12);
  color: var(--success);
}

.status-revision {
  background: rgba(239, 68, 68, .12);
  color: var(--danger);
}

/* ============ ACCOUNT MENU ============ */

.account-menu { position: relative; display: inline-flex; }

.account-btn {
  display: flex; padding: 10px 14px; gap: 10px;
  align-items: center; cursor: pointer;
  border-radius: var(--radius-sm); transition: var(--transition);
}
.account-btn:hover { background: var(--bg-hover); }

.account-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: var(--shadow-sm); flex: 0 0 auto;
}

.account-label { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.account-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.account-plan { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.account-caret { margin-left: 2px; color: var(--text-muted); font-size: 12px; }

.account-popover {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: 260px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 10px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: var(--transition); z-index: 200;
}
.account-menu.open .account-popover {
  opacity: 1; visibility: visible; transform: translateY(0);
}

.account-popover-header { padding: 10px 10px 8px 10px; }
.account-popover-title { font-size: 13px; font-weight: 800; color: var(--text-primary); }
.account-popover-sub { margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }

.account-popover-group {
  padding: 6px; background: var(--bg-hover);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}

.account-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px; border: none; background: transparent;
  cursor: pointer; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 700;
  transition: var(--transition); text-align: left;
}
.account-item:hover { background: var(--bg-active); color: var(--text-primary); }
.account-item:active { transform: translateY(1px); }

.account-item-icon { width: 18px; display: inline-flex; justify-content: center; }

.account-item.danger { color: var(--danger); }
.account-item.danger:hover { background: rgba(239, 68, 68, 0.12); }

.account-popover-divider { height: 1px; background: var(--border); margin: 10px 6px; }

.account-btn:focus-visible,
.account-item:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
  border-radius: var(--radius-md);
}

.account-btn.account-past-due {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  animation: pastDuePulse 2s ease-in-out infinite;
}
.account-btn.account-past-due:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.5);
}
.account-avatar.past-due { background: linear-gradient(135deg, #ef4444, #dc2626); font-size: 16px; font-weight: 900; }
.account-plan.past-due { color: #ef4444; font-weight: 700; }

@keyframes pastDuePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2); }
  50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1); }
}

.account-popover-past-due-banner {
  background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px; padding: 12px 14px; margin: 0 12px 12px;
  font-size: 12px; line-height: 1.4; color: #dc2626;
}

.account-item.highlight { background: rgba(239, 68, 68, 0.08); color: #dc2626; font-weight: 700; }
.account-item.highlight:hover { background: rgba(239, 68, 68, 0.15); }
.account-item.highlight .account-item-icon { animation: shake 0.5s ease-in-out infinite; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* ============ EXPORT ACTIONS (Doc Review) ============ */

.scan-export-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.btn-export-annotated {
  flex: 1.6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: -0.1px;
}
.btn-export-annotated:hover {
  box-shadow: var(--shadow-md), 0 0 20px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-export-annotated:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn-export-annotated svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-export-report {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-export-report:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-hover);
}
.btn-export-report:active {
  background: var(--bg-active);
}
.btn-export-report svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* =====================================================
   FINDINGS SUMMARY PANEL (detail page + doc review)
   ===================================================== */

/* Two-column layout: docs left, findings right */
.doc-findings-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.doc-findings-col-docs { flex: 1; min-width: 0; container-type: inline-size; }
.doc-findings-col-findings { flex: 2; min-width: 0; }

@media (max-width: 900px) {
  .doc-findings-layout { flex-direction: column; }
  .doc-findings-col-findings { flex: none; width: 100%; }
}

/* Mobile sub-tabs ("AI Findings" / "Documents") inside the docs panel.
   Hidden on desktop — both columns render side-by-side as before. */
.doc-mobile-tabs { display: none; }

@media (max-width: 960px) {
  /* Show the tab switcher only when there's actually a findings panel
     to switch to (toggled by Dart via the .has-findings class). */
  .doc-findings-section.has-findings .doc-mobile-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 12px;
  }
  .doc-mobile-tab {
    flex: 1;
    text-align: center;
    padding: 9px 12px;
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
  }
  .doc-mobile-tab.active {
    background: var(--bg-active);
    color: var(--primary);
  }

  /* When findings panel exists, hide whichever column the active tab
     isn't pointing at. When findings doesn't exist (no .has-findings),
     the docs col always shows and findings stays hidden via inline style. */
  .doc-findings-section.has-findings.mobile-active-findings .doc-findings-col-docs { display: none; }
  .doc-findings-section.has-findings.mobile-active-docs .doc-findings-col-findings { display: none; }

  /* align-items: stretch (default) overrides desktop's flex-start so the
     docs col fills the row width. Without this, word-break inside doc-row
     lets the col shrink to a single character wide. */
  .doc-findings-layout { flex-direction: column; gap: 14px; align-items: stretch; }
  .doc-findings-col-docs { container-type: normal; width: 100%; }

  /* Override the @container query that turns doc-row into a 40px-icon
     grid layout when narrow. On mobile we want a clean stacked card. */
  .doc-findings-col-docs .doc-row {
    display: flex;
    grid-template-columns: none;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    gap: 8px 10px;
  }
  .doc-findings-col-docs .doc-icon { display: none; }
  .doc-findings-col-docs .doc-info { flex: 1 1 100%; min-width: 0; }
  .doc-findings-col-docs .doc-name {
    font-size: 13px;
    word-break: break-word;
  }
  .doc-findings-col-docs .doc-row-meta {
    flex-basis: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px 10px;
    margin-top: 2px;
  }
  .doc-findings-col-docs .doc-row-meta .btn {
    padding: 5px 10px; font-size: 11.5px;
    white-space: nowrap;
  }
  .doc-findings-col-docs .doc-size,
  .doc-findings-col-docs .doc-review-status { font-size: 10.5px; }

  /* ============ DOC REVIEW VIEW ============ */

  /* Hide the PDF pane on mobile — at phone width it's unreadable. The
     findings checklist gets the full width since triaging findings is
     the entire reason a user opens this page on a phone. */
  .split-pane {
    height: auto;
    min-height: calc(100vh - 180px);
    flex-direction: column;
  }
  .pdf-pane { display: none; }
  .split-pane .split-resizer { display: none; }

  /* Stack form fields vertically on mobile so placeholders don't get
     truncated by the cramped 2-column grid. */
  .form-row { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
  .checklist-pane {
    flex: 1 1 auto;
    width: 100% !important;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  /* Doc info bar — stack file name above the Type/PI/Site row */
  .doc-info-bar {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 2px 12px;
    font-size: 11.5px;
  }
  .doc-info-bar .doc-id {
    flex: 1 1 100%;
    font-size: 13px;
    word-break: break-word;
  }
  .doc-info-bar .doc-meta { font-size: 11px; }
  .doc-info-bar .doc-actions {
    flex: 1 1 100%;
    margin-left: 0;
    margin-top: 6px;
    flex-wrap: wrap;
  }

  /* Checklist header — tighter padding, smaller title */
  .checklist-header { padding: 12px 14px; }
  .checklist-header h3 { font-size: 13px; line-height: 1.4; }

  /* Meta row: run selector full width on its own line; filter chips
     scroll horizontally so all stat pills stay reachable. */
  .scan-meta-row {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 8px 14px;
  }
  .scan-meta-row .scan-run-row {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
  }
  .scan-meta-row .scan-provenance { flex: 1 1 100%; }
  .scan-meta-row .scan-run-select { width: 100%; }

  .checklist-stats {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: 0;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .checklist-stats::-webkit-scrollbar { display: none; }
  .cl-stat { flex-shrink: 0; }

  /* Findings list (the body) gets the rest of the screen */
  .checklist-body {
    flex: 1 1 auto;
    overflow-y: auto;
  }

  /* ============ USER MANAGEMENT ============ */

  /* The user list and the user-edit panel share the screen via a flex
     side-by-side layout on desktop. On mobile that overlaps badly — we
     stack and turn the detail panel into a full-screen takeover. */
  .um-layout {
    flex-direction: column;
    min-height: 0;
  }
  .um-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .um-detail-container.open {
    width: 100%;
    min-width: 0;
    border-left: none;
  }
  /* When a user row is open, hide the page header / search / list so
     the edit panel gets the entire screen. The .um-detail-close button
     inside the panel returns the user to the list. */
  .view:has(.um-detail-container.open) .view-header,
  .view:has(.um-detail-container.open) .um-search-bar { display: none; }
  .um-layout:has(.um-detail-container.open) .um-table-wrap { display: none; }

  /* Search bar stacks vertically so the input gets full width and the
     Active/Deactivated/All filter row doesn't squeeze it. */
  .um-search-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  /* ============ SETTINGS ============ */

  /* Settings has a left side-nav next to the panel area on desktop. On
     mobile we stack and turn the nav into horizontal tabs that scroll
     if needed. */
  .settings-layout {
    flex-direction: column;
    gap: 12px;
    min-height: 0;
  }
  .settings-nav {
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: static;
    top: auto;
    align-self: stretch;
    padding: 4px;
    gap: 4px;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav-item {
    flex: 1 1 auto;
    justify-content: center;
    white-space: nowrap;
    padding: 9px 14px;
  }

  .settings-panel-area { width: 100%; min-width: 0; }

  /* Profile card — name was getting squeezed against the avatar */
  .settings-profile-card { padding: 12px 14px; gap: 12px; }
  .settings-avatar { width: 44px; height: 44px; font-size: 16px; }
  .settings-profile-info { min-width: 0; flex: 1; }
  .settings-profile-name,
  .settings-profile-role,
  .settings-profile-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Stack two-up form rows */
  .settings-form-row { flex-direction: column; gap: 14px; }

  /* AI Rules: site banner + buttons + rule cards all need to fit */
  .airules-add-row { flex-wrap: wrap; gap: 8px; }
  .airules-add-row .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .airules-stats { flex-wrap: wrap; }
  .airules-stat { flex: 1 1 calc(50% - 6px); }

  /* Rule cards — chips and SYS/REQ pills were clipping on the right */
  .rule-card { padding: 12px 14px; }
  .rule-top { flex-direction: column; align-items: stretch; gap: 6px; }
  .rule-chips { justify-content: flex-start; }
}

/* Compact doc rows when the doc column is narrow (findings panel visible) */
@container (max-width: 500px) {
  .doc-row {
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    padding: 12px 14px;
  }
  .doc-icon {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: center;
  }
  .doc-info {
    grid-column: 2;
    grid-row: 1;
  }
  .doc-row-meta {
    grid-column: 2;
    grid-row: 2;
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  .doc-open-arrow { display: none; }
}

/* Findings summary panel card */
.findings-summary-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.findings-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.findings-summary-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.findings-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-findings-action {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s ease;
}
.btn-findings-action:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-findings-action:active {
  transform: translateY(0);
  box-shadow: none;
}
.btn-findings-action svg { width: 13px; height: 13px; }

/* Labeled export button */
.btn-findings-export {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--bg-input);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn-findings-export svg { width: 12px; height: 12px; }
.btn-findings-export:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 3px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-findings-export:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Stats row */
.findings-summary-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.findings-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
  padding: 5px 10px;
  background: var(--bg-active);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.findings-stat:hover { background: var(--bg-hover); }
.findings-stat.active { outline: 2px solid currentColor; outline-offset: -2px; }
.findings-stat-fail.active { outline-color: var(--danger); }
.findings-stat-warn.active { outline-color: var(--warning); }
.findings-stat-na.active { outline-color: #6b7280; }
.findings-stat-pass.active { outline-color: var(--success); }
.findings-stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}
.findings-stat-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}
.findings-stat-fail .findings-stat-num { color: var(--danger); }
.findings-stat-warn .findings-stat-num { color: var(--warning); }
.findings-stat-na .findings-stat-num { color: #6b7280; }
.findings-stat-pass .findings-stat-num { color: var(--success); }
.findings-stat-pend .findings-stat-num { color: var(--text-muted); }

/* Findings list */
.findings-summary-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.findings-summary-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.findings-summary-item:hover {
  background: var(--bg-hover);
}
.findings-item-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 2px;
}
.findings-item-icon svg { width: 14px; height: 14px; }
.findings-item-fail .findings-item-icon { color: var(--danger); }
.findings-item-warn .findings-item-icon { color: var(--warning); }
.findings-item-not_applicable .findings-item-icon { color: #999; }
.findings-item-pass .findings-item-icon { color: var(--success); }

.findings-item-content { flex: 1; min-width: 0; }
.findings-item-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.findings-item-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.findings-item-docs {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Passing rules toggle */
.findings-pass-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}
.findings-pass-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0;
}
.findings-pass-toggle:hover { color: var(--text-secondary); }
.findings-pass-chevron {
  font-size: 9px;
  transition: transform .15s ease;
}
.findings-pass-list { margin-top: 4px; }

/* Status banner for partial/failed runs */
.findings-status-banner {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.findings-status-partial {
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}
.findings-status-failed {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.findings-status-title {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 2px;
}
.findings-status-partial .findings-status-title { color: var(--warning); }
.findings-status-failed .findings-status-title { color: var(--danger); }
.findings-status-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Grouped sections inside findings panel */
.findings-summary-panel .cl-section { margin-top: 6px; }
.findings-summary-panel .cl-section-head { padding: 6px 8px; font-size: 11.5px; }
.findings-summary-panel .cl-section-body { padding: 0 4px 4px 4px; }
.findings-summary-panel .scan-run-row { margin-bottom: 10px; }
.findings-summary-panel .scan-provenance { margin-bottom: 10px; font-size: 11px; }

/* Doc links inside findings items */
.findings-item-docs .cl-cross-doc-link {
  display: inline-block;
  margin-right: 8px;
}

/* =====================================================
   FINDINGS OVERLAY (full-screen maximize)
   ===================================================== */

.findings-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
.findings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.findings-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.findings-overlay-card {
  position: relative;
  width: 96vw;
  max-width: 1280px;
  max-height: 92vh;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .25), 0 0 0 1px var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(.98);
  transition: transform .25s cubic-bezier(.16,1,.3,1);
}
.findings-overlay.open .findings-overlay-card {
  transform: translateY(0) scale(1);
}

/* Header */
.findings-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}
.findings-overlay-title-area h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.3px;
}
.findings-overlay-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.findings-overlay-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.findings-overlay-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.findings-overlay-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Provenance */
.findings-overlay-provenance {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.findings-overlay-provenance .prov-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Stats row */
.findings-overlay-stats {
  display: flex;
  gap: 10px;
  padding: 4px 24px 16px;
}
.findings-overlay-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 10px 18px;
  background: var(--bg-active);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.findings-overlay-stat:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.findings-overlay-stat.active {
  outline: 2px solid currentColor;
  outline-offset: -2px;
  transform: translateY(-1px);
}
.overlay-stat-pass.active { outline-color: var(--success); }
.overlay-stat-fail.active { outline-color: var(--danger); }
.overlay-stat-warn.active { outline-color: var(--warning); }
.overlay-stat-na.active { outline-color: #6b7280; }
.overlay-stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}
.overlay-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}
.overlay-stat-pass .overlay-stat-num { color: var(--success); }
.overlay-stat-fail .overlay-stat-num { color: var(--danger); }
.overlay-stat-warn .overlay-stat-num { color: var(--warning); }
.overlay-stat-na .overlay-stat-num { color: #6b7280; }

/* Scrollable body */
.findings-overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 24px;
  overscroll-behavior: contain;
}
.findings-overlay-body .cl-section { margin-top: 8px; }
.findings-overlay-body .cl-section-head { padding: 8px 10px; font-size: 12px; }
.findings-overlay-body .cl-section-body { padding: 0 6px 6px 6px; }
.findings-overlay-body .findings-summary-item { padding: 10px 12px; }
.findings-overlay-body .findings-item-name { font-size: 13px; }
.findings-overlay-body .cl-detail.scan-reasoning { font-size: 12px; }
.findings-overlay-body .cl-excerpt { font-size: 11.5px; }

/* Status banner inside overlay */
.findings-overlay-card .findings-status-banner { margin: 0 24px 8px; }

/* Document badges in overlay findings */
.findings-doc-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600; letter-spacing: .3px;
  padding: 2px 8px; border-radius: 10px;
  background: var(--bg-active); color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.findings-overlay-body .findings-item-docs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}

/* =====================================================
   DOC REVIEW: findings scope badge + other-docs section
   ===================================================== */

.findings-scope-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 16px 10px;
}
.findings-scope-badge .scope-other-link {
  color: var(--primary);
  cursor: pointer;
}
.findings-scope-badge .scope-other-link:hover {
  text-decoration: underline;
}

/* "Findings in other documents" collapsible section */
.findings-other-docs-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px solid var(--border-light);
}
.findings-other-docs-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 4px 0 8px;
}
.findings-other-docs-toggle:hover { color: var(--text-primary); }
.findings-other-chevron {
  font-size: 9px;
  transition: transform .15s ease;
}

/* Cross-document reference links on findings */
.cl-cross-doc-ref {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.cl-cross-doc-link {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: var(--transition);
}
.cl-cross-doc-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}


/* ==================== Document Analysis Summary ==================== */
.doc-analysis-section {
  margin: 10px 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.doc-analysis-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(135deg, rgba(99,102,241,.06), rgba(168,85,247,.06));
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.doc-analysis-header:hover {
  background: linear-gradient(135deg, rgba(99,102,241,.1), rgba(168,85,247,.1));
}
.doc-analysis-chevron {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform .15s ease;
}
.doc-analysis-icon {
  display: flex;
  align-items: center;
}
.doc-analysis-icon svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
}
.doc-analysis-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .2px;
}
.doc-analysis-body {
  padding: 6px 14px 14px;
}
.doc-analysis-sub {
  margin-top: 10px;
}
.doc-analysis-sub:first-child {
  margin-top: 4px;
}
.doc-analysis-sub-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}
.da-sub-warning { color: var(--warning); }
.da-sub-clinical { color: var(--primary); }
.da-sub-facts { color: var(--text-secondary); }
.da-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 5px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.55;
  transition: background .15s;
}
.da-card:last-child { margin-bottom: 0; }
.da-card-warning {
  background: rgba(245,158,11,.06);
  border: 1px solid rgba(245,158,11,.15);
  color: var(--text-primary);
}
.da-card-clinical {
  background: rgba(99,102,241,.04);
  border: 1px solid rgba(99,102,241,.12);
  color: var(--text-primary);
}
.da-card-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1.4;
}
.da-card-text {
  flex: 1;
}
/* Facts comparison table */
.da-facts-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.da-facts-row {
  display: flex;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.da-facts-row:last-child { border-bottom: none; }
.da-facts-row:hover { background: var(--bg-hover); }
.da-facts-label {
  flex: 0 0 120px;
  font-weight: 700;
  color: var(--text-secondary);
  padding-right: 10px;
}
.da-facts-value {
  flex: 1;
  color: var(--text-primary);
}
.da-consistent { color: var(--success); }
.da-inconsistent { color: var(--text-primary); }
/* Side-by-side comparison for facts with per-document values */
.da-facts-values {
  flex: 1;
  color: var(--text-secondary);
  line-height: 1.5;
}
.da-fact-chip {
  display: block;
  margin-bottom: 2px;
}
.da-fact-chip:last-child { margin-bottom: 0; }
.da-fact-doc-label {
  font-size: 12px;
  font-weight: 600;
}
.da-fact-doc-value {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-primary);
}
.da-facts-mismatch {
  background: rgba(245,158,11,.05);
  border-left: 3px solid var(--warning);
}
.da-facts-mismatch .da-facts-label { color: var(--warning); font-weight: 800; }
.da-facts-match { opacity: .55; }
.da-facts-match:hover { opacity: 1; }
.da-facts-match .da-facts-label { font-weight: 600; }
/* Status icon column */
.da-facts-status {
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.da-status-ok { color: var(--success); }
.da-status-warn { color: var(--warning); }
/* Mismatch summary row */
.da-facts-summary {
  display: flex;
  gap: 6px;
  padding: 5px 10px 5px 14px;
  background: rgba(245,158,11,.08);
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid var(--warning);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.da-facts-summary-icon {
  flex-shrink: 0;
  color: var(--warning);
  font-size: 12px;
}
.da-facts-summary-text { flex: 1; }
/* Truncated value expand toggle */
.da-expand-toggle {
  display: inline-block;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
}
.da-expand-toggle:hover { text-decoration: underline; }

/* =====================================================
   REDESIGNED COMPLIANCE REPORT — Status-Grouped Layout
   ===================================================== */

/* Insight callout cards — prominent at top */
.findings-insights {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 14px;
}
.findings-insight-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  line-height: 1.55;
}
.findings-insight-card-warning {
  background: rgba(245,158,11,.06);
  border: 1px solid rgba(245,158,11,.18);
  border-left: 4px solid var(--warning);
}
.findings-insight-card-clinical {
  background: rgba(99,102,241,.04);
  border: 1px solid rgba(99,102,241,.14);
  border-left: 4px solid var(--primary);
}
.findings-insight-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}
.findings-insight-title-warning { color: var(--warning); }
.findings-insight-title-clinical { color: var(--primary); }
.findings-insight-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.findings-insight-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.findings-insight-item-icon {
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1.5;
}
.findings-insight-item-text {
  flex: 1;
  font-size: 12.5px;
}

/* Key Facts section — standalone */
.findings-facts-section {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
.findings-facts-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(59,130,246,.05), rgba(99,102,241,.05));
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.findings-facts-header:hover {
  background: linear-gradient(135deg, rgba(59,130,246,.09), rgba(99,102,241,.09));
}
.findings-facts-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .2px;
}
.findings-facts-body {
  padding: 0;
}

/* Status group (Issues, Passing, N/A) */
.findings-status-group {
  margin-top: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
}
.findings-status-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-active);
  border-bottom: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.findings-status-group-header.open {
  border-bottom-color: var(--border-light);
}
.findings-status-group-header:hover {
  background: var(--bg-hover);
}
.findings-status-group-chevron {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform .2s ease;
}
.findings-status-group-header.open .findings-status-group-chevron {
  transform: rotate(90deg);
}
.findings-status-group-title {
  font-size: 12.5px;
  font-weight: 700;
  flex: 1;
}
.findings-status-group-fail .findings-status-group-title { color: var(--danger); }
.findings-status-group-warn .findings-status-group-title { color: var(--warning); }
.findings-status-group-pass .findings-status-group-title { color: var(--success); }
.findings-status-group-na   .findings-status-group-title { color: #6b7280; }
.findings-status-group-pend .findings-status-group-title { color: var(--text-muted); }
.findings-status-group-count {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.findings-status-group-body {
  padding: 0;
}

/* Expand / Collapse all toggle */
.findings-toggle-all {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle, rgba(0,0,0,.015));
}
.findings-toggle-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: all .15s;
}
.findings-toggle-btn:hover {
  background: var(--bg-hover);
  text-decoration: underline;
}

/* Collapsible rule card (fail/warn) */
.findings-rule-card {
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.findings-rule-card:last-child { border-bottom: none; }
.findings-rule-card:hover { background: var(--bg-hover); }
.findings-rule-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
}
.findings-rule-badge {
  flex-shrink: 0;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .3px;
  text-transform: uppercase;
  min-width: 46px;
  text-align: center;
}
.findings-rule-badge-fail {
  background: rgba(239,68,68,.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.25);
}
.findings-rule-badge-warn {
  background: rgba(245,158,11,.1);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,.25);
}
.findings-rule-card-title {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  min-width: 0;
}
.findings-rule-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.findings-rule-card-ref {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.findings-rule-card-chevron {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.findings-rule-card.open .findings-rule-card-chevron {
  transform: rotate(90deg);
}
.findings-rule-card-body {
  display: none;
  padding: 0 12px 12px 70px;
  animation: findingsSlideIn .2s ease;
}
.findings-rule-card.open .findings-rule-card-body {
  display: block;
}
.findings-rule-card-reasoning {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  padding: 10px 14px;
  background: var(--bg-active);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  margin-bottom: 8px;
}
.findings-rule-card-reasoning svg {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  margin-right: 4px;
  color: var(--primary);
}
.findings-rule-card-excerpt {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
  padding: 4px 0;
}
.findings-rule-card-docs {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}
.findings-rule-card-docs .cl-cross-doc-link {
  display: inline-block;
  margin-right: 10px;
}

/* Compact rule entry (pass / N/A) */
.findings-rule-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.findings-rule-compact:last-child { border-bottom: none; }
.findings-rule-compact:hover { background: var(--bg-hover); }
.findings-rule-compact-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.findings-rule-compact-dot-pass { background: var(--success); }
.findings-rule-compact-dot-na { background: #9ca3af; }
.findings-rule-compact-title {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.findings-rule-compact-ref {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}
.findings-rule-compact-reason {
  font-size: 10.5px;
  color: var(--text-muted);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

@keyframes findingsSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Print: expand everything */
@media print {
  .findings-rule-card-body { display: block !important; }
  .findings-status-group-body { display: block !important; }
  .findings-rule-card-chevron,
  .findings-status-group-chevron,
  .findings-toggle-all { display: none !important; }
  .findings-overlay-backdrop { display: none !important; }
  .findings-overlay-card {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
}

/* ── Document Legend (collapsible) ── */
.da-legend {
  margin-bottom: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.da-legend-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-subtle, rgba(0,0,0,.02));
  transition: background .15s;
}
.da-legend-header:hover {
  background: var(--bg-hover);
}
.da-legend-chevron {
  font-size: 8px;
  color: var(--text-muted);
  transition: transform .15s ease;
}
.da-legend-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .2px;
}
.da-legend-body {
  padding: 6px 10px 8px;
}
.da-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 11.5px;
  line-height: 1.4;
}
.da-doc-pill {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  color: #fff;
  padding: 1px 7px;
  border-radius: 3px;
  letter-spacing: .3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.da-legend-files {
  color: var(--text-secondary);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Inline document-type pills in text ── */
.da-inline-pill {
  font-weight: 700;
  border-bottom: 1.5px solid;
  padding-bottom: 0px;
}

/* ==================== Text Autocomplete ==================== */
.text-ac-dropdown {
  display: none;
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 200px; overflow-y: auto; margin-top: 2px;
}
.text-ac-item {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.text-ac-item:last-child { border-bottom: none; }
.text-ac-item:hover, .text-ac-item.active {
  background: var(--bg-hover);
}

/* ============ SCAN MODE SELECTION ============ */
.scan-mode-selection {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 32px 24px;
  max-width: 560px;
  margin: 24px auto;
  text-align: center;
}
.scan-mode-heading {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.scan-mode-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.scan-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 480px) {
  .scan-mode-grid { grid-template-columns: 1fr; }
}
.scan-mode-card {
  background: var(--bg-base);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.scan-mode-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.scan-mode-card-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
  color: var(--primary);
}
.scan-mode-card-icon svg {
  width: 32px;
  height: 32px;
}
.scan-mode-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.scan-mode-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.scan-mode-card-stale {
  font-size: 12px;
  color: var(--primary, #5b21b6);
  font-weight: 600;
  line-height: 1.4;
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(91,33,182,.08);
  border: 1px solid rgba(91,33,182,.18);
  border-radius: 6px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.scan-mode-card-stale svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  color: var(--primary, #5b21b6);
}
.scan-mode-stale {
  opacity: .55;
  cursor: default;
  pointer-events: none;
}
.scan-mode-cancel {
  text-align: center;
}
.scan-mode-cancel a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.scan-mode-cancel a:hover {
  color: var(--text-primary);
}

/* ============ SCAN MODE BADGES (results screen) ============ */
.scan-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  letter-spacing: .3px;
  text-transform: uppercase;
}
.scan-mode-badge svg {
  width: 12px;
  height: 12px;
}
.scan-mode-badge-quick {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
}
.scan-mode-badge-full {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}
.scan-quick-caption {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 6px 16px 8px;
  font-size: 11.5px;
  line-height: 1.4;
  color: #92400e;
  background: #fffbeb;
  border-bottom: 1px solid var(--border);
}
.scan-quick-caption svg {
  width: 13px; height: 13px; min-width: 13px;
  flex-shrink: 0;
  margin-top: 1px;
  opacity: .8;
}
.scan-quick-caption strong {
  font-weight: 700;
}

/* ============ DOCUMENT ANALYSIS UPSELL ============ */
.doc-analysis-upsell {
  padding: 10px 14px;
  margin-top: 8px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}
.doc-analysis-upsell a {
  font-size: 12px;
  color: var(--primary-dark);
  text-decoration: none;
  transition: color .15s;
}
.doc-analysis-upsell a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ============ TRIGGER QUICK REVIEW HINT ============ */
.trigger-quick-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
}