:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --border: #dee2e6;
  --success: #198754;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #0dcaf0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

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

/* Header */
.header {
  background: var(--text);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}
.header h1 span {
  color: var(--primary);
}

/* Search */
.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.search-bar input {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  width: 320px;
  font-size: 0.9rem;
}
.search-bar button {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
}
.search-bar button:hover { background: var(--primary-hover); }

/* Main content */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--text-muted); }

/* Stats dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}
.stat-card .number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* State grid */
.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.state-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
  cursor: pointer;
}
.state-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.state-card .code {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}
.state-card .name {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.state-card .count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* County list */
.county-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.5rem;
}
.county-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}
.county-item:hover {
  background: #f0f4ff;
}

/* WD cards */
.wd-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.wd-card .wd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.wd-card .wd-id {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
}
.wd-card .wd-type {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: #e7f1ff;
  color: var(--primary);
  text-transform: capitalize;
}

/* Rates table */
.rates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}
.rates-table th, .rates-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.rates-table th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
}
.rates-table td.rate {
  font-family: 'SF Mono', monospace;
  text-align: right;
}

/* Changelog */
.changelog-entry {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.changelog-entry .date {
  color: var(--text-muted);
  font-size: 0.8rem;
  min-width: 140px;
}
.changelog-entry .badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  min-width: 80px;
  text-align: center;
}
.badge-new_wd { background: #d1e7dd; color: var(--success); }
.badge-revised { background: #fff3cd; color: #664d03; }
.badge-rate_change { background: #cfe2ff; color: var(--primary); }
.badge-new_classification { background: #d1e7dd; color: var(--success); }
.badge-removed_classification { background: #f8d7da; color: var(--danger); }
.badge-removed { background: #f8d7da; color: var(--danger); }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Search results */
.search-result {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.search-result:hover { background: #f0f4ff; }
.search-result mark {
  background: #fff3cd;
  padding: 0 2px;
  border-radius: 2px;
}

/* Actions bar */
.actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: #e7f1ff; }

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state h3 { margin-bottom: 0.5rem; color: var(--text); }

/* Section headers */
.section-header {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

h2 { font-size: 1.5rem; margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 0.75rem; }
  .search-bar input { width: 100%; }
  .state-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .county-list { grid-template-columns: 1fr; }
}

/* Print styles */
@media print {
  .header, .search-bar, .breadcrumb, .tabs, .btn, .btn-outline,
  .actions-bar button, nav, #bulkPasteArea, input[type="file"] { display: none !important; }
  body { background: white; }
  .container { max-width: 100%; padding: 0; }
  .wd-card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .stat-card { box-shadow: none; border: 1px solid #ccc; }
  .rates-table { font-size: 9pt; }
  .rates-table th, .rates-table td { padding: 3px 6px; }
  h2::after { content: " — Prevailing Wage Intelligence (pwa.tax)"; font-size: 0.6em; color: #999; }
}

/* Dark mode */
.dark {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.dark .header { background: #020617; }
.dark .stat-card, .dark .wd-card { background: var(--card-bg); }
.dark .state-card { background: var(--card-bg); color: var(--text); }
.dark .state-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.dark .county-item { background: var(--card-bg); color: var(--text); }
.dark .county-item:hover { background: #253347; }
.dark .rates-table th { background: #253347; }
.dark .search-result:hover { background: #253347; }
.dark input, .dark select, .dark textarea { background: #0f172a; color: var(--text); border-color: var(--border); }
.dark a { color: #60a5fa; }
.dark .wd-id { color: #60a5fa; }
.dark mark { background: #854d0e; color: #fef3c7; }
