/* MediFinder Ghana -- mobile first, 360px up (PRD 8).
   No web fonts, no framework: every byte here is on the critical path for
   a user on a limited data bundle. */

:root {
  color-scheme: light;
  --blue: #1a56db;
  --blue-dark: #1436a4;
  --blue-tint: #eaf0fd;
  --red: #c81e1e;
  --red-dark: #9b1616;
  --red-tint: #fdecec;
  --amber: #8a5300;
  --amber-tint: #fdf3e2;
  --green: #05683b;
  --green-tint: #e6f5ee;
  --ink: #111827;
  --ink-soft: #4b5563;
  --line: #d8dde5;
  --bg: #f7f8fa;
  --card: #ffffff;
  --radius: 10px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- skeleton ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 64px; }

header.site {
  background: var(--blue);
  color: #fff;
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}
header.site .wrap { display: flex; align-items: center; gap: 12px; padding-bottom: 0; }
header.site a.brand {
  color: #fff; text-decoration: none; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; gap: 8px;
}
header.site .brand-logo {
  display: block; width: 108px; height: 32px; object-fit: contain;
  padding: 2px 4px; background: #fff; border-radius: 5px;
}
header.site nav { margin-left: auto; display: flex; gap: 4px; }
header.site nav a {
  color: #fff; text-decoration: none; font-size: 14px; padding: 10px 10px;
  border-radius: 8px; min-height: var(--tap); display: flex; align-items: center;
}
header.site nav a:hover, header.site nav a:focus-visible { background: rgba(255, 255, 255, 0.18); }
header.site nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.25); font-weight: 600; }

h1 { font-size: 22px; margin: 20px 0 4px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
h3 { font-size: 16px; margin: 0 0 4px; }
p.lede { color: var(--ink-soft); margin: 0 0 16px; }

/* ---------- data provenance banner ---------- */
.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 16px 0;
  font-size: 14px;
  border: 1px solid;
}
.banner.warn { background: var(--amber-tint); border-color: #e2c58a; color: var(--amber); }
.banner.warn strong { display: block; margin-bottom: 2px; }

/* ---------- emergency ---------- */
.emergency-cta {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 64px; margin: 16px 0 8px;
  background: var(--red); color: #fff; border: 0; border-radius: var(--radius);
  font-size: 19px; font-weight: 700; font-family: inherit; cursor: pointer;
}
.emergency-cta:hover { background: var(--red-dark); }

.emergency-panel {
  border: 2px solid var(--red); border-radius: var(--radius);
  background: var(--card); padding: 16px; margin: 16px 0;
}
.emergency-panel h2 { margin-top: 0; color: var(--red); }
.call-112 {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; background: var(--red); color: #fff; border-radius: var(--radius);
  font-size: 18px; font-weight: 700; text-decoration: none; margin-bottom: 12px;
}
.call-112:hover { background: var(--red-dark); }
.disclaimer {
  background: var(--red-tint); border-left: 4px solid var(--red);
  padding: 10px 12px; font-size: 14px; border-radius: 4px; margin-bottom: 14px;
}

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
}
textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; font-family: inherit; color: var(--ink);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #0b3fa8; outline-offset: 2px;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 150px; }

button, .btn {
  min-height: var(--tap); padding: 10px 16px; border-radius: 8px;
  font-size: 15px; font-family: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--blue); background: var(--blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
button.secondary, .btn.secondary {
  background: #fff; color: var(--blue); border-color: var(--line);
}
button.secondary:hover, .btn.secondary:hover { background: var(--blue-tint); }
button.danger {
  background: var(--red); border-color: var(--red);
}
button.danger:hover { background: var(--red-dark); border-color: var(--red-dark); }
button[disabled] { opacity: 0.55; cursor: not-allowed; }

details.filters {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin: 12px 0; overflow: hidden;
}
details.filters > summary {
  padding: 12px 14px; cursor: pointer; font-weight: 600; min-height: var(--tap);
  display: flex; align-items: center;
}
details.filters .body { padding: 0 14px 14px; border-top: 1px solid var(--line); padding-top: 14px; }

.checks { display: flex; flex-wrap: wrap; gap: 12px; }
.checks label {
  display: flex; align-items: center; gap: 6px; font-weight: 400;
  font-size: 15px; min-height: var(--tap); margin: 0;
}
.checks input { width: 20px; height: 20px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.meta { font-size: 14px; color: var(--ink-soft); margin: 2px 0; }
.distance {
  white-space: nowrap; font-weight: 700; color: var(--blue);
  background: var(--blue-tint); border-radius: 999px; padding: 4px 10px; font-size: 14px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions .btn { flex: 1 1 130px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.chip {
  font-size: 13px; padding: 3px 9px; border-radius: 999px;
  background: var(--blue-tint); color: var(--blue-dark); border: 1px solid #c9d8f8;
}
.chip.grey { background: #eef0f3; color: var(--ink-soft); border-color: var(--line); }
.chip.green { background: var(--green-tint); color: var(--green); border-color: #b6ddca; }
.chip.amber { background: var(--amber-tint); color: var(--amber); border-color: #e2c58a; }
.chip.red { background: var(--red-tint); color: var(--red-dark); border-color: #f0bcbc; }
.chip.dental { background: #f0e9fb; color: #5b2ca8; border-color: #d7c6f2; }

/* ---------- status ---------- */
.status { font-size: 14px; padding: 8px 10px; border-radius: 8px; margin-top: 10px; }
.status.fresh { background: var(--green-tint); color: var(--green); }
.status.stale { background: #eef0f3; color: var(--ink-soft); }

.notice { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

.empty, .loading {
  text-align: center; padding: 32px 16px; color: var(--ink-soft);
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
}
.error {
  background: var(--red-tint); border: 1px solid #f0bcbc; color: var(--red-dark);
  padding: 12px 14px; border-radius: var(--radius); margin: 12px 0; font-size: 14px;
}
.ok {
  background: var(--green-tint); border: 1px solid #b6ddca; color: var(--green);
  padding: 12px 14px; border-radius: var(--radius); margin: 12px 0; font-size: 14px;
}
.admin-section { margin: 24px 0; }
.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.admin-table th { background: var(--blue-tint); color: var(--blue-dark); white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .actions { margin: 0; min-width: 180px; }
.admin-table .actions button { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.admin-actions { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.admin-actions details > summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.admin-actions .editor-form { min-width: 320px; margin-top: 8px; }
.admin-actions .editor-form button { width: 100%; }

.results-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 20px 0 8px; gap: 10px; flex-wrap: wrap;
}
.results-head h2 { margin: 0; }
.count { font-size: 14px; color: var(--ink-soft); }

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }
.pager span { font-size: 14px; color: var(--ink-soft); }

dl.kv { margin: 12px 0 0; }
dl.kv dt { font-size: 13px; color: var(--ink-soft); margin-top: 10px; }
dl.kv dd { margin: 2px 0 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
a.skip {
  position: absolute; left: -9999px; background: #fff; color: var(--blue);
  padding: 10px 14px; z-index: 30; border-radius: 0 0 8px 0;
}
a.skip:focus { left: 0; top: 0; }

footer.site {
  border-top: 1px solid var(--line); margin-top: 32px; padding-top: 16px;
  font-size: 13px; color: var(--ink-soft);
}

@media (min-width: 620px) {
  h1 { font-size: 26px; }
  .wrap { padding: 0 20px 64px; }
}

@media (prefers-reduced-motion: no-preference) {
  .spinner {
    display: inline-block; width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--line); border-top-color: var(--blue);
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
}
