/* ==========================================================================
   MADI TBT AML Governance Dashboard & CMR Explorer — Modern Design System
   ========================================================================== */

:root {
  color-scheme: dark;
  /* Dark Theme (Default) */
  --bg-primary: #0b132b;
  --bg-secondary: #1c2541;
  --bg-card: rgba(28, 37, 65, 0.9);
  --bg-card-hover: rgba(36, 48, 84, 0.98);
  --bg-elevated: #243054;
  --bg-input: #121c38;
  --bg-subtle-box: rgba(0, 0, 0, 0.25);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(99, 102, 241, 0.4);
  --border-focus: #6366f1;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;       /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;          /* Cyan */
  --accent-emerald: #10b981;       /* Emerald Pass */
  --accent-amber: #f59e0b;         /* Amber Warn */
  --accent-rose: #ef4444;          /* Rose Fail */
  --accent-purple: #a855f7;        /* Purple AI */
  
  --banner-bg: linear-gradient(90deg, rgba(99, 102, 241, 0.3), rgba(6, 182, 212, 0.15));
  --banner-text: #ffffff;
  --banner-border: #6366f1;

  --hero-bg: linear-gradient(135deg, rgba(30, 41, 75, 0.95), rgba(15, 23, 42, 0.98));
  --hero-border: rgba(99, 102, 241, 0.35);

  --badge-pass-bg: rgba(16, 185, 129, 0.15);
  --badge-pass-text: #34d399;
  --badge-pass-border: rgba(16, 185, 129, 0.3);
  
  --badge-warn-bg: rgba(245, 158, 11, 0.15);
  --badge-warn-text: #fbbf24;
  --badge-warn-border: rgba(245, 158, 11, 0.3);
  
  --badge-fail-bg: rgba(239, 68, 68, 0.15);
  --badge-fail-text: #f87171;
  --badge-fail-border: rgba(239, 68, 68, 0.3);

  --badge-joint-bg: rgba(99, 102, 241, 0.15);
  --badge-joint-text: #818cf8;
  --badge-joint-border: rgba(99, 102, 241, 0.3);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  /* Light Theme — Executive Slate & Crisp Indigo */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-elevated: #f1f5f9;
  --bg-input: #ffffff;
  --bg-subtle-box: #ffffff;
  
  --border-color: #e2e8f0;
  --border-color-hover: rgba(99, 102, 241, 0.5);
  --border-focus: #4f46e5;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --banner-bg: linear-gradient(90deg, #e0e7ff, #e0f2fe);
  --banner-text: #1e1b4b;
  --banner-border: #818cf8;

  --hero-bg: linear-gradient(135deg, #eef2ff, #f0fdfa);
  --hero-border: #c7d2fe;
  
  --badge-pass-bg: #dcfce7;
  --badge-pass-text: #15803d;
  --badge-pass-border: #86efac;
  
  --badge-warn-bg: #fef3c7;
  --badge-warn-text: #b45309;
  --badge-warn-border: #fcd34d;
  
  --badge-fail-bg: #fee2e2;
  --badge-fail-text: #b91c1c;
  --badge-fail-border: #fca5a5;

  --badge-joint-bg: #e0e7ff;
  --badge-joint-text: #4338ca;
  --badge-joint-border: #a5b4fc;
}

/* Reset & Global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.6);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
  transition: width var(--transition-normal);
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-badge {
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}

.logo-text h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

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

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 12px 6px 12px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

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

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.1));
  color: #4f46e5;
  font-weight: 600;
  border-left: 3px solid var(--accent-primary);
}
[data-theme="dark"] .nav-item.active {
  color: #818cf8;
}

.nav-item-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rule-pill-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.pill-high { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.pill-med { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.pill-low { background: rgba(16, 185, 129, 0.15); color: #059669; }

[data-theme="dark"] .pill-high { color: #f87171; }
[data-theme="dark"] .pill-med { color: #fbbf24; }
[data-theme="dark"] .pill-low { color: #34d399; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent 400px);
}

/* Top App Header */
.top-header {
  height: 64px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}
.breadcrumb-active {
  color: var(--text-primary);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  position: relative;
  width: 280px;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.search-input:focus {
  border-color: var(--border-focus);
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
.btn-secondary {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--border-color);
}
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
}
.btn-icon:hover {
  color: var(--text-primary);
}

/* Content Container */
.content-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* KPI Metrics Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-color-hover);
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-primary);
}
.kpi-card.kpi-green::before { background: var(--accent-emerald); }
.kpi-card.kpi-amber::before { background: var(--accent-amber); }
.kpi-card.kpi-cyan::before { background: var(--accent-cyan); }

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.kpi-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-tag {
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}
.kpi-tag.positive { background: var(--badge-pass-bg); color: var(--badge-pass-text); }
.kpi-tag.neutral { background: var(--badge-joint-bg); color: var(--badge-joint-text); }

