/* ==========================================================================
   CIVALENT PROTOTYPE — Branded Stylesheet
   Style C "Stripe" aesthetic: gradients, layered shadows, editorial type
   Palette: Indigo + Copper (dark-first)

   Inherits design tokens from tokens.css — no duplicate custom properties.
   ========================================================================== */

/* --- Design Tokens (single source of truth) --- */
@import '../brand/tokens.css';

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

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

/* --- Palette activation (tokens.css uses [data-palette] selectors) --- */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Base --- */
body {
  font-family: var(--font-sans);
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background var(--duration-slow) ease, color var(--duration-slow) ease;
}

a { color: var(--text-link); text-decoration: none; transition: color var(--duration-fast); }
a:hover { color: var(--text-link-hover); }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Skip to Content (accessibility) --- */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 9999;
  padding: var(--space-3) var(--space-6);
  background: var(--gradient-primary);
  color: var(--accent-primary-text);
  font-weight: 700;
  font-size: var(--text-sm);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  text-decoration: none;
  transition: top var(--duration-normal) var(--ease-default);
}
.skip-to-content:focus {
  top: 0;
  outline: var(--focus-ring-width) solid var(--accent-primary);
  outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--duration-slow) var(--ease-default),
              background var(--duration-slow) ease,
              transform var(--duration-slow) var(--ease-default);
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.logo-icon {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.logo-icon .layer {
  position: absolute;
  border-radius: 2px;
  transform-origin: center center;
  background: var(--accent-primary);
}
.logo-icon .layer-1 { opacity: 0.3; width: 18px; height: 4px; top: 3px; left: 5px; transform: rotate(-8deg); }
.logo-icon .layer-2 { opacity: 0.6; width: 22px; height: 4px; top: 10px; left: 3px; transform: rotate(-4deg); }
.logo-icon .layer-3 { opacity: 1; width: 26px; height: 4px; top: 17px; left: 1px; transform: rotate(0deg); }

.logo-text {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-section-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
  min-height: 40px;
}

.sidebar-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  font-weight: 600;
}

.sidebar-link-new {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.sidebar-link-new:hover { color: var(--accent-primary); }

/* --- Nav Group (expandable chat section) --- */
.nav-group { position: relative; }

.nav-group-items {
  display: none;
  padding-left: 16px;
}
.nav-group.expanded .nav-group-items { display: block; }

.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 150ms;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-sublink i {
  font-size: 0.75rem;
  flex-shrink: 0;
}
.sidebar-sublink:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  background: var(--accent-primary);
  color: var(--accent-primary-text);
  border-radius: var(--radius-full);
  padding: 0 6px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-menu:hover {
  background: var(--bg-hover);
}

.sidebar-user-menu.menu-open .sidebar-user-dropdown {
  display: block !important;
}

.sidebar-user-dropdown a:hover {
  background: var(--bg-hover);
  color: var(--text-primary) !important;
}

.avatar {
  border-radius: var(--radius-full);
  background: var(--gradient-hero);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-inverse);
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.6875rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.8125rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1rem; }

.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.user-role {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* --- Hamburger button (mobile only) ---
   Uses .btn-icon.hamburger-btn to override .btn-icon display: inline-flex */
.btn-icon.hamburger-btn {
  display: none;
  font-size: 1.25rem;
}
.hamburger-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* --- Mobile sidebar overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-default);
}
.sidebar-overlay.visible {
  opacity: 1;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--duration-slow) var(--ease-default);
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border-default);
  background: rgba(11,15,34,0.6);
  backdrop-filter: blur(20px) saturate(1.5);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background var(--duration-slow) ease;
}

[data-theme="light"] .content-header {
  background: rgba(247,248,252,0.85);
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--text-primary);
}

.breadcrumb-sep {
  color: var(--border-strong);
  font-size: 0.75rem;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

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

.content-body {
  flex: 1;
  padding: 28px 32px 64px;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */
.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: var(--tracking-tighter);
  line-height: var(--leading-tight);
}

.page-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-top: 4px;
}

