html {
  font-size: 87.5%;          /* 14px base → everything scales ~87.5% */
}

:root {
  /* Layout (Fixed) */
  --sidebar-w: 48px;
  --topbar-h: 56px;
  --overlay-w: 480px;
  --radius: 6px;

  /* Backgrounds (Institutional) */
  --bg: #ffffff;
  --bg-soft: #f9fafb;
  --bg-2: #f3f4f6;
  --row-hover: #f9fafb;

  /* Borders (Softer) */
  --b1: #e5e7eb;
  --b2: #f3f4f6;

  /* Text (Institutional) */
  --t1: #111827;        /* Primary (near black) */
  --t2: #6b7280;        /* Secondary (gray) */
  --t3: #9ca3af;        /* Tertiary (light gray) */

  /* Status Colors (Muted, Sophisticated) */
  --g: #059669;         --g-bg: #ecfdf5;    /* Muted green */
  --y: #d97706;         --y-bg: #fef3c7;    /* Muted amber */
  --r: #dc2626;         --r-bg: #fef2f2;    /* Red */

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  /* Font sizes (Professional hierarchy) */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;

  /* Spacing (Tight, Organized) */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;

  /* Compact measurements */
  --table-row: 44px;
  --card-padding: 16px;
}

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.4;
  background: var(--bg-soft);
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Surfaces */
.card {
  background: var(--bg);
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  padding: var(--card-padding);
}

/* Buttons */
.btn {
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid var(--b1);
  background: var(--bg);
  color: var(--t1);
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--row-hover); }

.btn-primary {
  background: #111827;
  border-color: #111827;
  color: #fff;
}
.btn-primary:hover { opacity: 0.92; }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--t2);
}
.btn-ghost:hover { color: var(--t1); }

/* Inputs */
.input {
  width: 100%;
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  background: var(--bg);
  font-family: var(--font-sans);
}
.input:focus {
  outline: 2px solid #000;
  outline-offset: 1px;
  border-color: transparent;
}

/* Table */
.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--b2);
  font-weight: 600;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--b2);
  font-size: var(--fs-base);
  height: var(--table-row);
}

.tr-hover:hover { background: var(--row-hover); cursor: pointer; }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 4px 10px;
  border: 1px solid var(--b1);
  background: var(--bg);
  border-radius: 4px;
  font-size: var(--fs-sm);
  color: var(--t2);
}

.chip .remove {
  cursor: pointer;
  opacity: 0.6;
}
.chip .remove:hover { opacity: 1; }

.chip-tag {
  background: var(--bg-2);
  border-color: var(--b2);
  color: var(--t1);
}

/* Status Badges (Institutional: less rounded) */
.badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-active { background: var(--g-bg); color: var(--g); }
.badge-warning { background: var(--y-bg); color: var(--y); }
.badge-error { background: var(--r-bg); color: var(--r); }

/* Risk Badges */
.badge-risk-low { background: #ecfdf5; color: #059669; }
.badge-risk-medium { background: #fef3c7; color: #d97706; }
.badge-risk-high { background: #fef2f2; color: #dc2626; }

/* Code Blocks */
.code {
  background: #111827;
  color: #e5e7eb;
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: auto;
  position: relative;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s2);
}

/* Overlay */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 998;
}

.overlay {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: var(--overlay-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--bg);
  border-left: 1px solid var(--b1);
  overflow: auto;
  z-index: 999;
  animation: slideIn 0.2s ease-out;
}

/* Overlay resize handle (left edge) */
.overlay-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 10;
}
.overlay-resize:hover,
.overlay-resize.dragging {
  background: var(--accent, #3b82f6);
  opacity: 0.35;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--b1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 48px;
}

.sidebar.expanded {
  width: 240px;
}

/* Sidebar header */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 12px;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo-icon {
  font-size: 22px;
  color: var(--t1);
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--t1);
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.15s;
}

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

/* Subtitle */
.sidebar-subtitle {
  font-size: 11px;
  color: var(--t3);
  padding: 0 16px 8px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s;
}

