:root {
  --background: #ffffff;
  --foreground: #111827;
  --muted: #f3f4f6;
  --muted-foreground: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --primary: #059669;
  --primary-dark: #047857;
  --destructive: #dc2626;
  --amber: #d97706;
  --ring: rgba(5, 150, 105, 0.18);
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin-top: 0; }
button, input, textarea { font: inherit; }

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.finder-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 384px 1fr;
  background: var(--background);
}

.finder-sidebar {
  border-right: 1px solid var(--border);
  background: var(--card);
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.finder-head {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.finder-head h1 {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 8px;
  font-weight: 700;
}

.finder-head p {
  color: var(--muted-foreground);
  font-size: 14px;
  margin-bottom: 20px;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.search-box {
  position: relative;
}

.search-box .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
}

.clear-search {
  display: none;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
}

input, textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
}

input:focus, textarea:focus {
  outline: 2px solid var(--ring);
  border-color: var(--primary);
}

textarea { resize: vertical; }

button, .button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary, button.secondary {
  background: #fff;
  color: var(--foreground);
  border-color: var(--border);
}

.wide { width: 100%; }

.small-note {
  margin: 8px 0 0;
  min-height: 18px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.register-cta {
  margin-top: 18px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(5, 150, 105, 0.28);
  border-radius: 8px;
  color: var(--primary);
  text-decoration: none;
}

.register-cta small {
  display: block;
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 400;
}

.cta-icon, .clinic-fallback, .detail-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 150, 105, 0.1);
  color: var(--primary);
  border-radius: 999px;
}

.cta-icon { width: 30px; height: 30px; }

.clinic-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.mobile-register-cta {
  display: none;
}

.pagination {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0 2px;
}

.pagination span {
  color: var(--muted-foreground);
  font-size: 13px;
  text-align: center;
}