.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-primary-accent { color: var(--accent-primary); }

.code-text {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  color: var(--accent-primary);
}

/* ==========================================================================
   BUTTONS — Style C: gradient + glow + inset shadow + text-shadow
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
  text-decoration: none;
  white-space: nowrap;
  min-height: var(--btn-height-md);
  padding: 0 20px;
  font-size: var(--text-sm);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient-primary);
  color: var(--accent-primary-text);
  box-shadow: var(--shadow-sm), var(--shadow-button-inset);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow-primary), var(--shadow-button-inset);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-destructive {
  background: var(--status-violation);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-destructive:hover {
  background: #ef4444;
  box-shadow: var(--shadow-md), 0 0 16px rgba(248,113,113,0.2);
  transform: translateY(-1px);
}

.btn-sm {
  min-height: var(--btn-height-sm);
  padding: 0 12px;
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

.btn-lg {
  min-height: var(--btn-height-lg);
  padding: 0 28px;
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  font-size: 1rem;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* --- Alert Bell --- */
.alert-bell {
  position: relative;
}

.alert-bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 800;
  background: var(--status-violation);
  color: #fff;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
  line-height: 1;
}

/* ==========================================================================
   CARDS — Style C: gradient surface + hover elevation
   ========================================================================== */
.card {
  background: var(--gradient-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  transition: all var(--duration-normal) ease;
}

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

.card-clickable { cursor: pointer; }
.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   STAT CARDS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--gradient-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 20px;
  transition: all var(--duration-normal) ease;
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-change {
  font-size: 0.6875rem;
  font-weight: 600;
  margin-top: 8px;
}

.stat-change.positive { color: var(--status-compliant-text); }
.stat-change.negative { color: var(--status-violation-text); }
.stat-change.amber { color: var(--status-warning-text); }

/* ==========================================================================
   PROJECT HEALTH CARDS (Dashboard)
   ========================================================================== */
.project-health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.project-health-card {
  background: var(--gradient-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  position: relative;
  overflow: hidden;
}

.project-health-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-border);
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.project-health-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.project-health-card:hover::before { opacity: 1; }

.project-health-card .project-name {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.project-health-card .project-client {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.project-health-card .project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.project-health-card .compliance-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.project-health-card .compliance-row .progress-bar {
  flex: 1;
}

.project-health-card .compliance-row .compliance-pct {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--accent-primary);
  min-width: 40px;
  text-align: right;
}

.project-health-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ==========================================================================
   DETAIL HEADER CARD
   ========================================================================== */
.detail-header-card {
  background: var(--gradient-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.detail-header-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-border);
}

.detail-header-card .detail-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: var(--tracking-tighter);
  margin-bottom: 4px;
}

.detail-header-card .detail-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.detail-header-card .detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.detail-meta-item .meta-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-meta-item .meta-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
}

.detail-header-card .detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* --- Modern Detail Header (Stripe/Linear style) --- */
.detail-header-modern {
  position: relative;
  padding: 28px 32px 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  background: var(--bg-surface);
}
.detail-header-modern::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-border);
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}
.detail-header-modern .detail-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.detail-header-modern .detail-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: var(--tracking-tighter);
  line-height: var(--leading-tight);
  margin-bottom: 8px;
}
.detail-header-modern .detail-meta-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.detail-header-modern .detail-meta-inline .meta-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.detail-header-modern .detail-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.detail-header-modern .detail-stats {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.detail-header-modern .detail-stats a {
  color: var(--accent-primary);
  text-decoration: none;
}
.detail-header-modern .detail-stats a:hover {
  text-decoration: underline;
}

/* --- Permalink / Link Copy Icon --- */
.permalink-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0.3;
  cursor: pointer;
  transition: opacity 150ms, color 150ms;
  vertical-align: middle;
  margin-left: 4px;
  border: none;
  background: none;
  padding: 0;
}
.permalink-icon:hover {
  opacity: 1;
  color: var(--accent-primary);
}
h3:hover .permalink-icon,
.section-ref:hover + .permalink-icon,
.reg-content p:hover .permalink-icon,
*:hover > .permalink-icon {
  opacity: 0.7;
}

