/* ===========================================================================
   Blood Test Portal
   Mobile-first. Patients arrive by QR code, so the phone layout is the
   primary design and the desktop console is the progressive enhancement.
   =========================================================================== */

:root {
  --brand:        #0f766e;
  --brand-dark:   #115e59;
  --brand-light:  #ccfbf1;
  --brand-tint:   #f0fdfa;

  --ink:          #1c1917;
  --ink-2:        #44403c;
  --muted:        #78716c;
  --faint:        #a8a29e;

  --bg:           #f5f5f4;
  --surface:      #ffffff;
  --line:         #e7e5e4;
  --line-strong:  #d6d3d1;

  --good:         #15803d;
  --good-bg:      #f0fdf4;
  --warn:         #b45309;
  --warn-bg:      #fffbeb;
  --bad:          #b91c1c;
  --bad-bg:       #fef2f2;
  --info:         #1d4ed8;
  --info-bg:      #eff6ff;

  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 2px rgba(28,25,23,.05), 0 1px 3px rgba(28,25,23,.06);
  --shadow-lg:    0 4px 6px -1px rgba(28,25,23,.08), 0 2px 4px -2px rgba(28,25,23,.06);

  --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;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; letter-spacing: -.015em; }
h2 { font-size: 1.175rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 1rem; }
a  { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Visible focus everywhere - clinic staff work fast and often by keyboard. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.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;
}

/* --- Layout --------------------------------------------------------------- */

.container { width: 100%; max-width: 68rem; margin: 0 auto; padding: 0 1rem; }
.container-narrow { max-width: 40rem; }
.container-wide  { max-width: 84rem; }

.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: .5rem; }
.stack-lg > * + * { margin-top: 1.75rem; }

.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.grid { display: grid; gap: 1rem; }
@media (min-width: 640px)  { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .grid-3 { grid-template-columns: repeat(3, 1fr); }
                             .grid-4 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 899px)  { .grid-4 { grid-template-columns: repeat(2, 1fr); } }

/* --- Public header / footer ----------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.site-header .inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .875rem 1rem; max-width: 68rem; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: .625rem; font-weight: 700; color: var(--ink); font-size: 1.0625rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.header-links { display: flex; gap: 1.25rem; align-items: center; font-size: .9375rem; }
.header-links a { color: var(--ink-2); font-weight: 500; }

.site-footer {
  margin-top: 3rem; padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .875rem; text-align: center;
}
.site-footer a { color: var(--muted); text-decoration: underline; }

/* --- Cards ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-pad-lg { padding: 1.75rem; }
.card-flush  { padding: 0; overflow: hidden; }
.card-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--line); background: #fafaf9; }

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.15rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  font: 600 .9375rem/1.2 var(--font);
  cursor: pointer; text-align: center;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--faint); cursor: not-allowed; }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: #fafaf9; color: var(--ink); border-color: var(--muted); }

.btn-danger  { background: var(--bad); }
.btn-danger:hover { background: #991b1b; }

.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-tint); color: var(--brand-dark); }

.btn-sm  { padding: .45rem .75rem; font-size: .8125rem; }
.btn-lg  { padding: .9rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* --- Forms ---------------------------------------------------------------- */

.field { margin-bottom: 1.125rem; }
.field label, .label {
  display: block; font-weight: 600; font-size: .875rem;
  margin-bottom: .375rem; color: var(--ink-2);
}
.req { color: var(--bad); }

.input, input[type="text"], input[type="email"], input[type="tel"], input[type="password"],
input[type="number"], input[type="date"], input[type="url"], input[type="search"],
select, textarea {
  width: 100%;
  padding: .7rem .85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  /* 16px minimum stops iOS Safari zooming on focus. */
  font-size: 1rem;
}
textarea { min-height: 6rem; resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2378716c' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.25rem;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.input-error, .field.has-error input, .field.has-error select, .field.has-error textarea {
  border-color: var(--bad);
}
.field-hint { font-size: .8125rem; color: var(--muted); margin-top: .375rem; }
.field-error { font-size: .8125rem; color: var(--bad); margin-top: .375rem; font-weight: 500; }

.check {
  display: flex; align-items: flex-start; gap: .625rem;
  font-size: .9375rem; cursor: pointer; line-height: 1.5;
}
.check input[type="checkbox"], .check input[type="radio"] {
  width: 1.125rem; height: 1.125rem; margin: .1875rem 0 0; flex: 0 0 auto;
  accent-color: var(--brand); cursor: pointer;
}

