/* Everwell portal – AccessGP blue, Aller with system fallbacks, no external assets. */
:root {
  --blue-1: #3a6db5;
  --blue-2: #4a85cc;
  --blue-ink: #2a5390;      /* 7.6:1 on white */
  --blue-deep: #2f5d9c;     /* solid button face, 6.1:1 with white */
  --blue-soft: #e9f0f9;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e1e6ee;
  --border-strong: #c9d2de;
  --text: #1b2430;          /* 15.6:1 */
  --muted: #566070;         /* 6.3:1 on white, 5.6:1 on surface-2 */
  --focus: #2b7de9;

  /* Muted status colours. All text colours ≥ 4.5:1 on their tints. */
  --ok: #1e6b3f;      --ok-bg: #e8f4ec;    --ok-border: #bfe0cb;
  --warn: #7a4b00;    --warn-bg: #fff5e3;  --warn-border: #f1d7a1;
  --bad: #9b2c2c;     --bad-bg: #fbeeee;   --bad-border: #efc6c6;
  --neutral: #4f5968; --neutral-bg: #eef1f5; --neutral-border: #d6dce5;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 1px rgba(16, 24, 40, 0.04), 0 2px 10px rgba(16, 24, 40, 0.05);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, 0.06), 0 6px 18px rgba(16, 24, 40, 0.08);
  --ease: 150ms ease;
  --font: "Aller", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font);
  min-height: 100vh; display: flex; flex-direction: column;
  -webkit-user-select: none; user-select: none; /* a gentle nudge: this is not for copying */
}
input { -webkit-user-select: text; user-select: text; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { max-width: 1680px; padding: 0 24px; }
main { flex: 1; padding-bottom: 32px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
b { font-weight: 700; }

/* Header */
.top { background: linear-gradient(135deg, var(--blue-1), var(--blue-2)); color: #fff; box-shadow: 0 2px 10px rgba(42, 83, 144, 0.25); }
.top-inner { display: flex; align-items: center; gap: 16px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.brand { display: inline-flex; background: #fff; border-radius: 8px; padding: 6px 10px; line-height: 0; }
.brand img { height: 27px; width: auto; }
.top-title { flex: 1; min-width: 180px; }
.top h1 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.who { font-size: 13px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(20, 40, 80, 0.28); padding: 5px 10px; border-radius: 999px; }

/* Cards, forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.auth { max-width: 460px; margin: 36px auto 0; }
.auth h2 { margin: 0 0 6px; font-size: 22px; }
.auth p { margin: 0 0 16px; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field input { width: 100%; font: 18px var(--font); padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); transition: border-color var(--ease), box-shadow var(--ease); }
.field input:hover { border-color: var(--blue-2); }
.field input.shake { animation: shake 0.4s ease; border-color: var(--bad); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.form-msg.ok { color: var(--ok); }
#code { letter-spacing: 0.3em; font-size: 24px; text-align: center; font-variant-numeric: tabular-nums; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, .check:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.btn:focus-visible, .fchip:focus-visible, .seg-btn:focus-visible { border-radius: 999px; }
.btn-primary:focus-visible { border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.btn { appearance: none; cursor: pointer; font: 700 15px var(--font); border-radius: var(--radius-sm); padding: 11px 16px; border: 1px solid transparent; min-height: 44px; transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease), opacity var(--ease); }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.btn:active:not([disabled]) { transform: scale(0.98); }
.btn-primary { background: var(--blue-1); color: #fff; width: 100%; box-shadow: 0 1px 2px rgba(42, 83, 144, 0.25); }
.btn-primary:hover:not([disabled]) { background: var(--blue-deep); }
.btn-primary:active:not([disabled]) { background: var(--blue-ink); }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn-ghost:hover:not([disabled]) { background: var(--blue-soft); }
.btn-ghost:active:not([disabled]) { background: #dce7f5; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; animation: spin 0.8s linear infinite; }
.btn-ghost.is-busy::after { border-color: rgba(42, 83, 144, 0.25); border-top-color: var(--blue-ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.top .btn-ghost { border-color: rgba(255, 255, 255, 0.7); color: #fff; background: rgba(20, 40, 80, 0.28); padding: 7px 12px; min-height: 36px; font-size: 14px; }
.top .btn-ghost:hover { background: rgba(20, 40, 80, 0.4); }
.auth .btn-ghost { width: 100%; margin-top: 10px; color: var(--blue-ink); border-color: var(--border); }
.form-msg { margin: 12px 0 0; font-size: 14px; color: var(--muted); min-height: 1.2em; }
.form-msg.err { color: var(--bad); }
.disclaimer-text { background: var(--blue-soft); border-left: 4px solid var(--blue-1); padding: 12px 14px; border-radius: 8px; font-size: 15px; }
.check { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-weight: 700; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--blue-1); }
.loading { text-align: center; color: var(--muted); margin: 48px 0; }

/* Dashboard */
.tabs { display: flex; gap: 4px; margin: 16px 0 0; border-bottom: 2px solid var(--border); }
.tab { appearance: none; cursor: pointer; font: 700 15px var(--font); color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 14px; min-height: 44px; border-radius: 8px 8px 0 0; transition: color var(--ease), background var(--ease), border-color var(--ease); }
.tab:hover { color: var(--blue-ink); background: var(--blue-soft); }
.tab:active { transform: translateY(1px); }
.tab[aria-selected="true"] { color: var(--blue-ink); border-bottom-color: var(--blue-1); }
.tab:focus-visible { outline-offset: -3px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 10px; flex-wrap: wrap; }
.updated { margin: 0; font-size: 14px; color: var(--muted); }
.updated b { color: var(--text); }
.toolbar .btn-ghost { color: var(--blue-ink); border-color: var(--border); background: var(--surface); padding: 8px 14px; min-height: 38px; font-size: 14px; }
.notice { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn); font-size: 14px; }

.filters { display: flex; align-items: center; gap: 8px 10px; margin: 0 0 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips + .chips { padding-left: 10px; border-left: 1px solid var(--border); }
.fchip { appearance: none; cursor: pointer; font: 600 13px var(--font); color: var(--blue-ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 12px; min-height: 34px; transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease); }
.fchip:hover { background: var(--blue-soft); border-color: var(--blue-2); }
.fchip:active { transform: scale(0.97); }
.fchip[aria-pressed="true"] { background: var(--blue-1); color: #fff; border-color: var(--blue-1); }
.fchip[aria-pressed="true"]:hover { background: var(--blue-deep); }
.search { flex: 1 1 180px; max-width: 280px; }
.search input { width: 100%; font: 15px var(--font); padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); min-height: 34px; transition: border-color var(--ease), box-shadow var(--ease); }
.search input:hover { border-color: var(--blue-2); }
.sort { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.sort select { font: 600 13px var(--font); color: var(--blue-ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 7px 10px; min-height: 34px; cursor: pointer; }
.sort select:hover { background: var(--blue-soft); }
.sort .dir { padding: 0 11px; min-height: 34px; font-size: 16px; color: var(--blue-ink); border-color: var(--border); background: var(--surface); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile .n { display: block; font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile .l { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile.hero { background: var(--blue-ink); color: #fff; border-color: transparent; }
.tile.hero .l { color: #fff; opacity: 0.92; }
.tile { transition: box-shadow var(--ease); }

/* Booking list */
.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 0 0 12px; }
details.month > summary:hover, details.dayd > summary:hover, .pt-row > summary:hover { background: var(--blue-soft); }
details.month > summary, details.dayd > summary, .pt-row > summary { transition: background var(--ease); }
.group.is-today { border-color: var(--blue-2); box-shadow: 0 0 0 2px rgba(74, 133, 204, 0.25), var(--shadow); }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.group.is-today .group-head { background: var(--blue-soft); }
.group-head h3 { margin: 0; font-size: 15px; }
.group-head h3 small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.group-count { font-weight: 700; color: var(--blue-ink); font-size: 13px; white-space: nowrap; }
.group ul { list-style: none; margin: 0; padding: 4px 0; }
.appt { display: grid; grid-template-columns: max-content minmax(140px, 1.2fr) minmax(140px, 1fr) auto; gap: 4px 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); align-items: center; }
.appt:last-child { border-bottom: 0; }
.appt:hover, .cappt:hover { background: var(--surface-2); }
.appt .when { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--blue-ink); white-space: nowrap; }
.appt .when small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.appt .name { font-weight: 700; }
.appt .meta { font-size: 13px; color: var(--muted); }
.appt .chip { justify-self: end; }
.appt.cancelled .name, .appt.cancelled .when { text-decoration: line-through; color: var(--muted); }
.appt.dna .name { color: var(--bad); }
.empty { padding: 18px 14px; color: var(--muted); font-size: 14px; }
.empty-card { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Calendar (week / day) */
.calnav { display: flex; align-items: center; gap: 10px 14px; margin: 0 0 12px; flex-wrap: wrap; }
.calnav-btns { display: flex; gap: 6px; }
.calnav .btn-ghost { color: var(--blue-ink); border-color: var(--border); background: var(--surface); padding: 7px 12px; min-height: 36px; font-size: 14px; }
.calnav-title { margin: 0; font-size: 17px; font-weight: 700; flex: 1; min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg-btn { appearance: none; cursor: pointer; font: 600 13px var(--font); color: var(--blue-ink); background: none; border: 0; padding: 7px 14px; min-height: 36px; transition: background var(--ease), color var(--ease); }
.seg-btn:hover { background: var(--blue-soft); }
.seg-btn[aria-pressed="true"] { background: var(--blue-1); color: #fff; }
.seg-btn:focus-visible { outline-offset: -3px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 160px; }
.day.is-today { border-color: var(--blue-2); box-shadow: 0 0 0 2px rgba(74, 133, 204, 0.25), var(--shadow); }
.day.is-past { background: var(--surface-2); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.day.is-today .day-head { background: var(--blue-soft); }
.day-head h3 { margin: 0; font-size: 14px; }
.day-head h3 small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.day-count { font-weight: 700; color: var(--blue-ink); font-size: 12px; white-space: nowrap; }
.day ul { list-style: none; margin: 0; padding: 4px 0; }
.cappt { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
.cappt:last-child { border-bottom: 0; }
.cappt .time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--blue-ink); }
.cappt .name { font-weight: 700; overflow-wrap: anywhere; }
.cappt .meta { grid-column: 1 / 3; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.cappt .meta .chip { font-size: 11px; padding: 1px 7px; }
.cappt .meta .ctype { color: var(--muted); font-size: 12px; max-width: none; white-space: normal; }
.cappt.cancelled .name, .cappt.cancelled .time { text-decoration: line-through; color: var(--muted); }
.cappt.dna .name { color: var(--bad); }
.day .empty { padding: 14px 12px; font-size: 13px; }

/* Day view: one big card with the list rows */
.dayview .appt { grid-template-columns: max-content minmax(140px, 1.2fr) minmax(140px, 1fr) auto; }

.cappt .meta .ctype { flex: 1 1 auto; min-width: 0; }
@media (max-width: 1240px) {
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .day { min-height: 0; }
}
@media (max-width: 980px) {
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Loading skeletons */
.sk { position: relative; overflow: hidden; background: #e9edf3; border-radius: 8px; color: transparent !important; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .sk::after { animation: none; } }
.sk-line { height: 12px; margin: 6px 0; }
.sk-line.w40 { width: 40%; } .sk-line.w60 { width: 60%; } .sk-line.w80 { width: 80%; }
.sk-chip { display: inline-block; width: 72px; height: 20px; border-radius: 999px; }
.sk-tile .n, .sk-tile .l { display: block; }
.sk-row { display: grid; grid-template-columns: 72px 1.2fr 1fr 84px; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); align-items: center; }
.sk-row:last-child { border-bottom: 0; }
.loading-line { text-align: center; color: var(--muted); font-size: 14px; margin: 14px 0 0; }
.loading-line::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--blue-1); animation: spin 0.8s linear infinite; }

/* Content fades: list updates and tab switches */
.fade-in { animation: fadein 150ms ease; }
@keyframes fadein { from { opacity: 0.35; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.result-count { font-size: 13px; color: var(--muted); margin: -4px 0 10px; min-height: 1.2em; }

/* Friendly empty / error states */
.state { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 32px 20px; text-align: center; color: var(--muted); }
.state svg { width: 40px; height: 40px; color: var(--blue-2); margin-bottom: 8px; }
.state p { margin: 0 0 12px; font-size: 15px; }
.state .btn { width: auto; display: inline-block; color: var(--blue-ink); border-color: var(--border-strong); background: var(--surface); padding: 8px 14px; min-height: 38px; font-size: 14px; }
.state .btn-primary { color: #fff; background: var(--blue-1); border-color: transparent; }
.updated .ago { color: var(--text); font-weight: 700; }

/* Collapsible month / day sections in the lists */
details.month { margin: 0 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
details.month > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 14px; font-weight: 700; font-size: 16px; background: var(--surface-2); }
details.month > summary::-webkit-details-marker { display: none; }
details.month > summary::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--blue-ink); transition: transform 0.15s; }
details.month[open] > summary::before { transform: rotate(90deg); }
details.month > summary .cnt { font-weight: 700; color: var(--blue-ink); font-size: 13px; white-space: nowrap; }
details.month > .month-body { padding: 8px 10px 4px; background: var(--bg); }
details.dayd { margin: 0 0 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
details.dayd.is-today { border-color: var(--blue-2); }
details.dayd > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 12px; font-weight: 700; font-size: 14px; }
details.dayd > summary::-webkit-details-marker { display: none; }
details.dayd > summary::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform 0.15s; }
details.dayd[open] > summary::before { transform: rotate(90deg); }
details.dayd > summary .cnt { font-weight: 600; color: var(--muted); font-size: 12px; white-space: nowrap; }
details.dayd > ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.list-tools { display: flex; gap: 8px; margin: 0 0 10px; }
.list-tools .btn-ghost { color: var(--blue-ink); border-color: var(--border); background: var(--surface); padding: 5px 10px; min-height: 30px; font-size: 12px; }

/* Patients */
.pt-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pt-head-row, .pt-row > summary { display: grid; grid-template-columns: minmax(160px, 1.3fr) 70px minmax(150px, 1fr) minmax(150px, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 14px; }
.pt-head-row { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.pt-row { border-bottom: 1px solid var(--border); }
.pt-row:last-child { border-bottom: 0; }
.pt-row > summary { cursor: pointer; list-style: none; font-size: 14px; }
.pt-row > summary::-webkit-details-marker { display: none; }
.pt-row > summary .pname { font-weight: 700; }
.pt-row > summary .pname::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform 0.15s; }
.pt-row[open] > summary .pname::before { transform: rotate(90deg); }
.pt-row > summary .pn { font-variant-numeric: tabular-nums; color: var(--muted); }
.pt-row > summary .pstep { font-size: 13px; color: var(--muted); }
.pt-row > summary .pstep b { color: var(--text); font-weight: 600; }
.pt-row > summary .pflags { display: flex; gap: 4px; justify-self: end; }
.pt-row > summary .pflags .chip { font-size: 11px; padding: 1px 7px; }
.pt-row > .pt-body { background: var(--bg); border-top: 1px solid var(--border); padding: 4px 14px 8px 36px; }
.pt-body ol { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.pt-body li { display: grid; grid-template-columns: 22px max-content minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 7px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.pt-body li:last-child { border-bottom: 0; }
.pt-body li::before { counter-increment: step; content: counter(step); font-weight: 700; color: var(--muted); font-size: 12px; background: var(--neutral-bg); border-radius: 50%; width: 20px; height: 20px; display: inline-grid; place-items: center; }
.pt-body li .when { font-variant-numeric: tabular-nums; color: var(--blue-ink); font-weight: 700; white-space: nowrap; }
.pt-body li .when small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.pt-body li.cancelled .when { text-decoration: line-through; color: var(--muted); }
.pt-body li .t { min-width: 0; overflow-wrap: anywhere; }
.pt-body li .t small { color: var(--muted); font-size: 12px; margin-left: 6px; white-space: nowrap; }

/* Admin */
.admin-intro { margin: 14px 0; font-size: 14px; }
.admin-intro code { font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table code { font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; -webkit-user-select: text; user-select: text; }
.table-wrap { overflow-x: auto; }
.flag { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; border: 1px solid; white-space: nowrap; }
.flag.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.flag.missing { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-border); }
.flag.renamed { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.missing-note { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.missing-note.ok { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok); }
.missing-note.bad { background: var(--bad-bg); border: 1px solid var(--bad-border); color: var(--bad); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; border: 1px solid; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.booked { color: var(--blue-ink); background: var(--blue-soft); border-color: #bcd2ee; }
.chip.completed { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.chip.cancelled { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-border); }
.chip.cancelled::before { content: "×"; width: auto; height: auto; background: none; line-height: 1; }
.chip.dna { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-border); }
.chip.dna::before { content: "!"; width: auto; height: auto; background: none; line-height: 1; }

footer.foot { padding: 14px 16px 24px; font-size: 13px; text-align: center; }
.foot { font-size: 13px; }

@media (max-width: 640px) {
  .top h1 { font-size: 17px; }
  .who { display: none; }
  .tab { padding: 10px 10px; font-size: 14px; }
  .chips + .chips { padding-left: 0; border-left: 0; }
  .search { max-width: none; }
  .sort { margin-left: 0; width: 100%; }
  .sort select { flex: 1; }
  .appt { grid-template-columns: max-content minmax(0, 1fr); }
  .appt .meta { grid-column: 1 / 3; }
  .appt .chip { grid-column: 1 / 3; justify-self: start; }
  .week { grid-template-columns: 1fr; }
  .calnav-title { order: -1; flex-basis: 100%; }
  main.wrap { padding: 0 16px; }
  .pt-head-row { display: none; }
  .pt-row > summary { grid-template-columns: 1fr auto; }
  .pt-row > summary .pstep { grid-column: 1 / 3; }
  .pt-row > summary .pflags { grid-column: 1 / 3; justify-self: start; }
  .pt-row > .pt-body { padding-left: 14px; }
  .pt-body li { grid-template-columns: 22px max-content minmax(0, 1fr); }
  .pt-body li .when small { display: block; margin-left: 0; }
  .pt-body li .chip { grid-column: 2 / 4; justify-self: start; }
}
@media print { body { display: none; } }

/* Clickable patient names */
.name-btn { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; text-align: left; border-radius: 4px; text-decoration: underline dotted transparent; text-underline-offset: 3px; transition: color var(--ease), text-decoration-color var(--ease); }
.name-btn:hover { color: var(--blue-ink); text-decoration-color: var(--blue-2); }
.name-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.appt.cancelled .name-btn, .cappt.cancelled .name-btn { text-decoration-line: line-through; color: var(--muted); }
.appt.dna .name-btn, .cappt.dna .name-btn { color: var(--bad); }

/* Per-booking actions button */
.act { appearance: none; cursor: pointer; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--muted); font: 700 16px/1 var(--font); width: 28px; height: 28px; display: inline-grid; place-items: center; transition: background var(--ease), color var(--ease), border-color var(--ease); }
.act:hover { background: var(--blue-soft); color: var(--blue-ink); border-color: var(--border); }
.act:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.appt .act, .pt-body li .act { justify-self: end; }
.appt { grid-template-columns: max-content minmax(140px, 1.2fr) minmax(140px, 1fr) auto auto; }
.cappt .meta { align-items: center; }
.cappt .meta .act { margin-left: 4px; }
.pt-body li { grid-template-columns: 22px max-content minmax(0, 1fr) auto auto; }

/* Popover (patient details) and menu (actions) */
.pop-backdrop { position: fixed; inset: 0; z-index: 40; }
.pop { position: fixed; z-index: 50; min-width: 240px; max-width: min(360px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-hover); padding: 14px 16px; animation: fadein 150ms ease; }
.pop h4 { margin: 0 0 8px; font-size: 15px; }
.pop dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0 0 12px; font-size: 14px; }
.pop dt { color: var(--muted); }
.pop dd { margin: 0; -webkit-user-select: text; user-select: text; overflow-wrap: anywhere; }
.pop .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pop .btn { width: auto; min-height: 36px; padding: 7px 12px; font-size: 14px; }
.pop .btn-ghost { color: var(--blue-ink); border-color: var(--border-strong); }
.pop .close { margin-left: auto; }
.pop .pop-msg { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.pop .pop-msg.err { color: var(--bad); }
.pop .pop-msg::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 7px; vertical-align: -1px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--blue-1); animation: spin 0.8s linear infinite; }
.pop .pop-msg.err::before, .pop .pop-msg.plain::before { display: none; }
.menu { padding: 6px; min-width: 220px; }
.menu a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; }
.menu a:hover, .menu a:focus-visible { background: var(--blue-soft); color: var(--blue-ink); outline: none; }
.menu a small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.menu .menu-title { font-size: 12px; color: var(--muted); padding: 6px 12px 2px; }
@media (max-width: 640px) {
  .pop { left: 12px !important; right: 12px; top: auto !important; bottom: 12px; max-width: none; }
  .appt { grid-template-columns: max-content minmax(0, 1fr) auto; }
  .appt .meta { grid-column: 1 / 4; }
  .appt .chip { grid-column: 1 / 3; justify-self: start; }
  .pt-body li { grid-template-columns: 22px max-content minmax(0, 1fr) auto; }
  .pt-body li .chip { grid-column: 2 / 4; justify-self: start; }
}

/* Upcoming: cancellations toggle */
.fchip.toggle { color: var(--muted); border-style: dashed; }
.fchip.toggle[aria-pressed="true"] { background: var(--neutral-bg); color: var(--neutral); border-color: var(--border-strong); border-style: solid; }

/* Patients: full-width search */
.pt-search { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.pt-search-field { position: relative; flex: 1 1 320px; display: flex; align-items: center; }
.pt-search-field svg { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.pt-search-field input { width: 100%; font: 17px var(--font); padding: 12px 44px 12px 42px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); min-height: 48px; transition: border-color var(--ease), box-shadow var(--ease); }
.pt-search-field input:hover { border-color: var(--blue-2); }
.pt-search-field input::-webkit-search-cancel-button { display: none; }
.pt-clear { position: absolute; right: 8px; appearance: none; cursor: pointer; background: var(--neutral-bg); border: 0; border-radius: 50%; width: 30px; height: 30px; font: 20px/1 var(--font); color: var(--neutral); display: grid; place-items: center; transition: background var(--ease), color var(--ease); }
.pt-clear:hover { background: var(--border-strong); color: var(--text); }
.pt-count { font-size: 14px; color: var(--muted); white-space: nowrap; }

/* Patients: A–Z jump bar + sticky letter headers */
.pt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 28px; gap: 12px; align-items: start; }
.jump { position: sticky; top: 12px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); max-height: calc(100vh - 24px); overflow: hidden; }
.jump button { appearance: none; background: none; border: 0; cursor: pointer; font: 700 11px/1 var(--font); color: var(--blue-ink); width: 22px; height: 19px; border-radius: 999px; padding: 0; transition: background var(--ease), color var(--ease); }
.jump button:hover { background: var(--blue-soft); }
.jump button:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.jump button[disabled] { color: #b4bcc8; cursor: default; background: none; }
.pt-letter { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--blue-ink); font-weight: 700; font-size: 13px; padding: 6px 14px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); letter-spacing: 0.04em; scroll-margin-top: 8px; }
.pt-list .pt-letter:first-of-type { border-top: 0; }
@media (max-width: 760px) {
  .pt-layout { grid-template-columns: minmax(0, 1fr); }
  .jump { position: sticky; top: 0; z-index: 3; flex-direction: row; justify-content: flex-start; gap: 0; max-height: none; overflow-x: auto; border-radius: var(--radius-sm); padding: 4px 6px; order: -1; scrollbar-width: none; }
  .jump button { width: 26px; height: 28px; font-size: 12px; flex: none; }
  .pt-letter { top: 40px; }
  .pt-count { flex-basis: 100%; }
}

/* Popover: copy confirmation + menu note */
.pop .confirm { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 4px; }
.pop .confirm p { margin: 0 0 10px; font-size: 14px; color: var(--warn); }
.pop .confirm .row { gap: 8px; }
.menu .menu-note { margin: 4px 0 2px; padding: 8px 12px; font-size: 13px; color: var(--muted); max-width: 300px; }
.act-spacer { display: inline-block; width: 28px; height: 28px; }

.menu .menu-btn { appearance: none; display: block; width: 100%; text-align: left; background: none; border: 0; cursor: pointer; padding: 10px 12px; border-radius: 8px; color: var(--text); font: 600 14px var(--font); }
.menu .menu-btn:hover, .menu .menu-btn:focus-visible { background: var(--blue-soft); color: var(--blue-ink); outline: none; }
.menu .menu-btn small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.menu .menu-title + .menu-title { padding-top: 0; font-weight: 700; color: var(--text); font-size: 13px; }

/* Analytics */
.analytics { -webkit-user-select: none; user-select: none; }
.an-controls { display: flex; align-items: flex-end; gap: 10px 14px; margin: 14px 0 14px; flex-wrap: wrap; }
.an-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.an-field input, .an-field select { font: 15px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 40px; }
.an-controls .btn-ghost { color: var(--blue-ink); border-color: var(--border-strong); background: var(--surface); padding: 8px 14px; min-height: 40px; font-size: 14px; }
.an-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 16px; }
.an-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.an-card .n { display: block; font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--blue-ink); }
.an-card .l { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.an-card .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.an-card .info { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); font: 700 12px/1 var(--font); display: grid; place-items: center; cursor: help; }
.an-card .info:hover, .an-card .info:focus-visible { color: var(--blue-ink); border-color: var(--blue-2); background: var(--blue-soft); outline: none; }
.an-card .info:focus-visible { box-shadow: 0 0 0 3px rgba(43, 125, 233, 0.35); }
.an-card .info .tip { position: absolute; right: 0; top: 28px; z-index: 5; width: 240px; background: var(--text); color: #fff; font: 400 12px/1.45 var(--font); padding: 8px 10px; border-radius: 8px; text-align: left; display: none; box-shadow: var(--shadow-hover); }
.an-card .info:hover .tip, .an-card .info:focus-visible .tip, .an-card .info:focus-within .tip { display: block; }
.an-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; margin: 0 0 16px; }
.chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 10px; box-shadow: var(--shadow); min-width: 0; }
.chart h3 { margin: 0 0 2px; font-size: 15px; }
.chart .chart-sub { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .legend { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.chart .legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--sw); margin-right: 5px; vertical-align: -1px; }
.chart .legend .line::before { height: 2px; border-radius: 1px; vertical-align: 3px; }
.chart .axis text { font: 11px var(--font); fill: var(--muted); }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart .bar { shape-rendering: crispEdges; }
.chart .bar:hover { opacity: 0.85; }
.chart .dot { fill: var(--surface); stroke-width: 2; }
.chart .pct-label { font: 700 11px var(--font); fill: var(--text); }
.an-notice { margin: 8px 0 0; padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); line-height: 1.5; }
@media (max-width: 640px) { .an-charts { grid-template-columns: 1fr; } .an-field { flex: 1 1 40%; } }
@media print { .analytics, #analytics-ui { display: none !important; } }

/* Inline ⓘ notes (cancellations) */
.inline-info { position: relative; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); font: 700 12px/1 var(--font); cursor: help; vertical-align: middle; align-self: center; }
.inline-info:hover, .inline-info:focus-visible { color: var(--blue-ink); border-color: var(--blue-2); background: var(--blue-soft); outline: none; }
.inline-info:focus-visible { box-shadow: 0 0 0 3px rgba(43, 125, 233, 0.35); }
.inline-info .tip { position: absolute; left: 0; top: 28px; z-index: 5; width: 260px; background: var(--text); color: #fff; font: 400 12px/1.45 var(--font); padding: 8px 10px; border-radius: 8px; text-align: left; display: none; box-shadow: var(--shadow-hover); white-space: normal; }
.inline-info:hover .tip, .inline-info:focus-visible .tip { display: block; }
.chips .inline-info { margin-left: 2px; }

/* Floating tooltip for status pills */
.tipbox { position: fixed; z-index: 60; background: var(--text); color: #fff; font: 400 12px/1.45 var(--font); padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow-hover); pointer-events: none; animation: fadein 120ms ease; }
.chip.has-tip { cursor: help; }
.chip.has-tip:hover { filter: brightness(0.96); }
.chip.has-tip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
