/* =========================================
   Proceno — Design System v2
   Professional data platform aesthetic
   ========================================= */

/* === Custom Properties === */
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-darker: #1e3a8a;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-50: #eff6ff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --bg: #f1f5f9;
  --bg-elevated: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.2s;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-sans); color: var(--text); background: var(--bg); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; transition: color var(--duration) var(--ease); }
a:hover { color: var(--primary-dark); }

/* === Layout === */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }

/* === Navbar === */
.navbar {
  background: var(--primary-darker);
  color: var(--text-inverse);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
}
.nav-content { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo {
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  transition: opacity var(--duration) var(--ease);
}
.logo:hover { text-decoration: none; opacity: 0.85; }
.logo span { font-weight: 400; letter-spacing: 0.02em; }
.logo strong { font-weight: 800; color: #93c5fd; }
.logo svg { opacity: 0.85; }
.nav-links { display: flex; gap: 0.125rem; }
.nav-link {
  color: rgba(255,255,255,0.7);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
  font-size: 0.875rem;
  font-weight: 500;
}
.nav-link:hover { color: var(--text-inverse); background: rgba(255,255,255,0.1); text-decoration: none; }
.nav-link.active { color: var(--text-inverse); background: rgba(255,255,255,0.15); font-weight: 600; }
.menu-toggle { display: none; background: none; border: none; color: var(--text-inverse); cursor: pointer; padding: 0.5rem; border-radius: var(--radius-sm); }
.menu-toggle:hover { background: rgba(255,255,255,0.1); }

/* === Hero === */
.hero { text-align: center; padding: 3.5rem 1rem 2.5rem; position: relative; }
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 100%;
  background: radial-gradient(ellipse at center, rgba(37,99,235,0.04) 0%, transparent 70%);
  pointer-events: none;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--primary-50);
  color: var(--primary);
  padding: 0.375rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  border: 1px solid var(--primary-light);
}
.hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}
.hero-search {
  display: flex;
  max-width: 640px;
  margin: 0 auto;
  gap: 0.5rem;
  background: var(--surface);
  padding: 0.375rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
}
.hero-search input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: transparent;
  color: var(--text);
}
.hero-search input::placeholder { color: var(--text-muted); }
.hero-search input:focus { outline: none; }
.hero-search button {
  background: var(--primary);
  color: var(--text-inverse);
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  cursor: pointer;
  font-weight: 600;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}
.hero-search button:hover { background: var(--primary-hover); transform: translateY(-1px); }

/* === Stats Grid === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: all var(--duration) var(--ease);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-number {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.stat-label {
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* === Sections === */
.section { margin: 2.5rem 0; }
.section h2 { font-size: 1.375rem; margin-bottom: 1rem; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }

/* === Card List === */
.card-list { display: flex; flex-direction: column; gap: 0.625rem; }
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  transition: all var(--duration) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--primary-light); }
.card-title { font-weight: 600; color: var(--text); margin-bottom: 0.125rem; line-height: 1.4; font-size: 0.9375rem; }
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-top: 0.5rem;
  align-items: center;
}
.card-meta span { display: flex; align-items: center; gap: 0.25rem; }
.card-contractor { font-size: 0.8125rem; margin-top: 0.375rem; color: var(--text-secondary); font-weight: 500; }
.cat-pills { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.375rem; }
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--primary-50);
  color: var(--primary-dark);
  border: 1px solid var(--primary-light);
  white-space: nowrap;
  font-weight: 500;
}

/* === Badges === */
.badge { display: inline-block; padding: 0.125rem 0.625rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; }
.badge-construction { background: var(--primary-light); color: var(--primary-dark); }
.badge-supply { background: var(--warning-light); color: var(--warning); }
.badge-service { background: var(--success-light); color: var(--success); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-red { background: var(--danger-light); color: var(--danger); }

/* === Search Bar === */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.search-bar input {
  flex: 1;
  min-width: 180px;
  padding: 0.625rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  background: var(--surface);
  color: var(--text);
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.search-bar select {
  padding: 0.625rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--surface);
  min-width: 150px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease);
}
.search-bar select:focus { outline: none; border-color: var(--primary); }
.search-bar button {
  background: var(--primary);
  color: var(--text-inverse);
  border: none;
  padding: 0.625rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  cursor: pointer;
  font-weight: 600;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}