.sidebar.collapsed .sidebar-subtitle {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
  gap: 0;
}

/* Section titles */
.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 16px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s;
}

.sidebar.collapsed .sidebar-section-title {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--s2) 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Nav items */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--t2);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-soft);
  color: var(--t1);
}

.nav-item.active {
  color: var(--t1);
  background: var(--bg-2);
}

.active-indicator {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--g);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 1;
  transition: opacity 0.15s;
}

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

/* Collapsed: center icons */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}

/* Tooltip on hover (collapsed only) */
.sidebar.collapsed .nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  margin-left: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 12px;
  background: var(--t1);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  white-space: nowrap;
  border-radius: 6px;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--b1);
  z-index: 99;
  display: flex;
  align-items: center;
  padding: 0 var(--s6);
  gap: var(--s4);
  transition: left 0.2s ease;
}

.topbar-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--t1);
  flex-shrink: 0;
}

.topbar-search {
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--t3);
  pointer-events: none;
}

.topbar-search-input {
  width: 100%;
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  background: var(--bg-soft);
  font-family: var(--font-sans);
  color: var(--t1);
}
.topbar-search-input::placeholder { color: var(--t3); }
.topbar-search-input:focus {
  outline: 2px solid #000;
  outline-offset: 1px;
  border-color: transparent;
  background: var(--bg);
}

.topbar-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--t3);
  background: var(--bg-2);
  border: 1px solid var(--b1);
  border-radius: 4px;
  padding: 2px 6px;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-shrink: 0;
}

.topbar-action {
  background: none;
  border: none;
  color: var(--t2);
  cursor: pointer;
  font-size: 14px;
  padding: 6px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  transition: color 0.15s;
}
.topbar-action:hover { color: var(--t1); }

.topbar-bell { position: relative; }

.topbar-profile { font-size: 13px; font-weight: 500; }
.topbar-profile svg { flex-shrink: 0; }

/* ── Main ── */
.main {
  margin-left: 240px;
  margin-top: var(--topbar-h);
  padding: var(--s6);
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left 0.2s ease;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--s5);
}
.page-title { font-size: var(--fs-xl); font-weight: 700; color: var(--t1); letter-spacing: -0.01em; }
.page-meta { color: var(--t2); font-size: var(--fs-base); margin-top: 2px; }

/* Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--s1); }
.gap-2 { gap: var(--s2); }
.gap-3 { gap: var(--s3); }
.gap-4 { gap: var(--s4); }
.gap-6 { gap: var(--s6); }
.mb-4 { margin-bottom: var(--s4); }
.mb-6 { margin-bottom: var(--s6); }
.mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); }
.text-secondary { color: var(--t2); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.fw-600 { font-weight: 600; }
.w-full { width: 100%; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  background: var(--bg);
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  margin-bottom: var(--s3);
}

.filter-search {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  position: relative;
}
.filter-search input {
  width: 100%;
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  padding: 7px 10px 7px 30px;
  font-size: 13px;
  background: var(--bg-soft);
  font-family: var(--font-sans);
  color: var(--t1);
}
.filter-search input::placeholder { color: var(--t3); }
.filter-search input:focus {
  outline: 2px solid #000;
  outline-offset: 1px;
  border-color: transparent;
}
.filter-search svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--t3);
  pointer-events: none;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
  color: var(--t2);
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.filter-btn:hover { border-color: var(--b1); color: var(--t1); }
.filter-btn.active { border-color: var(--t1); color: var(--t1); }

.filter-sep {
  width: 1px;
  height: 24px;
  background: var(--b2);
  flex-shrink: 0;
}

/* ── Filter Panel (inline slide-down) ── */
.filter-panel {
  background: var(--bg);
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--s3);
  animation: fpSlideDown 0.2s ease-out;
}

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

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

.fp-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
}

.fp-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.fp-field,
.fp-operator,
.fp-value {
  padding: 7px 10px;
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--t1);
  background: var(--bg);
}

.fp-field { width: 140px; flex-shrink: 0; }
.fp-operator { width: 120px; flex-shrink: 0; }
.fp-value { flex: 1; min-width: 100px; }

