:root {
  --bg-dark: #0b0f17;
  --bg-card: rgba(18, 26, 42, 0.75);
  --bg-card-solid: #121a2a;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(16, 185, 129, 0.4);
  
  --primary-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, .font-heading {
  font-family: var(--font-heading);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}

/* Header */
.app-header {
  height: 68px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 15, 23, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  gap: 20px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  height: 34px;
  width: auto;
  display: block;
}

.app-mode-badge {
  font-size: 0.75rem;
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

/* Search Box */
.search-box-wrapper {
  position: relative;
  flex: 1;
  max-width: 520px;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0 14px;
  height: 42px;
  transition: all 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary-emerald);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
  background: rgba(255, 255, 255, 0.09);
}

.search-icon {
  color: var(--text-dim);
  margin-right: 10px;
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 0.9rem;
  width: 100%;
  outline: none;
}

.search-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}

.search-dropdown {
  position: absolute;
  top: 48px;
  left: 0;
  width: 100%;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
}

.search-item {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.search-item:hover {
  background: rgba(16, 185, 129, 0.12);
}

.search-item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.search-item-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Header Buttons */
.header-actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-emerald);
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

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

.btn-outline-emerald {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-outline-emerald:hover {
  background: rgba(16, 185, 129, 0.2);
}

/* App Layout */
.app-layout {
  display: flex;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Sidebar Panel */
.sidebar-panel {
  width: 340px;
  background: rgba(11, 15, 23, 0.6);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 68px);
}

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

.sidebar-header h3 {
  font-size: 1.1rem;
}

.sidebar-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.preset-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}

.preset-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-btn {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.preset-btn.active {
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary-emerald);
  border-color: var(--primary-emerald);
}

.sliders-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 12px;
}

.slider-header-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.slider-val-badge {
  color: var(--primary-emerald);
}

.weight-range-slider {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  border-radius: 2px;
}

.weight-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary-emerald);
  cursor: pointer;
}

/* Main Content Panel */
.main-content-panel {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

/* Location Pills Bar */
.featured-pills-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pills-title {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}

.pills-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.loc-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.loc-pill.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary-emerald);
  border-color: var(--primary-emerald);
}

/* Hero Card */
.location-hero-card {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: radial-gradient(circle at right, rgba(16, 185, 129, 0.1) 0%, rgba(18, 26, 42, 0.8) 70%);
}

.loc-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.loc-title {
  font-size: 2rem;
  font-weight: 800;
}

.fips-tag {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-weight: 700;
}

.loc-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.location-score-display {
  display: flex;
  align-items: center;
  gap: 20px;
}

.score-ring-large {
  position: relative;
  width: 110px;
  height: 110px;
}

.score-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 8; }
.ring-progress { fill: none; stroke: var(--primary-emerald); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }

.ring-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.hero-score-val {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  display: block;
  line-height: 1;
}

.hero-score-denom {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.score-label-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-grade-badge {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Tabs */
.view-tabs {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.view-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
}

.view-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Category Cards Grid */
.category-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.category-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}

.cat-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cat-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.cat-score-badge {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-emerald);
}

.metric-items-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.metric-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.metric-name-str {
  font-weight: 600;
  color: var(--text-main);
}

.metric-score-str {
  font-weight: 700;
  color: var(--primary-emerald);
}

.metric-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  background: var(--primary-emerald);
  border-radius: 3px;
}

.metric-note {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Map Card */
.map-card-wrapper {
  padding: 16px;
}

.map-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.map-legend { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.leg-green { background: #10b981; }
.leg-cyan { background: #06b6d4; }
.leg-amber { background: #f59e0b; }
.leg-red { background: #ef4444; }

.map-container {
  height: 480px;
  width: 100%;
  border-radius: 10px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal-overlay.hidden { display: none; }

.modal-card {
  width: 90%;
  max-width: 860px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.8rem;
  cursor: pointer;
}

.modal-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.math-formula-banner {
  background: rgba(11, 15, 23, 0.9);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.formula-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.formula-code {
  font-family: monospace;
  color: var(--primary-emerald);
  font-size: 0.9rem;
  margin-top: 4px;
}

.transparent-math-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.transparent-math-table th, .transparent-math-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.transparent-math-table th {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.hidden { display: none !important; }
.w-full { width: 100%; }

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar-panel { width: 100%; max-height: none; }
  .category-cards-grid { grid-template-columns: 1fr; }
  .location-hero-card { flex-direction: column; text-align: center; gap: 20px; }
}