/* Visual Charts Row */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 1100px) {
  .charts-grid { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-container {
  position: relative;
  height: 260px;
  width: 100%;
}

/* Master Comparison Table Section */
.section-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-btn.active, .filter-btn:hover {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

/* Scroll Controls Toolbar */
.table-scroll-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.scroll-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.scroll-nav-btn:hover, .scroll-nav-btn.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

/* Table Wrappers & Responsive Scrolling */
.table-responsive, .sheet-grid-wrapper {
  width: 100%;
  max-height: 480px;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.5) var(--bg-elevated);
}

.table-responsive::-webkit-scrollbar, .sheet-grid-wrapper::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
.table-responsive::-webkit-scrollbar-track, .sheet-grid-wrapper::-webkit-scrollbar-track {
  background: var(--bg-input);
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb, .sheet-grid-wrapper::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.6);
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover, .sheet-grid-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ==========================================================================
   SMART TABLE SIZING — ROBUST & THEME AWARE
   ========================================================================== */
/* ==========================================================================
   SMART TABLE SIZING & COMPACT HIGH-DENSITY DATA DISPLAY
   ========================================================================== */
.data-table, .sheet-table {
  min-width: 100%;
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11.5px;
  text-align: left;
  table-layout: auto;
}

.data-table th, .sheet-table th {
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 7px 10px;
  border-bottom: 2px solid var(--accent-primary);
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

.data-table td, .sheet-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
  line-height: 1.35;
  font-size: 11.5px;
}

/* Smart Column Type Classes */
.cell-num {
  text-align: right !important;
  white-space: nowrap !important;
  font-variant-numeric: tabular-nums !important;
  font-weight: 600 !important;
  min-width: 60px;
  max-width: 120px;
}

.cell-id {
  white-space: nowrap !important;
  font-family: var(--font-mono) !important;
  font-weight: 700 !important;
  color: var(--accent-primary) !important;
  min-width: 75px;
  max-width: 160px;
}

.cell-badge {
  text-align: center !important;
  white-space: nowrap !important;
  min-width: 70px;
  max-width: 120px;
}

.cell-text {
  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.4 !important;
  min-width: 160px;
  max-width: 380px;
}

.cell-code {
  font-family: var(--font-mono) !important;
  font-size: 11px !important;
  white-space: nowrap !important;
  color: #38bdf8;
}

/* Master Comparison Table Columns */
.master-id-col {
  width: 90px;
  min-width: 85px;
  max-width: 105px;
  text-align: center;
  white-space: nowrap;
}

.master-date-col {
  width: 100px;
  min-width: 95px;
  text-align: center;
  white-space: nowrap;
  font-size: 11px;
}

.master-badge-col {
  width: 85px;
  min-width: 80px;
  text-align: center;
  white-space: nowrap;
}

.master-num-col {
  width: 80px;
  min-width: 70px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Responsive Natural Wrapping for Text Cells */
.data-table td.text-wrap-cell, 
.sheet-table td.text-wrap-cell,
.data-table td.commentary-cell,
.sheet-table td.commentary-cell,
.data-table td.note-cell,
.sheet-table td.note-cell {
  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.4 !important;
  min-width: 180px;
  max-width: 450px;
}

/* ==========================================================================
   UNIVERSAL FROZEN / STICKY HEADERS & LEFT COLUMNS
   ========================================================================== */
/* Freeze Top Headers */
.sheet-table thead th,
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 25;
  background-color: var(--bg-elevated) !important;
}

/* Freeze 1st Column (Rule ID / Parameter / Key) */
.sheet-table th:first-child,
.sheet-table td:first-child,
.data-table th:first-child,
.data-table td:first-child,
.master-sticky-table th:first-child,
.master-sticky-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 15;
  background-color: var(--bg-card) !important;
  border-right: 2px solid var(--accent-primary) !important;
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.25);
}