.fp-remove {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid var(--b1);
  background: var(--bg);
  color: var(--t2);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}
.fp-remove:hover { background: var(--r-bg); color: var(--r); border-color: var(--r); }

.fp-add {
  font-size: 12px;
  color: var(--g);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  font-weight: 500;
  font-family: var(--font-sans);
}
.fp-add:hover { text-decoration: underline; }

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  background: var(--t1);
  color: var(--bg);
  font-size: 10px;
  font-weight: 600;
  border-radius: 50%;
  margin-left: 4px;
  padding: 0 4px;
}

/* ── Filter Chips ── */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s3);
}
.filter-chips:empty { display: none; }

/* ── Grouped Table ── */
.group-header {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--bg-2);
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  margin-bottom: 1px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.group-header:hover { background: #efefef; }

.group-arrow {
  font-size: 10px;
  color: var(--t2);
  width: 16px;
  text-align: center;
  transition: transform 0.15s;
}
.group-header.collapsed .group-arrow { transform: rotate(-90deg); }

.group-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--t1);
}

.group-count {
  font-size: 12px;
  color: var(--t2);
}

.group-stats {
  margin-left: auto;
  display: flex;
  gap: var(--s5);
  font-size: 12px;
  color: var(--t2);
}

.group-body {
  border: 1px solid var(--b2);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: var(--s3);
  overflow: hidden;
}
.group-header.collapsed + .group-body { display: none; }

/* Table rows inside groups */
.agent-row {
  display: grid;
  grid-template-columns: 2fr 100px 120px 90px 100px 100px 110px;
  align-items: center;
  padding: 0 var(--s4);
  height: var(--table-row);
  border-bottom: 1px solid var(--b2);
  cursor: pointer;
  transition: background 0.1s;
  font-size: var(--fs-base);
}
.agent-row:last-child { border-bottom: none; }
.agent-row:hover { background: var(--row-hover); }

.agent-row .agent-name { font-weight: 500; color: var(--t1); }
.agent-row .agent-id { font-size: 11px; color: var(--t3); font-family: var(--font-mono); }

.col-header {
  display: grid;
  grid-template-columns: 2fr 100px 120px 90px 100px 100px 110px;
  padding: 0 var(--s4);
  height: 36px;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--t2);
  font-weight: 500;
  border-bottom: 1px solid var(--b2);
  background: var(--bg);
}

/* ── Right Overlay ── */
.overlay-header {
  padding: var(--s5);
  border-bottom: 1px solid var(--b2);
}

.overlay-close {
  position: absolute;
  top: var(--s4);
  right: var(--s4);
  background: none;
  border: none;
  font-size: 18px;
  color: var(--t2);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}
.overlay-close:hover { background: var(--bg-2); color: var(--t1); }

.overlay-tabs {
  display: flex;
  border-bottom: 1px solid var(--b2);
  padding: 0 var(--s5);
}

.overlay-tab {
  padding: var(--s3) var(--s4);
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.15s;
}
.overlay-tab:hover { color: var(--t1); }
.overlay-tab.active {
  color: var(--t1);
  border-bottom-color: var(--t1);
}

.overlay-body { padding: var(--s5); }

/* Governance edit form */
.gov-form-group {
  margin-bottom: 12px;
}

.gov-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t2);
  margin-bottom: 4px;
}

.gov-input {
  font-size: 13px;
}

/* ── Metrics Grid ── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}

.metric-card {
  padding: var(--s3);
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--b2);
}
.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--t2);
  margin-bottom: 2px;
}
.metric-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--t1);
}

/* ── Sparkline ── */
.sparkline-container {
  height: 48px;
  margin-bottom: var(--s4);
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--b2);
  overflow: hidden;
  padding: var(--s2);
}
.sparkline-container svg { width: 100%; height: 100%; }

/* ── Detail Row ── */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--b2);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--t2); }
.detail-value { color: var(--t1); font-weight: 500; }

/* ── Activity Item ── */
.activity-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--b2);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }

.decision-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.decision-approved { background: var(--g-bg); color: var(--g); }
.decision-denied { background: var(--r-bg); color: var(--r); }

/* ── Loading Spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--b1);
  border-top-color: var(--t1);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: var(--s8);
  color: var(--t2);
  font-size: 13px;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: var(--s8);
  color: var(--t2);
}
.empty-state-icon { font-size: 32px; margin-bottom: var(--s3); opacity: 0.4; }
.empty-state-text { font-size: 13px; }

/* ── Settings Layout ── */
.settings-layout {
  display: flex;
  gap: 0;
  background: var(--bg);
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  min-height: 600px;
}

.settings-sidebar {
  width: 200px;
  border-right: 1px solid var(--b1);
  padding: var(--s3);
  flex-shrink: 0;
}

.settings-nav-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: var(--fs-base);
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--t2);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.settings-nav-item:hover {
  background: var(--bg-soft);
  color: var(--t1);
}

.settings-nav-item.active {
  background: var(--bg-2);
  color: var(--t1);
  font-weight: 600;
}

.settings-content {
  flex: 1;
  padding: var(--s6);
  min-width: 0;
}

.settings-section-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--t1);
  margin-bottom: 4px;
}

.settings-section-desc {
  font-size: var(--fs-base);
  color: var(--t2);
  margin-bottom: var(--s6);
}

.settings-card {
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  padding: var(--s4);
  margin-bottom: var(--s3);
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s4);
}

.settings-row-info { flex: 1; min-width: 0; }

.settings-row-label {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--t1);
}

.settings-row-desc {
  font-size: var(--fs-sm);
  color: var(--t2);
  margin-top: 2px;
}

.settings-sub {
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--b2);
}

.settings-row-inline {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.settings-help {
  font-size: var(--fs-xs);
  color: var(--t3);
  margin-top: 4px;
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--b1);
  border-radius: 12px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--g);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Blocked category chip */
.chip-blocked {
  background: var(--r-bg);
  border-color: #fecaca;
  color: var(--r);
}

/* API key row */
.api-key-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s3);
  background: var(--bg-soft);
  border: 1px solid var(--b2);
  border-radius: var(--radius);
}

/* Webhook row */
.webhook-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--radius);
}

/* Toast Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

/* ── Stat Cards (dashboard, budget) ── */
.stat-card {
  background: var(--bg);
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  padding: var(--s5);
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t2);
  font-weight: 500;
  margin-bottom: var(--s1);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--t1);
  line-height: 1.1;
}
.stat-sub {
  font-size: 12px;
  color: var(--t3);
  margin-top: var(--s1);
}

/* ── Pipeline Step Row (shared: bridge, audit, dashboard) ── */
.step-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 8px 0;
  border-bottom: 1px solid var(--b2);
  font-size: 13px;
}
.step-row:last-child { border-bottom: none; }

.step-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.step-pass { background: var(--g-bg); color: var(--g); }
.step-fail { background: var(--r-bg); color: var(--r); }
.step-skip { background: var(--bg-2); color: var(--t3); }
.step-name { flex: 1; }
.step-dur { font-size: 11px; color: var(--t3); font-family: var(--font-mono); }

/* ── Focus States (Accessibility) ── */
a:focus-visible,
button:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

.nav-item:focus-visible {
  outline: 2px solid var(--g);
  outline-offset: -2px;
  border-radius: 4px;
}

.overlay-tab:focus-visible {
  outline: 2px solid #000;
  outline-offset: -2px;
}

/* ── Hamburger (visible on desktop + mobile) ── */
.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t2);
  font-size: 18px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--radius);
  transition: all 0.15s;
}
.hamburger:hover { background: var(--bg-2); color: var(--t1); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 150;
}

/* ── Dropdown Components ── */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--b1);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: 6px;
  z-index: 1000;
  display: none;
}

.dropdown-menu.open {
  display: block;
  animation: dropdownFadeIn 0.15s ease-out;
}