/* --- Analysis Detail View (Upload page) --- */
.analysis-detail-view {
  display: none;
}
.analysis-detail-view.active {
  display: block;
}
.uploads-main-view.hidden {
  display: none;
}

/* ==========================================================================
   BADGES & TAGS — All 7 variants per component library
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.6;
}

.badge-compliant, .badge-green {
  background: var(--status-compliant-bg);
  color: var(--status-compliant-text);
  border: 1px solid var(--status-compliant-border);
}

.badge-warning, .badge-yellow {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}

.badge-violation, .badge-red {
  background: var(--status-violation-bg);
  color: var(--status-violation-text);
  border: 1px solid var(--status-violation-border);
}

.badge-neutral, .badge-gray {
  background: var(--status-neutral-bg);
  color: var(--status-neutral-text);
  border: 1px solid var(--status-neutral-border);
}

.badge-info, .badge-blue {
  background: var(--status-info-bg);
  color: var(--status-info-text);
  border: 1px solid var(--status-info-border);
}

.badge-accent, .badge-violet {
  background: var(--accent-secondary-subtle);
  color: var(--accent-secondary);
  border: 1px solid var(--accent-secondary-muted);
}

.badge-copper {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.green { background: var(--status-compliant); }
.status-dot.yellow { background: var(--status-warning); }
.status-dot.red { background: var(--status-violation); }
.status-dot.gray { background: var(--status-neutral); }
.status-dot.blue { background: var(--status-info); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--bg-overlay);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
}

.table-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table-container th {
  text-align: left;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  user-select: none;
  transition: color 150ms ease;
}

.table-container th:hover {
  color: var(--text-primary);
}

.table-container th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.5rem;
  opacity: 0.4;
  transition: opacity 150ms ease;
}

.table-container th.sorted .sort-icon {
  opacity: 1;
  color: var(--accent-primary);
}

.table-container td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.table-container tbody tr {
  transition: background 100ms;
  cursor: pointer;
}
.table-container tbody tr:hover td { background: var(--bg-hover); }
.table-container td:first-child { color: var(--text-primary); font-weight: 500; }

/* ==========================================================================
   TABS — Pill-style per component library
   ========================================================================== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  border: 1px solid var(--border-default);
  width: fit-content;
}

.tab {
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 150ms ease;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
}

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

.tab.active {
  color: var(--accent-primary-text);
  background: var(--gradient-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.tab-count {
  font-size: 0.625rem;
  font-weight: 700;
  background: var(--bg-overlay);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.tab.active .tab-count {
  background: rgba(255,255,255,0.2);
  color: var(--accent-primary-text);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
  animation: fadeIn var(--duration-normal) var(--ease-default);
}

/* ==========================================================================
   TOOLBAR & FILTERS
   ========================================================================== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .btn-primary,
.toolbar .toolbar-action,
.toolbar .btn-action-primary {
  margin-left: auto;
}

.search-input {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-input i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.search-input input {
  width: 100%;
  height: var(--search-height);
  padding: 0 14px 0 38px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: all var(--duration-normal) ease;
}

.search-input input::placeholder { color: var(--text-muted); }

.search-input input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--accent-primary-subtle), var(--shadow-glow-primary);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 150ms ease;
}

.filter-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.filter-btn.active {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border-color: var(--accent-primary-muted);
  font-weight: 600;
}

/* ==========================================================================
   FORMS — Premium 10px radius, enhanced focus
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: all var(--duration-normal) ease;
}

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

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--accent-primary-subtle), var(--shadow-glow-primary);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--status-violation);
  box-shadow: 0 0 0 4px var(--status-violation-bg);
}

.form-input.valid,
.form-select.valid,
.form-textarea.valid {
  border-color: var(--status-compliant);
  box-shadow: 0 0 0 4px var(--status-compliant-bg);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--status-violation-text);
  margin-top: 4px;
  display: none;
}
.form-error.visible { display: block; }

.form-textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.6;
}

.form-select {
  appearance: none;
  cursor: pointer;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23586380' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* --- Toggle Switch --- */