.search-bar button:hover { background: var(--primary-hover); }

/* === Results === */
.results-area { min-height: 200px; }
.hint { color: var(--text-muted); text-align: center; padding: 3rem 0; font-size: 0.9375rem; }
.loading { color: var(--text-secondary); text-align: center; padding: 2.5rem 0; font-size: 0.9375rem; }
.loading::after {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-count { color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.875rem; }

/* === Pages === */
.page { display: none; padding: 1.5rem 0 4rem; min-height: calc(100vh - 160px); }
.page.active { display: block; animation: pageIn 0.3s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page h1 { font-size: 1.75rem; margin-bottom: 0.375rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.page-desc { color: var(--text-secondary); font-size: 0.9375rem; margin-bottom: 1.25rem; line-height: 1.5; max-width: 640px; }

/* === Price Table (legacy) === */
.price-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.price-table th { background: var(--bg-elevated); padding: 0.75rem 1rem; text-align: left; font-size: 0.8125rem; color: var(--text-secondary); font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap; }
.price-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; }
.price-table tr:hover td { background: var(--bg-elevated); }
.price-table .price-value { font-weight: 600; color: var(--success); white-space: nowrap; }
.price-table .description-cell { max-width: 400px; }

/* === Pagination === */
.pagination { display: flex; justify-content: center; gap: 0.375rem; margin-top: 1.5rem; }
.pagination button {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  color: var(--text-secondary);
}
.pagination button:hover { background: var(--bg-elevated); border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: var(--text-inverse); border-color: var(--primary); font-weight: 600; }

/* === Price Groups === */
.price-group { background: var(--surface); border-radius: var(--radius-md); margin-bottom: 0.75rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.price-group-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; cursor: pointer; transition: background var(--duration) var(--ease); gap: 1rem; }
.price-group-header:hover { background: var(--bg-elevated); }
.group-main { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; min-width: 0; }
.group-description { font-weight: 600; color: var(--text); font-size: 0.95rem; }
.group-unit { color: var(--text-secondary); font-size: 0.8rem; }
.group-stats { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }
.group-price { font-weight: 700; color: var(--success); white-space: nowrap; font-size: 0.95rem; }
.group-count { background: var(--primary-light); color: var(--primary-dark); padding: 0.2rem 0.75rem; border-radius: var(--radius-full); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.group-arrow { color: var(--text-muted); font-size: 0.85rem; transition: transform var(--duration); user-select: none; }
.price-group-details { border-top: 1px solid var(--border); padding: 0; }
.inner-table { box-shadow: none; border-radius: 0; }
.inner-table th { background: var(--bg-elevated); font-size: 0.8rem; padding: 0.5rem 0.75rem; }
.inner-table td { padding: 0.5rem 0.75rem; font-size: 0.85rem; }

/* === Grouped Price Table === */
.prices-grouped-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.prices-grouped-table th {
  background: var(--bg-elevated);
  padding: 0.75rem;
  text-align: left;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--duration) var(--ease);
}
.prices-grouped-table th:hover { color: var(--primary); }
.prices-grouped-table th.sorted { color: var(--primary); }
.prices-grouped-table th .arrow { font-size: 0.7rem; margin-left: 3px; }
.prices-grouped-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-light); font-size: 0.85rem; }
.prices-grouped-table tr:hover td { background: var(--bg-elevated); }
.number { text-align: right; font-variant-numeric: tabular-nums; }

/* === Expandable Row === */
.expand-toggle {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all var(--duration) var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
  user-select: none;
}
.expand-toggle:hover { background: var(--primary-50); color: var(--primary); }
.expand-toggle.open { transform: rotate(90deg); color: var(--primary); }
tr.group-row { cursor: pointer; transition: background var(--duration) var(--ease); }
tr.group-row:hover td { background: var(--primary-50); }