/* Top-Left Corner Intersection Cell (Stays above row AND column scrolls) */
.sheet-table thead th:first-child,
.data-table thead th:first-child,
.master-sticky-table thead th:first-child {
  z-index: 35 !important;
  background-color: var(--bg-elevated) !important;
}

/* Optional 2nd Frozen Column */
.freeze-col-2 th:nth-child(2),
.freeze-col-2 td:nth-child(2) {
  position: sticky;
  left: 110px;
  z-index: 14;
  background-color: var(--bg-card) !important;
  border-right: 2px solid var(--accent-primary) !important;
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.25);
}
.freeze-col-2 thead th:nth-child(2) {
  z-index: 34 !important;
  background-color: var(--bg-elevated) !important;
}

/* Row Hover on Frozen Cells */
.sheet-table tr:hover td:first-child,
.data-table tr:hover td:first-child,
.master-sticky-table tr:hover td:first-child {
  background-color: var(--bg-elevated) !important;
}

/* Table Maximize / Expand Viewport */
.sheet-grid-wrapper.maximized {
  max-height: 85vh !important;
  min-height: 600px !important;
}

/* ==========================================================================
   WINDOW-FITTING & HORIZONTALLY FROZEN NOTES & BANNERS
   ========================================================================== */
.table-note-banner-cell,
.table-section-banner-cell {
  padding: 8px 12px !important;
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

/* Frozen Banner Inner Content */
.sticky-banner-content {
  position: sticky;
  left: 14px;
  max-width: min(920px, calc(100vw - 360px));
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 11.5px;
  color: var(--accent-primary);
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

/* Frozen Warning/Callout Note Box */
.sticky-note-callout {
  position: sticky;
  left: 14px;
  max-width: min(940px, calc(100vw - 360px));
  width: fit-content;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  white-space: normal;
  word-break: break-word;
}

.sticky-note-callout .note-icon {
  color: #f59e0b;
  font-size: 14px;
  margin-top: 1px;
  flex-shrink: 0;
}

.sticky-note-callout .note-text {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-primary);
}

.sticky-note-callout .note-title {
  font-weight: 700;
  color: #f59e0b;
  margin-bottom: 2px;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

/* Prompt / AI Review Callout Note Box */
.sticky-prompt-callout {
  position: sticky;
  left: 14px;
  max-width: min(940px, calc(100vw - 360px));
  width: fit-content;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-left: 4px solid #a855f7;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  white-space: normal;
  word-break: break-word;
}

.sticky-prompt-callout .prompt-icon {
  color: #a855f7;
  font-size: 14px;
  margin-top: 1px;
  flex-shrink: 0;
}

.sticky-prompt-callout .prompt-text {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-primary);
}

/* ==========================================================================
   CATEGORY FILTER TOOLBAR COMPONENT
   ========================================================================== */
.category-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.category-filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.category-filter-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  max-width: 160px;
}

.category-filter-select:focus {
  border-color: var(--accent-primary);
}

.btn-clear-filter {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-clear-filter:hover {
  background: rgba(239, 68, 68, 0.25);
}

.filter-counter-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   EXECUTIVE NARRATIVE COLLAPSIBLE COMPONENTS
   ========================================================================== */
.narrative-collapse-wrapper {
  margin-top: 14px;
  margin-bottom: 14px;
  transition: all 0.25s ease;
}

.narrative-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.narrative-toggle-bar:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
}

.narrative-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-primary);
}

.narrative-toggle-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.executive-narrative-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 16px 20px;
  margin-top: -2px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.executive-narrative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.narrative-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
}