.toggle-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.toggle-switch:last-child { border-bottom: none; }

.toggle-switch-label {
  font-size: var(--text-sm);
  font-weight: 500;
}
.toggle-switch-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: all 150ms;
  flex-shrink: 0;
}
.toggle-track.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 150ms;
}
.toggle-track.active::after {
  transform: translateX(20px);
}

/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */
.progress-bar {
  height: 6px;
  background: var(--bg-overlay);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  transition: width 0.6s var(--ease-default);
}

.progress-fill.green { background: var(--status-compliant); }
.progress-fill.yellow { background: var(--status-warning); }
.progress-fill.red { background: var(--status-violation); }

/* ==========================================================================
   ALERT ITEMS
   ========================================================================== */
.alert-item {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 100ms;
}

.alert-item:last-child { border-bottom: none; }

.alert-severity {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  min-height: 32px;
}

.alert-severity.critical { background: var(--status-violation); }
.alert-severity.high { background: var(--status-warning); }
.alert-severity.medium { background: var(--status-info); }
.alert-severity.info { background: var(--status-neutral); }

.alert-content { flex: 1; }
.alert-title { font-size: var(--text-base); font-weight: 600; margin-bottom: 2px; }
.alert-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}
.alert-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 8px;
}

.alert-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ==========================================================================
   DIFF BLOCK
   ========================================================================== */
.diff-block {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 12px;
  display: none;
}
.diff-block.visible { display: block; }

.diff-removed {
  background: var(--status-violation-bg);
  text-decoration: line-through;
  color: var(--status-violation-text);
  padding: 8px 12px;
  text-decoration: line-through;
  border-bottom: 1px solid var(--border-default);
}

.diff-added {
  background: var(--status-compliant-bg);
  color: var(--status-compliant-text);
  padding: 8px 12px;
}

/* ==========================================================================
   FLYOUT PANEL
   ========================================================================== */
.flyout-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-default);
}
.flyout-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.flyout {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  z-index: calc(var(--z-overlay) + 1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-spring);
}
.flyout.visible {
  transform: translateX(0);
}

.flyout-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-default);
}
.flyout-header h3 {
  font-size: var(--text-lg);
  font-weight: 700;
}
.flyout-close { margin-left: auto; }

.flyout-body {
  flex: 1;
  overflow-y: auto;
}

.flyout-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-default);
  text-align: center;
}

/* ==========================================================================
   DETAIL PANEL (side panel in split views)
   ========================================================================== */
.content-split {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}

.detail-panel {
  background: var(--gradient-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
  max-height: calc(100vh - var(--topbar-height) - 40px);
  overflow-y: auto;
}

.detail-panel-title {
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-default);
}

.detail-field {
  margin-bottom: 16px;
}

.detail-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.5;
}

.code-block {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  background: var(--bg-root);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ==========================================================================
   GRID UTILITIES
   ========================================================================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

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

.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-6 { margin-bottom: 24px; }

/* ==========================================================================
   SECTION
   ========================================================================== */
.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

/* ==========================================================================
   REVIEW CARDS (Dashboard)
   ========================================================================== */
.review-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.review-card {
  background: var(--gradient-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  position: relative;
  overflow: hidden;
}

.review-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-border);
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.review-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

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

.review-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.review-card-client {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.review-card-location {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.review-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.review-card-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ==========================================================================
   ACTIVITY FEED
   ========================================================================== */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child { border-bottom: none; }

.activity-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--gradient-hero);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-inverse);
  flex-shrink: 0;
}