.pagination button {
  min-height: 34px;
  padding: 6px 10px;
  border-color: var(--border);
  background: #fff;
  color: var(--foreground);
  font-size: 13px;
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.clinic-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.clinic-card:hover, .clinic-card.selected {
  border-color: rgba(5, 150, 105, 0.55);
  background: rgba(5, 150, 105, 0.05);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.clinic-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}

.clinic-fallback {
  width: 36px;
  height: 36px;
  margin-top: 2px;
}

.clinic-card h3 {
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clinic-card p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clinic-card .distance {
  margin-top: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.chevron {
  color: var(--muted-foreground);
  align-self: center;
}

.map-stage {
  min-height: 100vh;
  background: var(--muted);
  padding: 0;
}

.map {
  width: 100%;
  height: 100vh;
}

.popup-card {
  width: 230px;
}

.detail-logo {
  height: 46px;
  max-width: 160px;
  object-fit: contain;
  margin-bottom: 10px;
}

.detail-icon {
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
}

.popup-card h2, .detail-panel h2 {
  font-size: 15px;
  margin-bottom: 4px;
  font-weight: 700;
}

.address {
  color: var(--muted-foreground);
  font-size: 12px;
  margin-bottom: 6px;
}

.description {
  font-style: italic;
  color: #4b5563;
  font-size: 12px;
}

.detail-actions {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.detail-actions a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.detail-actions svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-actions .directions {
  color: #15803d;
}

.simple-header {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.simple-header.sticky {
  position: sticky;
  top: 0;
  z-index: 10;
}

.simple-header .container {
  min-height: 64px;
  display: flex;
  align-items: center;
}

.logo {
  height: 36px;
  width: auto;
}

.register-page, .admin-page {
  background: rgba(243, 244, 246, 0.65);
}

.register-layout {
  padding: 48px 0;
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 32px;
  align-items: start;
}

.register-intro h1, .admin-title h1 {
  font-size: 30px;
  line-height: 1.2;
  margin-bottom: 12px;
  font-weight: 700;
}

.register-intro > p, .admin-title p, .panel-head p {
  color: var(--muted-foreground);
}

.benefit {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  margin-top: 22px;
}

.benefit-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(5, 150, 105, 0.1);
  color: var(--primary);
}

.benefit-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.benefit p {
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.panel, .login-card, .success-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(243, 244, 246, 0.24);
}

.panel-head h2 {
  margin-bottom: 4px;
  font-size: 20px;
  font-weight: 600;
}

.form-panel .stacked-form, .panel > .stacked-form {
  padding: 24px;
}

.stacked-form {
  display: grid;
  gap: 18px;
}

.stacked-form label {
  display: grid;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
}

.stacked-form .check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(243, 244, 246, 0.4);
  font-weight: 500;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
}

.stacked-form label span {
  color: var(--muted-foreground);
  font-weight: 400;
}

.char-count {
  justify-self: end;
  margin-top: -3px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 400;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
}

.alert {
  margin: 18px 24px 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card, .success-card {
  width: min(100%, 390px);
  padding: 30px;
  text-align: center;
}

.login-card p, .success-card p {
  color: var(--muted-foreground);
}

.lock-icon, .success-icon {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(5, 150, 105, 0.1);
  color: var(--primary);
  font-size: 28px;
  margin-bottom: 18px;
}

.success-icon {
  font-weight: 700;
}

.admin-nav {
  justify-content: space-between;
}

.admin-nav nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.admin-nav nav strong {
  color: var(--primary);
}

.admin-nav a {
  text-decoration: none;
}

.admin-layout {
  padding: 32px 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.stat-card {
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-card span {
  display: block;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.stat-card strong {
  font-size: 28px;
}

.stat-card.pending strong { color: var(--amber); }
.stat-card.approved strong { color: var(--primary); }
.stat-card.rejected strong { color: var(--destructive); }

.admin-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 28px;
  align-items: start;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 18px 24px;
  padding: 4px;
  border-radius: 8px;
  background: var(--muted);
}

.tabs button {
  min-height: 32px;
  padding: 5px 12px;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 14px;
}

.tabs button.active {
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.table-wrap {
  margin: 0 24px 24px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 14px;
}

th {
  background: rgba(243, 244, 246, 0.6);
  color: #374151;
  font-weight: 600;
}

td small {
  display: block;
  color: var(--muted-foreground);
  font-size: 12px;
  margin-top: 2px;
}

code {
  display: inline-block;
  padding: 3px 7px;
  background: var(--muted);
  border-radius: 5px;
  font-size: 12px;
}

.clinic-cell {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.admin-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
}

.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.badge.approved { background: #10b981; color: #fff; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.rejected { background: #dc2626; color: #fff; }

.row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.mini {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 12px;
  text-decoration: none;
}

.mini.approve { background: var(--primary); border-color: var(--primary); color: #fff; }
.mini.reject { background: var(--destructive); border-color: var(--destructive); color: #fff; }
.mini.ghost { background: #fff; color: var(--foreground); border-color: transparent; }
.mini.danger { color: var(--destructive); }

.settings-stack {
  display: grid;
  gap: 24px;
}

.edit-dialog {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

.edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.empty-state, .empty {
  text-align: center;
  color: var(--muted-foreground);
  padding: 48px 20px;
}

.mobile-detail {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--background);
  padding: 16px 24px;
  transform: translateX(100%);
  animation: slide-detail-in 180ms ease-out forwards;
  overflow-y: auto;
}

@keyframes slide-detail-in {
  to {
    transform: translateX(0);
  }
}

.back-button {
  background: transparent;
  border: 0;
  color: var(--muted-foreground);
  padding: 0;
  margin-bottom: 18px;
}

@media (max-width: 1023px) {
  .finder-shell {
    grid-template-columns: 1fr;
  }

  .finder-sidebar {
    height: 100vh;
  }

  .finder-head {
    padding: 14px;
  }

  .finder-head h1 {
    font-size: 21px;
    margin-bottom: 4px;
  }

  .finder-head > p {
    display: none;
  }

  .finder-head .register-cta {
    display: none;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-form button[type="submit"] {
    padding-inline: 12px;
  }

  .small-note {
    margin-top: 6px;
    min-height: 16px;
    font-size: 11px;
  }

  .clinic-list {
    padding: 12px;
    gap: 10px;
  }

  .clinic-card {
    padding: 12px;
  }

  .mobile-register-cta {
    display: grid;
    margin-top: 2px;
  }

  .map-stage {
    display: none;
  }

  .mobile-detail {
    display: block;
  }

  .register-layout, .admin-grid, .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .search-form, .two-col {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    align-items: flex-start;
    padding: 12px 0;
  }

  .admin-nav nav {
    flex-wrap: wrap;
    gap: 10px;
  }

  .register-layout, .admin-layout {
    padding: 28px 0;
  }
}
