/**
 * KYT Alert Analysis Dashboard — Design System
 *
 * Institutional precision aesthetic for compliance teams.
 * Typography: DM Sans + IBM Plex Mono
 * Layout: Persistent left sidebar, card-based content
 */

/* Google Fonts loaded via <link> in HTML */

/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
  /* Sidebar / Dark surfaces */
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: rgba(59, 130, 246, 0.15);
  --sidebar-border: #1e293b;
  --sidebar-width: 56px;
  --sidebar-width-expanded: 240px;

  /* Brand */
  --primary-dark: #1e3a5f;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-subtle: #eff6ff;

  /* Status */
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-light: #fef2f2;
  --success: #10b981;
  --success-dark: #059669;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-dark: #d97706;
  --warning-light: #fffbeb;
  --info: #8b5cf6;
  --info-dark: #7c3aed;
  --info-light: #f5f3ff;

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Surfaces */
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;

  /* Borders */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

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

  /* Type Scale — use these for consistency */
  --text-2xs: 0.65rem;   /* 10.4px — badges, micro labels */
  --text-xs: 0.7rem;     /* 11.2px — hints, captions, timestamps */
  --text-sm: 0.78rem;    /* 12.5px — table cells, form labels, descriptions */
  --text-base: 0.85rem;  /* 13.6px — body text, buttons, card content */
  --text-lg: 0.95rem;    /* 15.2px — section headers, column titles */
  --text-xl: 1.1rem;     /* 17.6px — page subtitles */
  --text-2xl: 1.3rem;    /* 20.8px — page headings */
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--gray-800);
  line-height: 1.6;
  font-size: 0.875rem;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .font-mono { font-family: var(--font-mono); }

/* ==========================================================================
   App Layout — Persistent Left Sidebar
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Left Sidebar — Slim Icon Rail (desktop) / Full Panel (mobile)
   ========================================================================== */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

.sidebar-right {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar-right.show {
  transform: translateX(0) !important;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f8fafc;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand-mark svg {
  color: #60a5fa;
}

.sidebar-brand-mark:hover {
  text-decoration: none;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sidebar-brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidebar-brand-sub {
  font-size: 0.65rem;
  color: var(--gray-500);
  font-weight: 400;
  white-space: nowrap;
}

.sidebar-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  flex-shrink: 0;
}

.sidebar-close:hover {
  background: var(--sidebar-hover);
  color: #f8fafc;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 6px 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  color: var(--gray-400);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.12s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  position: relative;
  font-family: var(--font-sans);
}

.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: #f8fafc;
  text-decoration: none;
}

.sidebar-item.active {
  color: #60a5fa;
  background: var(--sidebar-active);
}

.sidebar-item.active svg {
  color: #60a5fa;
}

.sidebar-item svg {
  flex-shrink: 0;
  color: var(--gray-500);
  transition: color 0.12s;
}

.sidebar-item:hover svg {
  color: var(--gray-300);
}

.sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item.sidebar-status {
  cursor: default;
}

.sidebar-item.sidebar-status:hover {
  background: transparent;
}

/* API Status in Sidebar */
.sidebar-item .config-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}

.sidebar-item .config-indicator .status-dot {
  width: 7px;
  height: 7px;
}

.sidebar-item .api-status-text {
  color: var(--gray-500);
  font-size: 0.78rem;
}

.sidebar-item .config-indicator.api-on .status-dot {
  background: var(--success);
}

.sidebar-item .config-indicator.api-on .api-status-text {
  color: var(--success);
}

.sidebar-logout {
  color: #f87171 !important;
}

.sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.08) !important;
}

.sidebar-logout svg {
  stroke: #f87171;
}

/* ---- Desktop: Slim Icon Rail ---- */
@media (min-width: 1024px) {
  .app-layout .sidebar-right {
    width: var(--sidebar-width);
    transform: translateX(0);
  }

  .app-layout .sidebar-overlay {
    display: none !important;
  }

  .app-main {
    margin-left: var(--sidebar-width);
  }

  .app-layout .btn-menu {
    display: none !important;
  }

  /* Header: hidden on desktop (brand mark removed, nav items start at top) */
  .sidebar-header {
    display: none;
  }

  /* Nav items: icon-only, centered */
  .sidebar-item {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
    font-size: 0;
    border-left: 3px solid transparent;
  }

  .sidebar-item.active {
    border-left-color: #3b82f6;
  }

  .sidebar-item:hover {
    border-left-color: rgba(255,255,255,0.08);
  }

  .sidebar-item svg {
    width: 18px;
    height: 18px;
  }

  .sidebar-label,
  .sidebar-item .api-status-text {
    display: none;
  }

  .sidebar-item.sidebar-status {
    padding: 8px 0;
    justify-content: center;
  }

  .sidebar-item.sidebar-status .config-indicator {
    gap: 0;
    justify-content: center;
  }

  .sidebar-item.sidebar-status .config-indicator .status-dot {
    width: 8px;
    height: 8px;
  }

  /* CSS Tooltips on hover */
  .sidebar-item[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-900);
    color: #f8fafc;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: var(--font-sans);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }

  .sidebar-item[data-tip]:hover::after {
    opacity: 1;
  }
}

/* ---- Mobile: Full expanded panel ---- */
@media (max-width: 1023px) {
  .sidebar-right {
    width: var(--sidebar-width-expanded);
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }

  .sidebar-header {
    padding: 16px;
    gap: 12px;
    justify-content: flex-start;
  }

  .sidebar-brand-mark {
    width: 32px;
    height: 32px;
    background: rgba(96, 165, 250, 0.12);
    border-radius: 8px;
  }

  .sidebar-brand-text {
    flex: 1;
  }

  .sidebar-close {
    display: block;
  }

  .sidebar-item {
    gap: 12px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 450;
    border-left: 3px solid transparent;
  }

  .sidebar-item.active {
    border-left-color: #3b82f6;
  }

  .sidebar-item.sidebar-status {
    padding: 8px 16px;
  }

  .app-main {
    margin-left: 0;
  }
}

/* ==========================================================================
   Header / Top Bar
   ========================================================================== */

.header {
  background: var(--bg-card);
  color: var(--gray-800);
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.header p {
  color: var(--gray-500);
  font-size: 0.8rem;
  margin-top: 2px;
}

.header.dashboard {
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
}

.header.detail {
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
}

.header.detail h1 {
  font-size: 1.1rem;
}

.header-ca-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  letter-spacing: 0.02em;
  margin-top: 4px;
}
.header-ca-unreviewed { background: #fef3c7; color: #92400e; }
.header-ca-flagged { background: #fee2e2; color: #991b1b; }
.header-ca-dismissed { background: #d1fae5; color: #065f46; }
.header-ca-in-review { background: #dbeafe; color: #1e40af; }

.header .alert-id {
  opacity: 0.6;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

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

.btn-back,
.btn-settings {
  padding: 7px 14px;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-back:hover,
.btn-settings:hover {
  background: var(--gray-200);
  text-decoration: none;
}

/* Burger Menu Button */
.btn-menu {
  padding: 7px;
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-menu:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* Environment Badge Inline */
.env-badge-inline {
  padding: 5px 10px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  color: var(--gray-500);
  letter-spacing: 0.04em;
  font-weight: 500;
}

.env-badge-inline strong {
  color: var(--gray-800);
  font-weight: 700;
}

.env-badge-inline.env-test {
  background: #fef9c3;
  border-color: #fde68a;
}

.env-badge-inline.env-test strong {
  color: #92400e;
}

.env-badge-inline.env-uat {
  background: var(--primary-light);
  border-color: #93c5fd;
}

.env-badge-inline.env-uat strong {
  color: var(--primary);
}

.env-badge-inline.env-prod,
.env-badge-inline.env-production {
  background: #fef2f2;
  border-color: #fecaca;
}

.env-badge-inline.env-prod strong,
.env-badge-inline.env-production strong {
  color: #dc2626;
}

.env-badge-inline.env-dev,
.env-badge-inline.env-development {
  background: var(--success-light);
  border-color: #6ee7b7;
}

.env-badge-inline.env-dev strong,
.env-badge-inline.env-development strong {
  color: var(--success-dark);
}

.env-badge-inline.env-overridden {
  background: #fef3c7;
  border-color: #fcd34d;
}

.env-badge-inline.env-overridden strong {
  color: #78350f;
}

.env-override-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: #b45309;
  background: rgba(180, 83, 9, 0.12);
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 4px;
}

/* ==========================================================================
   Container
   ========================================================================== */

.container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px 28px;
}

/* ==========================================================================
   Stats Section — Two Column Layout
   ========================================================================== */

.stats-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.stats-column {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
}

.stats-column.ca-column {
  border-left: 3px solid var(--gray-300);
}

.stats-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
}

.column-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -0.01em;
}

.column-pct {
  font-size: 0.7rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.stats-column-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Mini Donut Chart */
.stats-chart-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  min-width: 130px;
  gap: 10px;
  /* Sit at the top of the card; the legend row follows immediately
     below. (Previous justify-content: space-between pushed the legend
     to the bottom of the full card height, which produced a big void
     between donut and legend when the card grew wider with filters
     no longer beside it.) */
}

.donut-chart-mini {
  position: relative;
  width: 130px;
  height: 130px;
}

.donut-chart-mini .donut-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-bg {
  fill: none;
  stroke: var(--gray-100);
  stroke-width: 3;
}

.donut-segment {
  fill: none;
  stroke-width: 3;
  stroke-linecap: butt;
  transition: stroke-dasharray 0.6s ease;
}

.flag-segment { stroke: var(--danger); }
.dismiss-segment { stroke: var(--success); }
.review-segment { stroke: var(--warning); }
.unanalyzed-segment { stroke: var(--info); }
.ca-unreviewed-segment { stroke: var(--gray-400); }
.ca-flagged-segment { stroke: var(--danger); }
.ca-dismissed-segment { stroke: var(--success); }
.ca-inreview-segment { stroke: var(--warning); }

.donut-center-mini {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-value-mini {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.donut-label-mini {
  display: block;
  font-size: 0.7rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
  font-weight: 500;
}

.chart-legend-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
  margin-top: 8px;
  font-size: 0.6rem;
  color: var(--gray-500);
}

.chart-legend-mini .legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chart-legend-mini .legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.flag { background: var(--danger); }
.legend-dot.dismiss { background: var(--success); }
.legend-dot.review { background: var(--warning); }
.legend-dot.unanalyzed { background: var(--info); }
.legend-dot.ca-unreviewed { background: var(--gray-400); }
.legend-dot.ca-flagged { background: var(--danger); }
.legend-dot.ca-dismissed { background: var(--success); }
.legend-dot.ca-inreview { background: var(--warning); }

/* Stats Rows Compact */
.stats-rows-compact {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
  /* Cap so bars don't become ridiculously long on ultra-wide displays */
  max-width: 820px;
}

.stat-row {
  display: grid;
  /* Columns: icon | name | bar (grows with container via 1fr, min 200px) |
     count | pct. The 1fr track absorbs leftover space so wide cards don't
     leave a dead whitespace strip on the right. Cap the whole rows block
     via max-width on .stats-rows-compact to keep bars from stretching
     ridiculously on ultra-wide screens. */
  grid-template-columns: 20px minmax(0, 200px) minmax(200px, 1fr) 40px 44px;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}

.stat-icon {
  font-size: 0.7rem;
  text-align: center;
}

.stat-row.flag .stat-icon { color: var(--danger); }
.stat-row.dismiss .stat-icon { color: var(--success); }
.stat-row.review .stat-icon { color: var(--warning); }
.stat-row.unanalyzed .stat-icon { color: var(--info); }
.stat-row.ca-unreviewed .stat-icon { color: var(--gray-400); }
.stat-row.ca-flagged .stat-icon { color: var(--danger); }
.stat-row.ca-dismissed .stat-icon { color: var(--success); }
.stat-row.ca-inreview .stat-icon { color: var(--warning); }
.stat-row.severe .stat-icon { color: var(--danger); }
.stat-row.high .stat-icon { color: #f97316; }
.stat-row.medium .stat-icon { color: var(--warning); }
.stat-row.low .stat-icon { color: var(--success); }

.stat-name {
  color: var(--gray-600);
  font-weight: 500;
}

.stat-bar {
  height: 5px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}

.stat-row.flag .stat-bar-fill { background: var(--danger); }
.stat-row.dismiss .stat-bar-fill { background: var(--success); }
.stat-row.review .stat-bar-fill { background: var(--warning); }
.stat-row.unanalyzed .stat-bar-fill { background: var(--info); }
.stat-row.ca-unreviewed .stat-bar-fill { background: var(--gray-400); }
.stat-row.ca-flagged .stat-bar-fill { background: var(--danger); }
.stat-row.ca-dismissed .stat-bar-fill { background: var(--success); }
.stat-row.ca-inreview .stat-bar-fill { background: var(--warning); }
.stat-row.severe .stat-bar-fill { background: var(--danger); }
.stat-row.high .stat-bar-fill { background: #f97316; }
.stat-row.medium .stat-bar-fill { background: var(--warning); }
.stat-row.low .stat-bar-fill { background: var(--success); }

.stat-count {
  font-weight: 600;
  text-align: right;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.stat-pct {
  font-size: 0.65rem;
  color: var(--gray-400);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1024px) {
  .stats-two-column {
    grid-template-columns: 1fr;
  }

  .stats-column.ca-column {
    border-left: none;
    border-top: 3px solid var(--gray-300);
  }
}

@media (max-width: 600px) {
  .stats-column-content {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-chart-mini {
    flex-direction: row;
    gap: 16px;
    justify-content: center;
    margin-bottom: 8px;
  }

  .chart-legend-mini {
    margin-top: 0;
    align-self: center;
  }
}

/* Legacy stats-compact (still used by some pages) */
.stats-compact {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
}

.stats-chart-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-right: 20px;
  border-right: 1px solid var(--gray-200);
}

.donut-chart {
  position: relative;
  width: 110px;
  height: 110px;
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.donut-label {
  display: block;
  font-size: 0.6rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.chart-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-top: 12px;
  font-size: 0.7rem;
  color: var(--gray-600);
}

.stats-panel { min-width: 0; }

.stats-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
}

.panel-pct {
  font-size: 0.7rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 10px;
}

.stats-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.users-stats { display: block; }
.users-stats .stats-panel { max-width: 600px; }

@media (max-width: 900px) {
  .stats-compact {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .stats-chart-section {
    flex-direction: row;
    gap: 20px;
    padding-right: 0;
    padding-bottom: 16px;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }
}

/* ==========================================================================
   Filters
   ========================================================================== */

.filters {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}

.filter-group select,
.filter-group input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--bg-card);
  color: var(--gray-800);
  font-family: var(--font-sans);
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.btn-reset {
  padding: 6px 14px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  color: var(--gray-600);
  margin-left: auto;
  transition: all 0.15s;
}

.btn-reset:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* (.dashboard-top-row layout removed — filters now sit directly above the
   table instead of in a side-by-side column next to the pipeline card.) */

/* Top stats row: Alert Pipeline (2fr) + AI Performance (1fr). Uses CSS
   grid so both cards stretch to equal height. Wraps to a single column
   on narrow screens. */
.dashboard-stats-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (min-width: 1100px) {
  .dashboard-stats-row {
    grid-template-columns: 2fr 1fr;
  }
}
/* Reset per-card bottom margins inside the row — the row itself spaces
   things below it. */
.dashboard-stats-row > .stats-two-column,
.dashboard-stats-row > .stats-column.ai-perf-card {
  margin-bottom: 0;
}
/* The Alert Pipeline side wraps a single .stats-column. Force the wrapper
   to flex so its child card stretches to match the grid row height,
   keeping the two card bottoms perfectly aligned with the AI Performance
   card next to it. */
.dashboard-stats-row > .stats-two-column.pipeline-wrap {
  display: flex;
  flex-direction: column;
}
.dashboard-stats-row > .stats-two-column.pipeline-wrap > .stats-column {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.dashboard-stats-row > .stats-two-column.pipeline-wrap > .stats-column > .stats-column-content {
  flex: 1;
}
.ai-perf-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.ai-perf-card .stats-column-header {
  flex: 0 0 auto;
}
.ai-perf-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ai-perf-chart-area {
  width: 100%;
  flex: 1;
  min-height: 90px;
  position: relative;
}
.ai-perf-chart-area svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
/* Each run renders as a vertical bar via JS-injected <rect> elements */
.ai-perf-bar {
  transition: opacity 0.15s, height 0.4s ease-out, y 0.4s ease-out;
}
.ai-perf-bar:hover {
  opacity: 0.7;
}
.ai-perf-median-line {
  stroke: var(--gray-500);
  stroke-width: 0.6;
  stroke-dasharray: 1.5 1.5;
  opacity: 0.7;
}
.ai-perf-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
}
.ai-perf-stat {
  text-align: center;
}
.ai-perf-stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.1;
}
.ai-perf-stat-label {
  font-size: 0.6rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.ai-perf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.65rem;
  color: var(--gray-500);
  justify-content: center;
}
.ai-perf-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ai-perf-legend-item .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.btn-analyze {
  padding: 6px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  font-weight: 500;
}

.btn-analyze:hover {
  background: var(--primary-hover);
}

/* ==========================================================================
   Column Toggle
   ========================================================================== */

.column-toggle-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.column-toggle-wrapper {
  position: relative;
}

/* Dashboard insight strip: three cards above the alerts table surfacing
   patterns that are invisible in the per-alert view — $ impact per
   pipeline state, repeat-offender users, recurring illicit sources. */
.dashboard-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}
.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px 12px;
  min-width: 0;
}
.insight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 10px;
}
.insight-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -0.01em;
}
/* (.insight-card-hint removed — the per-row hover chevron + title tooltip
   carry the click affordance well enough without an extra header line.) */
.insight-card-sub {
  font-size: 0.7rem;
  color: var(--gray-500);
  font-weight: 500;
  text-align: right;
}
/* Donut + list side-by-side inside each insight card. Mini donut mirrors
   the Alert Pipeline donut's visual style at a smaller scale, with its
   own segment colours that match the list rows beneath. */
.insight-card-content {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.insight-donut-wrap {
  position: relative;
  flex-shrink: 0;
  width: 110px;
  height: 110px;
}
.insight-donut {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  display: block;
}
.insight-donut .donut-bg {
  fill: none;
  stroke: var(--gray-100);
  stroke-width: 3;
}
.insight-donut-segment {
  fill: none;
  stroke-width: 3;
  stroke-linecap: butt;
  transition: stroke-dasharray 0.6s ease;
}
.insight-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.insight-donut-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}
.insight-donut-label {
  font-size: 0.55rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 3px;
  font-weight: 500;
}

.insight-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  flex: 1;
  min-width: 0;
}
.insight-empty {
  font-size: var(--text-xs);
  color: var(--gray-400);
  font-style: italic;
  padding: 10px 0;
  text-align: center;
}
.insight-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-50);
  border-radius: 4px;
  padding: 6px 6px;
  margin: 0 -6px;
  transition: background 0.15s, transform 0.15s;
  position: relative;
}
/* Click affordance: a right-chevron appears on hover for rows that filter
   the table when clicked. Cards mark their rows with [data-clickable="1"]
   so informational-only rows (like the illicit-source aggregations) don't
   falsely promise an action. */