.activity-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.activity-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.activity-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   UPLOAD ZONE
   ========================================================================== */
.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-xl);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
}

.upload-zone:hover {
  border-color: var(--accent-primary);
  background: var(--accent-primary-subtle);
}

.upload-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upload-text {
  font-size: var(--text-md);
  color: var(--text-secondary);
  font-weight: 500;
}

.upload-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 6px;
}

/* ==========================================================================
   CHAT LAYOUT
   ========================================================================== */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  height: calc(100vh - var(--topbar-height));
}

.chat-main {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-default);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.chat-message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-message-avatar.human {
  background: var(--accent-primary-muted);
  color: var(--accent-primary);
}

.chat-message-avatar.ai {
  background: var(--gradient-hero);
  color: var(--text-inverse);
}

.chat-message-body {
  max-width: 680px;
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-secondary);
}

.chat-message.user .chat-message-body {
  background: var(--accent-primary-muted);
  border: 1px solid var(--accent-primary-subtle);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
  padding: 12px 16px;
  color: var(--text-primary);
}

.chat-message-body p { margin-bottom: 8px; }
.chat-message-body p:last-child { margin-bottom: 0; }

.chat-citation {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--accent-primary-subtle);
  border: 1px solid var(--accent-primary-muted);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.chat-citation:hover {
  background: var(--accent-primary-muted);
  color: var(--accent-primary-hover);
}

.chat-input-area {
  padding: 16px 32px 24px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.chat-input-row {
  display: flex;
  gap: 12px;
}

.chat-input-wrapper {
  flex: 1;
}

.chat-input-wrapper textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  outline: none;
  resize: none;
  transition: all var(--duration-normal) ease;
  line-height: 1.5;
}

.chat-input-wrapper textarea::placeholder { color: var(--text-muted); }

.chat-input-wrapper textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--accent-primary-subtle), var(--shadow-glow-primary);
}

.chat-pin-btn {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 150ms;
}

.chat-pin-btn:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary-muted);
  background: var(--accent-primary-subtle);
}

/* Chat sidebar */
.chat-sidebar {
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-surface);
}

.chat-sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.chat-source-item {
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 150ms;
}

.chat-source-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.source-badge {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: var(--accent-primary-subtle);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 4px;
}

.source-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
}

.source-detail {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   COMPARISON TABLE
   ========================================================================== */
.comparison-cell {
  padding: 8px 0;
}

.comparison-cell.aligned {
  border-left: 3px solid var(--status-compliant);
  padding-left: 12px;
}

.comparison-cell.conflict {
  border-left: 3px solid var(--status-violation);
  padding-left: 12px;
  background: var(--status-violation-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: -4px 0;
  padding: 8px 12px;
}

.comparison-cell.gap {
  border-left: 3px solid var(--status-warning);
  padding-left: 12px;
  background: var(--status-warning-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: -4px 0;
  padding: 8px 12px;
}

/* ==========================================================================
   INTAKE
   ========================================================================== */
.intake-card {
  background: var(--gradient-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  transition: all var(--duration-normal) ease;
}
.intake-card:hover {
  border-color: var(--border-strong);
}

.intake-processing-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.intake-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
}

.intake-step-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
}

.intake-step.complete .intake-step-icon {
  background: var(--status-compliant);
  color: var(--text-inverse);
}
.intake-step.complete .intake-step-text { color: var(--text-secondary); }

.intake-step.active {
  background: var(--accent-primary-subtle);
}
.intake-step.active .intake-step-icon {
  background: var(--accent-primary);
  color: var(--accent-primary-text);
}
.intake-step.active .intake-step-text {
  color: var(--accent-primary);
  font-weight: 600;
}

.intake-step.pending .intake-step-icon {
  background: var(--bg-overlay);
  color: var(--text-muted);
}
.intake-step.pending .intake-step-text { color: var(--text-muted); }

/* ==========================================================================
   SECTION NAV (Regulation Detail)
   ========================================================================== */
.section-nav {
  list-style: none;
  padding: 0;
}

.section-nav li { margin-bottom: 2px; }

.section-nav a {
  display: block;
  padding: 8px 12px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: all 150ms;
}

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

.section-nav a.active {
  border-left-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-primary-subtle);
  font-weight: 600;
}

.code-ref {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent-primary);
  margin-right: 6px;
}

