:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
}

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--gray-900);
  color: white;
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-logo {
  padding: 0 20px 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--gray-700);
  margin-bottom: 10px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--gray-700);
  color: white;
}
.sidebar-section {
  padding: 16px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gray-500);
}
.main { flex: 1; margin-left: 240px; }
.topbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.content { padding: 24px; }

/* Login */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--gray-100);
}
.login-box {
  background: white;
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 400px;
  max-width: 90vw;
}
.login-box h1 { margin-bottom: 24px; text-align: center; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h2 { font-size: 16px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.stat-card .label { font-size: 13px; color: var(--gray-500); margin-bottom: 4px; }
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card .sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 12px; background: var(--gray-50); border-bottom: 2px solid var(--gray-200); font-weight: 600; color: var(--gray-600); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); }
tr:hover td { background: var(--gray-50); }
.clickable { cursor: pointer; }

/* Pipeline / Kanban */
.pipeline-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.pipeline-column {
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
}
.pipeline-column-header {
  padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  color: white;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}
.pipeline-column-body {
  background: var(--gray-100);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 8px;
  min-height: 200px;
}
.pipeline-card {
  background: white;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s;
}
.pipeline-card:hover { box-shadow: var(--shadow-md); }
.pipeline-card .name { font-weight: 600; font-size: 14px; }
.pipeline-card .meta { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* State compliance badges */
.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: help;
  position: relative;
}
.state-badge.federal { background: #dcfce7; color: #166534; }
.state-badge.moderate { background: #fef9c3; color: #854d0e; }
.state-badge.strict { background: #fee2e2; color: #991b1b; }
.state-badge .tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--gray-900);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  z-index: 200;
  margin-top: 4px;
}
.state-badge:hover .tooltip { display: block; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="tel"],
select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; }

/* Filters */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filters input, .filters select { width: auto; min-width: 180px; }
.search-input { position: relative; }
.search-input input { padding-left: 36px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
  z-index: 1000;
}
.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); }

/* Notifications */
.notif-bell { position: relative; cursor: pointer; font-size: 20px; }
.notif-count {
  position: absolute;
  top: -6px;
  right: -8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}
.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 360px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  font-size: 13px;
}
.notif-item.unread { background: #f0f7ff; }
.notif-item:hover { background: var(--gray-50); }
.notif-item .title { font-weight: 600; }
.notif-item .time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* Activity timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item {
  position: relative;
  padding-bottom: 16px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid white;
}
.timeline-item.system::before { background: var(--gray-400); }
.timeline-item.stage_change::before { background: var(--warning); }
.timeline-item .ti-header { font-size: 13px; color: var(--gray-500); }
.timeline-item .ti-body { font-size: 14px; margin-top: 4px; }

/* Compliance table colors */
.compliance-federal { background: #f0fdf4; }
.compliance-moderate { background: #fffbeb; }
.compliance-strict { background: #fef2f2; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .pipeline-board { flex-direction: column; }
  .pipeline-column { min-width: auto; max-width: none; }
}

/* Loading / Empty states */
.loading { text-align: center; padding: 40px; color: var(--gray-400); }
.empty { text-align: center; padding: 40px; color: var(--gray-400); }
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
