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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #0f172a;
}

.app-header {
  padding: 1.25rem 1rem 0.75rem;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  margin-top: 0.25rem;
  color: #9ca3af;
}

.app-nav {
  margin-top: 0.75rem;
  display: inline-flex;
  gap: 1.25rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
  justify-content: center;
}

.app-nav a,
.app-nav button.app-nav-link {
  color: #e5e7eb;
  text-decoration: none;
  position: relative;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.app-nav a::after,
.app-nav button.app-nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.15rem;
  width: 0;
  height: 2px;
  background: #60a5fa;
  transition: width 0.15s ease;
}

.app-nav a:hover::after,
.app-nav button.app-nav-link:hover::after {
  width: 100%;
}

.app-nav-link-active {
  color: #bfdbfe;
}

.container {
  max-width: 1080px;
  margin: 0 auto 2rem;
  padding: 0 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: #f9fafb;
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
}

.page-heading {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  color: #e5e7eb;
}

.page-heading h2 {
  margin: 0;
  font-size: 1.4rem;
}

.page-heading p {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  color: #9ca3af;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

.hero-card p {
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
  color: #4b5563;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
}

input[type="text"] {
  flex: 1 1 180px;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  font-size: 1rem;
}

input[type="text"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.input-error {
  border-color: #b91c1c !important;
  box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.4);
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #f9fafb;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.1s ease;
}

button:hover {
  filter: brightness(1.03);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
}

button:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

button.tab {
  background: transparent;
  color: #4b5563;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.4rem 0.9rem;
  box-shadow: none;
}

button.tab.active {
  background: #111827;
  color: #f9fafb;
  border-color: #111827;
}

.error-message {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: #b91c1c;
}

.loading-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #4b5563;
  margin-top: 0.25rem;
}

.loading-indicator.active {
  display: inline-flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid #d1d5db;
  border-top-color: #2563eb;
  animation: spin 0.7s linear infinite;
}

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

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #6b7280;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  background: #e5e7eb;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.results {
  min-height: 3.5rem;
}

.placeholder {
  margin: 0.5rem 0 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.results-meta {
  min-height: 1.3rem;
  font-size: 0.85rem;
  color: #4b5563;
  margin-bottom: 0.35rem;
}

.results-meta span {
  margin-right: 0.6rem;
}

.service-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.service-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 6px 15px rgba(15, 23, 42, 0.08);
}

.service-item-selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25),
    0 6px 18px rgba(37, 99, 235, 0.25);
}

.service-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.service-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-right: 0.25rem;
}

.service-icon-gp {
  background: #eff6ff;
  color: #1d4ed8;
}

.service-icon-dentist {
  background: #ecfdf3;
  color: #16a34a;
}

.service-icon-optician {
  background: #fffbeb;
  color: #b45309;
}

.service-meta {
  font-size: 0.8rem;
  color: #6b7280;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-gp {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-dentist {
  background: #dcfce7;
  color: #15803d;
}

.badge-optician {
  background: #fef3c7;
  color: #b45309;
}

.distance {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4b5563;
}

.selection-summary p {
  margin: 0.25rem 0;
}

.selected-type {
  font-weight: 600;
}

.selected-none {
  color: #6b7280;
  font-style: italic;
}

.app-footer {
  text-align: center;
  color: #9ca3af;
  font-size: 0.8rem;
  padding: 0.5rem 1rem 1.25rem;
}

.selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.clear-btn {
  background: #f3f4f6;
  color: #374151;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  box-shadow: none;
}

.clear-btn:hover {
  filter: none;
  box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
}

.secondary-btn {
  background: #f3f4f6;
  color: #111827;
  box-shadow: none;
}

.secondary-btn:hover {
  filter: none;
  box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
}

/* New home page layout */

.home-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 1.25rem;
}

.home-hero-main h2 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 1.6rem;
}

.home-hero-main p {
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: #4b5563;
}

.home-hero-side {
  align-self: stretch;
  padding: 0.25rem 0 0;
}

.home-feature-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: #4b5563;
  font-size: 0.9rem;
}

.home-feature-grid {
  display: grid;
  gap: 1rem;
}

.home-feature-card h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.home-feature-card p {
  margin: 0;
  font-size: 0.9rem;
  color: #4b5563;
}

/* About page layout */

.about-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.about-intro-card h2 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.about-intro-card p {
  margin: 0.35rem 0 0;
  color: #4b5563;
}

.about-grid {
  display: grid;
  gap: 1rem;
}

.about-card h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.about-card .about-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  color: #4b5563;
}

/* Postcodes page */

.postcodes-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.postcode-list-header {
  display: grid;
  grid-template-columns: 0.9fr 1.2fr 1.8fr;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4b5563;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.postcode-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.postcode-row {
  display: grid;
  grid-template-columns: 0.9fr 1.2fr 1.8fr;
  gap: 0.75rem;
  font-size: 0.9rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed #e5e7eb;
}

.postcode-row:last-child {
  border-bottom: none;
}

.postcode-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-weight: 600;
}

.postcode-city {
  color: #111827;
}

.postcode-area {
  color: #4b5563;
}

/* Layout for new two-column section under the hero */

.grid-two-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.grid-left,
.grid-right {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.85rem;
  color: #6b7280;
}

@media (min-width: 768px) {
  .card {
    padding: 1.5rem 1.75rem;
  }

  .home-hero {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }

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

  .grid-two-column {
    flex-direction: row;
    align-items: flex-start;
  }

  .grid-left {
    flex: 1.05;
  }

  .grid-right {
    flex: 1.45;
  }

  .results {
    max-height: 480px;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .home-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-row button {
    width: 100%;
    justify-content: center;
  }

  .app-header h1 {
    font-size: 1.4rem;
  }
}