/* ==========================================================================
   COPY CITATION
   ========================================================================== */
.copy-citation {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 150ms;
  margin-left: 8px;
  vertical-align: middle;
}
.copy-citation:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary-muted);
  background: var(--accent-primary-subtle);
}

/* ==========================================================================
   APPROVAL WORKFLOW
   ========================================================================== */
.approval-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.approval-step:last-child { border-bottom: none; }

.approval-step-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.approval-step-indicator.done {
  background: var(--status-compliant);
  color: var(--text-inverse);
}
.approval-step-indicator.pending {
  background: var(--bg-overlay);
  color: var(--text-muted);
  border: 1px solid var(--border-default);
}
.approval-step-indicator.current {
  background: var(--accent-primary);
  color: var(--accent-primary-text);
}

/* ==========================================================================
   THEME TOGGLE
   ========================================================================== */
.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  font-size: 1rem;
  font-family: var(--font-sans);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ==========================================================================
   SKELETON LOADING
   ========================================================================== */
.skeleton {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  color: transparent !important;
}
.skeleton * { visibility: hidden; }

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-skeleton);
  background-size: 200% 100%;
  animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
}

.skeleton-text {
  height: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
  margin-bottom: 8px;
}
.skeleton-text::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-skeleton);
  background-size: 200% 100%;
  animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--card-radius);
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-skeleton);
  background-size: 200% 100%;
  animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-loading .stat-card,
.skeleton-loading .review-card,
.skeleton-loading .project-health-card,
.skeleton-loading .table-container tbody tr td,
.skeleton-loading .card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  color: transparent !important;
}
.skeleton-loading .stat-card *,
.skeleton-loading .review-card *,
.skeleton-loading .project-health-card *,
.skeleton-loading .table-container tbody tr td *,
.skeleton-loading .card * {
  visibility: hidden;
}
.skeleton-loading .stat-card::after,
.skeleton-loading .review-card::after,
.skeleton-loading .project-health-card::after,
.skeleton-loading .table-container tbody tr td::after,
.skeleton-loading .card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-skeleton);
  background-size: 200% 100%;
  animation: skeleton-shimmer var(--skeleton-duration) ease-in-out infinite;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-xl);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.5;
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  opacity: 0;
  transition: all var(--duration-slow) var(--ease-spring);
}
.toast.visible {
  transform: translateX(0);
  opacity: 1;
}
.toast.hiding {
  transform: translateX(120%);
  opacity: 0;
}

.toast-success {
  background: var(--status-compliant-bg);
  color: var(--status-compliant-text);
  border: 1px solid var(--status-compliant-border);
}
.toast-error {
  background: var(--status-violation-bg);
  color: var(--status-violation-text);
  border: 1px solid var(--status-violation-border);
}
.toast-warning {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}
.toast-info {
  background: var(--status-info-bg);
  color: var(--status-info-text);
  border: 1px solid var(--status-info-border);
}

.toast-message { flex: 1; }

.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
  transition: opacity 150ms;
}
.toast-close:hover { opacity: 1; }

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-default);
}
.modal-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: calc(var(--z-modal) + 1);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-spring);
}
.modal.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}
.modal.modal-lg { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-default);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: all 150ms ease;
  padding: 0;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-default);
}