.narrative-box-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.narrative-box-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
}

.narrative-kpis-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.narrative-kpi-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Pipeline Clarification Banner */
.pipeline-clarification-banner {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-left: 4px solid #6366f1;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.pcb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-primary);
}

.pcb-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.pcb-step {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.pcb-step.active {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  font-weight: 600;
}

.pcb-step.joint {
  border-color: #10b981;
  color: #34d399;
  font-weight: 600;
}

.pcb-arrow {
  color: var(--text-muted);
  font-size: 10px;
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
  cursor: pointer;
}
.data-table tbody tr:hover {
  background-color: var(--bg-elevated);
}

/* Sheet Hero Header Card (Theme-Aware) */
.sheet-hero-header {
  background: var(--hero-bg);
  border: 1px solid var(--hero-border);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.hero-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-title-text {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.hero-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg-subtle-box);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-weight: 500;
}

/* Full Width Table Section Banners (Theme-Aware) */
.table-section-banner {
  background: var(--banner-bg) !important;
}
.table-section-banner td {
  padding: 10px 16px !important;
  font-weight: 800 !important;
  color: var(--banner-text) !important;
  font-size: 12px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  border-top: 1px solid var(--banner-border) !important;
  border-bottom: 1px solid var(--banner-border) !important;
  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.5 !important;
}

/* ==========================================================================
   NARRATIVE COMMENTARY CARDS (Theme-Aware)
   ========================================================================== */
.narrative-cards-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.narrative-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--bg-elevated);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.narrative-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.narrative-meta-pill strong {
  color: var(--text-primary);
}

.narrative-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.narrative-card:hover {
  border-color: var(--border-color-hover);
  transform: translateY(-2px);
}
.narrative-card.card-aml { border-left-color: #06b6d4; }
.narrative-card.card-gov { border-left-color: #6366f1; }
.narrative-card.card-ops { border-left-color: #10b981; }
.narrative-card.card-exec { border-left-color: #f59e0b; }
.narrative-card.card-mrm { border-left-color: #ef4444; }
.narrative-card.card-ai { border-left-color: #a855f7; }

.narrative-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}
.narrative-role-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.02em;
}

.narrative-body-text {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-primary);
  white-space: pre-line;
  word-break: break-word;
  background: var(--bg-subtle-box);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.badge-pass { background-color: var(--badge-pass-bg); color: var(--badge-pass-text); border: 1px solid var(--badge-pass-border); }
.badge-warn { background-color: var(--badge-warn-bg); color: var(--badge-warn-text); border: 1px solid var(--badge-warn-border); }
.badge-fail { background-color: var(--badge-fail-bg); color: var(--badge-fail-text); border: 1px solid var(--badge-fail-border); }
.badge-joint { background-color: var(--badge-joint-bg); color: var(--badge-joint-text); border: 1px solid var(--badge-joint-border); }
.badge-single { background-color: rgba(6, 182, 212, 0.15); color: #0284c7; border: 1px solid rgba(6, 182, 212, 0.3); }
[data-theme="dark"] .badge-single { color: #22d3ee; }

/* ==========================================================================
   VIEW 2: RULE CMR 18-TAB EXPLORER
   ========================================================================== */
.rule-view-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.rule-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.rule-title-group h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}
.rule-meta-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.rule-quick-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}
.quick-metric-box {
  background: var(--bg-elevated);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border-color);
}
.quick-metric-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}
.quick-metric-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

/* 18 Tabs Navigation System */
.cmr-tabs-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tabs-category-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tabs-category-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tabs-nav-bar {
  display: flex;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  gap: 8px;
  padding: 4px 2px 8px 2px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.5) var(--bg-secondary);
}

.tabs-nav-bar::-webkit-scrollbar {
  height: 6px;
}
.tabs-nav-bar::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}
.tabs-nav-bar::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.5);
  border-radius: 4px;
}
.tabs-nav-bar::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

.cmr-tab-btn {
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.cmr-tab-btn:hover {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-color-hover);
  transform: translateY(-1px);
}
.cmr-tab-btn.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  border-color: #6366f1;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
.cmr-tab-btn.posthoc-btn.active {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: #ffffff;
  border-color: #a855f7;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.4);
}