.filters {
  display: grid; gap: .75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 700px) { .filters { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); align-items: end; } }
.filters .field { margin: 0; }

/* --- Alerts --------------------------------------------------------------- */

.alert {
  padding: .875rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid; font-size: .9375rem; margin-bottom: 1rem;
}
.alert p:last-child { margin-bottom: 0; }
.alert-success { background: var(--good-bg); border-color: #bbf7d0; color: #14532d; }
.alert-error   { background: var(--bad-bg);  border-color: #fecaca; color: #7f1d1d; }
.alert-warn    { background: var(--warn-bg); border-color: #fde68a; color: #78350f; }
.alert-info    { background: var(--info-bg); border-color: #bfdbfe; color: #1e3a8a; }

/* --- Status pills --------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
  border: 1px solid;
}
.pill.is-pending    { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.pill.is-confirmed  { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }
.pill.is-assigned   { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.pill.is-collected  { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.pill.is-lab        { background: #fdf4ff; color: #a21caf; border-color: #f5d0fe; }
.pill.is-ready      { background: var(--good-bg); color: var(--good); border-color: #bbf7d0; }
.pill.is-cancelled  { background: #f5f5f4; color: var(--muted); border-color: var(--line-strong); }
.pill.is-default    { background: #f5f5f4; color: var(--ink-2); border-color: var(--line-strong); }

.tag {
  display: inline-block; padding: .15rem .5rem; border-radius: 6px;
  background: var(--brand-tint); color: var(--brand-dark);
  font-size: .75rem; font-weight: 600;
}
.tag-muted { background: #f5f5f4; color: var(--muted); }

/* --- Tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9375rem; }
table.data th {
  text-align: left; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); font-weight: 700;
  padding: .75rem 1rem; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fafaf9;
}
table.data td {
  padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafaf9; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.empty {
  padding: 3rem 1.5rem; text-align: center; color: var(--muted);
}
.empty h3 { color: var(--ink-2); margin-bottom: .35rem; }

/* --- Console shell -------------------------------------------------------- */

.console { min-height: 100vh; display: flex; flex-direction: column; }

.console-bar {
  background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 50;
}
.console-bar .inner {
  max-width: 84rem; margin: 0 auto; padding: .75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.console-bar .brand { color: #fff; font-size: 1rem; }
.console-bar .brand-mark { background: var(--brand); }
.console-user { display: flex; align-items: center; gap: .75rem; font-size: .875rem; color: #d6d3d1; }
.console-role {
  padding: .15rem .5rem; border-radius: 5px;
  background: rgba(255,255,255,.12); font-size: .6875rem;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
}
.console-bar form { display: inline; }
.link-button {
  background: none; border: 0; padding: 0; color: #d6d3d1;
  font: inherit; cursor: pointer; text-decoration: underline;
}
.link-button:hover { color: #fff; }

.console-nav {
  background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.console-nav ul {
  max-width: 84rem; margin: 0 auto; padding: 0 1rem;
  display: flex; gap: .25rem; list-style: none;
}
.console-nav a {
  display: block; padding: .8rem .9rem;
  color: var(--ink-2); font-size: .9375rem; font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.console-nav a:hover { color: var(--brand); text-decoration: none; }
.console-nav a.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.console-main { flex: 1; padding: 1.5rem 1rem 4rem; }
.console-main > .container-wide > * + * { margin-top: 1.25rem; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head p { color: var(--muted); margin: .15rem 0 0; font-size: .9375rem; }

/* --- Stat tiles ----------------------------------------------------------- */

.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.125rem;
}
.stat .stat-label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; margin-bottom: .35rem;
}
.stat .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .stat-note { font-size: .8125rem; color: var(--muted); margin-top: .25rem; }
.stat-accent { border-left: 3px solid var(--brand); }

/* --- Booking flow --------------------------------------------------------- */

.steps {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1.5rem; font-size: .8125rem; overflow-x: auto; padding-bottom: .25rem;
}
.steps li { display: flex; align-items: center; gap: .5rem; list-style: none; white-space: nowrap; }
.steps ol { display: flex; gap: .5rem; padding: 0; margin: 0; }
.step-dot {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--line); color: var(--muted); font-weight: 700; font-size: .75rem;
}
.step.is-current .step-dot { background: var(--brand); color: #fff; }
.step.is-done .step-dot    { background: var(--brand-light); color: var(--brand-dark); }
.step.is-current { color: var(--ink); font-weight: 600; }
.step { color: var(--muted); }
.step-sep { color: var(--faint); }

/* Selectable test / package / slot cards */
.choice {
  display: block; position: relative;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 1rem; background: var(--surface); cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.choice:hover { border-color: var(--brand); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) {
  border-color: var(--brand); background: var(--brand-tint);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.choice:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.choice-title { font-weight: 650; display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.choice-meta { font-size: .8125rem; color: var(--muted); margin-top: .25rem; }
.choice-price { font-weight: 700; color: var(--brand-dark); white-space: nowrap; }
.choice-mrp { color: var(--faint); text-decoration: line-through; font-weight: 400; font-size: .8125rem; margin-right: .3rem; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: .5rem; }
.slot {
  position: relative; text-align: center; padding: .65rem .4rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: .875rem; font-weight: 600;
}
.slot input { position: absolute; opacity: 0; pointer-events: none; }
.slot:hover { border-color: var(--brand); }
.slot:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.slot-left { display: block; font-size: .6875rem; font-weight: 500; opacity: .75; margin-top: .1rem; }

/* Sticky cart summary on mobile */
.cart-bar {
  position: sticky; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: .875rem 1rem; margin: 1.5rem -1rem 0;
  box-shadow: 0 -2px 8px rgba(28,25,23,.06);
}
.cart-bar .inner {
  max-width: 40rem; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.cart-total { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.cart-count { font-size: .8125rem; color: var(--muted); }

/* --- Summary rows --------------------------------------------------------- */

.summary { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.summary td { padding: .45rem 0; vertical-align: top; }
.summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary tr.total td { border-top: 1px solid var(--line); padding-top: .75rem; font-weight: 700; font-size: 1.0625rem; }
.summary tr.saving td { color: var(--good); }

.detail-list { margin: 0; }
.detail-list dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.detail-list dd { margin: .15rem 0 .9rem; }
.detail-list dd:last-child { margin-bottom: 0; }

/* --- Timeline ------------------------------------------------------------- */

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1.25rem 1.75rem; }
.timeline li::before {
  content: ""; position: absolute; left: .3125rem; top: .45rem;
  width: .625rem; height: .625rem; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
.timeline li::after {
  content: ""; position: absolute; left: .5625rem; top: 1.25rem; bottom: 0;
  width: 1px; background: var(--line);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline-time { font-size: .8125rem; color: var(--muted); }
.timeline-who  { font-size: .8125rem; color: var(--muted); }

/* --- Auth page ------------------------------------------------------------ */

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 2rem 1rem; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 24rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow-lg);
}
.auth-head { text-align: center; margin-bottom: 1.75rem; }
.auth-head .brand-mark { margin: 0 auto .75rem; width: 44px; height: 44px; font-size: 19px; border-radius: 12px; }

/* --- Hero (landing) ------------------------------------------------------- */

.hero {
  background: linear-gradient(170deg, var(--brand-tint), var(--bg) 65%);
  padding: 3rem 1rem 2.5rem;
  border-bottom: 1px solid var(--line);
}
.hero .inner { max-width: 40rem; margin: 0 auto; text-align: center; }
.hero h1 { font-size: 1.875rem; letter-spacing: -.02em; margin-bottom: .75rem; }
.hero p.lede { font-size: 1.0625rem; color: var(--ink-2); margin-bottom: 1.5rem; }
@media (min-width: 700px) { .hero h1 { font-size: 2.375rem; } }

.trust { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; font-size: .875rem; color: var(--muted); }
.trust b { display: block; color: var(--ink); font-size: 1.125rem; }

/* --- Pagination ----------------------------------------------------------- */

.pagination { display: flex; gap: .375rem; align-items: center; justify-content: center; flex-wrap: wrap; padding: 1rem; }
.pagination a, .pagination span {
  padding: .4rem .7rem; border-radius: 6px; font-size: .875rem;
  border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface);
}
.pagination .is-current { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.pagination a:hover { border-color: var(--brand); text-decoration: none; }

/* --- Utilities ------------------------------------------------------------ */

.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.big   { font-size: 1.125rem; }
.bold  { font-weight: 650; }
.mono  { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: .875em; }
.center { text-align: center; }
.right  { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.divider { height: 1px; background: var(--line); border: 0; margin: 1.25rem 0; }
.hide { display: none !important; }

@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  h1 { font-size: 1.3125rem; }
}

/* --- Print (day sheets, receipts) ----------------------------------------- */

@media print {
  .site-header, .site-footer, .console-bar, .console-nav,
  .cart-bar, .btn, .filters, .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .table-wrap { overflow: visible; }
}
