html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
}

main.map {
  --map-safe-top: 76px;
  --map-safe-bottom: 88px;
  position: absolute;
  top: var(--map-safe-top);
  right: 0;
  bottom: var(--map-safe-bottom);
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.map svg {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  touch-action: manipulation;
}

.map path {
  fill: #cbd5e1;
  stroke: #f1f5f9;
  stroke-width: 0.75;
  cursor: pointer;
  transition: fill 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.map path:focus,
.map path:focus-visible {
  outline: none;
}

.map path:hover,
.map path.is-active {
  fill: #c8102e;
}

.map path:hover {
  transition-duration: 0s;
}

.map path.is-active {
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.28));
}

.county-tooltip {
  --ct-safe-top: 8px;
  --ct-safe-bottom: 8px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(420px, calc(100vw - 40px));
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 8px;
  color: #1e293b;
  background: rgba(255, 255, 255, 0.985);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 6px, 0);
  transition:
    opacity 0.18s ease,
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.county-tooltip.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  overscroll-behavior: auto;
}

.ct-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.ct-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: -5px -7px -5px auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #64748b;
  background: transparent;
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.ct-close:hover,
.ct-close:focus-visible {
  color: #c8102e;
  background: #fef2f2;
}

.ct-close:focus-visible {
  outline: 2px solid rgba(200, 16, 46, 0.4);
  outline-offset: 1px;
}

.ct-state {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 6px 30px 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  color: #0f172a;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23C8102E'/%3E%3C/svg%3E") no-repeat right 10px center;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  cursor: pointer;
  appearance: none;
}

.ct-state:hover {
  border-color: #c8102e;
}

.ct-state:focus-visible {
  border-color: #c8102e;
  outline: 2px solid rgba(200, 16, 46, 0.24);
  outline-offset: 1px;
}

.ct-services {
  padding: 2px 0;
}

.ct-svc-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 16px;
  font-size: 0.84rem;
}

.ct-svc-row + .ct-svc-row {
  border-top: 1px solid #f1f5f9;
}

.ct-svc-contact {
  display: flex;
  flex: 0 0 140px;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
}

.ct-svc-num {
  flex-shrink: 0;
  width: auto;
  padding-top: 1px;
  color: #c8102e;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.ct-svc-num:hover {
  text-decoration: underline;
}

.ct-svc-num.is-missing {
  color: #64748b;
  font-weight: 650;
  letter-spacing: 0;
  pointer-events: none;
}

.ct-county-number-view {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 3px;
}

.ct-county-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 4px;
  border: 0;
  border-radius: 999px;
  color: #475569;
  background: transparent;
  cursor: pointer;
}

.ct-county-edit:hover,
.ct-county-edit:focus-visible {
  color: #c8102e;
  background: #fef2f2;
  outline: 2px solid rgba(200, 16, 46, 0.2);
  outline-offset: 1px;
}

.ct-county-edit-icon {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ct-county-edit-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 140px;
}

