.crc-calculator,
.crc-calculator * {
  box-sizing: border-box;
}

.crc-calculator {
  --crc-accent: #0f766e;
  --crc-accent-dark: color-mix(in srgb, var(--crc-accent) 82%, #000);
  --crc-bg: #f5f7f8;
  --crc-border: #dce3e7;
  --crc-text: #17212b;
  --crc-muted: #66717d;
  --crc-map-height: 420px;
  max-width: 1100px;
  margin: 2rem auto;
  color: var(--crc-text);
  font-family: inherit;
}

.crc-card {
  background: #fff;
  border: 1px solid var(--crc-border);
  border-radius: 20px;
  box-shadow: 0 14px 40px rgba(24, 39, 52, 0.08);
  overflow: hidden;
}

.crc-form-card,
.crc-summary-card {
  padding: clamp(1.25rem, 3vw, 2.25rem);
}

.crc-heading,
.crc-summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.crc-kicker {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--crc-accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.crc-heading h2,
.crc-summary-top h3 {
  margin: 0;
  color: var(--crc-text);
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  line-height: 1.15;
}

.crc-summary-top h3 {
  max-width: 760px;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
}

.crc-heading-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--crc-accent) 12%, #fff);
  color: var(--crc-accent);
  font-size: 1.5rem;
  font-weight: 800;
}

.crc-route-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  align-items: end;
  gap: 0.75rem;
}

.crc-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.crc-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.crc-field label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--crc-text);
  font-size: 0.9rem;
  font-weight: 700;
}

.crc-field label small {
  color: var(--crc-muted);
  font-weight: 500;
}

.crc-field input,
.crc-field select {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid #cbd5dc;
  border-radius: 11px;
  background: #fff;
  color: var(--crc-text);
  font: inherit;
  line-height: 1.2;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.crc-field input:focus,
.crc-field select:focus {
  border-color: var(--crc-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crc-accent) 16%, transparent);
  outline: none;
}

.crc-swap {
  width: 44px;
  height: 44px;
  margin-bottom: 2px;
  padding: 0;
  border: 1px solid var(--crc-border);
  border-radius: 12px;
  background: #fff;
  color: var(--crc-accent);
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 800;
}

.crc-swap:hover,
.crc-swap:focus-visible {
  border-color: var(--crc-accent);
  outline: none;
}

.crc-secondary-fields {
  align-items: end;
}

.crc-checks {
  display: flex;
  min-height: 48px;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
}

.crc-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--crc-text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.crc-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--crc-accent);
}

.crc-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.crc-submit,
.crc-reset,
.crc-print {
  min-height: 46px;
  border-radius: 11px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

.crc-submit {
  display: inline-flex;
  min-width: 220px;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.75rem 1.1rem;
  border: 1px solid var(--crc-accent);
  background: var(--crc-accent);
  color: #fff;
}

.crc-submit:hover:not(:disabled),
.crc-submit:focus-visible:not(:disabled) {
  filter: brightness(0.92);
  outline: none;
}

.crc-submit:disabled {
  cursor: wait;
  opacity: 0.78;
}

.crc-reset,
.crc-print {
  padding: 0.7rem 1rem;
  border: 1px solid var(--crc-border);
  background: #fff;
  color: var(--crc-text);
}

.crc-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: crc-spin 0.8s linear infinite;
}

.crc-submit.is-loading .crc-spinner {
  display: inline-block;
}

@keyframes crc-spin {
  to { transform: rotate(360deg); }
}

.crc-message {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

.crc-message.is-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.crc-config-link {
  color: inherit;
  font-weight: 800;
}

.crc-results {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.crc-results[hidden] {
  display: none;
}

.crc-summary-card {
  align-self: start;
}

.crc-print {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

.crc-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.crc-metric {
  min-height: 96px;
  padding: 1rem;
  border: 1px solid var(--crc-border);
  border-radius: 14px;
  background: var(--crc-bg);
}

.crc-metric span,
.crc-cost-grid span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--crc-muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.crc-metric strong {
  display: block;
  color: var(--crc-text);
  font-size: 1.35rem;
  line-height: 1.15;
}

.crc-metric-primary {
  border-color: color-mix(in srgb, var(--crc-accent) 30%, #fff);
  background: color-mix(in srgb, var(--crc-accent) 11%, #fff);
}

.crc-metric-primary strong {
  color: var(--crc-accent);
}

.crc-cost-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--crc-border);
}

.crc-cost-grid > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
}

.crc-cost-grid span {
  margin: 0;
}

.crc-cost-grid strong {
  white-space: nowrap;
  color: var(--crc-text);
  font-size: 0.95rem;
}

.crc-map-card {
  min-height: var(--crc-map-height);
}

.crc-map {
  width: 100%;
  height: var(--crc-map-height);
  min-height: 260px;
  background: #e9eef1;
}

.crc-map-attribution {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--crc-border);
  background: #fff;
  color: var(--crc-muted);
  font-size: 0.7rem;
  text-align: right;
}

.crc-disclaimer {
  margin: 0.9rem 0 0;
  color: var(--crc-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 880px) {
  .crc-results {
    grid-template-columns: 1fr;
  }

  .crc-map-card {
    order: -1;
  }
}

@media (max-width: 680px) {
  .crc-calculator {
    margin: 1rem auto;
  }

  .crc-form-card,
  .crc-summary-card {
    padding: 1.1rem;
    border-radius: 15px;
  }

  .crc-route-fields {
    grid-template-columns: 1fr 44px;
  }

  .crc-route-fields .crc-field:last-child {
    grid-column: 1 / -1;
  }

  .crc-swap {
    align-self: end;
  }

  .crc-grid-3 {
    grid-template-columns: 1fr;
  }

  .crc-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .crc-submit,
  .crc-reset {
    width: 100%;
  }

  .crc-metrics,
  .crc-cost-grid {
    grid-template-columns: 1fr 1fr;
  }

  .crc-summary-top {
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .crc-metrics,
  .crc-cost-grid {
    grid-template-columns: 1fr;
  }

  .crc-heading-icon {
    display: none;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  .crc-calculator,
  .crc-calculator * {
    visibility: visible;
  }

  .crc-calculator {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .crc-form-card,
  .crc-print,
  .crc-disclaimer {
    display: none !important;
  }

  .crc-results {
    display: block !important;
    margin: 0;
  }

  .crc-summary-card,
  .crc-map-card {
    margin-bottom: 1rem;
    box-shadow: none;
    break-inside: avoid;
  }
}