.insight-row[data-clickable="1"] {
  cursor: pointer;
  padding-right: 22px;
}
.insight-row[data-clickable="1"]::after {
  content: "›";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--gray-300);
  transition: color 0.15s, right 0.15s;
  font-weight: 600;
}
.insight-row[data-clickable="1"]:hover {
  background: var(--gray-50);
  transform: translateX(2px);
}
.insight-row[data-clickable="1"]:hover::after {
  color: var(--primary);
  right: 6px;
}
/* Non-clickable rows (Top Illicit Sources) explicitly do NOT change on
   hover so compliance doesn't get a false-positive 'this is interactive'
   signal. cursor stays default, no background tint. */
.insight-row:not([data-clickable="1"]) {
  cursor: default;
}
.insight-row:last-child {
  border-bottom: none;
}
.insight-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.insight-row-title {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.insight-row-meta {
  font-size: var(--text-2xs);
  color: var(--gray-500);
  line-height: 1.4;
}
.insight-row-value {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.insight-row-value .primary {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.85rem;
}
.insight-row-value .secondary {
  font-size: var(--text-2xs);
  color: var(--gray-500);
}
.insight-flag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: var(--text-2xs);
  font-weight: 600;
  margin-right: 4px;
}
.insight-flag-chip.short-path { background: #fef3c7; color: #b45309; }
.insight-flag-chip.same-day   { background: #fee2e2; color: #b91c1c; }
.insight-flag-chip.both       { background: #fee2e2; color: #b91c1c; }

/* Table toolbar lives inside the table card and holds the Columns button
   (and any future table-scoped controls). Visually reads as part of the
   table card rather than a floating chip between cards. */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.table-toolbar-spacer {
  flex: 1;
}
.table-toolbar .btn-column-toggle {
  /* Slimmer in the toolbar than when it was a floating button */
  padding: 5px 10px;
  font-size: 0.75rem;
}

.btn-column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-600);
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-column-toggle:hover {
  color: var(--gray-800);
  border-color: var(--gray-300);
  background: var(--gray-50);
}

.column-picker {
  position: fixed;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 8px 0;
  min-width: 180px;
  z-index: 50;
  max-height: 360px;
  overflow-y: auto;
}

.column-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.1s;
}

.column-picker-item:hover {
  background: var(--gray-50);
}

.column-picker-item input[type="checkbox"] {
  accent-color: var(--primary);
}

/* ==========================================================================
   Batch Actions Bar
   ========================================================================== */

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

.batch-info {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 10px;
  letter-spacing: 0.01em;
}

.btn-batch {
  padding: 4px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.btn-batch:hover:not(:disabled) {
  background: #1d4ed8;
}

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

/* Destructive variant — used for Bulk Dismiss to set it apart from Analyze. */
.btn-batch-dismiss { background: var(--danger, #dc2626); }
.btn-batch-dismiss:hover:not(:disabled) { background: #b91c1c; }

/* Generic .btn-danger for modal primary buttons on destructive flows. */
.btn-danger {
  background: var(--danger, #dc2626);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-danger:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-batch-clear {
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  color: var(--gray-400);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.btn-batch-clear:hover {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-300);
}

/* ==========================================================================
   Table
   ========================================================================== */

.table-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--gray-50);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover {
  background: var(--gray-100);
}

th .sort-icon {
  margin-left: 3px;
  opacity: 0.4;
}

th.sorted .sort-icon {
  opacity: 1;
}

td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.78rem;
  white-space: nowrap;
  color: var(--gray-700);
}

tr:hover {
  background: var(--gray-50);
}

tr:last-child td {
  border-bottom: none;
}

/* Sticky Action column */
th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  background: var(--bg-card);
  box-shadow: -2px 0 4px rgba(0,0,0,0.03);
}

th:last-child {
  background: var(--gray-50);
  z-index: 2;
}

tr:hover td:last-child {
  background: var(--gray-50);
}

tr.selected {
  background: var(--primary-subtle);
}

tr.selected td:last-child {
  background: var(--primary-subtle);
}

tr.selected:hover {
  background: var(--primary-light);
}

tr.selected:hover td:last-child {
  background: var(--primary-light);
}

/* Checkbox columns */
.th-checkbox,
.td-checkbox {
  width: 36px;
  text-align: center;
  padding: 6px 10px;
}

.th-checkbox {
  cursor: default;
}

.row-checkbox {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Action badges */
.badge-flag { background: #fef2f2; color: #dc2626; }
.badge-dismiss { background: #ecfdf5; color: #059669; }
.badge-review { background: #fffbeb; color: #d97706; }
.badge-pending { background: #f5f3ff; color: #7c3aed; }
.badge-enriched { background: #ecfdf5; color: #059669; }
.badge-analyzing { background: #dbeafe; color: #1d4ed8; }
.badge-unanalyzed { background: var(--gray-100); color: var(--gray-500); }
.badge-unknown { background: var(--gray-100); color: var(--gray-500); }

/* Severity badges */
.badge-severe { background: #fef2f2; color: #b91c1c; }
.badge-high { background: #fff7ed; color: #c2410c; }
.badge-medium { background: #fefce8; color: #a16207; }
.badge-low { background: #f0fdf4; color: #15803d; }

/* Exposure badges */
.badge-direct { background: #fef2f2; color: #b91c1c; }
.badge-indirect { background: var(--primary-light); color: var(--primary); }

/* Direction badges */
.badge-sent { background: #fffbeb; color: #b45309; }
.badge-received { background: #eef2ff; color: #4338ca; }

/* Reactor badges */
.badge-reactor-yes { background: var(--primary-light); color: var(--primary); }
.badge-reactor-no { background: var(--gray-100); color: var(--gray-500); }

/* CA Status badges */
.badge-ca-unreviewed { background: var(--gray-100); color: var(--gray-600); }
.badge-ca-flagged { background: #fef2f2; color: #dc2626; }
.badge-ca-dismissed { background: #ecfdf5; color: #059669; }
.badge-ca-in-review { background: #fffbeb; color: #d97706; }

/* Legacy score badges */
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-amber { background: #fff7ed; color: #c2410c; }
.badge-green { background: #f0fdf4; color: #15803d; }

/* ==========================================================================
   AI Indicator in Table Headers
   ========================================================================== */

.th-ai-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.th-ai-indicator .ai-icon {
  color: var(--info);
  flex-shrink: 0;
}

thead th .th-ai-indicator {
  white-space: nowrap;
}

/* ==========================================================================
   Copyable IDs
   ========================================================================== */

.alert-id-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.alert-id-copy:hover {
  background: var(--gray-100);
}

.alert-id-copy code {
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.alert-id-truncate {
  display: block;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-id-copy .copy-icon {
  opacity: 0.3;
  transition: opacity 0.15s;
}

.alert-id-copy:hover .copy-icon {
  opacity: 0.8;
}

.alert-id-copy.copied {
  background: var(--success-light);
}

.alert-id-copy.detail {
  padding: 5px 8px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  max-width: 100%;
}

.alert-id-copy.detail code {
  word-break: break-all;
  flex: 1;
}

.alert-id-copy.detail .copy-icon {
  flex-shrink: 0;
}

.copy-tooltip {
  position: fixed;
  background: var(--gray-900);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.copy-tooltip.show {
  opacity: 1;
}

.user-id-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.user-id-copy:hover {
  background: var(--gray-100);
}

.user-id-copy code {
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.user-id-copy .copy-icon {
  opacity: 0.3;
  transition: opacity 0.15s;
}

.user-id-copy:hover .copy-icon {
  opacity: 0.8;
}

.user-id-copy.copied {
  background: var(--success-light);
}

/* ==========================================================================
   Risk Score Display
   ========================================================================== */

.risk-bar {
  width: 56px;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.risk-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.risk-high { background: var(--danger); }
.risk-medium { background: var(--warning); }
.risk-low { background: var(--success); }

.risk-score-display {
  display: flex;
  align-items: center;
  gap: 16px;
}

.risk-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.risk-circle.high { background: linear-gradient(135deg, var(--danger), var(--danger-dark)); }
.risk-circle.medium { background: linear-gradient(135deg, var(--warning), var(--warning-dark)); }
.risk-circle.low { background: linear-gradient(135deg, var(--success), var(--success-dark)); }

.risk-circle .score { font-size: 1.5rem; }
.risk-circle .max { font-size: 0.7rem; opacity: 0.8; }

.risk-breakdown { flex: 1; }

.risk-bar-item {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.risk-bar-item .name {
  width: 70px;
  color: var(--gray-500);
}

.risk-bar-item .bar {
  flex: 1;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  margin: 0 8px;
  overflow: hidden;
}

.risk-bar-item .bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

.risk-bar-item .score-text {
  width: 40px;
  text-align: right;
  font-weight: 500;
  font-size: 0.75rem;
}

/* ==========================================================================
   Action Buttons
   ========================================================================== */

.btn-view {
  padding: 5px 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-family: var(--font-sans);
}

.btn-view:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-action-icon {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-analyze-icon {
  background: var(--primary);
  color: white;
}

.btn-analyze-icon:hover {
  background: var(--primary-hover);
}

.btn-view-icon {
  background: var(--gray-800);
  color: white;
}

.btn-view-icon:hover {
  background: var(--gray-700);
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-nav:hover {
  background: var(--gray-200);
  text-decoration: none;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--gray-50);
  border-top: 1px solid var(--border);
}

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

.pagination-info {
  font-size: 0.78rem;
  color: var(--gray-500);
}

.rows-per-page {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rows-per-page label {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.rows-per-page select {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  background: white;
  cursor: pointer;
  font-family: var(--font-sans);
}

.rows-per-page select:focus {
  outline: none;
  border-color: var(--primary);
}

.pagination-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pagination-controls button {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  color: var(--gray-700);
  transition: all 0.12s;
}

.pagination-controls button:hover:not(:disabled) {
  background: var(--gray-100);
}

.pagination-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-controls .page-num {
  padding: 5px 10px;
  background: var(--gray-900);
  color: white;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Empty State & Loading
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}

.empty-state h3 {
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--gray-700);
}

.loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}

/* ==========================================================================
   Cards (Detail Page)
   ========================================================================== */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  background: var(--gray-50);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header .icon { opacity: 0.6; }

.card-body {
  padding: 16px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================================
   Detail Page — Redesigned Layout
   ========================================================================== */

.detail-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 24px;
  align-items: start;
}

.detail-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.detail-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 80px;
}

/* Full-width decision banner above the grid */
.detail-decision-banner {
  margin-bottom: 20px;
}

/* Compact 3-column info grid for alert metadata */
.info-grid-compact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.info-grid-compact .info-cell {
  padding: 10px 14px;
  background: var(--bg-card);
  min-width: 0;
}

.info-grid-compact .info-cell .label {
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  margin-bottom: 3px;
  white-space: nowrap;
}

.info-grid-compact .info-cell .value {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-grid-compact .info-cell.full-width {
  grid-column: 1 / -1;
}

.info-grid-compact .info-cell.span-2 {
  grid-column: span 2;
}

/* Alert details card — borderless cells */
.card-compact .card-body {
  padding: 0;
}

.card-compact .info-grid-compact {
  border-top: none;
}

.card-compact .info-grid-compact .info-cell:not(:last-child) {
  border-right: 1px solid var(--gray-100);
}

/* Horizontal divider between rows */
.card-compact .info-grid-compact .info-cell {
  border-bottom: 1px solid var(--gray-100);
}

/* Risk score — vertical layout for sidebar */
.risk-score-vertical .risk-score-display {
  flex-direction: column;
  text-align: center;
  gap: 16px;
}

.risk-score-vertical .risk-breakdown {
  width: 100%;
}

/* ==========================================================================
   Analysis Indicators (Resistant AI-style)
   ========================================================================== */

.indicator-card {
  border: 1px solid var(--border);
  overflow: hidden;
}

.indicator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.indicator-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--gray-700);
}

.indicator-title svg { opacity: 0.6; }

.indicator-counts {
  display: flex;
  gap: 6px;
}

.indicator-count {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.indicator-count.high { background: var(--danger-light); color: var(--danger-dark); }
.indicator-count.medium { background: var(--warning-light); color: var(--warning-dark); }
.indicator-count.low { background: var(--success-light); color: var(--success-dark); }

.indicator-list {
  display: flex;
  flex-direction: column;
}

.indicator-row {
  border-bottom: 1px solid var(--gray-100);
}

.indicator-row:last-child { border-bottom: none; }

.indicator-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.12s;
}

.indicator-summary::-webkit-details-marker { display: none; }
.indicator-summary:hover { background: var(--gray-50); }

.indicator-bar {
  width: 3px;
  height: 22px;
  border-radius: 2px;
  flex-shrink: 0;
}

.indicator-bar.high { background: var(--danger); }
.indicator-bar.medium { background: var(--warning); }
.indicator-bar.low { background: var(--success); }
.indicator-bar.info { background: var(--gray-300); }

.indicator-name {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--gray-700);
  line-height: 1.4;
}

.indicator-chevron {
  flex-shrink: 0;
  color: var(--gray-300);
  transition: transform 0.2s ease;
}

.indicator-row[open] .indicator-chevron {
  transform: rotate(180deg);
  color: var(--gray-500);
}

.indicator-detail {
  padding: 0 16px 14px 31px;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--gray-500);
}

/* ==========================================================================
   Unified Reactor Analysis Card
   ========================================================================== */

.reactor-unified {
  border: 1px solid var(--border);
  overflow: visible;
}

.reactor-unified-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}

.reactor-unified-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--gray-700);
}

.reactor-unified-title svg { opacity: 0.6; }

.reactor-unified-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.reactor-unified-badge.na { background: var(--gray-100); color: var(--gray-500); }
.reactor-unified-badge.pending { background: #fffbeb; color: #92400e; }

.reactor-unified-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--gray-500);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}
.reactor-unified-action-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.reactor-unified-body { padding: 16px; }

/* Stats row */
.reactor-stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.reactor-stat-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-100);
}

.reactor-stat-pill .reactor-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
}

.reactor-stat-pill .reactor-stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  margin-top: 2px;
}

.reactor-stat-pill.hop-remote {
  background: var(--success-light);
  border-color: rgba(16,185,129,0.2);
}
.reactor-stat-pill.hop-remote .reactor-stat-value { color: var(--success-dark); }

.reactor-stat-pill.hop-moderate {
  background: var(--warning-light);
  border-color: rgba(245,158,11,0.2);
}
.reactor-stat-pill.hop-moderate .reactor-stat-value { color: var(--warning-dark); }

.reactor-stat-pill.hop-close {
  background: var(--danger-light);
  border-color: rgba(239,68,68,0.2);
}
.reactor-stat-pill.hop-close .reactor-stat-value { color: var(--danger-dark); }

/* Compact flow diagram */
.reactor-flow-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.reactor-flow-endpoint {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.reactor-flow-endpoint svg { flex-shrink: 0; }
.reactor-flow-endpoint.source svg { stroke: var(--danger); }
.reactor-flow-endpoint.dest svg { stroke: var(--success); }

.reactor-flow-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.reactor-flow-cat {
  font-size: 0.6rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reactor-flow-connector {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 60px;
}

.reactor-flow-line {
  flex: 1;
  height: 1px;
  background: var(--gray-300);
}

.reactor-flow-hop-badge {
  padding: 2px 8px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Findings grid */
.reactor-findings {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--gray-100);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.reactor-finding {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-card);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.reactor-finding-label {
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.7rem;
  padding-top: 1px;
}

.reactor-finding-value {
  color: var(--gray-700);
}

.reactor-finding.good .reactor-finding-value { color: var(--success-dark); }
.reactor-finding.bad .reactor-finding-value { color: var(--danger-dark); }
.reactor-finding.summary {
  background: var(--primary-subtle);
}
.reactor-finding.summary .reactor-finding-label { color: var(--primary); }
.reactor-finding.summary .reactor-finding-value { color: var(--primary-dark); font-weight: 500; }

/* Evidence Dimensions Card */
.evidence-dimensions-card {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.evidence-dimensions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 14px 4px;
  background: var(--white);
}

.evidence-dimension {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 10px 14px;
  background: var(--white);
}

.evidence-signal-bar {
  width: 3px;
  min-height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}
.evidence-signal-bar.strong-dismiss { background: var(--success); }
.evidence-signal-bar.dismiss { background: #6cc070; }
.evidence-signal-bar.neutral { background: var(--gray-300); }
.evidence-signal-bar.flag { background: var(--warning); }
.evidence-signal-bar.strong-flag { background: var(--danger); }

.evidence-content { flex: 1; min-width: 0; }

.evidence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.evidence-dimension-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.evidence-signal-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 3px;
}
.evidence-signal-label.strong-dismiss { color: var(--success-dark); background: var(--success-light); }
.evidence-signal-label.dismiss { color: #3a7d3e; background: #e8f5e9; }
.evidence-signal-label.neutral { color: var(--gray-500); background: var(--gray-100); }
.evidence-signal-label.flag { color: var(--warning-dark); background: var(--warning-light); }
.evidence-signal-label.strong-flag { color: var(--danger-dark); background: var(--danger-light); }

.evidence-value {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
  line-height: 1.4;
}

.evidence-explanation {
  font-size: 0.75rem;
  color: var(--gray-400);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .evidence-dimension { padding: 8px 10px; }
  .evidence-header { flex-direction: column; align-items: flex-start; gap: 2px; }
}

/* Footer */
.reactor-unified-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-top: 1px solid var(--gray-100);
  font-size: 0.65rem;
  color: var(--gray-400);
}

/* Responsive */
@media (max-width: 600px) {
  .reactor-flow-compact { flex-direction: column; gap: 8px; }
  .reactor-flow-connector { width: 100%; min-width: auto; }
  .reactor-flow-name { max-width: none; }
  .reactor-finding { grid-template-columns: 1fr; gap: 2px; }
  .reactor-stats-row { flex-wrap: wrap; }
}

/* Risk score card */
.risk-card {
  border: 1px solid var(--border);
  overflow: visible;
}

/* Breakdown list */
.risk-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Each expandable row */
.risk-detail {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.risk-detail[open] {
  background: var(--gray-50);
}

.risk-detail-summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 4px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}

.risk-detail-summary::-webkit-details-marker { display: none; }
.risk-detail-summary:hover { background: var(--gray-50); }

.risk-detail-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.risk-detail-label {
  width: 60px;
  font-size: 0.7rem;
  color: var(--gray-500);
  flex-shrink: 0;
}

.risk-detail-bar {
  flex: 1;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}

.risk-detail-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease-out;
}

.risk-detail-score {
  width: 36px;
  text-align: right;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-700);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.risk-detail-chevron {
  flex-shrink: 0;
  color: var(--gray-300);
  transition: transform 0.2s ease;
}

.risk-detail[open] .risk-detail-chevron {
  transform: rotate(180deg);
  color: var(--gray-500);
}

.risk-detail-matched {
  margin-top: 2px;
  margin-left: 68px;
  font-size: 0.6rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Scoring table dropdown */
.risk-table {
  padding: 4px 4px 6px 4px;
}

.risk-table-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 0.65rem;
  color: var(--gray-400);
}

.risk-table-row.active {
  background: white;
  color: var(--gray-800);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.risk-table-name { flex: 1; }

.risk-table-score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 20px;
  text-align: right;
}

/* ==========================================================================
   Compliance Action Card
   ========================================================================== */

.compliance-card {
  border: 1px solid var(--border);
  overflow: visible;
}

/* Recommendation context bar */
.compliance-rec-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.compliance-rec-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.compliance-rec-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  letter-spacing: 0.04em;
}

.compliance-body { padding: 16px; }

/* AI Analysis — native <details> collapsible */
.compliance-ai-details {
  margin-bottom: 14px;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.compliance-ai-details summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--gray-50);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.compliance-ai-details summary::-webkit-details-marker { display: none; }

.compliance-ai-details summary svg { flex-shrink: 0; opacity: 0.5; }

.compliance-chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.compliance-ai-details[open] .compliance-chevron {
  transform: rotate(180deg);
}

.compliance-ai-text {
  padding: 10px 12px;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--gray-600);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid var(--gray-100);
}

/* Form */
.compliance-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compliance-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.compliance-form-group label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.compliance-required {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--danger);
  text-transform: lowercase;
  letter-spacing: 0;
}

.compliance-form-group select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  font-weight: 500;
  background: white;
  color: var(--gray-800);
  cursor: pointer;
}

.compliance-form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.compliance-form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  line-height: 1.6;
  resize: vertical;
  color: var(--gray-700);
}

.compliance-form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.compliance-clear-btn {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: transparent;
  border: none;
  color: var(--gray-400);
  font-size: 0.6rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: color 0.15s;
}

.compliance-clear-btn:hover { color: var(--gray-600); }

/* Submit button */
.compliance-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  background: var(--gray-900);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
}

.compliance-submit-btn:hover:not(:disabled) {
  background: var(--gray-800);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.compliance-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.compliance-submit-btn.btn-submitted {
  background: var(--success-dark);
}

.compliance-api-off {
  padding: 10px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* Last update footer */
.compliance-last-update {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  font-size: 0.68rem;
  color: var(--gray-400);
}

.compliance-last-update strong { color: var(--gray-500); }

/* Detail page responsive */
@media (max-width: 1024px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .detail-aside {
    position: static;
  }
  .info-grid-compact {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .info-grid-compact {
    grid-template-columns: 1fr;
  }
  .info-grid-compact .info-cell.span-2,
  .info-grid-compact .info-cell.full-width {
    grid-column: 1;
  }
}

/* ==========================================================================
   Decision Banner
   ========================================================================== */

.decision-banner {
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.decision-text {
  flex: 1 1 280px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.decision-banner.flag {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border-left: 4px solid var(--danger);
}

.decision-banner.dismiss {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-left: 4px solid var(--success);
}

.decision-banner.review {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-left: 4px solid var(--warning);
}

.decision-banner.pending {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border-left: 4px solid #7c3aed;
}

.decision-banner.unanalyzed {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border-left: 4px solid var(--info);
}

.decision-banner.analyzing {
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8e 100%);
  color: white;
}

.analysis-progress-pipeline {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 12px 0 8px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  opacity: 0.4;
  transition: opacity 0.3s;
}

.progress-step.active {
  opacity: 1;
  font-weight: 600;
}

.progress-step.completed {
  opacity: 0.7;
}

.progress-step.completed svg {
  color: #4ade80;
}

.progress-connector {
  width: 20px;
  height: 2px;
  background: rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.analysis-progress-detail {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 4px;
}

.decision-text h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.decision-text p {
  opacity: 0.8;
  font-size: 0.85rem;
}

.decision-meta { text-align: right; }
.decision-meta .confidence { font-size: 2.5rem; font-weight: 700; }
.decision-meta .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; }

/* AI verdict summary strip inside decision banner */
.decision-ai-summary {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: -1px;
}
.decision-ai-summary-label {
  font-size: var(--text-2xs);
  font-weight: 700;
  color: inherit;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.decision-ai-summary-text {
  font-size: var(--text-xs);
  line-height: 1.6;
  opacity: 0.8;
  min-width: 0;
  overflow-wrap: anywhere;
}
.decision-ai-summary .evidence-pills-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Evidence dimension pills */
.evidence-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.evidence-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--text-2xs);
  line-height: 1.4;
  white-space: nowrap;
}
.evidence-pill-dim {
  font-weight: 600;
  opacity: 0.7;
}

/* Question cards for PENDING */
.pending-questions { margin-top: 16px; }
.question-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; margin-bottom: 12px; }
.question-card .q-text { font-weight: 600; margin-bottom: 6px; }
.question-card .q-why { font-size: 0.85em; color: var(--gray-500); margin-bottom: 8px; }
.question-card .q-outcomes { display: flex; gap: 12px; font-size: 0.82em; color: var(--gray-600); margin-bottom: 8px; }
.question-card .q-outcomes span { flex: 1; padding: 4px 8px; background: var(--gray-50); border-radius: 4px; }
.question-card textarea { width: 100%; min-height: 60px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; font-size: 0.9em; resize: vertical; font-family: var(--font-sans); }
.btn-submit-answers { margin-top: 12px; padding: 10px 24px; background: #7c3aed; color: white; border: none; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; font-family: var(--font-sans); }
.btn-submit-answers:hover { background: #6d28d9; }
.btn-submit-answers:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================================================
   Info Grid
   ========================================================================== */

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.info-item .label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-400); margin-bottom: 2px; }
.info-item .value { font-size: 0.85rem; font-weight: 500; }
.info-item.full-width { grid-column: 1 / -1; }

/* ==========================================================================
   Rules Section
   ========================================================================== */

.rules-section { margin-bottom: 12px; }
.rules-section:last-child { margin-bottom: 0; }
.rules-section h4 { font-size: 0.65rem; color: var(--gray-500); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.rules-list { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-badge { padding: 3px 7px; border-radius: 4px; font-size: 0.65rem; font-weight: 500; }
.rule-met { background: #ecfdf5; color: var(--success-dark); }
.rule-not { background: var(--gray-100); color: var(--gray-400); }
.rule-reactor { background: #fffbeb; color: var(--warning-dark); }

/* ==========================================================================
   Comment Box
   ========================================================================== */

.comment-box {
  background: var(--gray-50);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* AI Analysis Expandable */
.ai-analysis-container { position: relative; }
.ai-analysis-content { transition: max-height 0.3s ease-out; overflow: hidden; }
.ai-analysis-content.collapsed { max-height: 120px; }
.ai-analysis-content.collapsed::after { content: ''; position: absolute; bottom: 28px; left: 0; right: 0; height: 40px; background: linear-gradient(to bottom, transparent, rgba(236,253,245,0.95)); pointer-events: none; }
.ai-analysis-content.expanded { max-height: none; }
.ai-analysis-toggle { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; padding: 5px 10px; margin-top: 4px; background: transparent; border: 1px solid var(--border); border-radius: 4px; color: var(--gray-500); font-size: 0.7rem; font-weight: 500; cursor: pointer; transition: all 0.15s; font-family: var(--font-sans); }
.ai-analysis-toggle:hover { background: var(--gray-50); color: var(--gray-700); }
.ai-analysis-toggle .toggle-icon { transition: transform 0.2s; }

/* ==========================================================================
   Forms & Buttons
   ========================================================================== */

.action-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.form-group select,
.form-group input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: white;
  font-family: var(--font-sans);
}

.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.form-row .form-group { flex: 1; }

.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-200);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: var(--success-dark);
}

.btn-success.btn-submitted {
  background: #059669;
  cursor: default;
}

/* ==========================================================================
   Reactor Card
   ========================================================================== */

.reactor-card {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
}

.reactor-card .card-header {
  background: transparent;
  border-bottom: 1px solid #93c5fd;
  color: #1d4ed8;
}

.reactor-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.reactor-stat {
  text-align: center;
  padding: 8px;
  background: white;
  border-radius: 6px;
}

.reactor-stat .value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1d4ed8;
}

.reactor-stat .label {
  font-size: 0.7rem;
  color: var(--gray-500);
  text-transform: uppercase;
}

/* Reactor Graph Section */
.reactor-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: auto;
}

.reactor-status.analyzed {
  background: #d1fae5;
  color: #065f46;
}

.reactor-status.pending {
  background: #fef3c7;
  color: #92400e;
}

.reactor-pending {
  padding: 12px;
  background: #f9fafb;
  border-radius: 6px;
  text-align: center;
  margin-bottom: 12px;
}

.reactor-pending p {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.btn-reactor {
  background: #1d4ed8;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.btn-reactor:hover {
  background: #1e40af;
}

.reactor-link-container {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #93c5fd;
}

.btn-reactor-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #1d4ed8;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-reactor-link:hover {
  background: #1e40af;
}

.reactor-no-url {
  margin-top: 12px;
  padding: 8px;
  text-align: center;
}

.reactor-cache-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
}

.reactor-cache-info svg {
  flex-shrink: 0;
}

.btn-reactor-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  padding: 0;
  background: transparent;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  color: #1d4ed8;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reactor-refresh:hover {
  background: #1d4ed8;
  color: white;
  border-color: #1d4ed8;
}

.btn-reactor-refresh:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Reactor Graph Preview Card Styles */
.reactor-graph-preview {
  margin-top: 16px;
  border: 1px solid #e0e7ff;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
}

.reactor-graph-preview-visual {
  padding: 24px 16px;
  background: white;
}

.reactor-graph-preview-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 8px;
  min-width: 100px;
  text-align: center;
}

.flow-node svg {
  opacity: 0.9;
}

.flow-node span {
  font-size: 0.75rem;
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-node.source {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border: 1px solid #fecaca;
  color: #dc2626;
}

.flow-node.destination {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

.flow-path {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  max-width: 150px;
}

.flow-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, #c7d2fe, #a5b4fc, #c7d2fe);
  position: relative;
}

.flow-line::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-left-color: #a5b4fc;
}

.flow-hops {
  padding: 4px 10px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.reactor-graph-preview-action {
  padding: 16px;
  text-align: center;
  border-top: 1px solid #c7d2fe;
}

.btn-view-reactor-graph {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-view-reactor-graph:hover {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.reactor-graph-note {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #6366f1;
}

/* D3 Interactive Graph */
.reactor-d3-container {
  width: 100%;
  height: 400px;
  margin-top: 16px;
  border: 1px solid #e0e7ff;
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
  position: relative;
}

.reactor-d3-container svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

.reactor-d3-container svg:active {
  cursor: grabbing;
}

.reactor-tooltip {
  position: absolute;
  padding: 8px 12px;
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: 6px;
  font-size: 0.78rem;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  max-width: 320px;
  line-height: 1.4;
}

.reactor-tooltip code {
  background: #334155;
  padding: 1px 4px;
  border-radius: 3px;
}

.reactor-node { cursor: pointer; }
.reactor-node-label {
  font-size: 0.7rem;
  fill: #64748b;
  pointer-events: none;
}

/* Pulse animation for alert (destination) node */
@keyframes reactor-alert-pulse {
  0%   { opacity: 0.7; r: attr(r); }
  50%  { opacity: 0;   }
  100% { opacity: 0.7; }
}
.reactor-alert-pulse {
  animation: reactor-alert-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

.reactor-edge {
  cursor: pointer;
  transition: stroke-opacity 0.15s;
}

.reactor-graph-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.reactor-graph-controls button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  color: #475569;
  transition: all 0.15s;
}

.reactor-graph-controls button:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.reactor-analytics-bar {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
  align-items: center;
}

.reactor-analytics-bar .stat {
  font-weight: 600;
  color: #1e293b;
}

.reactor-graph-legend {
  display: flex;
  gap: 14px;
  padding: 6px 12px;
  font-size: 0.75rem;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
  align-items: center;
}

.reactor-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Node detail panel (click) */
.reactor-node-detail {
  border-top: 1px solid #e2e8f0;
  padding: 10px 14px;
  font-size: 0.8rem;
  background: #f8fafc;
}

.reactor-node-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.reactor-node-detail-cat {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
}

.reactor-node-detail-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #94a3b8;
  padding: 0 4px;
}

.reactor-node-detail-close:hover { color: #475569; }

.reactor-node-detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 16px;
}

.reactor-node-detail-body .label {
  font-weight: 600;
  color: #64748b;
}

.reactor-node-detail-body code {
  font-size: 0.72rem;
  word-break: break-all;
}

.reactor-no-url-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  margin-top: 16px;
  background: #f9fafb;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  color: #6b7280;
  text-align: center;
}

.reactor-no-url-card p {
  margin-top: 8px;
  font-size: 0.85rem;
}

/* Responsive adjustments for flow diagram */
@media (max-width: 480px) {
  .reactor-graph-preview-diagram {
    flex-direction: column;
    gap: 4px;
  }

  .flow-path {
    flex-direction: column;
    max-width: none;
    width: 100%;
  }

  .flow-line {
    width: 2px;
    height: 20px;
    background: linear-gradient(180deg, #c7d2fe, #a5b4fc, #c7d2fe);
  }

  .flow-line::after {
    right: 50%;
    top: auto;
    bottom: -4px;
    transform: translateX(50%);
    border: 4px solid transparent;
    border-top-color: #a5b4fc;
    border-left-color: transparent;
  }
}

/* Spin animation for loading indicators */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spin {
  animation: spin 1s linear infinite;
}

/* ==========================================================================
   Modals & Settings
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  transform: translateY(-16px) scale(0.98);
  transition: transform 0.2s;
}

.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  position: sticky;
  top: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  z-index: 1;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.12s;
}

.modal-close:hover {
  color: var(--gray-800);
  background: var(--gray-100);
}

.modal-body {
  padding: 20px;
}

/* Account Modal */
.account-modal { max-width: 480px; }

.setting-group { margin-bottom: 20px; }
.setting-group:last-child { margin-bottom: 0; }

.setting-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-description {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.setting-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.setting-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.account-display-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-800);
  padding: 8px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}

.env-badge-small {
  display: inline-block;
  padding: 3px 10px;
  background: var(--primary);
  color: white;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.token-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  resize: vertical;
  min-height: 56px;
}

.account-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Batch Analyze Modal
   ========================================================================== */

.batch-analyze-modal { max-width: 400px; }
.batch-status-modal { max-width: 550px; }

.batch-confirm-text {
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-bottom: 14px;
}

.batch-summary-section {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.batch-summary-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.batch-summary-header svg { color: var(--primary); }

.batch-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.batch-breakdown-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 10px;
  border: 1px solid var(--gray-200);
}

.breakdown-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--gray-700);
}

.breakdown-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.breakdown-dot.severe { background: #dc2626; }
.breakdown-dot.high { background: #f97316; }
.breakdown-dot.medium { background: #eab308; }
.breakdown-dot.low { background: #22c55e; }
.breakdown-dot.category { background: var(--primary); }

.breakdown-count {
  margin-left: auto;
  font-weight: 600;
  color: var(--gray-800);
}

.batch-token-section { margin-bottom: 14px; }

.batch-token-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 14px;
}

.batch-token-warning-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 6px;
}

.batch-token-warning-header svg { flex-shrink: 0; }

.batch-token-warning p {
  font-size: 0.85rem;
  color: #78350f;
  margin-bottom: 10px;
  line-height: 1.5;
}

.batch-token-warning .btn {
  background: #f59e0b;
  color: white;
  border: none;
}

.batch-token-warning .btn:hover { background: #d97706; }

.batch-token-ready {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-left: 4px solid #10b981;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.batch-token-ready svg { color: #059669; flex-shrink: 0; }
.batch-token-ready span { font-size: 0.85rem; color: #065f46; font-weight: 500; }

.batch-actions-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.batch-actions-footer .btn { display: inline-flex; align-items: center; gap: 8px; }
.batch-actions-footer .btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================================================
   Batch Results Modal
   ========================================================================== */

.batch-results-modal { max-width: 700px; max-height: 85vh; }

.batch-results-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-left: 4px solid #10b981;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.batch-results-summary.has-errors {
  background: #fffbeb;
  border-color: #fde68a;
  border-left-color: #f59e0b;
}

.batch-results-summary svg { flex-shrink: 0; color: #059669; }
.batch-results-summary.has-errors svg { color: #d97706; }
.batch-results-summary-text { flex: 1; }
.batch-results-summary-title { font-size: 0.95rem; font-weight: 600; color: #065f46; }
.batch-results-summary.has-errors .batch-results-summary-title { color: #92400e; }
.batch-results-summary-detail { font-size: 0.85rem; color: #047857; margin-top: 2px; }
.batch-results-summary.has-errors .batch-results-summary-detail { color: #b45309; }

.batch-results-breakdown { margin-bottom: 16px; }

.results-breakdown-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.results-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.results-breakdown-card {
  padding: 14px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid;
}

.results-breakdown-card.flag { background: #fef2f2; border-color: #fecaca; }
.results-breakdown-card.dismiss { background: #f0fdf4; border-color: #bbf7d0; }
.results-breakdown-card.review { background: #fffbeb; border-color: #fde68a; }

.results-breakdown-count { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.results-breakdown-card.flag .results-breakdown-count { color: var(--danger); }
.results-breakdown-card.dismiss .results-breakdown-count { color: var(--success); }
.results-breakdown-card.review .results-breakdown-count { color: var(--warning); }

.results-breakdown-label { font-size: 0.75rem; font-weight: 500; color: var(--gray-600); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

.batch-results-table-container { margin-bottom: 16px; max-height: 250px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.batch-results-table-container .results-breakdown-title { position: sticky; top: 0; background: white; padding: 10px 12px; margin-bottom: 0; border-bottom: 1px solid var(--border); z-index: 1; }

.batch-results-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.batch-results-table th { background: var(--gray-50); padding: 8px 10px; text-align: left; font-weight: 600; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); border-bottom: 1px solid var(--border); position: sticky; top: 40px; }
.batch-results-table td { padding: 8px 10px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.batch-results-table tr:last-child td { border-bottom: none; }
.batch-results-table tr:hover { background: var(--gray-50); }
.batch-results-table .alert-id-link { color: var(--primary); text-decoration: none; font-family: var(--font-mono); font-size: 0.78rem; }
.batch-results-table .alert-id-link:hover { text-decoration: underline; }
.batch-results-table .risk-score { display: flex; align-items: center; gap: 6px; }
.batch-results-table .risk-score-bar { width: 48px; height: 5px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.batch-results-table .risk-score-fill { height: 100%; border-radius: 3px; }
.batch-results-table .risk-score-fill.high { background: var(--danger); }
.batch-results-table .risk-score-fill.medium { background: var(--warning); }
.batch-results-table .risk-score-fill.low { background: var(--success); }
.batch-results-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }

@media (max-width: 500px) { .batch-breakdown-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .results-breakdown-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; } .results-breakdown-card { padding: 10px 8px; } .results-breakdown-count { font-size: 1.4rem; } }

/* ==========================================================================
   Sync Button
   ========================================================================== */

.sync-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sync {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--primary-subtle);
  border: 1px solid #93c5fd;
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.btn-sync:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
}

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

.btn-sync .sync-icon {
  transition: transform 0.3s ease;
}

.btn-sync.syncing .sync-icon {
  animation: spin 1s linear infinite;
}

.last-synced {
  font-size: 0.7rem;
  color: var(--gray-400);
  white-space: nowrap;
}

/* ==========================================================================
   Status Indicators
   ========================================================================== */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16,185,129,0.4);
}

.status-dot.offline {
  background: #ef4444;
}

.status-dot.checking {
  background: #f59e0b;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-text { font-size: 0.85rem; color: var(--gray-700); }
.status-text.online { color: var(--success); }
.status-text.offline { color: var(--danger); }

.config-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
}

.config-indicator.api-on { background: rgba(16,185,129,0.1); color: #10b981; }
.config-indicator.api-off { background: rgba(239,68,68,0.1); color: #ef4444; }

/* Status message (toast-like, detail page) */
.status-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
  transform: translateX(-50%) translateY(-20px);
  box-shadow: var(--shadow-lg);
  max-width: 90%;
  text-align: center;
}

.status-message.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.status-message.success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.status-message.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.status-message.warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.modified-badge { display: inline-block; padding: 2px 7px; background: #fffbeb; color: #92400e; border-radius: 4px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; margin-left: 8px; }

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-notification {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 10px 18px;
  background: var(--gray-900);
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  transform: translateY(-16px);
  transition: all 0.25s ease;
  pointer-events: none;
  font-family: var(--font-sans);
}

.toast-notification.show { opacity: 1; transform: translateY(0); }
.toast-notification.success { background: var(--success); }
.toast-notification.error { background: var(--danger); }
.toast-notification.warning { background: var(--warning); color: #1f2937; }
.toast-notification.info { background: var(--info); }

/* ==========================================================================
   Env Badge / Login / User
   ========================================================================== */

.env-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.env-badge.env-test { background: rgba(99,102,241,0.15); color: #818cf8; border: 1px solid rgba(99,102,241,0.25); }
.env-badge.env-uat { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.env-badge.env-prod { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }

.btn-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-user:hover { background: var(--gray-200); }
.btn-user.logged-in { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.3); }

.login-modal { max-width: 400px; }
.login-modal .setting-label .required { color: #ef4444; font-weight: normal; }
.login-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ==========================================================================
   Reactor Card
   ========================================================================== */

.reactor-card { background: linear-gradient(135deg, var(--primary-subtle), var(--primary-light)); border: 1px solid #93c5fd; }
.reactor-card .card-header { background: transparent; border-bottom: 1px solid #93c5fd; color: var(--primary); }
.reactor-info { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.reactor-stat { text-align: center; padding: 8px; background: white; border-radius: var(--radius-sm); }
.reactor-stat .value { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.reactor-stat .label { font-size: 0.65rem; color: var(--gray-500); text-transform: uppercase; }

.reactor-status { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 0.6rem; font-weight: 600; text-transform: uppercase; margin-left: auto; }
.reactor-status.analyzed { background: #ecfdf5; color: #065f46; }
.reactor-status.pending { background: #fffbeb; color: #92400e; }

.reactor-pending { padding: 12px; background: var(--gray-50); border-radius: var(--radius-sm); text-align: center; margin-bottom: 12px; }
.reactor-pending p { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 12px; }

.btn-reactor { background: var(--primary); color: white; border: none; padding: 8px 14px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: background 0.15s; font-family: var(--font-sans); }
.btn-reactor:hover { background: var(--primary-hover); }
.reactor-link-container { margin-top: 12px; padding-top: 12px; border-top: 1px solid #93c5fd; }
.btn-reactor-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--primary); color: white; text-decoration: none; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; transition: background 0.15s; }
.btn-reactor-link:hover { background: var(--primary-hover); text-decoration: none; }
.reactor-no-url { margin-top: 12px; padding: 8px; text-align: center; }
.reactor-cache-info { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; color: var(--gray-500); margin-top: 12px; padding: 8px 10px; background: rgba(255,255,255,0.7); border-radius: var(--radius-sm); }
.reactor-cache-info svg { flex-shrink: 0; }
.btn-reactor-refresh { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-left: auto; padding: 0; background: transparent; border: 1px solid #93c5fd; border-radius: 4px; color: var(--primary); cursor: pointer; transition: all 0.15s; }
.btn-reactor-refresh:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-reactor-refresh:disabled { opacity: 0.5; cursor: not-allowed; }

/* Reactor Graph Preview */
.reactor-graph-preview { margin-top: 16px; border: 1px solid #e0e7ff; border-radius: var(--radius-lg); overflow: hidden; background: linear-gradient(135deg, #eef2ff, #e0e7ff); }
.reactor-graph-preview-visual { padding: 24px 16px; background: white; }
.reactor-graph-preview-diagram { display: flex; align-items: center; justify-content: center; gap: 8px; }
.flow-node { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px; border-radius: var(--radius-md); min-width: 100px; text-align: center; }
.flow-node svg { opacity: 0.9; }
.flow-node span { font-size: 0.7rem; font-weight: 500; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-node.source { background: linear-gradient(135deg, #fef2f2, #fee2e2); border: 1px solid #fecaca; color: #dc2626; }
.flow-node.destination { background: linear-gradient(135deg, #f0fdf4, #dcfce7); border: 1px solid #bbf7d0; color: #16a34a; }
.flow-path { display: flex; align-items: center; gap: 4px; flex: 1; max-width: 150px; }
.flow-line { flex: 1; height: 2px; background: linear-gradient(90deg, #c7d2fe, #a5b4fc, #c7d2fe); position: relative; }
.flow-line::after { content: ''; position: absolute; right: -4px; top: 50%; transform: translateY(-50%); border: 4px solid transparent; border-left-color: #a5b4fc; }
.flow-hops { padding: 4px 10px; background: linear-gradient(135deg, #4f46e5, #6366f1); color: white; border-radius: 12px; font-size: 0.65rem; font-weight: 600; white-space: nowrap; }
.reactor-graph-preview-action { padding: 16px; text-align: center; border-top: 1px solid #c7d2fe; }
.btn-view-reactor-graph { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: linear-gradient(135deg, #4f46e5, #6366f1); color: white; border: none; border-radius: var(--radius-md); font-size: 0.85rem; font-weight: 600; text-decoration: none; cursor: pointer; transition: all 0.15s; box-shadow: 0 4px 12px rgba(79,70,229,0.25); }
.btn-view-reactor-graph:hover { background: linear-gradient(135deg, #4338ca, #4f46e5); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,70,229,0.35); }
.reactor-graph-note { margin-top: 6px; font-size: 0.7rem; color: #6366f1; }
.reactor-no-url-card { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; margin-top: 16px; background: var(--gray-50); border: 2px dashed var(--border); border-radius: var(--radius-md); color: var(--gray-500); text-align: center; }
.reactor-no-url-card p { margin-top: 8px; font-size: 0.85rem; }

@media (max-width: 480px) {
  .reactor-graph-preview-diagram { flex-direction: column; gap: 4px; }
  .flow-path { flex-direction: column; max-width: none; width: 100%; }
  .flow-line { width: 2px; height: 20px; background: linear-gradient(180deg, #c7d2fe, #a5b4fc, #c7d2fe); }
  .flow-line::after { right: 50%; top: auto; bottom: -4px; transform: translateX(50%); border: 4px solid transparent; border-top-color: #a5b4fc; border-left-color: transparent; }
}

/* ==========================================================================
   Recommendation Section & Modal
   ========================================================================== */

.recommendation-section { margin-bottom: 20px; }
.recommendation-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; font-size: 0.75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.recommendation-header svg { opacity: 0.6; }

.btn-reanalyze { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--info); color: white; border: none; border-radius: var(--radius-sm); font-size: 0.7rem; font-weight: 500; cursor: pointer; text-transform: none; letter-spacing: normal; transition: all 0.15s; font-family: var(--font-sans); }
.btn-reanalyze:hover { background: var(--info-dark); }
.btn-reanalyze:disabled { background: var(--gray-400); cursor: not-allowed; }
.btn-reanalyze svg { opacity: 1; }
.btn-reanalyze svg.spin { animation: spin 1s linear infinite; }

.btn-read-more { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; padding: 5px 10px; background: rgba(0,0,0,0.08); border: none; border-radius: 4px; font-size: 0.7rem; font-weight: 500; cursor: pointer; transition: background 0.15s; font-family: var(--font-sans); }
.btn-read-more:hover { background: rgba(0,0,0,0.12); }
.decision-banner.flag .btn-read-more { color: #991b1b; }
.decision-banner.dismiss .btn-read-more { color: #065f46; }
.decision-banner.review .btn-read-more { color: #92400e; }

.recommendation-modal { max-width: 700px; }
.recommendation-modal .modal-body { padding: 0; }
.rec-section { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.rec-section:last-child { border-bottom: none; }
.rec-section-title { font-size: 0.7rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.rec-section-title svg { opacity: 0.5; }
.rec-summary { background: var(--gray-50); border-radius: var(--radius-md); padding: 14px; margin-bottom: 14px; }
.rec-summary-action { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.02em; }
.rec-summary-action.flag { color: var(--danger); }
.rec-summary-action.dismiss { color: var(--success); }
.rec-summary-action.review { color: var(--warning); }
.rec-summary-reason { font-size: 0.85rem; color: var(--gray-700); line-height: 1.6; }
.rec-full-comment { background: #ecfdf5; border-left: 3px solid #10b981; padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.85rem; line-height: 1.7; color: var(--gray-700); white-space: pre-wrap; }
.rec-rules-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.rec-rule { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 0.78rem; }
.rec-rule.met { background: #ecfdf5; color: #065f46; }
.rec-rule.not-met { background: var(--gray-100); color: var(--gray-400); }
.rec-rule.needs-reactor { background: #fffbeb; color: #92400e; }
.rec-rule-icon { flex-shrink: 0; }
.rec-rule-name { flex: 1; text-transform: capitalize; }
.rec-factors { display: flex; flex-wrap: wrap; gap: 6px; }
.rec-factor { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--gray-100); border-radius: var(--radius-sm); font-size: 0.78rem; }
.rec-factor-label { color: var(--gray-500); }
.rec-factor-value { font-weight: 600; color: var(--gray-800); }
.rec-reactor-path { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--primary-subtle); border-radius: var(--radius-md); border: 1px solid #bfdbfe; }
.rec-reactor-entity { text-align: center; padding: 8px 12px; background: white; border-radius: var(--radius-sm); min-width: 90px; }
.rec-reactor-entity.illicit { border: 2px solid var(--danger); }
.rec-reactor-entity.user { border: 2px solid var(--success); }
.rec-reactor-entity-name { font-weight: 600; font-size: 0.85rem; }
.rec-reactor-entity-cat { font-size: 0.65rem; color: var(--gray-500); text-transform: uppercase; }
.rec-reactor-arrow { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rec-reactor-arrow-line { width: 100%; height: 2px; background: linear-gradient(90deg, var(--danger), var(--success)); position: relative; }
.rec-reactor-arrow-line::after { content: ''; position: absolute; right: 0; top: -4px; border: 5px solid transparent; border-left-color: var(--success); }
.rec-reactor-hops { font-size: 0.7rem; font-weight: 600; color: var(--primary); background: white; padding: 2px 7px; border-radius: 10px; }

@media (max-width: 600px) { .rec-rules-grid { grid-template-columns: 1fr; } .rec-reactor-path { flex-direction: column; } .rec-reactor-arrow { width: 100%; transform: rotate(90deg); } }

/* ==========================================================================
   Icon Button
   ========================================================================== */

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* ==========================================================================
   History & Analysis
   ========================================================================== */

.btn-history { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 0.7rem; font-weight: 500; color: var(--gray-600); background: var(--gray-100); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s; font-family: var(--font-sans); }
.btn-history:hover { background: var(--gray-200); color: var(--gray-700); }
.btn-history svg { stroke: currentColor; }
.history-summary { padding: 10px 14px; background: var(--gray-50); border-radius: var(--radius-md); margin-bottom: 14px; font-size: 0.85rem; color: var(--gray-600); }
.history-timeline { display: flex; flex-direction: column; gap: 14px; }
.history-entry { position: relative; padding-left: 18px; border-left: 2px solid var(--gray-200); }
.history-entry.current { border-left-color: var(--success); }
.history-entry::before { content: ''; position: absolute; left: -6px; top: 0; width: 10px; height: 10px; background: var(--gray-300); border-radius: 50%; border: 2px solid white; }
.history-entry.current::before { background: var(--success); }
.history-entry-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.history-badge { display: inline-block; padding: 2px 7px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; border-radius: 4px; }
.history-badge.current { background: #ecfdf5; color: #059669; }
.history-badge.version { background: var(--gray-200); color: var(--gray-600); }
.history-date { font-size: 0.7rem; color: var(--gray-500); }
.history-duration {
  font-size: 0.68rem;
  color: var(--gray-600);
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: auto;
  white-space: nowrap;
}
.history-entry-content { background: white; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; }
.history-entry.current .history-entry-content { border-color: #a7f3d0; background: linear-gradient(to right, rgba(16,185,129,0.03), white); }
.history-action { display: inline-block; padding: 3px 8px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; border-radius: 4px; margin-bottom: 6px; }
.history-action.flag { background: #fef2f2; color: #dc2626; }
.history-action.dismiss { background: #f0fdf4; color: #16a34a; }
.history-action.review { background: #fefce8; color: #ca8a04; }
.history-action.unknown { background: var(--gray-100); color: var(--gray-600); }
.history-details { display: flex; gap: 14px; font-size: 0.78rem; color: var(--gray-600); margin-bottom: 6px; }
.history-reason { font-size: 0.78rem; color: var(--gray-700); margin: 0 0 6px; line-height: 1.5; }
.history-meta { display: flex; gap: 14px; font-size: 0.7rem; color: var(--gray-500); padding-top: 6px; border-top: 1px dashed var(--gray-200); }
.history-meta span { display: flex; align-items: center; gap: 4px; }
.history-meta svg { opacity: 0.6; }
.history-comment { margin-top: 8px; font-size: 0.7rem; }
.history-comment summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.history-comment summary:hover { text-decoration: underline; }
.history-comment pre { margin-top: 6px; padding: 8px 10px; background: var(--gray-50); border-radius: var(--radius-sm); font-size: 0.7rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; }

/* ==========================================================================
   Env / Settings
   ========================================================================== */

.env-selector-row { display: flex; gap: 8px; align-items: center; }
.env-select { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; background: white; cursor: pointer; font-family: var(--font-sans); }
.env-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.btn-env-reset { display: flex; align-items: center; gap: 4px; padding: 8px 10px; background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.78rem; color: var(--gray-600); cursor: pointer; transition: all 0.15s; font-family: var(--font-sans); }
.btn-env-reset:hover { background: var(--gray-50); color: var(--gray-800); }
.env-warning { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; padding: 8px 10px; background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius-sm); font-size: 0.78rem; color: #92400e; }
.env-warning svg { flex-shrink: 0; margin-top: 2px; }
.env-info-display { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--gray-50); border-radius: var(--radius-md); }
.env-badge-large { padding: 6px 14px; font-size: 0.85rem; font-weight: 700; border-radius: var(--radius-sm); background: linear-gradient(135deg, #ecfdf5, #d1fae5); color: #166534; border: 1px solid #86efac; }
.env-badge-large.test { background: linear-gradient(135deg, #ecfdf5, #d1fae5); color: #166534; border-color: #86efac; }
.env-badge-large.uat { background: linear-gradient(135deg, #fffbeb, #fef3c7); color: #92400e; border-color: #fcd34d; }
.env-badge-large.prod { background: linear-gradient(135deg, #fef2f2, #fee2e2); color: #991b1b; border-color: #fca5a5; }
.btn-change-env { font-size: 0.78rem; color: var(--primary); text-decoration: none; margin-left: auto; }
.btn-change-env:hover { text-decoration: underline; }

/* Toggle Switch */
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--gray-50); border-radius: var(--radius-md); }
.toggle-label { font-size: 0.85rem; font-weight: 500; }
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--gray-300); border-radius: 24px; transition: 0.2s; }
.toggle-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

.api-status { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--gray-50); border-radius: var(--radius-md); margin-top: 10px; }
.command-box { background: var(--gray-900); color: var(--gray-200); padding: 10px 14px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.78rem; display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.command-box code { flex: 1; }
.command-copy { background: rgba(255,255,255,0.1); border: none; color: var(--gray-400); padding: 3px 6px; border-radius: 4px; cursor: pointer; font-size: 0.7rem; }
.command-copy:hover { background: rgba(255,255,255,0.2); color: white; }

/* ==========================================================================
   CA Info & Meta
   ========================================================================== */

.ca-last-update { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--primary-subtle); border: 1px solid #bfdbfe; border-radius: var(--radius-sm); font-size: 0.78rem; color: var(--primary); margin-bottom: 14px; }
.ca-last-update svg { flex-shrink: 0; opacity: 0.7; }
.ca-last-update strong { font-weight: 600; }
.meta-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 0.78rem; color: var(--gray-500); padding: 10px 14px; background: var(--gray-50); border-radius: var(--radius-md); }
.footer { text-align: center; padding: 14px; color: var(--gray-400); font-size: 0.7rem; }

/* ==========================================================================
   Guide Page
   ========================================================================== */

.guide-content { max-width: 100%; margin: 0 auto; background: var(--bg-card); border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; }
.guide-content .hiw-section { padding: 24px 32px; }
.guide-content .hiw-footer { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.how-it-works-modal { max-width: 800px; max-height: 90vh; }
.how-it-works-content { padding: 0; }
.hiw-section { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.hiw-section:last-of-type { border-bottom: none; }
.hiw-section h4 { font-size: 0.85rem; font-weight: 600; color: var(--gray-800); margin-bottom: 10px; display: flex; align-items: center; }
.hiw-section p { font-size: 0.85rem; color: var(--gray-600); line-height: 1.6; }
.hiw-flow { display: flex; align-items: stretch; gap: 8px; overflow-x: auto; padding: 4px 0; }
.hiw-flow-step { flex: 1; min-width: 140px; background: var(--gray-50); border-radius: var(--radius-md); padding: 10px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.hiw-step-num { width: 26px; height: 26px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.hiw-step-content { display: flex; flex-direction: column; gap: 2px; }
.hiw-step-content strong { font-size: 0.78rem; color: var(--gray-800); }
.hiw-step-content span { font-size: 0.7rem; color: var(--gray-500); }
.hiw-flow-arrow { display: flex; align-items: center; color: var(--gray-400); font-size: 1.2rem; flex-shrink: 0; }
.hiw-score-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.hiw-score-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--gray-50); border-radius: var(--radius-sm); }
.hiw-score-label { font-weight: 600; font-size: 0.78rem; color: var(--gray-800); min-width: 60px; }
.hiw-score-range { font-size: 0.7rem; font-weight: 600; color: var(--primary); background: var(--primary-light); padding: 2px 6px; border-radius: 4px; }
.hiw-score-desc { font-size: 0.7rem; color: var(--gray-500); flex: 1; }
.hiw-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.hiw-table th, .hiw-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.hiw-table th { background: var(--gray-50); font-weight: 600; color: var(--gray-600); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em; }
.hiw-table tr:last-child td { border-bottom: none; }
.hiw-table .flag-row td:first-child { border-left: 3px solid var(--danger); }
.hiw-table .dismiss-row td:first-child { border-left: 3px solid var(--success); }
.hiw-table .review-row td:first-child { border-left: 3px solid var(--warning); }
.hiw-table .badge { font-size: 0.6rem; padding: 2px 7px; }
.hiw-table .badge.flag { background: #fef2f2; color: var(--danger); }
.hiw-table .badge.dismiss { background: #ecfdf5; color: var(--success); }
.hiw-table .badge.review { background: #fffbeb; color: var(--warning); }
.hiw-rules-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.hiw-rules-list li { font-size: 0.78rem; color: var(--gray-700); padding: 7px 10px; background: var(--gray-50); border-radius: var(--radius-sm); border-left: 3px solid var(--danger); }
.hiw-rules-list li strong { color: var(--gray-800); }
.hiw-section:has(.badge.dismiss) .hiw-rules-list li { border-left-color: var(--success); }
.hiw-rules-list.reactor li { border-left-color: var(--info); }
.hiw-section.ai-section { background: linear-gradient(135deg, #f5f3ff, #ede9fe); }
.hiw-ai-components { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.hiw-ai-item { padding: 8px 12px; background: white; border-radius: var(--radius-sm); border-left: 3px solid var(--info); }
.hiw-ai-item strong { display: block; font-size: 0.78rem; color: #7c3aed; margin-bottom: 2px; }
.hiw-ai-item span { font-size: 0.7rem; color: var(--gray-500); }
.hiw-section.highlight { background: #fffbeb; border-left: 4px solid #f59e0b; }
.hiw-section.highlight h4 { color: #92400e; margin-bottom: 6px; }
.hiw-section.highlight p { color: #78350f; }
.hiw-footer { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 14px 20px; background: var(--gray-50); font-size: 0.7rem; color: var(--gray-500); border-top: 1px solid var(--border); }

/* KYT Thresholds */
.kyt-thresholds { background: var(--gray-50); }
.threshold-group { margin-bottom: 16px; background: white; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.threshold-group:last-of-type { margin-bottom: 0; }
.threshold-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.threshold-header.severe { background: linear-gradient(135deg, #fef2f2, #fee2e2); }
.threshold-header.high { background: linear-gradient(135deg, #fff7ed, #ffedd5); }
.threshold-header.medium { background: linear-gradient(135deg, #fefce8, #fef9c3); }
.threshold-header.low { background: linear-gradient(135deg, #f0fdf4, #dcfce7); }
.severity-badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.severity-badge.severe { background: #dc2626; color: white; }
.severity-badge.high { background: #ea580c; color: white; }
.severity-badge.medium { background: #ca8a04; color: white; }
.severity-badge.low { background: #16a34a; color: white; }
.threshold-subtitle { font-size: 0.78rem; color: var(--gray-600); font-weight: 500; }
.threshold-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.threshold-table thead { background: var(--gray-50); }
.threshold-table th { padding: 8px 14px; text-align: left; font-weight: 600; color: var(--gray-700); border-bottom: 1px solid var(--border); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; }
.threshold-table td { padding: 8px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.threshold-table tbody tr:last-child td { border-bottom: none; }
.threshold-table tbody tr:hover { background: var(--gray-50); }
.threshold-table td:first-child { font-weight: 500; color: var(--gray-800); }
.threshold-table td:last-child { font-family: var(--font-mono); font-size: 0.7rem; color: var(--gray-600); }

/* Auto-Rules stacked block (FLAG then DISMISS) */
.auto-rules-heading { font-size: 0.78rem; font-weight: 600; color: var(--gray-800); text-transform: uppercase; letter-spacing: 0.05em; margin: 22px 0 10px; }
.auto-rules-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.auto-rules-table { font-size: 0.78rem; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.auto-rules-table thead th { background: var(--gray-50); padding: 8px 10px; font-size: 0.75rem; }
.auto-rules-table tbody td:first-child { width: 22%; font-weight: 600; color: var(--gray-700); }
.auto-rules-table tbody td:last-child { color: var(--gray-600); }
.auto-rules-sub { font-size: 0.7rem; color: var(--gray-500); font-weight: 500; margin-left: 6px; text-transform: none; letter-spacing: 0; }

/* Risk Score Formula table */
.formula-table { font-size: 0.78rem; table-layout: fixed; }
.formula-table td { vertical-align: middle; }
.formula-table td.formula-component { font-weight: 600; color: var(--gray-800); background: var(--primary-subtle); border-right: 1px solid var(--border); text-align: left; }
.formula-table td.formula-max { font-family: var(--font-mono); font-weight: 600; color: var(--primary); background: var(--primary-subtle); text-align: center; border-right: 1px solid var(--border); }
.formula-table td.formula-score { font-family: var(--font-mono); font-weight: 600; color: var(--gray-900); text-align: center; }
.formula-table tr.formula-divider td { border-top: 2px solid var(--border); }
.formula-table tr.formula-total td { background: var(--gray-50); font-weight: 600; color: var(--gray-900); border-top: 2px solid var(--gray-300); }
.formula-table tr.formula-total td.formula-component,
.formula-table tr.formula-total td.formula-max { background: var(--primary-light); }
.formula-fallback { color: var(--gray-500); font-size: 0.7rem; font-style: italic; }

/* Category Score Reference */
.category-score-table td:first-child { text-align: center; font-family: var(--font-mono); font-size: 0.9rem; color: var(--primary); background: var(--primary-subtle); width: 70px; }
.category-score-table td:nth-child(2) { font-weight: 500; color: var(--gray-800); font-size: 0.78rem; }
.category-score-table td:nth-child(3) { text-align: center; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; color: var(--success-dark); }
.category-score-table tr.kyt-inactive td:nth-child(3) { color: var(--gray-500); }
.category-score-table tr.kyt-inactive td:nth-child(2) { color: var(--gray-500); font-style: italic; }
.category-score-table tr.kyt-inactive td:first-child { color: var(--gray-400); background: var(--gray-50); }

/* Risk Score Calculator */
.calc-section { background: linear-gradient(135deg, var(--primary-subtle), #ffffff); }
.calc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; margin-bottom: 18px; }
.calc-field { display: flex; flex-direction: column; gap: 4px; }
.calc-field label { font-size: 0.7rem; font-weight: 600; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.03em; }
.calc-input { width: 100%; padding: 8px 10px; font-size: 0.82rem; color: var(--gray-800); background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; }
.calc-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.calc-output { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; padding: 14px; background: white; border: 1px solid var(--border); border-radius: var(--radius-md); }
.calc-breakdown { display: flex; flex-direction: column; gap: 4px; }
.calc-row { display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 8px; padding: 4px 8px; border-radius: var(--radius-sm); }
.calc-row:nth-child(odd) { background: var(--gray-50); }
.calc-row-label { font-size: 0.78rem; color: var(--gray-700); }
.calc-row-val { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 600; color: var(--gray-900); }
.calc-row-max { font-family: var(--font-mono); font-size: 0.7rem; color: var(--gray-500); }
.calc-total { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; background: var(--gray-50); border-radius: var(--radius-md); border: 1px solid var(--border); }
.calc-total-score { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.calc-total-label { font-size: 0.65rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.06em; }
.calc-total-value { font-family: var(--font-mono); font-size: 2.2rem; font-weight: 700; color: var(--primary-dark); line-height: 1; }
.calc-total-max { font-family: var(--font-mono); font-size: 0.75rem; color: var(--gray-500); }
.calc-total .badge { font-size: 0.75rem; padding: 4px 12px; }

/* ==========================================================================
   Session Page — Centered Card
   ========================================================================== */

.session-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  position: relative;
  padding: 24px;
  font-family: var(--font-sans);
}

.session-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.session-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.session-card-header {
  padding: 28px 28px 0;
  text-align: center;
}

.session-logo {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.session-logo svg {
  color: white;
}

.session-card-header h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.session-card-header p {
  font-size: var(--text-sm);
  color: var(--gray-500);
}

.session-card-body {
  padding: 20px 28px 24px;
}

.session-error {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  color: var(--danger-dark);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  margin-bottom: 14px;
  display: none;
}

.session-error.visible {
  display: block;
}

.session-section {
  margin-bottom: 20px;
}

.session-section:last-child {
  margin-bottom: 0;
}

.session-section-title {
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.session-field {
  margin-bottom: 14px;
}

.session-field:last-child {
  margin-bottom: 0;
}

.session-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.session-field select,
.session-field input,
.session-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  background: white;
  color: var(--gray-800);
  font-family: var(--font-sans);
}

.session-field textarea {
  font-family: var(--font-mono);
  resize: vertical;
  min-height: 56px;
  font-size: var(--text-xs);
}

.session-field select:focus,
.session-field input:focus,
.session-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.session-field input::placeholder,
.session-field textarea::placeholder {
  color: var(--gray-400);
}

.session-field .field-hint {
  font-size: var(--text-2xs);
  color: var(--gray-400);
  margin-top: 4px;
}

.btn-enter {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 20px;
  font-family: var(--font-sans);
}

.btn-enter:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-enter:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.session-footer {
  padding: 0 28px 20px;
  text-align: center;
}

.session-footer a {
  color: var(--gray-400);
  text-decoration: none;
  font-size: var(--text-xs);
}

.session-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.btn-bookmarklet {
  display: inline-block;
  padding: 7px 14px;
  background: var(--primary);
  color: white !important;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.btn-bookmarklet:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
}

kbd {
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
}

@media (max-width: 480px) {
  .session-page {
    padding: 16px;
  }

  .session-card-header {
    padding: 24px 20px 0;
  }

  .session-card-body {
    padding: 20px;
  }

  .session-footer {
    padding: 0 20px 16px;
  }
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.4s ease both;
}

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }

/* ==========================================================================
   Responsive — General
   ========================================================================== */

@media (max-width: 900px) {
  .two-column { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-aside { position: static; }
}

@media (max-width: 768px) {
  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-reset {
    margin-left: 0;
    margin-top: 4px;
  }

  td, th {
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  .hide-mobile {
    display: none;
  }

  .container {
    padding: 16px;
  }
}

@media (max-width: 700px) {
  .hiw-flow { flex-direction: column; align-items: stretch; }
  .hiw-flow-arrow { justify-content: center; transform: rotate(90deg); }
  .hiw-flow-step { flex-direction: row; text-align: left; min-width: auto; }
  .hiw-step-content { align-items: flex-start; }
  .hiw-score-grid { grid-template-columns: 1fr; }
  .hiw-ai-components { grid-template-columns: 1fr; }
  .threshold-table { font-size: 0.7rem; }
  .threshold-table th, .threshold-table td { padding: 6px 10px; }
  .guide-content .hiw-section { padding: 16px; }
  .calc-grid { grid-template-columns: 1fr; }
  .calc-output { grid-template-columns: 1fr; }
  .calc-total-value { font-size: 1.8rem; }
}

/* =============================================================================
   Investigation Hub — Triage/Investigation Mode
   ============================================================================= */

/* Action toolbar — all buttons grouped in one row */
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 6px 0;
}
.detail-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Mode toggle button in header */
.btn-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}
.btn-mode-toggle:hover {
  background: var(--primary);
  color: white;
}

/* Triage mode: single viewport, no investigation tabs */
.detail-triage .detail-investigation-tabs { display: none; }
.detail-triage .detail-sticky-bar { display: none; }

/* Investigation mode: hide triage-only elements */
.detail-investigation .detail-triage-only { display: none; }

/* =============================================================================
   Tab Component
   ============================================================================= */

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}

.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover {
  color: var(--gray-700);
  background: var(--gray-50);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

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

/* =============================================================================
   Risk Heatmap Strip
   ============================================================================= */

.risk-heatmap {
  display: flex;
  gap: 2px;
  height: 18px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}
.risk-heatmap-segment {
  position: relative;
  background: var(--gray-100);
  overflow: hidden;
}
.risk-heatmap-fill {
  position: absolute;
  inset: 0;
  transform-origin: left;
}
.risk-heatmap-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-2xs);
  color: var(--gray-400);
}

/* =============================================================================
   Tag Strip (Alert Overview)
   ============================================================================= */

.tag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.tag-strip .tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.4;
}
.tag-strip .tag-high { background: var(--danger-light); color: var(--danger-dark); font-weight: 600; }
.tag-strip .tag-medium { background: var(--warning-light); color: var(--warning-dark); }
.tag-strip .tag-low { background: var(--gray-100); color: var(--gray-600); }
.tag-strip .tag-info { background: var(--primary-light); color: var(--primary); }

/* Right-aligned label rows */
.field-rows {
  font-size: var(--text-sm);
}
.field-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  border-bottom: 1px solid var(--gray-100);
  line-height: 2;
}
.field-row:last-child { border-bottom: none; }
.field-label {
  text-align: right;
  color: var(--gray-400);
  font-size: var(--text-xs);
  padding-right: 10px;
}
.field-value {
  color: var(--gray-900);
  font-weight: 500;
  padding-left: 10px;
}

/* =============================================================================
   Triage Action Card
   ============================================================================= */

.triage-action-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

/* =============================================================================
   Submit Comment Area (shared between triage + sticky)
   ============================================================================= */

.submit-comment-area {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.submit-ai-included {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--info-dark);
  background: var(--info-light);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.submit-ai-included:hover {
  background: #ede9fe;
}
.submit-preview-chevron {
  transition: transform 0.2s;
  margin-left: 2px;
}
.submit-preview {
  padding: 6px 10px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-bottom: none;
  font-size: var(--text-xs);
  color: var(--gray-500);
  line-height: 1.5;
}
.submit-preview-content {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  white-space: pre-wrap;
  word-break: break-word;
}
.submit-comment-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.submit-comment-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* =============================================================================
   Triage Inline Action Form
   ============================================================================= */

.triage-action-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-top: none;
}
.triage-action-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: white;
  font-family: var(--font-sans);
}
.triage-action-bar select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* =============================================================================
   Sticky Action Bar (Investigation Mode)
   ============================================================================= */

.detail-sticky-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width, 0px);
  right: 0;
  z-index: 100;
  padding: 0;
  background: white;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}
.sticky-bar-inner {
  display: flex;
  flex-direction: column;
}
.sticky-ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 14px;
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--info-dark);
  background: var(--info-light);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.sticky-ai-tag:hover { background: #ede9fe; }
.sticky-preview {
  padding: 6px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}
.sticky-bar-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 14px;
}
.sticky-bar-controls select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: white;
  font-family: var(--font-sans);
}
.sticky-bar-controls input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.sticky-bar-controls input:focus,
.sticky-bar-controls select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.sticky-bar-controls .btn-primary {
  white-space: nowrap;
}

/* =============================================================================
   Node Detail Drawer (Fund Flow Tab)
   ============================================================================= */

.node-drawer {
  width: 260px;
  border-left: 1px solid var(--border);
  background: white;
  padding: 14px;
  overflow-y: auto;
  max-height: 100%;
  display: none;
}
.node-drawer.open { display: block; }

.node-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.node-drawer-name { font-weight: 600; font-size: var(--text-sm); color: var(--gray-900); }
.node-drawer-type {
  font-size: var(--text-2xs);
  padding: 1px 6px;
  border-radius: 3px;
}

.node-drawer-rows {
  font-size: var(--text-xs);
  color: var(--gray-600);
  line-height: 1.8;
}
.node-drawer-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--gray-50);
}
.node-drawer-row-label { color: var(--gray-400); }
.node-drawer-row-value { font-weight: 500; color: var(--gray-900); }

/* =============================================================================
   Fund Flow Toolbar
   ============================================================================= */

.flow-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}
.flow-toolbar-group {
  display: flex;
  gap: 2px;
}
.flow-toolbar-btn {
  padding: 4px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--gray-600);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.12s;
}
.flow-toolbar-btn:hover { background: var(--gray-100); }
.flow-toolbar-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.flow-toolbar-search {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  width: 160px;
  font-family: var(--font-sans);
}
.flow-toolbar-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* =============================================================================
   Flow Table View
   ============================================================================= */

.flow-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
.flow-table th {
  padding: 6px 8px;
  text-align: left;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: var(--text-2xs);
  border-bottom: 2px solid var(--border);
}
.flow-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-100);
}
.flow-table tr.source { background: var(--danger-light); }
.flow-table tr.destination { background: var(--primary-light); }
.flow-table tr.exchange { background: var(--warning-light); }
.flow-table tr.collapsed-group {
  color: var(--gray-500);
  cursor: pointer;
}
.flow-table tr.collapsed-group:hover { background: var(--gray-50); }

/* Fullscreen graph */
.reactor-d3-container.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: white;
  padding: 0;
}

/* =============================================================================
   Exposure Panel
   ============================================================================= */

#exposure-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

#exposure-panel svg text {
  pointer-events: none;
}

/* =============================================================================
   Responsive Adjustments for Investigation Hub
   ============================================================================= */

@media (max-width: 1024px) {
  .flow-toolbar { flex-wrap: wrap; }
  .flow-toolbar-search { width: 100%; }
  .node-drawer { width: 100%; border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 768px) {
  .triage-action-bar { flex-direction: column; }
  .triage-action-bar input { width: 100%; }
  .detail-sticky-bar { flex-direction: column; padding: 10px 16px; left: 0; }
  .detail-sticky-bar input { width: 100%; }
  .tag-strip { gap: 4px; }
  .field-row { grid-template-columns: 70px 1fr; }
}

/* ==========================================================================
   Progress Banner — persistent top bar for sync/enrichment status
   ========================================================================== */

.progress-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #1e3a5f;
  color: white;
  padding: 8px 20px;
  font-size: 0.8rem;
  transition: all 0.3s;
}

.progress-banner.hidden {
  display: none;
}

.progress-banner.paused {
  background: #92400e;
}

.progress-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1200px;
  margin: 0 auto;
}

.progress-banner-icon svg {
  display: block;
}

.progress-banner-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-banner-bar-fill {
  height: 100%;
  background: #60a5fa;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.progress-banner-bar-fill.indeterminate {
  animation: indeterminate 1.5s infinite;
  width: 30% !important;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ==========================================================================
   Bulk Dismiss Modal — bd-* namespace
   Wide flex-column layout with fixed-column data grid
   ========================================================================== */

/* Overlay reuses .modal-overlay; only the inner panel is custom */
.bd-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  width: min(92vw, 1080px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-16px) scale(0.98);
  transition: transform 0.2s;
}

.modal-overlay.show .bd-modal {
  transform: translateY(0) scale(1);
}

/* Header */
.bd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}

.bd-modal-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-900);
}

.bd-modal-title svg { color: var(--danger, #dc2626); }

/* Stats bar */
.bd-stats-bar {
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--gray-50, #f9fafb);
}

.bd-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 12px 0;
}

.bd-stat-num {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.bd-stat-lbl {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 400;
}

.bd-stat-danger .bd-stat-num { color: var(--danger, #dc2626); }
.bd-stat-warn   .bd-stat-num { color: #d97706; }
.bd-stat-muted  .bd-stat-num { color: var(--gray-500); }

.bd-stat-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 16px;
  flex-shrink: 0;
}

/* Skipped reasons inline strip */
.bd-skip-strip {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 20px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  font-size: 0.76rem;
  color: #78350f;
  flex-shrink: 0;
}

.bd-skip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.bd-skip-list li::before { content: '· '; color: #d97706; }

/* Table section — flex-1 so it takes remaining height */
.bd-table-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bd-table-cap {
  padding: 7px 20px;
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}

.bd-table-wrap {
  overflow-y: auto;
  flex: 1;
}

.bd-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.bd-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--gray-50, #f9fafb);
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.bd-table tbody tr {
  border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.bd-table tbody tr:hover td { background: var(--gray-50); }

.bd-table tbody tr.bd-row-warn td { background: #fffbeb; }
.bd-table tbody tr.bd-row-warn:hover td { background: #fef3c7; }

.bd-table td {
  padding: 7px 12px;
  vertical-align: middle;
  overflow: hidden;
}

/* Cell content helpers */
.bd-alert-id {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--gray-700);
  display: block;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.bd-user-id {
  font-size: 0.75rem;
  color: var(--gray-600);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-amount {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-800);
}

.bd-asset {
  font-size: 0.68rem;
  color: var(--gray-400);
  margin-left: 3px;
}

.bd-category {
  font-size: 0.76rem;
  color: var(--gray-700);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-meta-sub {
  font-size: 0.68rem;
  color: var(--gray-400);
  display: block;
  margin-top: 1px;
}

.bd-score {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-block;
  min-width: 28px;
  text-align: center;
}

.bd-score-high { color: #dc2626; }
.bd-score-med  { color: #d97706; }
.bd-score-low  { color: #16a34a; }

.bd-comment-text {
  font-size: 0.76rem;
  color: var(--gray-700);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bd-comment-empty {
  font-size: 0.72rem;
  color: var(--gray-400);
  font-style: italic;
}

/* Warning strip */
.bd-warning-strip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 20px;
  background: #fef2f2;
  border-top: 1px solid #fecaca;
  font-size: 0.76rem;
  color: #991b1b;
  line-height: 1.5;
  flex-shrink: 0;
}

.bd-warning-strip svg { color: #ef4444; margin-top: 2px; }

/* Footer */
.bd-modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--gray-50, #f9fafb);
  flex-shrink: 0;
}

/* Alert ID cell — float copy button right, ID wraps below as a plain block */
.bd-td-alert { position: relative; }

.bd-td-alert .bd-copy-btn {
  float: right;
  margin-left: 4px;
}

.bd-copy-btn {
  flex-shrink: 0;
  opacity: 0;
  background: none;
  border: none;
  padding: 3px;
  cursor: pointer;
  color: var(--gray-400);
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: opacity 0.1s, color 0.1s, background 0.1s;
  line-height: 0;
}

.bd-table tbody tr:hover .bd-copy-btn { opacity: 1; }
.bd-copy-btn:hover { color: var(--primary, #2563eb); background: var(--gray-100, #f3f4f6); }
.bd-copy-btn.bd-copy-done { opacity: 1; color: #16a34a; }

/* ==========================================================================
   Policies Page
   ========================================================================== */

/* Page wrapper */
.page-policies {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 860px;
}

/* Header row: title left, "+ New policy" button right */
.page-policies-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

/* Policy list — vertical stack */
.policy-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---- Policy Card ---- */
.policy-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.policy-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.policy-card--disabled {
  opacity: 0.55;
  border-color: var(--gray-200);
  background: var(--gray-50);
}

/* Card header: name + priority chip */
.policy-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.policy-card__name {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: -0.01em;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.policy-card__priority {
  flex-shrink: 0;
  display: inline-block;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* Meta line */
.policy-card__meta {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: 2px;
}

/* Body preview */
.policy-card__body {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* When fully expanded (show-more toggled), remove clamp */
.policy-card__body.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

/* Actions row */
.policy-card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Push buttons to the right, keep toggle on the left */
.policy-card__actions .switch {
  margin-right: auto;
}

/* ---- Pure CSS Toggle Switch ---- */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

/* Hide native checkbox */
.switch input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Track */
.switch__slider {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  background: var(--gray-300);
  border-radius: 10px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

/* Knob */
.switch__slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}

/* Checked state */
.switch input[type="checkbox"]:checked + .switch__slider {
  background: var(--primary);
}

.switch input[type="checkbox"]:checked + .switch__slider::before {
  transform: translateX(16px);
}

/* Focus ring for accessibility */
.switch input[type="checkbox"]:focus-visible + .switch__slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---- Warning Banner ---- */
.warning-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: var(--text-sm);
  color: var(--warning-dark);
  margin-bottom: 4px;
}

.warning-banner[hidden] {
  display: none;
}

.warning-banner::before {
  content: "⚠";
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
  font-size: var(--text-base);
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-state p {
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ---- Inline link button ---- */
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: var(--text-xs);
  padding: 0;
  text-decoration: underline;
  font-family: var(--font-sans);
  transition: color 0.12s;
}

.btn-link:hover {
  color: var(--primary-hover);
}

/* ==========================================================================
   Policy Explainer (onboarding panel)
   ========================================================================== */
.policy-explainer {
  position: relative;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(37, 99, 235, 0.08) 0%, rgba(37, 99, 235, 0) 55%),
    var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 26px 22px;
  overflow: hidden;
}

.policy-explainer::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary), var(--info));
}

.policy-explainer__collapse {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--gray-500);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.2s;
}
.policy-explainer__collapse:hover { background: var(--gray-50); color: var(--gray-700); }
.policy-explainer--collapsed .policy-explainer__collapse { transform: rotate(180deg); }

.policy-explainer__eyebrow {
  display: inline-block;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}

.policy-explainer__headline {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--gray-900);
  margin: 0 0 8px;
}
.policy-explainer__headline em {
  font-style: italic;
  color: var(--primary);
}

.policy-explainer__lede {
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--gray-600);
  max-width: 64ch;
  margin: 0 0 20px;
}

/* Steps */
.policy-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.policy-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.policy-step__num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
}

.policy-step__title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-900);
  margin: 1px 0 4px;
}

.policy-step__desc {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--gray-600);
  margin: 0;
}

.policy-step__example {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--primary-dark);
  background: var(--primary-subtle);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}

/* Collapsed state — hide everything but the eyebrow/headline */
.policy-explainer--collapsed {
  padding-bottom: 22px;
}
.policy-explainer--collapsed .policy-explainer__lede,
.policy-explainer--collapsed .policy-steps {
  display: none;
}
.policy-explainer--collapsed .policy-explainer__headline {
  margin-bottom: 0;
}

/* ==========================================================================
   Policy Toolbar + live status
   ========================================================================== */
.policy-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.policy-status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--text-sm);
  color: var(--gray-600);
}
.policy-status strong { color: var(--gray-900); font-weight: 600; }
.policy-status__muted { color: var(--gray-400); }

.policy-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gray-300);
  flex-shrink: 0;
}
.policy-status__dot--active {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-light);
}

/* ==========================================================================
   Policy card extras (status pill, toggle label)
   ========================================================================== */
.policy-card__heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.policy-pill {
  flex-shrink: 0;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
}
.policy-pill--on  { background: var(--success-light); color: var(--success-dark); }
.policy-pill--off { background: var(--gray-100); color: var(--gray-500); }

.policy-card__toggle-label {
  font-size: var(--text-xs);
  color: var(--gray-500);
  font-weight: 500;
}
.policy-card__actions-spacer { flex: 1; }

/* ==========================================================================
   Policy empty state (rich)
   ========================================================================== */
.policy-empty {
  text-align: center;
  padding: 44px 28px;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.policy-empty__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
}
.policy-empty__title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--gray-900);
  margin: 0 0 6px;
}
.policy-empty__desc {
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--gray-600);
  max-width: 52ch;
  margin: 0 auto 18px;
}
.policy-empty__templates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

/* Template chips (empty state + editor) */
.policy-template-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
  background: var(--gray-50);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.policy-template-chip:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.policy-template-chip__plus { font-weight: 700; color: var(--primary); }
.policy-template-chip--sm {
  font-size: var(--text-xs);
  padding: 3px 10px;
}

/* ==========================================================================
   Policy Editor & History Dialogs
   ========================================================================== */

/* Native <dialog> centering + backdrop */
dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 16px 48px rgba(0,0,0,0.14);
  background: var(--bg-card);
  padding: 0;
  max-height: 90vh;
  overflow-y: auto;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

/* Editor form */
.policy-editor {
  width: 840px;
  max-width: 95vw;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.policy-editor__title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.policy-editor__title--danger {
  color: var(--danger-dark);
}

/* Label wrapping input/textarea */
.policy-editor__label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.policy-editor__label input,
.policy-editor__label textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}

.policy-editor__label textarea {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  min-height: 180px;
}

.policy-editor__label input:focus,
.policy-editor__label textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Inline row: checkbox + priority */
.policy-editor__row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.policy-editor__check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
}

.policy-editor__check-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Priority label inline variant */
.policy-editor__label--inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.policy-editor__label--inline input[type="number"] {
  width: 80px;
}

/* Footer: cancel + save */
.policy-editor__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Delete modal note */
.policy-delete__note {
  font-size: var(--text-sm);
  color: var(--gray-600);
  line-height: 1.6;
}

/* ---- Editor head ---- */
.policy-editor__head { display: flex; flex-direction: column; gap: 4px; }
.policy-editor__subtitle {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--gray-500);
  margin: 0;
  max-width: 70ch;
}

/* ---- Two-column editor body ---- */
.policy-editor__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}
.policy-editor__form { display: flex; flex-direction: column; gap: 16px; }
.policy-editor__field { display: flex; flex-direction: column; gap: 4px; }

/* Body textarea lives in __field, not __label — style it to match */
.policy-editor__field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  min-height: 200px;
  color: var(--gray-800);
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}
.policy-editor__field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.policy-editor__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.policy-editor__label-text {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.policy-editor__hint {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--gray-500);
  line-height: 1.4;
}
.policy-editor__hint--inline { display: inline; }

/* Starter-template chips inside editor */
.policy-editor__templates {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.policy-editor__templates-label {
  font-size: var(--text-xs);
  color: var(--gray-400);
  margin-right: 2px;
}

/* ---- Live AI preview pane ---- */
.policy-preview {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.policy-preview__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.policy-preview__label svg {
  /* simple sparkle/AI mark drawn via border */
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--info);
  transform: rotate(45deg);
}
.policy-preview__code {
  background: var(--gray-900);
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
  border: 1px solid var(--gray-800);
}

.policy-tips {
  background: var(--info-light);
  border: 1px solid var(--info-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.policy-tips__title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--info-dark);
  margin-bottom: 6px;
}
.policy-tips__list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.policy-tips__list li {
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--gray-600);
}

/* Stack to one column on narrow viewports */
@media (max-width: 720px) {
  .policy-editor__body { grid-template-columns: 1fr; }
  .policy-preview { position: static; }
  .policy-steps { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Policy History Dialog
   ========================================================================== */

/* History dialog is wider to show body comfortably */
#policy-history {
  width: 640px;
  max-width: 95vw;
  padding: 28px;
}

/* Delete confirmation is a compact, centered prompt.
   Scope to [open] so the closed dialog keeps the UA `display: none`. */
#policy-delete-confirm[open] {
  width: 440px;
  max-width: calc(100vw - 32px);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.policy-history {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  margin: 12px 0;
  padding-right: 4px;
}

.policy-history__entry {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.policy-history__entry:hover {
  border-color: var(--border-strong);
}

.policy-history__head {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.policy-history__version {
  font-size: var(--text-xs);
  color: var(--gray-600);
  font-family: var(--font-mono);
  font-weight: 500;
}

.policy-history__date {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

.policy-history__author {
  font-size: var(--text-xs);
  color: var(--gray-600);
}

.policy-history__body {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.6;
  color: var(--gray-700);
}

.policy-history__empty {
  font-size: var(--text-sm);
  color: var(--gray-500);
  text-align: center;
  padding: 24px;
  font-style: italic;
}

/* ==========================================================================
   Action Tags (history pill badges)
   ========================================================================== */

.tag {
  display: inline-block;
  border-radius: 999px;
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  line-height: 1.5;
  white-space: nowrap;
  flex-shrink: 0;
}

.tag--create  { background: #dcfce7; color: #166534; }
.tag--update  { background: var(--primary-light); color: var(--primary-dark); }
.tag--enable  { background: #ccfbf1; color: #0f766e; }
.tag--disable { background: var(--gray-100); color: var(--gray-600); }
.tag--delete  { background: var(--danger-light); color: var(--danger-dark); }
.tag--restore { background: var(--info-light); color: var(--info-dark); }
