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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --radius: 8px;
}

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

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.header-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  background: #fff;
  padding: 4px 10px;
  border-radius: 6px;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
}

.search-container {
  display: flex;
  gap: 8px;
}

#zip-search {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  width: 200px;
  outline: none;
  transition: border-color 0.2s;
}

#zip-search:focus {
  border-color: var(--accent);
}

#search-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

#search-btn:hover {
  opacity: 0.85;
}

.search-results {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100%);
  padding: 20px 22px;
  background: var(--surface);
  border-left: 1px solid var(--accent);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.35);
  overflow-y: auto;
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.22s ease, visibility 0.22s ease;
  z-index: 80;
}

.search-results.hidden {
  transform: translateX(100%);
  visibility: hidden;
}

.search-results .close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
}

.search-results .close-btn:hover {
  color: var(--text);
}

.search-results h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
  padding-right: 28px;
}

.search-results .result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.search-results .result-item {
  display: flex;
  flex-direction: column;
}

.search-results .result-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-results .result-value {
  font-size: 0.95rem;
}

.search-results .region-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.search-results .region-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.search-results .not-found {
  color: var(--text-muted);
}

.result-shipping {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.method-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.method-name {
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.guarantee-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.guarantee-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
}

.guarantee-table td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
}

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

.main {
  padding: 16px 24px 24px;
  min-height: 500px;
}

.map-container {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 190px);
  min-height: 460px;
}

.map-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.map-loading.hidden {
  display: none;
}

.map-search {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

#map-zip-search {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  width: 200px;
  outline: none;
  transition: border-color 0.2s;
}

#map-zip-search:focus {
  border-color: var(--accent);
}

#map-search-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

#map-search-btn:hover {
  opacity: 0.85;
}

.map-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-controls button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.map-controls button:hover {
  background: var(--surface-hover);
}

.legend {
  margin: 12px 24px 0;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
}

.legend h2 {
  font-size: 1rem;
  margin-bottom: 10px;
  font-weight: 600;
}

.legend-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.3);
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.legend-info h3 {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.legend-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.legend-info .zip-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.legend-item-none {
  opacity: 0.5;
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.825rem;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  max-width: 260px;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip .tip-zip {
  font-weight: 600;
  font-size: 0.95rem;
}

.tooltip .tip-name {
  color: var(--text-muted);
}

.tooltip .tip-region {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.tooltip .tip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.zip-path {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 0.3px;
  transition: opacity 0.15s;
  cursor: pointer;
}

.zip-path:hover {
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1px;
}

.zip-path.highlighted {
  stroke: #fbbf24;
  stroke-width: 2px;
  fill: #fbbf24 !important;
  fill-opacity: 0.6 !important;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.8));
}

.county-border {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 0.5px;
  stroke-dasharray: 2 1;
  pointer-events: none;
}

.zip-label {
  fill: rgba(255, 255, 255, 0.9);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  pointer-events: none;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8), 0 0 6px rgba(0, 0, 0, 0.5);
}

.state-border {
  fill: none;
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1px;
  pointer-events: none;
}

@media (max-width: 900px) {
  .main {
    height: auto;
  }

  .map-container {
    width: 100%;
    height: min(70vh, 520px);
    min-height: 360px;
    aspect-ratio: auto;
    max-height: none;
  }

  .legend-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header {
    padding: 12px 16px;
  }

  .main {
    padding: 12px 16px;
  }

  .legend {
    margin: 12px 16px 0;
  }
}

@media (max-width: 500px) {
  .search-results {
    width: 100%;
  }

  .legend-list {
    grid-template-columns: 1fr;
  }

  #zip-search {
    width: 140px;
  }

  .header h1 {
    font-size: 1.05rem;
  }
}