.ct-county-phone-input {
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
  box-sizing: border-box;
  border: 1px solid #94a3b8;
  border-radius: 5px;
  color: #0f172a;
  background: #fff;
  font: inherit;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.ct-county-phone-input:focus {
  border-color: #c8102e;
  outline: 2px solid rgba(200, 16, 46, 0.18);
}

.ct-county-edit-actions {
  display: flex;
  gap: 5px;
}

.ct-county-save,
.ct-county-cancel {
  padding: 4px 8px;
  border: 1px solid #c8102e;
  border-radius: 4px;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.ct-county-save {
  color: #fff;
  background: #c8102e;
}

.ct-county-cancel {
  color: #c8102e;
  background: #fff;
}

.ct-county-save:disabled,
.ct-county-cancel:disabled,
.ct-county-phone-input:disabled {
  cursor: wait;
  opacity: 0.62;
}

.ct-county-edit-form[hidden],
.ct-county-number-view[hidden],
.ct-county-edit[hidden],
.ct-contact-action[hidden] {
  display: none !important;
}

.ct-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ct-contact-action {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.ct-qr-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #fff;
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.ct-qr-trigger:hover,
.ct-qr-trigger:focus-visible {
  border-color: #c8102e;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.14);
  transform: scale(1.03);
}

.ct-qr-trigger:focus-visible {
  outline: 2px solid rgba(200, 16, 46, 0.32);
  outline-offset: 2px;
}

.ct-qr-canvas {
  display: block;
  width: 56px !important;
  max-width: 100%;
  height: 56px !important;
  max-height: 100%;
  image-rendering: pixelated;
}

.ct-save-contact {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #c8102e;
  border-radius: 999px;
  color: #fff;
  background: #c8102e;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.ct-save-contact-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ct-save-contact-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ct-save-contact-hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 9px);
  z-index: 4;
  display: none;
  width: max-content;
  max-width: 150px;
  padding: 7px 10px;
  border-radius: 5px;
  color: #fff;
  background: #0f172a;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.ct-save-contact-hint::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 15px;
  border: 5px solid transparent;
  border-top-color: #0f172a;
}

.ct-save-contact:hover,
.ct-save-contact:focus-visible {
  color: #fff;
  background: #a80d27;
}

.ct-save-contact:focus-visible {
  outline: 2px solid rgba(200, 16, 46, 0.32);
  outline-offset: 2px;
}

.ct-qr-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.72);
}

.ct-qr-dialog[hidden] {
  display: none;
}

.ct-qr-dialog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(360px, calc(100vw - 40px));
  padding: 26px 22px 22px;
  box-sizing: border-box;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.ct-qr-dialog-title {
  max-width: 290px;
  color: #0f172a;
  font-size: 0.98rem;
  line-height: 1.35;
  text-align: center;
}

.ct-qr-dialog-canvas {
  display: block;
  width: min(300px, calc(100vw - 84px));
  height: auto;
  aspect-ratio: 1;
}

.ct-qr-dialog-hint {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 600;
}

.ct-qr-dialog-close {
  position: absolute;
  top: 6px;
  right: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #64748b;
  background: transparent;
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.ct-qr-dialog-close:hover,
.ct-qr-dialog-close:focus-visible {
  color: #c8102e;
  background: #fef2f2;
}

.ct-svc-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.ct-svc-use {
  color: #1e293b;
  font-size: 0.85rem;
  font-weight: 600;
}

.ct-svc-example {
  color: #000;
  font-size: 0.73rem;
  line-height: 1.45;
}

.ct-county-phone-status {
  display: block;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.35;
}

.ct-county-phone-status:empty {
  display: none;
}

.ct-county-phone-status.is-checking {
  color: #475569;
}

.ct-county-phone-status.is-success {
  color: #166534;
}

.ct-county-phone-status.is-pending {
  color: #c8102e;
  font-style: italic;
}

.ct-county-phone-status.is-error {
  color: #b91c1c;
}

.ct-custom-select {
  position: relative;
  display: inline;
}

.ct-custom-select-btn {
  display: inline;
  padding: 0 14px 0 0;
  border-bottom: 1.5px solid #cbd5e1;
  color: #c8102e;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23C8102E'/%3E%3C/svg%3E") no-repeat right 2px center;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}

.ct-custom-select-btn:hover {
  border-bottom-color: #c8102e;
}

.ct-custom-select-drop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999999;
  display: none;
  min-width: 160px;
  max-height: 148px;
  margin-top: 0;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.ct-custom-select-drop.is-open {
  display: block;
}

.ct-custom-select-drop::-webkit-scrollbar {
  width: 5px;
}

.ct-custom-select-drop::-webkit-scrollbar-track {
  background: #f8fafc;
}

.ct-custom-select-drop::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: #c8102e;
}

.ct-custom-opt {
  display: block;
  padding: 6px 12px;
  color: #1e293b;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}

.ct-custom-opt:hover,
.ct-custom-opt.is-selected {
  color: #c8102e;
  background: #fef2f2;
}

.ct-custom-opt.is-selected {
  font-weight: 650;
}

.ct-disclaimer {
  margin: 0;
  padding: 10px 16px 12px;
  border-top: 1px solid #e2e8f0;
  color: #94a3b8;
  font-size: 0.66rem;
  line-height: 1.45;
  text-align: center;
}

.ct-disclaimer[hidden] {
  display: none;
}

/* ── Narrow screens: center tooltip & stack phone on top ── */
@media (max-width: 960px) {
  .county-tooltip {
    width: min(420px, calc(100vw - 24px));
  }

  .county-tooltip.is-visible {
    left: 50% !important;
    top: calc(var(--ct-safe-top) + (100vh - var(--ct-safe-top) - var(--ct-safe-bottom)) / 2) !important;
    top: calc(var(--ct-safe-top) + (100dvh - var(--ct-safe-top) - var(--ct-safe-bottom)) / 2) !important;
    transform: translate(-50%, -50%) !important;
    overscroll-behavior: auto;
  }

  .ct-svc-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .ct-svc-num {
    width: auto;
    font-size: 0.92rem;
  }
}

@media (max-width: 600px) {
  .ct-svc-contact {
    flex-basis: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
  }

  .ct-contact-action {
    flex-shrink: 0;
    width: auto;
  }

  .ct-qr-trigger {
    display: none;
  }

  .ct-save-contact {
    display: inline-flex;
    width: 1.25rem;
    height: 1.25rem;
    border: 0;
    border-radius: 0;
    color: #c8102e;
    background: transparent;
  }

  .ct-save-contact:hover,
  .ct-save-contact:focus-visible {
    color: #a80d27;
    background: transparent;
  }

  .ct-save-contact-icon {
    width: 1.15rem;
    height: 1.15rem;
  }

  .ct-save-contact-hint::after {
    right: 5px;
  }

  .ct-save-contact-hint {
    display: block;
  }

  .ct-save-contact-hint.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}