.dropdown-menu-wide {
  min-width: 360px;
  max-width: 400px;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  color: var(--t1);
  font-size: 13px;
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.1s;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-2);
}

.dropdown-item-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.status-dot-green {
  color: var(--g);
  font-size: 10px;
}

.dropdown-item-danger {
  color: var(--r);
}

.dropdown-item-danger:hover {
  background: var(--r-bg);
}

.dropdown-divider {
  height: 1px;
  background: var(--b2);
  margin: 4px 0;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 8px;
}

.dropdown-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
}

.dropdown-header-profile {
  padding: 12px;
}

.profile-info {}

.profile-name-large {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
}

.profile-email {
  font-size: 12px;
  color: var(--t2);
  margin-top: 2px;
}

.btn-text-sm {
  font-size: 12px;
  color: var(--t2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  padding: 2px 4px;
  border-radius: 4px;
}
.btn-text-sm:hover { color: var(--t1); background: var(--bg-2); }

.dropdown-footer {
  border-top: 1px solid var(--b2);
  margin-top: 4px;
  padding-top: 4px;
}

.dropdown-footer-link {
  color: var(--t2);
  font-size: 12px;
}

/* ── Notification List ── */
.notification-list {
  max-height: 360px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.1s;
  text-align: left;
  position: relative;
  font-family: var(--font-sans);
}

.notification-item:hover {
  background: var(--bg-soft);
}

.notification-item.unread {
  background: #f0f7ff;
}

.notification-item.unread:hover {
  background: #e4f0fd;
}

.notification-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

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

.notification-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 3px;
}

.notification-message {
  font-size: 12px;
  color: var(--t2);
  margin-bottom: 3px;
  line-height: 1.4;
}

.notification-time {
  font-size: 11px;
  color: var(--t3);
}

.unread-dot {
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

/* ── Notification Badge (updated) ── */
.topbar-bell-badge {
  position: absolute;
  top: 2px;
  right: 0px;
  min-width: 16px;
  height: 16px;
  background: var(--r);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1.5px solid var(--bg);
}

/* ── Status Dots ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-active { background: var(--g); }
.dot-suspended { background: var(--y); }
.dot-revoked { background: var(--r); }

/* Agent cell with status dot */
.agent-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── View Controls ── */
.view-controls {
  display: flex;
  gap: 2px;
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-btn {
  padding: 6px 10px;
  background: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--t2);
  transition: all 0.1s;
}
.view-btn:hover { background: var(--bg-soft); color: var(--t1); }
.view-btn.active { background: var(--bg-2); color: var(--t1); }

/* Compact view */
.view-compact .agent-row { height: 36px; }
.view-compact .col-header { height: 30px; }

/* ── Column Config Panel ── */
.column-config-panel {
  background: var(--bg);
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--s3);
  animation: fpSlideDown 0.2s ease-out;
}

.column-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s2);
}

.column-toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.column-toggle-item:hover { background: var(--bg-soft); }
.column-toggle-item input { accent-color: var(--g); }

/* ── Bridge Tab ── */
.bridge-section {
  margin-bottom: var(--s3);
}

.bridge-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s2);
}

.bridge-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t2);
}

.btn-copy {
  padding: 4px 10px;
  border: 1px solid var(--b1);
  border-radius: 4px;
  background: var(--bg);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--t2);
  font-family: var(--font-sans);
  transition: all 0.1s;
}
.btn-copy:hover { background: var(--bg-2); color: var(--t1); }

.bridge-arrow {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: var(--s3) 0;
}

.bridge-arrow-line {
  flex: 1;
  height: 1px;
  background: var(--b1);
}

.bridge-arrow-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t2);
  white-space: nowrap;
}

.bridge-notary {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--g-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
}

.bridge-notary-icon {
  font-size: 18px;
}

.bridge-notary-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--g);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bridge-trace summary {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t2);
  cursor: pointer;
  padding: var(--s2) 0;
}
.bridge-trace summary:hover { color: var(--t1); }

.bridge-trace-content {
  padding: var(--s3) 0;
}