body.modal-open {
  overflow: hidden;
}

/* ==========================================================================
   ACTION DRAWER (left-side flyout for create/submit/upload forms)
   ========================================================================== */
.action-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-default);
}
.action-drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.action-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 420px;
  max-width: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  z-index: calc(var(--z-modal) + 1);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.action-drawer.open {
  transform: translateX(0);
}

.action-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.action-drawer-header h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.action-drawer-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: all 150ms ease;
  padding: 0;
}
.action-drawer-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.action-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.action-drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

body.drawer-open {
  overflow: hidden;
}

/* --- Action trigger button (Copper accent, consistent across pages) --- */
.btn-action-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  background: var(--accent-secondary);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn-action-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-action-primary:active {
  transform: translateY(0) scale(0.97);
}

/* Mobile: drawer takes full width */
@media (max-width: 768px) {
  .action-drawer {
    width: 100%;
  }
}

/* ==========================================================================
   DROPDOWN MENU
   ========================================================================== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--z-dropdown);
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--duration-normal) var(--ease-default);
}

.dropdown.dropdown-open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 100ms ease;
  text-align: left;
  text-decoration: none;
}

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

.dropdown-divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-2) 0;
}

/* ==========================================================================
   COMMAND PALETTE (Cmd+K)
   ========================================================================== */
.command-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: calc(var(--z-modal) + 10);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-fast) var(--ease-default);
}
.command-palette-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.command-palette {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  z-index: calc(var(--z-modal) + 11);
  width: 540px;
  max-width: 90%;
  max-height: 60vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-spring);
}
.command-palette.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

.command-palette-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-default);
}

.command-palette-search i {
  color: var(--text-muted);
  font-size: 1.125rem;
}

.command-palette-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text-primary);
}
.command-palette-search input::placeholder { color: var(--text-muted); }

.command-palette-results {
  overflow-y: auto;
  max-height: calc(60vh - 60px);
  padding: var(--space-2);
}

.command-palette-group {
  padding: var(--space-2) var(--space-3);
}

.command-palette-group-title {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2-5) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 100ms ease;
}

.command-palette-item:hover,
.command-palette-item.focused {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.command-palette-item i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ==========================================================================
   SCROLL ANIMATIONS
   ========================================================================== */
.animate-on-scroll {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.animate-on-scroll.visible {
  opacity: 1;
}

/* ==========================================================================
   SLIDE/FADE TRANSITIONS
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.fade-in { animation: fadeIn var(--duration-normal) var(--ease-default); }
.slide-up { animation: slideUp var(--duration-slow) var(--ease-default); }
.slide-in-right { animation: slideInRight var(--duration-slow) var(--ease-default); }

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */

/* --- 1200px: content-split single column, flyout full-width --- */
@media (max-width: 1200px) {
  .content-split {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    display: none;
  }

  .flyout {
    width: 100%;
  }

  .project-health-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- 1024px: sidebar 200px, grid-3 becomes 2 columns --- */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  .main-content {
    margin-left: 200px;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .review-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- 768px: sidebar hidden (hamburger), grid 1 column, stats 2 columns --- */
@media (max-width: 768px) {
  .btn-icon.hamburger-btn {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    z-index: 200;
  }

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

  .sidebar-overlay.visible {
    display: block;
  }

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

  .content-header {
    padding: 0 16px;
  }

  .content-body {
    padding: 20px 16px 48px;
  }

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

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

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

  .review-cards {
    grid-template-columns: 1fr;
  }

  .project-health-grid {
    grid-template-columns: 1fr;
  }

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

  .search-input {
    max-width: none;
  }

  .page-title-row {
    flex-direction: column;
    gap: 12px;
  }

  .command-palette {
    top: 10%;
    width: 95%;
  }

  .detail-header-card .detail-meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tabs {
    overflow-x: auto;
    width: 100%;
  }
}