.tab-badge-num {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.25);
  padding: 1px 5px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

/* Tab Content Display Area */
.tab-content-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.tab-header-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}
.tab-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.tab-header-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Utility & Animations */
.fade-in {
  animation: fadeIn 0.25s ease-in-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   AD-HOC RULE TUNING & EXCEL UPLOAD WORKSPACE STYLING
   ========================================================================== */
.file-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 36px 24px;
  text-align: center;
  background-color: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.file-dropzone:hover, .file-dropzone.dragover {
  border-color: var(--accent-primary);
  background-color: var(--bg-elevated);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}
.dropzone-icon {
  font-size: 40px;
  color: #10b981;
}
.dropzone-text h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.dropzone-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.adhoc-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: all var(--transition-fast);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.form-control-sm {
  padding: 5px 8px;
  font-size: 12px;
}

.adhoc-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Light Theme Overrides for Form Controls */
[data-theme="light"] .form-control {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}
[data-theme="light"] .form-control:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
[data-theme="light"] .file-dropzone {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}
[data-theme="light"] .file-dropzone:hover, [data-theme="light"] .file-dropzone.dragover {
  background-color: #f1f5f9;
  border-color: #6366f1;
}

/* ==========================================================================
   AML GOVERNANCE & TUNING COPILOT (OPTION A: DETERMINISTIC ENGINE)
   ========================================================================== */

/* Floating Launcher Button */
.copilot-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 995;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-launcher-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.6);
}

.copilot-pulse-dot {
  width: 8px;
  height: 8px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: copilot-pulse 2s infinite;
}

@keyframes copilot-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.copilot-launcher-context {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-family: var(--font-mono);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Copilot Backdrop Overlay */
.copilot-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.copilot-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Copilot Slide-Out Drawer */
.copilot-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-drawer.open {
  transform: translateX(0);
}

/* Drawer Header */
.copilot-drawer-header {
  padding: 14px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.copilot-header-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.copilot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.copilot-title-text h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copilot-title-text p {
  font-size: 10.5px;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.copilot-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Context Badge in Drawer */
.copilot-context-bar {
  padding: 7px 18px;
  background: rgba(99, 102, 241, 0.08);
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.copilot-context-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-primary);
  font-weight: 600;
}

/* Messages Stream */
.copilot-messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-card);
}

.copilot-msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: copilot-msg-fade 0.2s ease-out;
}

@keyframes copilot-msg-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.copilot-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  padding: 9px 14px;
  border-radius: 14px 14px 2px 14px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.copilot-msg-bot {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px 14px 14px 2px;
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  max-width: 95%;
}

.copilot-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.copilot-msg-badge {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  font-weight: 700;
  text-transform: uppercase;
}

/* Grounding Citations */
.copilot-citation {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  margin: 3px 2px;
  transition: all 0.15s ease;
}

.copilot-citation:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-primary);
  color: #ffffff;
}

/* Suggestion Chip Tray */
.copilot-chip-tray {
  padding: 10px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.copilot-chip-tray::-webkit-scrollbar {
  height: 4px;
}

.copilot-chip-tray::-webkit-scrollbar-track {
  background: transparent;
}

.copilot-chip-tray::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.copilot-chip {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.copilot-chip:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

/* Drawer Input Area */
.copilot-input-bar {
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  align-items: center;
}

.copilot-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.copilot-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.copilot-send-btn {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.copilot-send-btn:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: scale(1.05);
}

/* Copilot Inline Data Cards */
.copilot-data-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 11px;
}

.copilot-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 6px;
}

.copilot-data-table th {
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
}

.copilot-data-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.copilot-memo-box {
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-left: 3px solid var(--accent-primary);
  border-radius: 4px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.45;
}

/* ==========================================================================
   CONTEXTUAL FAQ KNOWLEDGE SYSTEM
   ========================================================================== */
.contextual-faq-wrapper {
  margin-top: 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: all 0.25s ease;
}

.faq-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  background: rgba(99, 102, 241, 0.08);
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  cursor: pointer;
  transition: all 0.2s ease;
}