/* ── Transaction Cards ── */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.transaction-card {
  position: relative;
  padding: var(--s3);
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  transition: background 0.1s, border-color 0.1s;
}
.transaction-card:hover {
  background: var(--bg-soft);
  border-color: var(--t3);
}

.transaction-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.transaction-id {
  font-size: 12px;
  font-weight: 600;
  color: var(--t1);
}

.transaction-amount {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
}

.transaction-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.transaction-type {
  font-size: 12px;
  color: var(--t2);
}

.transaction-time {
  font-size: 11px;
  color: var(--t3);
}

/* ── Slider ── */
.slider-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.risk-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--b1);
  border-radius: 3px;
  outline: none;
}
.risk-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--t1);
  cursor: pointer;
}
.risk-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--t1);
  cursor: pointer;
  border: none;
}

.slider-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  min-width: 40px;
  text-align: right;
}

/* ── Chip Input ── */
.chip-input-container {
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip-input-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip-removable {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg-2);
  border: 1px solid var(--b2);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--t1);
}

.chip-remove {
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  line-height: 1;
}
.chip-remove:hover { opacity: 1; color: var(--r); }

.chip-input-field {
  flex: 1;
  min-width: 100px;
  border: none !important;
  padding: 4px !important;
  font-size: 13px;
  outline: none;
}

/* ── Responsive: < 768px ── */
@media (max-width: 768px) {
  .sidebar {
    width: 240px !important;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-overlay { display: block; }
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .sidebar-logo-text,
  .sidebar.collapsed .sidebar-subtitle,
  .sidebar.collapsed .sidebar-section-title {
    display: revert;
  }
  .sidebar.collapsed .sidebar-header {
    justify-content: flex-start;
    padding: 0 12px;
    gap: 12px;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 10px 12px;
    gap: 12px;
  }

  .topbar { left: 0 !important; }
  .topbar-search { display: none; }
  .topbar-kbd { display: none; }

  .main { margin-left: 0 !important; }

  /* Overlay → full-screen */
  .overlay {
    width: 100%;
    top: 0;
    height: 100vh;
  }

  /* Tables → horizontal scroll */
  .group-body { overflow-x: auto; }
  .agent-row, .col-header { min-width: 700px; }
  .auth-row, .auth-col-header { min-width: 900px; }
  .cand-row, .cand-col-header { min-width: 780px; }
  .feed-row, .feed-col-header { min-width: 600px; }

  /* Stats grid → 2 columns */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Dashboard → stack panels */
  .dash-layout { grid-template-columns: 1fr; }

  /* Bridge → stack vertically */
  .bridge-layout { flex-direction: column; }
  .bridge-left, .bridge-right {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--b1);
  }

  /* Governance → stack vertically */
  .gov-layout { flex-direction: column; }
  .gov-left {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--b1);
  }

  /* Filter bar → wrap */
  .filter-bar { flex-wrap: wrap; }
  .filter-sep { display: none; }

  /* Page header → stack */
  .page-header { flex-direction: column; gap: var(--s3); }

  /* Token table → scroll */
  .token-row { min-width: 600px; }
  .token-table { overflow-x: auto; }

  /* Modal → full-width */
  .modal { width: 95vw; max-height: 90vh; }

  /* Settings → stack */
  .settings-layout { flex-direction: column; }
  .settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--b1);
    display: flex;
    overflow-x: auto;
    padding: var(--s2);
    gap: var(--s1);
  }
  .settings-nav-item { white-space: nowrap; }

  /* Dropdown menus → constrained width */
  .dropdown-menu-wide {
    min-width: 280px;
    max-width: calc(100vw - 24px);
    right: -40px;
  }

  /* Filter panel rows → stack on mobile */
  .fp-row {
    flex-wrap: wrap;
  }
  .fp-field, .fp-operator { width: calc(50% - 20px); }
  .fp-value { width: 100%; }

  /* Settings cards → full width */
  .settings-row { flex-direction: column; align-items: flex-start; gap: var(--s2); }
  .settings-row-inline { flex-direction: column; align-items: flex-start; }
}