/* === Detail Panel === */
.detail-panel { background: var(--bg-elevated); border-left: 4px solid var(--primary); }
.detail-panel td { padding: 0 !important; }
.detail-inner { padding: 1rem 1.25rem; animation: fadeIn 0.25s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.detail-stats { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.detail-stat {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-xs);
  text-align: center;
  min-width: 80px;
  border: 1px solid var(--border);
}
.detail-stat .ds-value { font-size: 1.25rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.detail-stat .ds-label { font-size: 0.6875rem; color: var(--text-secondary); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.03em; }

/* === Histogram === */
.histogram-section { margin-bottom: 1rem; }
.histogram-title { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.histogram { display: flex; align-items: flex-end; gap: 2px; height: 60px; margin: 0.5rem 0; padding: 0 4px; }
.histogram-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 3px 3px 0 0;
  min-width: 8px;
  position: relative;
  opacity: 0.65;
  transition: opacity var(--duration) var(--ease);
}
.histogram-bar:hover { opacity: 1; }
.histogram-bar .hb-tooltip {
  display: none;
  position: absolute;
  bottom: 100%; left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--text-inverse);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  white-space: nowrap;
  z-index: 10;
}
.histogram-bar:hover .hb-tooltip { display: block; }
.histogram-labels { display: flex; justify-content: space-between; font-size: 0.65rem; color: var(--text-secondary); margin-bottom: 0.5rem; }

/* === Detail Table === */
.detail-table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
}
.detail-table th {
  background: var(--bg-elevated);
  padding: 0.5rem 0.6rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color var(--duration) var(--ease);
}
.detail-table th:hover { color: var(--primary); }
.detail-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border-light); }
.detail-table tr:hover { background: var(--bg-elevated); }

/* === Detail Pagination === */
.detail-pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 0.75rem; font-size: 0.8rem; color: var(--text-secondary); }
.detail-pagination button {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--duration) var(--ease);
}
.detail-pagination button:hover { border-color: var(--primary); color: var(--primary); }
.detail-pagination button:disabled { opacity: 0.4; cursor: default; }

/* === Year Slider === */
.year-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1rem;
  padding: 0.625rem 1rem;
  background: var(--primary-50);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
  border: 1px solid var(--primary-light);
}
.year-filter label { font-weight: 600; white-space: nowrap; color: var(--text); }
.year-range-track { position: relative; flex: 1; height: 6px; background: #cbd5e1; border-radius: 3px; min-width: 120px; }
.year-range-fill { position: absolute; height: 100%; background: var(--primary); border-radius: 3px; }
.year-filter input[type=range] { position: absolute; top: -6px; width: 100%; height: 18px; -webkit-appearance: none; appearance: none; background: transparent; pointer-events: none; margin: 0; }
.year-filter input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 2px solid var(--text-inverse); box-shadow: 0 1px 4px rgba(0,0,0,0.3); cursor: pointer; pointer-events: auto; }
.year-filter input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 2px solid var(--text-inverse); box-shadow: 0 1px 4px rgba(0,0,0,0.3); cursor: pointer; pointer-events: auto; }
.year-val { font-weight: 700; color: var(--primary); min-width: 32px; text-align: center; }
.year-reset { font-size: 0.7rem; padding: 2px 8px; border: 1px solid var(--text-muted); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: all var(--duration) var(--ease); }
.year-reset:hover { border-color: var(--danger); color: var(--danger); }

/* === Price Range Bar === */
.price-range { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; min-width: 160px; }
.price-range-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; position: relative; min-width: 50px; }
.price-range-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--success), var(--orange)); }
.price-range .min { color: var(--success); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-range .max { color: var(--orange); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* === Export Button === */
.export-btn {
  padding: 0.625rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-secondary);
}
.export-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }

/* === Count Badge === */
.count-badge {
  background: var(--primary);
  color: var(--text-inverse);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* === Table Wrapper === */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* === Generic Data Table === */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.data-table th {
  background: var(--bg-elevated);
  padding: 0.75rem;
  text-align: left;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--duration) var(--ease);
}
.data-table th:hover { color: var(--primary); }
.data-table th.sorted { color: var(--primary); }
.data-table th .arrow { font-size: 0.7rem; margin-left: 3px; }
.data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-light); font-size: 0.85rem; }
.data-table tr:hover td { background: var(--bg-elevated); }
.data-table tr.group-row:hover td { background: var(--primary-50); }