.faq-toggle-bar:hover {
  background: rgba(99, 102, 241, 0.15);
}

.faq-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-primary);
}

.faq-toggle-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.faq-content-container {
  padding: 10px 16px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
}

.faq-accordion-item {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  overflow: hidden;
  transition: all 0.2s ease;
}

.faq-accordion-item:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.faq-question-btn {
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
}

.faq-question-btn:hover {
  color: var(--accent-primary);
}

.faq-answer-panel {
  padding: 0 14px 12px 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  border-top: 1px dashed var(--border-color);
  margin-top: 4px;
  padding-top: 8px;
}

.faq-answer-panel p {
  margin: 4px 0;
}

.faq-answer-panel strong {
  color: var(--text-primary);
}

/* ==========================================================================
   COPILOT KNOWLEDGE SOURCE SELECTOR
   ========================================================================== */
.copilot-source-bar {
  padding: 8px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.copilot-source-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.copilot-source-pills-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 2px 4px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.copilot-source-pills-list::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.copilot-source-pills-list::-webkit-scrollbar-track {
  background: transparent;
}

.copilot-source-pills-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.copilot-source-pills-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

.source-pill-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.source-pill-label input[type="checkbox"] {
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.source-pill-label.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-add-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px dashed var(--accent-primary);
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-add-source:hover {
  background: rgba(99, 102, 241, 0.15);
}

/* ==========================================================================
   DOCUMENT MANAGER MODAL & UPLOAD
   ========================================================================== */
.doc-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.doc-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.doc-modal-card {
  width: 580px;
  max-width: 92vw;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-modal-header {
  padding: 14px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-modal-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.doc-upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-surface);
  transition: all 0.2s ease;
}

.doc-upload-dropzone:hover,
.doc-upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
}

.doc-dropzone-icon {
  font-size: 28px;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.doc-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
}

.doc-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.doc-file-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.doc-badge-pdf { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.doc-badge-docx { background: rgba(59, 130, 246, 0.15); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.doc-badge-txt { background: rgba(168, 85, 247, 0.15); color: #a855f7; border: 1px solid rgba(168, 85, 247, 0.3); }
.doc-badge-csv { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }

.doc-item-meta {
  font-size: 10.5px;
  color: var(--text-muted);
}

.btn-doc-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.btn-doc-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Document Passage Citation in Chat */
.doc-citation-card {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-left: 3px solid var(--accent-cyan);
  border-radius: 4px;
  padding: 8px 12px;
  margin-top: 6px;
  font-size: 11px;
}

.doc-citation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 4px;
  font-size: 10.5px;
}

.doc-citation-snippet {
  color: var(--text-secondary);
  line-height: 1.45;
  font-style: italic;
}

/* ==========================================================================
   DOCUMENT READER & SECTION VIEWER MODAL
   ========================================================================== */
.doc-reader-card {
  width: 860px;
  max-width: 94vw;
  height: 86vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-reader-view-toggle {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
}

.doc-view-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.doc-view-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.doc-reader-toolbar {
  padding: 8px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.doc-reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-card);
}

.doc-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
  transition: all 0.2s ease;
}

.doc-section-card.referenced-active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.doc-section-header-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-primary);
}

.doc-text-content {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-primary);
}

/* ==========================================================================
   DASHBOARD PIN LOCK SCREEN
   ========================================================================== */
.lock-screen-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #090d16 100%);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.lock-screen-backdrop.unlocked {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  display: none !important;
}

.lock-screen-card {
  width: 420px;
  max-width: 92vw;
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(99, 102, 241, 0.15);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lock-screen-icon {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent-primary);
  margin-bottom: 16px;
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.2);
}

.lock-screen-input {
  width: 100%;
  padding: 12px 42px 12px 16px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  letter-spacing: 0.5px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.lock-screen-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: rgba(15, 23, 42, 1);
}

.btn-toggle-pin {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}

.btn-toggle-pin:hover {
  color: var(--text-primary);
}

.lock-screen-error {
  color: #ef4444;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn-unlock-dashboard {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-unlock-dashboard:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}