/* === Municipality Tags === */
.muni-tags { display: flex; flex-wrap: wrap; gap: 3px; max-width: 220px; }
.muni-tag { background: var(--bg-elevated); color: var(--text-secondary); padding: 1px 6px; border-radius: var(--radius-sm); font-size: 0.7rem; white-space: nowrap; border: 1px solid var(--border); }
.muni-tag.more { background: var(--primary-50); color: var(--primary-dark); border-color: var(--primary-light); cursor: default; }

/* === Contract Type Tags === */
.type-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.type-tag { padding: 1px 6px; border-radius: var(--radius-sm); font-size: 0.7rem; white-space: nowrap; }

/* === Entity Detail Panel === */
.entity-detail { padding: 1rem 1.25rem; animation: fadeIn 0.25s var(--ease); }
.entity-detail .card-list { max-height: 400px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.entity-detail .card-list::-webkit-scrollbar { width: 6px; }
.entity-detail .card-list::-webkit-scrollbar-track { background: transparent; }
.entity-detail .card-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.entity-detail .card { padding: 0.75rem 1rem; margin-bottom: 0.5rem; }

/* === Footer === */
.footer {
  background: var(--text);
  color: var(--text-muted);
  padding: 2.5rem 0;
  text-align: center;
  font-size: 0.8125rem;
  margin-top: auto;
}
.footer-brand { font-size: 1.125rem; color: rgba(255,255,255,0.9); margin-bottom: 0.75rem; }
.footer-brand strong { font-weight: 800; color: #93c5fd; }
.footer-links { display: flex; gap: 1.5rem; justify-content: center; margin-bottom: 1rem; flex-wrap: wrap; }
.footer-links a { color: rgba(255,255,255,0.5); font-size: 0.8125rem; transition: color var(--duration) var(--ease); }
.footer-links a:hover { color: rgba(255,255,255,0.9); text-decoration: none; }
.footer a { color: var(--primary-light); }
.footer a:hover { color: var(--text-inverse); text-decoration: underline; }
.footer-copy { margin-top: 0.375rem; color: rgba(255,255,255,0.35); font-size: 0.75rem; }

/* === Mobile === */
@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--primary-darker);
    flex-direction: column;
    padding: 0.5rem;
    box-shadow: var(--shadow-lg);
    border-top: 1px solid rgba(255,255,255,0.08);
  }
  .nav-links.open { display: flex; }
  .menu-toggle { display: block; }
  .hero { padding: 2rem 0.5rem 1.5rem; }
  .hero::before { display: none; }
  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: 1rem; }
  .hero-search { flex-direction: column; padding: 0.5rem; }
  .hero-search button { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .stat-card { padding: 1rem; }
  .stat-number { font-size: 1.5rem; }
  .search-bar { flex-direction: column; padding: 0.625rem; }
  .search-bar input, .search-bar select { min-width: 100%; }
  .price-table { font-size: 0.8rem; }
  .price-table th, .price-table td { padding: 0.5rem; }
  .price-group-header { flex-direction: column; align-items: flex-start; }
  .group-stats { width: 100%; justify-content: space-between; }
  .inner-table th, .inner-table td { padding: 0.4rem 0.5rem; font-size: 0.75rem; }
  .detail-stats { flex-direction: column; align-items: stretch; }
  .detail-stat { min-width: auto; }
  .price-range { flex-direction: column; align-items: flex-start; min-width: auto; }
  .prices-grouped-table th, .prices-grouped-table td { padding: 0.5rem 0.4rem; font-size: 0.8rem; }
  .detail-table th, .detail-table td { padding: 0.4rem 0.5rem; font-size: 0.75rem; }
  .year-filter { flex-wrap: wrap; }
  .page h1 { font-size: 1.375rem; }
  .card { padding: 0.875rem 1rem; }
  .footer { padding: 1.5rem 0; }
}

/* === Tablet breakpoint === */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* === Print === */
@media print {
  .navbar, .search-bar, .hero-search, .menu-toggle, .pagination, .export-btn { display: none !important; }
  .page { display: block !important; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: white; }
}
