/* ============================================================
   PrecisionSight — Design tokens
   ============================================================ */
/* Tokens taken DIRECTLY from the live Precision Sight website CSS:
   --primary: 183 80% 28%  (deep teal),
   --foreground: 200 25% 10%, --background: 200 20% 98%,
   --muted-foreground: 200 8% 42%, --border: 200 12% 88%,
   font: General Sans + Inter (Fontshare). */
:root {
  --canvas: hsl(200, 20%, 98%);      /* #f9fafb cool near-white */
  --canvas-2: hsl(200, 15%, 95%);
  --surface: #ffffff;
  --surface-2: hsl(200, 15%, 97%);   /* matches --card */
  --border: hsl(200, 12%, 88%);      /* #dbe1e4 */
  --border-strong: hsl(200, 10%, 78%);
  --ink: hsl(200, 25%, 10%);         /* #142026 deep slate-blue */
  --ink-muted: hsl(200, 8%, 42%);    /* #626e75 */
  --ink-faint: hsl(200, 6%, 60%);    /* #939a9e */

  --accent: hsl(183, 80%, 28%);      /* #0e7d80 deep teal — brand primary */
  --accent-2: hsl(183, 55%, 42%);    /* #318f9c lighter teal */
  --accent-soft: hsl(183, 45%, 92%); /* #e0f0f1 wash */
  --accent-ink: #ffffff;
  --accent-ring: hsl(183, 80%, 28% / 0.35);

  --link: hsl(183, 80%, 28%);

  --success: hsl(160, 60%, 32%);
  --success-soft: hsl(160, 50%, 92%);
  --warning: hsl(35, 75%, 42%);
  --warning-soft: hsl(35, 70%, 92%);
  --error: hsl(0, 72%, 45%);         /* matches --destructive */
  --error-soft: hsl(0, 70%, 95%);

  --shadow-1: 0 1px 2px hsl(200 25% 10% / 0.04), 0 8px 24px hsl(200 25% 10% / 0.06);
  --shadow-2: 0 2px 6px hsl(200 25% 10% / 0.08), 0 18px 40px hsl(200 25% 10% / 0.1);
  --shadow-paper: 0 1px 0 hsl(200 25% 10% / 0.04),
    0 12px 32px -10px hsl(200 25% 10% / 0.14);

  --radius-card: 14px;
  --radius-card-lg: 20px;
  --radius-input: 8px;               /* matches website --radius: .5rem */
  --radius-pill: 9999px;

  --ease: cubic-bezier(0.32, 0.72, 0.16, 1);
  --t-fast: 180ms;
  --t-med: 260ms;
  --t-slow: 360ms;

  --serif: "General Sans", "Inter", system-ui, sans-serif;   /* website has no serif — display = General Sans 600/700 */
  --sans: "General Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --canvas: hsl(200, 15%, 7%);       /* #0e1418 */
  --canvas-2: hsl(200, 12%, 10%);
  --surface: hsl(200, 15%, 12%);
  --surface-2: hsl(200, 12%, 14%);
  --border: hsl(200, 8%, 18%);
  --border-strong: hsl(200, 8%, 28%);
  --ink: hsl(200, 10%, 95%);         /* #ecf0f2 */
  --ink-muted: hsl(200, 6%, 60%);
  --ink-faint: hsl(200, 6%, 42%);

  --accent: hsl(183, 55%, 42%);      /* #318f9c lighter teal in dark */
  --accent-2: hsl(183, 80%, 28%);
  --accent-soft: hsl(183, 40%, 16%);
  --accent-ink: hsl(200, 25%, 10%);
  --accent-ring: hsl(183, 55%, 42% / 0.45);

  --link: hsl(183, 55%, 60%);

  --success: hsl(160, 50%, 50%);
  --success-soft: hsl(160, 30%, 14%);
  --warning: hsl(35, 70%, 55%);
  --warning-soft: hsl(35, 30%, 14%);
  --error: hsl(0, 65%, 55%);
  --error-soft: hsl(0, 30%, 14%);

  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.5), 0 18px 40px rgba(0, 0, 0, 0.5);
  --shadow-paper: 0 1px 0 rgba(0, 0, 0, 0.4), 0 12px 32px -10px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  transition: background var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
}

::selection {
  background: var(--accent);
  color: #fff;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.tabular {
  font-variant-numeric: tabular-nums lining-nums;
}

.serif {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.005em;
}

.serif-italic {
  font-family: var(--serif);
  font-weight: 700;
  font-weight: 400;
  letter-spacing: -0.005em;
}

.muted {
  color: var(--ink-muted);
}
.faint {
  color: var(--ink-faint);
}

/* ============================================================
   Layout shell
   ============================================================ */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 1024px) {
  .shell {
    padding: 0 40px;
  }
}

.page {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.page-enter {
  animation: pageIn 320ms var(--ease);
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  /* On the live site the eye is just the icon in teal — no dark tile. */
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.brand-mark svg {
  display: block;
}

.brand-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
}

.brand-sub {
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}

/* ============================================================
   Buttons / Pills
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-2);
  box-shadow: 0 4px 14px var(--accent-ring);
}
.btn-primary:active {
  transform: translateY(1px);
}
.btn-primary:disabled {
  background: var(--ink-faint);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

/* Outlined accent variant for "alternate primary" actions — e.g. the
   consent drawer's "Send for at-home signing" sitting next to the filled
   "Sign now on this iPad" primary. Clearly a button (visible border + tint)
   without competing with the primary action. */
.btn-secondary {
  background: var(--accent-ring, rgba(14, 125, 128, 0.08));
  color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:hover {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 14px var(--accent-ring);
}
.btn-secondary:active {
  transform: translateY(1px);
}
.btn-secondary:disabled {
  background: transparent;
  color: var(--ink-faint);
  border-color: var(--ink-faint);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12.5px;
}

.btn-lg {
  height: 44px;
  padding: 0 22px;
  font-size: 14.5px;
}

/* status pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-pending {
  background: var(--accent-soft);
  color: var(--accent);
}
.pill-synced {
  background: var(--success-soft);
  color: var(--success);
}
.pill-archived {
  background: var(--surface-2);
  color: var(--ink-faint);
  border-color: var(--border);
}
.pill-warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.pill-neutral {
  background: var(--surface-2);
  color: var(--ink-muted);
  border-color: var(--border);
}
.pill-setmore {
  background: hsl(183 60% 95%);
  color: hsl(183 80% 24%);
  border-color: hsl(183 50% 80%);
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .pill-setmore {
  background: hsl(183 40% 16%);
  color: hsl(183 60% 78%);
  border-color: hsl(183 30% 30%);
}

/* ============================================================
   Setmore — booking drawer post-op review section
   ============================================================ */
.postop-block {
  margin-top: 18px;
  padding: 14px 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: hsl(183 30% 98%);
}
[data-theme="dark"] .postop-block {
  background: hsl(183 30% 12%);
  border-color: var(--border-strong);
}
.postop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.postop-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.postop-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 10px;
  font-size: 14px;
}
.drawer-body .postop-modes label,
.postop-modes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13.5px;
  letter-spacing: normal;
  text-transform: none;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0;
  white-space: nowrap;
}
.drawer-body .postop-block .postop-title {
  text-transform: none;
  letter-spacing: normal;
}
.postop-modes input[type="radio"] {
  margin: 0;
}
.postop-status {
  font-size: 13px;
  margin-bottom: 6px;
}
.drawer-sm { max-width: 480px; }

/* ============================================================
   Inputs
   ============================================================ */
.input {
  height: 42px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--ink);
  font-size: 14px;
  width: 100%;
  transition: border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.input::placeholder {
  color: var(--ink-faint);
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26, 22, 18, 0.06);
}

.input-pill {
  height: 42px;
  padding: 0 18px 0 44px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
}

.search {
  position: relative;
  flex: 1;
  max-width: 380px;
}

.search svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

/* ============================================================
   Cards / Folder cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
  transition: transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.card-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
}

/* Patient folder row */
.folder-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.folder-row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.9fr auto;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-1);
  cursor: pointer;
  /* Skip iOS double-tap-zoom delay on patient cards. */
  touch-action: manipulation;
  transition: transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.folder-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
}

.folder-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.folder-row.expanded {
  border-color: var(--ink);
  box-shadow: var(--shadow-2);
}

.folder-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  color: var(--ink);
}

.folder-meta {
  font-size: 13px;
  color: var(--ink-muted);
}

.folder-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover {
  background: var(--canvas-2);
  color: var(--ink);
}

/* Drill detail panel */
.drill {
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  margin-top: -10px;
  margin-bottom: 10px;
  animation: drillIn 200ms var(--ease);
  /* Hint the compositor — animate on its own layer to avoid main-thread paints. */
  will-change: transform, opacity;
}

/* GPU-only keyframes: animating max-height triggered a full reflow on every
   frame for 340ms on every expand, which dominated the sluggish iPad feel.
   Now we animate only opacity + transform, both compositor-friendly. */
@keyframes drillIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.drill-inner {
  padding: 22px 24px 26px;
}

/* When a row is expanded, square its bottom corners */
.folder-row.expanded {
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  border-bottom-color: var(--border);
}

/* ============================================================
   Filter chips
   ============================================================ */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--canvas);
}

.chip-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--canvas-2);
  color: var(--ink-muted);
}

.chip[aria-pressed="true"] .chip-count {
  background: rgba(255, 255, 255, 0.14);
  color: var(--canvas);
}

/* ============================================================
   Heidi sync bar
   ============================================================ */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-1);
}

.sync-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--canvas-2);
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.sync-text {
  font-size: 14px;
  color: var(--ink);
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-text strong {
  font-family: var(--serif);
  font-weight: 700;
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
}

.sync-text .roll {
  line-height: 1;
}

.sync-text .roll-digit {
  height: 1em;
  line-height: 1;
}

.sync-text .roll-digit-track span {
  height: 1em;
  line-height: 1;
}

.progress-arc {
  width: 22px;
  height: 22px;
}

/* Number roll widget */
.roll {
  display: inline-flex;
  align-items: baseline;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum", "lnum";
  letter-spacing: -0.01em;
}

.roll-digit {
  display: inline-block;
  overflow: hidden;
  height: 1em;
  line-height: 1;
  vertical-align: baseline;
  text-align: center;
}

.roll-digit-track {
  display: flex;
  flex-direction: column;
  transition: transform 420ms var(--ease);
}

.roll-digit-track span {
  height: 1em;
  line-height: 1;
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ============================================================
   Document stack
   ============================================================ */
.doc-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.doc-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
  border-color: var(--border-strong);
}

.doc-icon {
  width: 36px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--canvas);
  position: relative;
  flex-shrink: 0;
}

.doc-icon::before {
  content: "";
  position: absolute;
  inset: 8px 6px;
  background: repeating-linear-gradient(
    to bottom,
    var(--border-strong) 0,
    var(--border-strong) 1px,
    transparent 1px,
    transparent 6px
  );
}

.doc-icon::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: var(--surface-2);
  border-left: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.doc-title {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}

.doc-meta {
  font-size: 12px;
  color: var(--ink-faint);
}

.doc-body {
  flex: 1;
  min-width: 0;
}

/* ============================================================
   Start hub tiles
   ============================================================ */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 640px) {
  .tile-grid {
    grid-template-columns: 1fr;
  }
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card-lg);
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease),
    border-color var(--t-fast) var(--ease);
  min-height: 180px;
  box-shadow: var(--shadow-1);
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
}

.tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--canvas-2);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.tile-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 26px;
  color: var(--ink);
  line-height: 1.1;
}

.tile-desc {
  font-size: 13.5px;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ============================================================
   Paper-card form
   ============================================================ */
.paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 44px;
  box-shadow: var(--shadow-paper);
  max-width: 760px;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .paper {
    padding: 28px 24px;
  }
}

.paper-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 28px;
}

.paper-eyebrow {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.paper-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 36px;
  line-height: 1;
  color: var(--ink);
  margin: 6px 0 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px 24px;
}

@media (max-width: 640px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.field-input {
  border: none;
  background: transparent;
  border-bottom: 1px solid var(--border-strong);
  padding: 6px 0;
  font-size: 16px;
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease);
}

.field-input:hover {
  border-bottom-color: var(--ink-muted);
}

.field-input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.paper-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px dashed var(--border);
}

/* ============================================================
   Login
   ============================================================ */
.login-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-paper);
  text-align: center;
}

.login-mark {
  /* Match the live site: the eye sits naked in teal, no dark tile. */
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.login-mark svg {
  width: 44px;
  height: 44px;
}

.login-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  white-space: nowrap;
}

.login-sub {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 30px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.login-foot {
  margin-top: 22px;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ============================================================
   Done state
   ============================================================ */
.done-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px;
}

.done-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 96px;
  line-height: 0.95;
  margin: 0;
  letter-spacing: -0.02em;
}

@media (max-width: 720px) {
  .done-title {
    font-size: 72px;
  }
}

.done-sub {
  font-size: 17px;
  color: var(--ink-muted);
  margin: 16px 0 40px;
  max-width: 460px;
}

.download-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 620px;
}

@media (max-width: 640px) {
  .download-row {
    grid-template-columns: 1fr;
  }
}

.download-card {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  transition: transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease);
  box-shadow: var(--shadow-1);
}

.download-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.download-label {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
}

.download-meta {
  font-size: 12px;
  color: var(--ink-faint);
}

/* ============================================================
   Empty / loading / error
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--ink-muted);
}

.empty-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 36px;
  color: var(--ink);
  margin: 0 0 8px;
}

.empty-sub {
  margin-bottom: 26px;
  font-size: 14.5px;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  animation: pulse 1.6s var(--ease) infinite;
}

.skeleton-pill {
  background: var(--canvas-2);
  border-radius: var(--radius-pill);
  height: 12px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* Toast */
#toast-region {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: var(--canvas);
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  animation: toastIn 320ms var(--ease);
  max-width: 360px;
}

.toast.toast-error {
  background: var(--error);
  color: #fff;
}

.toast.leaving {
  animation: toastOut 240ms var(--ease) forwards;
}

@keyframes toastIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toastOut {
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}

/* ============================================================
   Theme toggle
   ============================================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.theme-toggle button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.theme-toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--canvas);
}

/* ============================================================
   Section headers
   ============================================================ */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 32px;
  line-height: 1;
  margin: 0;
  color: var(--ink);
}

.page-sub {
  font-size: 14px;
  color: var(--ink-muted);
  margin: 6px 0 0;
}

.section-h {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.toolbar .search {
  flex: 1;
  min-width: 220px;
}

/* ============================================================
   Detail block grid
   ============================================================ */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 28px;
}

@media (max-width: 720px) {
  .kv-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.kv-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

.kv-value {
  font-size: 14.5px;
  color: var(--ink);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* responsive folder row: phones / narrow tablets */
@media (max-width: 820px) {
  .folder-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name actions"
      "meta1 meta1"
      "meta2 meta2";
    row-gap: 6px;
    padding: 14px 18px;
  }
  .folder-row .col-name {
    grid-area: name;
  }
  .folder-row .col-actions {
    grid-area: actions;
  }
  .folder-row .col-dob,
  .folder-row .col-phone,
  .folder-row .col-visit {
    font-size: 12.5px;
    color: var(--ink-muted);
  }
  .folder-row .col-dob {
    grid-area: meta1;
    display: inline-flex;
    gap: 12px;
  }
  .folder-row .col-phone {
    grid-area: meta1;
    justify-self: end;
  }
  .folder-row .col-visit {
    grid-area: meta2;
  }
}

/* spinner */
.spinner {
  width: 14px;
  height: 14px;
  border: 1.6px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  display: inline-block;
}

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

/* check icon morph */
.check-svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.check-svg path {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: drawCheck 360ms var(--ease) forwards;
}

@keyframes drawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

/* Stagger helpers */
.stagger > * {
  animation: pageIn 380ms var(--ease) both;
}
.stagger > *:nth-child(1) { animation-delay: 30ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 90ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 150ms; }
.stagger > *:nth-child(6) { animation-delay: 180ms; }
.stagger > *:nth-child(7) { animation-delay: 210ms; }
.stagger > *:nth-child(8) { animation-delay: 240ms; }
.stagger > *:nth-child(9) { animation-delay: 270ms; }
.stagger > *:nth-child(10) { animation-delay: 300ms; }
.stagger > *:nth-child(n+11) { animation-delay: 330ms; }

/* Big serif emphasis */
.lede {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.15;
  color: var(--ink);
}

/* link-like */
.linkish {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-fast) var(--ease);
}
.linkish:hover {
  border-bottom-color: var(--accent);
}

/* divider */
.hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Tabs panel */
.tab-panel {
  animation: pageIn 280ms var(--ease);
}

/* Heidi push button states */
.morph-btn[data-state="loading"],
.morph-btn[data-state="done"] {
  pointer-events: none;
}

.morph-btn[data-state="done"] {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* Footer spacing */
.bottom-spacer {
  height: 80px;
}

/* =========================================================
   Generate action row + side drawer (NEW for filler app port)
   ========================================================= */
.gen-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.gen-row-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent-2, var(--accent));
  padding-right: 12px;
  border-right: 1px solid var(--border);
}
.gen-row-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.gen-row-buttons .btn {
  background: #fff;
  border: 1px solid var(--border);
}
.gen-row-buttons .btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.gen-row-buttons .btn svg {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  vertical-align: -3px;
}

/* Drawer */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(19, 28, 32, 0.42);
  backdrop-filter: blur(2px);
  z-index: 50;
  opacity: 0;
  animation: drawerFade 220ms var(--ease) forwards;
}
@keyframes drawerFade { to { opacity: 1; } }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 48px -12px rgba(19, 28, 32, 0.18);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  animation: drawerIn 320ms var(--ease) forwards;
}
@keyframes drawerIn { to { transform: translateX(0); } }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
}
.drawer-head .muted { font-size: 13px; margin-top: 4px; }
.drawer-close {
  background: transparent;
  border: 0;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink-muted);
}
.drawer-close:hover { background: var(--accent-soft); color: var(--accent); }
.drawer-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.drawer-body .field { margin-bottom: 16px; }
.drawer-body label {
  display: block;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.drawer-body input,
.drawer-body textarea,
.drawer-body select {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.drawer-body input:focus,
.drawer-body textarea:focus,
.drawer-body select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px hsl(183 45% 92%);
}
.drawer-body .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.drawer-services {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 8px;
}
.drawer-services label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}
.drawer-services label:hover { border-color: var(--accent); }
.drawer-services input[type=checkbox] { width: auto; }

/* Payment method — large, tappable segmented options for iPad. One per row
   on narrow widths; sit in a row when there's space. */
.pay-method-group {
  display: flex;
  gap: 10px;
}
.pay-method-opt {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  transition: border-color .12s, background .12s, color .12s;
}
.pay-method-opt:hover { border-color: var(--accent); }
.pay-method-opt input[type=radio] {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}
/* Highlight the chosen option (the radio is inside, :has is well-supported
   on the iPad Safari versions in use). */
.pay-method-opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-ring, rgba(14, 125, 128, 0.08));
  color: var(--accent);
}

/* Blocking warning splash (showWarningSplash) */
.warn-splash-scrim {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
  animation: warn-fade 0.14s ease;
}
@keyframes warn-fade { from { opacity: 0; } to { opacity: 1; } }
.warn-splash-card {
  background: #fff;
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  padding: 32px 28px 24px;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  animation: warn-pop 0.16s ease;
}
@keyframes warn-pop { from { transform: scale(0.94); } to { transform: scale(1); } }
.warn-splash-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--warning-dark, #b45309);
  background: var(--warning-bg, #fef3c7);
}
.warn-splash-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.warn-splash-msg {
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-muted, #5a7070);
  margin-bottom: 22px;
}
.warn-splash-ok {
  min-width: 120px;
  min-height: 46px;
}
.drawer-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface);
}
@media (max-width: 600px) {
  .drawer { width: 100vw; }
  .drawer-body .two-col { grid-template-columns: 1fr; }
}

/* =========================================================
   Tidied tiles on /start (New document picker)
   ========================================================= */
.tile-grid-tidy {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 24px;
}
@media (max-width: 720px) {
  .tile-grid-tidy { grid-template-columns: 1fr; }
}
.tile-tidy {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 180ms var(--ease), transform 180ms var(--ease), box-shadow 180ms var(--ease);
  min-height: 168px;
}
.tile-tidy:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -12px rgba(14, 123, 129, 0.25);
}
.tile-tidy:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tile-icon-teal {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.tile-icon-teal svg { width: 22px; height: 22px; }
.tile-tidy .tile-body { flex: 1; }
.tile-tidy .tile-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  line-height: 1.2;
  margin: 0 0 6px 0;
}
.tile-tidy .tile-desc {
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.5;
}
.tile-tidy .tile-cta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-top: auto;
}
.tile-tidy .tile-cta-chev svg {
  width: 16px;
  height: 16px;
  transition: transform 180ms var(--ease);
}
.tile-tidy:hover .tile-cta-chev svg { transform: translateX(3px); }

/* =========================================================
   Pick patient screen
   ========================================================= */
.pick-search {
  position: relative;
  margin: 18px 0 12px;
}
.pick-search input {
  width: 100%;
  padding: 14px 14px 14px 44px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
}
.pick-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px hsl(183 45% 92%);
}
.pick-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  display: grid; place-items: center;
}
.pick-search-icon svg { width: 18px; height: 18px; }
.pick-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pick-row {
  display: grid;
  grid-template-columns: 1fr auto 28px;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 160ms var(--ease), transform 160ms var(--ease);
}
.pick-row:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}
.pick-row-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}
.pick-row-meta {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 2px;
}
.pick-row-side { font-size: 13px; }
.pick-row-cta { color: var(--ink-muted); }
.pick-row-cta svg { width: 18px; height: 18px; }
.pick-empty {
  padding: 22px;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--ink-muted);
  font-size: 14px;
  text-align: center;
}
.pick-empty .link {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}
.pick-empty .link:hover { text-decoration: underline; }
@media (max-width: 600px) {
  .pick-row { grid-template-columns: 1fr 24px; }
  .pick-row-side { grid-column: 1; font-size: 12px; }
}

/* =========================================================
   Theatre List — Index page
   ========================================================= */
.theatre-index-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.theatre-index-row {
  display: grid;
  grid-template-columns: 1fr auto 28px;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 160ms var(--ease), transform 160ms var(--ease), box-shadow 160ms var(--ease);
}

.theatre-index-row:hover {
  border-color: var(--accent);
  transform: translateX(2px);
  box-shadow: var(--shadow-1);
}

.theatre-index-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Locked list — flagged red on the index page so it's obvious at a glance
   that the list is finalised and no further edits can be made. */
.theatre-index-row-locked {
  background: var(--error-soft);
  border-color: var(--error);
}

.theatre-index-row-locked:hover {
  border-color: var(--error);
}

.theatre-locked-pill {
  background: var(--error);
  color: #fff;
  font-weight: 600;
}

.theatre-index-date {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 3px;
}

.theatre-index-meta {
  font-size: 13px;
}

.theatre-index-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theatre-index-cta {
  color: var(--ink-muted);
}

.theatre-index-cta svg { width: 18px; height: 18px; }

/* =========================================================
   Theatre List — Editor page
   ========================================================= */
.theatre-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.theatre-header-left { flex: 1; }
.theatre-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

/* Horizontally scrollable table wrapper on mobile */
.theatre-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.theatre-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 980px;
}

/* Procedure names (e.g. "Right Cataract+POAG (Phaco/IOL/iStent/Goniotomy)")
   are long — give the column and its <select> enough room that the full
   text is always visible instead of being clipped. The table-wrap's
   overflow-x:auto handles the rest on narrow screens. */
.theatre-procedure-cell { min-width: 360px; }
.theatre-procedure-select { min-width: 360px; }

.theatre-table thead tr {
  background: var(--canvas-2);
  border-bottom: 2px solid var(--border);
}

.theatre-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}

.theatre-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--ink);
}

.theatre-table tbody tr:last-child td {
  border-bottom: none;
}

.theatre-table tbody tr:hover td {
  background: var(--canvas-2);
}

.theatre-name {
  font-weight: 500;
  white-space: nowrap;
}

.theatre-input {
  height: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  width: 100%;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}

.theatre-input:hover,
.theatre-input:focus {
  border-color: var(--border);
  background: var(--surface);
  outline: none;
}

.theatre-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theatre-lens::placeholder { color: var(--ink-faint); }
.theatre-lens-empty { font-style: italic; color: var(--ink-muted) !important; }

/* Consent received checkbox in theatre row */
.theatre-pt-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 500;
  color: var(--primary, #0e7d80);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}
.theatre-pt-link:hover {
  text-decoration-color: var(--primary, #0e7d80);
}

.theatre-consent-label {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; user-select: none;
}
.theatre-consent-cb {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand, #0a7ea4);
}

.theatre-select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  width: 100%;
  cursor: pointer;
}

.theatre-select:hover,
.theatre-select:focus {
  border-color: var(--border);
  background: var(--surface);
  outline: none;
}

.theatre-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theatre-empty {
  text-align: center;
  padding: 28px !important;
  color: var(--ink-muted);
  font-size: 14px;
}

/* Theatre add-to-list block in booking drawer */
.theatre-add-block {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: hsl(183 30% 98%);
}

[data-theme="dark"] .theatre-add-block {
  background: hsl(183 30% 12%);
  border-color: var(--border-strong);
}

.theatre-add-check-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600 !important;
  font-size: 14px !important;
  color: var(--ink) !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.theatre-add-check-label input[type="checkbox"] {
  width: auto !important;
  height: auto;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Dark mode: table and editor */
[data-theme="dark"] .theatre-table-wrap {
  border-color: var(--border);
}

[data-theme="dark"] .theatre-table thead tr {
  background: var(--canvas-2);
}

[data-theme="dark"] .theatre-table tbody tr:hover td {
  background: var(--surface-2);
}

[data-theme="dark"] .theatre-input:hover,
[data-theme="dark"] .theatre-input:focus {
  background: var(--canvas-2);
}

[data-theme="dark"] .theatre-select:hover,
[data-theme="dark"] .theatre-select:focus {
  background: var(--canvas-2);
}

[data-theme="dark"] .theatre-index-row {
  background: var(--surface);
}

/* Responsive: 375px */
@media (max-width: 600px) {
  .theatre-index-row {
    grid-template-columns: 1fr 28px;
    row-gap: 8px;
  }
  .theatre-index-side {
    display: flex;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
  }
  .theatre-header {
    flex-direction: column;
    gap: 12px;
  }
  .theatre-header-right {
    padding-top: 0;
  }
}

/* =========================================================
   Dark-mode overrides for hardcoded white surfaces
   ========================================================= */
[data-theme="dark"] .gen-row-buttons .btn {
  background: var(--surface);
  color: var(--ink);
}
[data-theme="dark"] .gen-row-buttons .btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
}
[data-theme="dark"] .drawer-body input,
[data-theme="dark"] .drawer-body textarea,
[data-theme="dark"] .drawer-body select {
  background: var(--canvas-2);
  color: var(--ink);
  border-color: var(--border);
}
[data-theme="dark"] .drawer-body input::placeholder,
[data-theme="dark"] .drawer-body textarea::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}
[data-theme="dark"] .drawer-body input:focus,
[data-theme="dark"] .drawer-body textarea:focus,
[data-theme="dark"] .drawer-body select:focus {
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px hsla(183, 60%, 35%, 0.25);
}
[data-theme="dark"] .tile-tidy {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .tile-tidy:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .pick-search input {
  background: var(--canvas-2);
  color: var(--ink);
}
[data-theme="dark"] .pick-search input::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}
[data-theme="dark"] .pick-row {
  background: var(--surface);
}
[data-theme="dark"] .pick-row:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
[data-theme="dark"] .pick-empty {
  background: var(--surface);
  color: var(--ink-muted);
}

/* ============================================================
   Row 3-dot menu popup (patient row "⋯" → Edit/Consent/etc.)
   ============================================================ */
.row-menu-pop {
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 32px -10px rgba(15, 29, 46, 0.18),
              0 4px 12px -4px rgba(15, 29, 46, 0.10);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: rowMenuIn 130ms ease-out;
  transform-origin: top right;
}
@keyframes rowMenuIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.row-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  transition: background 110ms ease, color 110ms ease;
  width: 100%;
}
.row-menu-item:hover,
.row-menu-item:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}
.row-menu-item svg {
  flex: 0 0 auto;
  color: var(--ink-muted);
}
.row-menu-item:hover svg,
.row-menu-item:focus-visible svg {
  color: var(--accent);
}
[data-theme="dark"] .row-menu-pop {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.6),
              0 6px 14px -4px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .row-menu-item {
  color: var(--ink);
}
[data-theme="dark"] .row-menu-item:hover,
[data-theme="dark"] .row-menu-item:focus-visible {
  background: var(--accent-soft);
  color: var(--ink);
}
[data-theme="dark"] .row-menu-item svg {
  color: var(--ink-muted);
}
[data-theme="dark"] .row-menu-item:hover svg,
[data-theme="dark"] .row-menu-item:focus-visible svg {
  color: var(--accent);
}

/* ----- Procedure preset chips ------------------------------------------- */
.proc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}
.proc-chip {
  appearance: none;
  background: var(--surface-2, #f4f5f7);
  border: 1px solid var(--border, #e2e4e8);
  color: var(--ink, #1a1d21);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.2;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.proc-chip:hover,
.proc-chip:focus-visible {
  background: var(--accent-tint, #e6f4f1);
  border-color: var(--accent, #1f8a72);
  color: var(--accent, #1f8a72);
  outline: none;
}
.proc-chip[aria-pressed="true"] {
  background: var(--accent, #1f8a72);
  border-color: var(--accent, #1f8a72);
  color: #fff;
}
[data-theme="dark"] .proc-chip {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.12);
  color: var(--ink, #e6e8ec);
}
[data-theme="dark"] .proc-chip:hover,
[data-theme="dark"] .proc-chip:focus-visible {
  background: rgba(31,138,114,.18);
  border-color: var(--accent, #4cc4a8);
  color: var(--accent, #4cc4a8);
}
[data-theme="dark"] .proc-chip[aria-pressed="true"] {
  background: var(--accent, #1f8a72);
  border-color: var(--accent, #1f8a72);
  color: #0b0e12;
}

/* ----- Upcoming appointment chip ---------------------------------------- */
.chip-upcoming {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #e0f2fe;
  color: #075985;
  margin-left: 8px;
}
[data-theme="dark"] .chip-upcoming {
  background: rgba(7, 89, 133, 0.35);
  color: #7dd3fc;
}
/* ============================================================
   Copilot-inspired sidebar shell layout
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 228px;
  flex-shrink: 0;
  background: hsl(200, 24%, 10%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  overflow-y: auto;
}

[data-theme="dark"] .sidebar {
  background: hsl(200, 20%, 7%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.main-wrap {
  flex: 1;
  min-width: 0;
  margin-left: 228px;
  min-height: 100vh;
}

/* Brand block */
.sidebar-brand {
  padding: 22px 18px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 4px;
  flex-shrink: 0;
}

.sidebar-brand-mark {
  width: 26px;
  height: 26px;
  color: hsl(183, 65%, 58%);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.sidebar-brand-mark svg { display: block; }

.sidebar-brand-name {
  font-weight: 700;
  font-size: 14.5px;
  color: rgba(255, 255, 255, 0.93);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.22);
  padding: 16px 8px 5px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.48);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 130ms ease, color 130ms ease;
  letter-spacing: -0.005em;
  font-family: var(--sans);
}

.sidebar-nav-item svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  opacity: 0.55;
  transition: opacity 130ms ease;
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.85);
}

.sidebar-nav-item:focus-visible {
  outline: 2px solid hsl(183, 60%, 74%);
  outline-offset: -2px;
  color: rgba(255, 255, 255, 0.95);
}

.sidebar-nav-item:hover svg { opacity: 0.9; }

.sidebar-nav-item.active {
  background: hsl(183 60% 20% / 0.7);
  color: hsl(183, 60%, 74%);
}

.sidebar-nav-item.active svg { opacity: 1; }

/* Status dot beside a sidebar nav item (e.g. Setmore connected/disconnected) */
.sidebar-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  margin-left: auto;
}
.sidebar-status-dot.connected {
  background: hsl(145, 60%, 48%);
  box-shadow: 0 0 4px hsl(145, 60%, 48%);
}

/* Footer */
.sidebar-foot {
  padding: 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar .theme-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar .theme-toggle button {
  color: rgba(255, 255, 255, 0.36);
}

.sidebar .theme-toggle button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.88);
}

.sidebar-avatar {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: hsl(183, 45%, 20%);
  color: hsl(183, 60%, 70%);
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid hsl(183, 35%, 30%);
}

/* Hide old topbar (now a no-op but keep selector for safety) */
.topbar { display: none; }

/* Mobile: stack sidebar above content */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    padding-bottom: 0;
  }
  .sidebar-brand { border-bottom: none; border-right: 1px solid rgba(255,255,255,0.07); margin-bottom: 0; }
  .sidebar-nav { flex-direction: row; flex: 0 0 auto; gap: 2px; padding: 8px 6px; overflow-x: auto; }
  .sidebar-section-label { display: none; }
  .sidebar-nav-item { padding: 7px 10px; font-size: 12.5px; gap: 6px; white-space: nowrap; }
  .sidebar-foot { padding: 8px 12px; border-top: none; border-left: 1px solid rgba(255,255,255,0.07); margin-left: auto; }
  .app-shell { flex-direction: column; }
  .main-wrap { margin-left: 0; }
}

/* ============================================================
   Copilot-inspired visual refinements
   ============================================================ */

/* Larger, bolder page title */
.page-title {
  font-size: 36px;
  letter-spacing: -0.025em;
}

/* Tighter section-head spacing */
.section-head {
  padding-top: 32px;
  padding-bottom: 4px;
}

/* Card: larger radius, airier shadow */
.card {
  border-radius: 16px;
  box-shadow: 0 1px 3px hsl(200 25% 10% / 0.04), 0 6px 20px hsl(200 25% 10% / 0.05);
}

/* Folder rows: more Copilot-like with accent hover border */
.folder-row {
  border-radius: 16px;
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), border-color 150ms ease;
}

.folder-row:hover {
  border-color: hsl(183 50% 72%);
  box-shadow: 0 4px 20px hsl(200 25% 10% / 0.08);
}

.folder-name {
  font-size: 17px;
  letter-spacing: -0.015em;
}

/* Tile hover: teal accent glow */
.tile-tidy:hover {
  box-shadow: 0 8px 28px -10px hsl(183 70% 40% / 0.3);
}

/* Chip active: use accent instead of pure ink */
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Search input: pill with more visual weight */
.input-pill {
  border-radius: var(--radius-pill);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 3px hsl(200 25% 10% / 0.04);
}

/* Page-enter animation plays relative to main-wrap */
.main-wrap .page-enter {
  animation: pageIn 300ms var(--ease);
}

/* ============================================================
   Copilot-style stats strip
   ============================================================ */
.stats-strip {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 3px hsl(200 25% 10% / 0.04), 0 4px 14px hsl(200 25% 10% / 0.04);
  overflow: hidden;
  margin-bottom: 24px;
}

.stat-cell {
  flex: 1;
  padding: 16px 22px;
  border-right: 1px solid var(--border);
}

.stat-cell:last-child { border-right: none; }

.stat-num {
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.03em;
  font-family: var(--serif);
}

.stat-label {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 5px;
  font-weight: 500;
}

[data-theme="dark"] .stats-strip {
  background: var(--surface);
  border-color: var(--border);
}

/* ============================================================
   Patient avatar (Copilot-style category icon)
   ============================================================ */
.patient-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  user-select: none;
  position: relative;
  /* Fallback surface so the avatar is always visible even if JS does not
     supply an inline category colour. */
  background: var(--accent-soft);
  color: var(--accent);
}

.avatar-setmore-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0d9488;
  border: 2px solid var(--surface);
  display: grid;
  place-items: center;
  pointer-events: none;
}

[data-theme="dark"] .avatar-setmore-badge {
  border-color: var(--surface, #1e1e2e);
}

/* Update folder-row grid to include avatar column */
.folder-row {
  grid-template-columns: 42px 1.4fr 1fr 1fr 0.9fr auto;
  padding: 14px 18px 14px 14px;
  border-radius: 16px;
}

/* Full-width search on the patient list */
.search-full {
  max-width: none;
  flex: 1;
}

.toolbar-list {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar-list .search-full {
  width: 100%;
}

.toolbar-list .chips {
  justify-content: flex-start;
}

/* Responsive: avatar in mobile grid */
@media (max-width: 820px) {
  .folder-row {
    grid-template-columns: 42px 1fr auto;
    grid-template-areas:
      "avatar name actions"
      "meta1 meta1 meta1"
      "meta2 meta2 meta2";
  }
  .folder-row .patient-avatar { grid-area: avatar; align-self: center; }
  .folder-row .col-name       { grid-area: name; }
  .folder-row .col-actions    { grid-area: actions; }
  .folder-row .col-dob        { grid-area: meta1; display: inline-flex; gap: 12px; }
  .folder-row .col-phone      { grid-area: meta1; justify-self: end; }
  .folder-row .col-visit      { grid-area: meta2; }
  .stats-strip { flex-wrap: wrap; }
  .stat-cell { flex: 1 1 40%; border-bottom: 1px solid var(--border); }
  .stat-cell:last-child { border-bottom: none; }
}

/* ---- Setmore search suggestions ---- */
.setmore-suggest-section {
  margin: 8px 0 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.setmore-suggest-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
  padding: 8px 16px 6px;
  border-bottom: 1px solid var(--border);
}
.setmore-suggest-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.setmore-suggest-row:last-child { border-bottom: none; }
.setmore-suggest-row:hover { background: var(--surface-2); }
.setmore-suggest-row:focus-visible {
  background: var(--surface-2);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.setmore-suggest-info { flex: 1; min-width: 0; }
.setmore-suggest-name { font-weight: 500; font-size: 14px; color: var(--ink); }
.setmore-suggest-meta { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }

/* ============================================================
   Setmore calendar (Month / Week / Day)
   ============================================================ */
:root {
  --cal-gutter: 58px;
  --cal-row-h: 56px;                 /* keep in sync with CAL_ROW_H in app.js */
  /* Three appointment categories — soft accents that read on app surfaces. */
  --cal-rev-bar: #b9a7e0; --cal-rev-bg: #ece7f6;   /* Reviews  → lavender */
  --cal-new-bar: #f0a868; --cal-new-bg: #fbe6d6;   /* New      → peach    */
  --cal-info-bar: #9bc4e8; --cal-info-bg: #e6f0fa; /* Info     → blue     */
}
[data-theme="dark"] {
  --cal-rev-bg: hsl(258 38% 24% / 0.6);
  --cal-new-bg: hsl(28 48% 24% / 0.55);
  --cal-info-bg: hsl(205 48% 24% / 0.55);
}

#setmore-calendar .section-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.cal-root {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.cal-toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cal-nav { display: inline-flex; align-items: center; gap: 4px; }
.cal-iconbtn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-muted);
  border-radius: var(--radius-input); cursor: pointer; transition: all .15s ease;
}
.cal-iconbtn:hover { color: var(--ink); border-color: var(--border-strong); }
.cal-todaybtn {
  height: 32px; padding: 0 14px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: 13px; border-radius: var(--radius-input);
  cursor: pointer; transition: all .15s ease;
}
.cal-todaybtn:hover { border-color: var(--border-strong); }
.cal-range-label { font-size: 16px; font-weight: 650; color: var(--ink); letter-spacing: -0.01em; }
.cal-viewtoggle {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-input); padding: 2px; gap: 2px;
}
.cal-viewbtn {
  border: 0; background: transparent; color: var(--ink-muted); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 5px 14px; border-radius: 6px; transition: all .15s ease;
}
.cal-viewbtn:hover { color: var(--ink); }
.cal-viewbtn.active { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.cal-body { padding: 0; }
.cal-loading, .cal-empty { padding: 48px 24px; text-align: center; }
.cal-empty-title { font-weight: 650; font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.cal-empty-sub { font-size: 13.5px; margin-bottom: 16px; }

/* ---- Month view ---- */
.cal-m-head, .cal-m-row {
  display: grid; grid-template-columns: var(--cal-gutter) repeat(7, minmax(0, 1fr));
}
.cal-m-head { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-m-wd {
  padding: 8px 10px; font-size: 11.5px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-faint); text-align: left;
}
.cal-m-row { border-bottom: 1px solid var(--border); }
.cal-m-row:last-child { border-bottom: 0; }
.cal-m-wk {
  border-right: 1px solid var(--border); background: var(--surface-2);
  display: grid; place-content: center; gap: 0;
}
.cal-m-wkbtn {
  border: 0; cursor: pointer; color: var(--ink-faint); width: 100%; height: 100%;
  display: grid; place-content: center; line-height: 1; transition: all .15s ease;
}
.cal-m-wkbtn:hover { background: var(--accent-soft); color: var(--accent); }
.cal-m-wknum { font-size: 14px; font-weight: 650; color: var(--ink-muted); }
.cal-m-wklbl { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; }
.cal-m-cell {
  border: 0; border-left: 1px solid var(--border); background: var(--surface); cursor: pointer;
  min-height: 96px; padding: 6px 7px; display: flex; flex-direction: column; gap: 4px;
  text-align: left; transition: background .12s ease; overflow: hidden;
}
.cal-m-cell:hover { background: var(--surface-2); }
.cal-m-out { background: var(--surface-2); }
.cal-m-out .cal-m-date { color: var(--ink-faint); }
.cal-m-top { display: flex; align-items: center; justify-content: space-between; }
.cal-m-date { font-size: 13px; font-weight: 600; color: var(--ink); }
.cal-m-today .cal-m-date {
  background: var(--accent); color: var(--accent-ink); width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: 50%; font-weight: 700;
}
.cal-m-count {
  font-size: 10.5px; font-weight: 700; color: var(--ink-faint);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 0 6px; line-height: 16px;
}
.cal-m-evs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-m-ev {
  font-size: 11px; line-height: 1.45; color: var(--ink); padding: 1px 6px;
  border-left: 3px solid var(--border-strong); border-radius: 3px; background: var(--surface-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-m-ev.cal-ev-reviews { border-left-color: var(--cal-rev-bar); background: var(--cal-rev-bg); }
.cal-m-ev.cal-ev-new { border-left-color: var(--cal-new-bar); background: var(--cal-new-bg); }
.cal-m-ev.cal-ev-info { border-left-color: var(--cal-info-bar); background: var(--cal-info-bg); }
.cal-m-ev b { font-weight: 700; opacity: .75; font-variant-numeric: tabular-nums; }
.cal-m-more { font-size: 10.5px; color: var(--ink-faint); padding: 0 6px; font-weight: 600; }

/* ---- Week / Day time grid ---- */
.cal-colhead { display: grid; border-bottom: 1px solid var(--border); background: var(--surface); }
.cal-w-gutter-head { border-right: 1px solid var(--border); }
.cal-dayhead {
  border: 0; border-left: 1px solid var(--border); background: transparent; cursor: pointer;
  padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background .12s ease;
}
.cal-dayhead:hover { background: var(--surface-2); }
.cal-dayhead-day { cursor: default; }
.cal-dh-dow { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-faint); }
.cal-dh-num { font-size: 17px; font-weight: 650; color: var(--ink); }
.cal-dayhead.today .cal-dh-dow { color: var(--accent); }
.cal-dayhead.today .cal-dh-num {
  background: var(--accent); color: var(--accent-ink); min-width: 28px; height: 28px; padding: 0 6px;
  display: grid; place-items: center; border-radius: 14px;
}
.cal-scroll { overflow-y: auto; max-height: min(660px, 64vh); }
.cal-grid { display: grid; }
.cal-w-gutter { position: relative; border-right: 1px solid var(--border); }
.cal-hr { position: relative; }
.cal-hr span {
  position: absolute; top: -8px; right: 8px; font-size: 11px; color: var(--ink-faint);
  background: var(--surface); padding: 0 3px; font-variant-numeric: tabular-nums;
}
.cal-col {
  position: relative; border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom,
    var(--border) 0, var(--border) 1px, transparent 1px, transparent var(--cal-row-h));
}
.cal-col.today { background-color: hsl(183 45% 50% / 0.05); }

.cal-ev {
  position: absolute; box-sizing: border-box; overflow: hidden; cursor: pointer;
  border: 1px solid transparent; border-left: 3px solid var(--cal-rev-bar);
  background: var(--cal-rev-bg); border-radius: 6px; padding: 3px 7px;
  text-align: left; transition: filter .12s ease, box-shadow .12s ease; z-index: 1;
}
.cal-ev:hover { filter: brightness(0.97); box-shadow: var(--shadow-1); z-index: 3; }
.cal-ev-title { display: block; font-size: 12px; font-weight: 650; color: var(--ink); line-height: 1.25; }
.cal-ev-sub { display: block; font-size: 11px; color: var(--ink-muted); line-height: 1.2; margin-top: 1px; }
.cal-ev.is-trunc .cal-ev-title, .cal-ev.is-trunc .cal-ev-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.is-tight { padding: 1px 7px; }
.cal-ev.is-tight .cal-ev-sub { display: none; }
.cal-ev.is-tight .cal-ev-title { font-size: 11.5px; }
.cal-ev-reviews { border-left-color: var(--cal-rev-bar); background: var(--cal-rev-bg); }
.cal-ev-new { border-left-color: var(--cal-new-bar); background: var(--cal-new-bg); }
.cal-ev-info { border-left-color: var(--cal-info-bar); background: var(--cal-info-bg); }

/* current-time indicator */
.cal-now { position: absolute; left: 0; right: 0; height: 0; z-index: 4; pointer-events: none; }
.cal-now::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--error);
}
.cal-now-dot {
  position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--error);
}
.cal-now-chip {
  position: absolute; left: 4px; top: -9px; font-size: 10.5px; font-weight: 700; color: #fff;
  background: var(--error); border-radius: var(--radius-pill); padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

/* event detail popover */
.cal-pop-overlay {
  position: fixed; inset: 0; background: hsl(200 25% 10% / 0.45); z-index: 1000;
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px);
}
.cal-pop {
  width: min(420px, 92vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-2); overflow: hidden;
}
.cal-pop-bar { height: 5px; background: var(--cal-rev-bar); }
.cal-pop-bar.cal-ev-new { background: var(--cal-new-bar); }
.cal-pop-bar.cal-ev-info { background: var(--cal-info-bar); }
.cal-pop-bar.cal-ev-reviews { background: var(--cal-rev-bar); }
.cal-pop-body { padding: 18px 20px; }
.cal-pop-when { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.cal-pop-title { font-size: 18px; font-weight: 650; color: var(--ink); margin-bottom: 12px; line-height: 1.3; }
.cal-pop-row { display: grid; grid-template-columns: 70px 1fr; gap: 8px; font-size: 13.5px; padding: 5px 0; border-top: 1px solid var(--border); }
.cal-pop-row span { color: var(--ink-faint); font-weight: 600; }
.cal-pop-row div { color: var(--ink); min-width: 0; }
.cal-pop-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ── Clinic booking drawer ──────────────────────────────────────────────── */
.clinic-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.clinic-type-btn {
  flex: 1 1 auto;
  min-width: 110px;
  justify-content: center;
}
.clinic-slot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.clinic-slot-btn {
  min-width: 66px;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.clinic-slot-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

@media (max-width: 720px) {
  :root { --cal-gutter: 46px; }
  .cal-m-cell { min-height: 64px; gap: 0; }
  .cal-m-evs { display: none; }
  .cal-range-label { font-size: 14px; }
}

/* --- Consent badge styles (Phase C) --- */
.badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-grey  { background: #e5e7eb; color: #374151; }

/* --- Full-screen consent signing overlay --- */
.sig-full-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: #fff;
  display: flex; flex-direction: column;
  /* Keep status bar / notch clear on modern iPads */
  padding-top: env(safe-area-inset-top, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sig-full-header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: #f5f7fa; border-bottom: 1.5px solid #dee1e6;
  min-height: 56px;
}
.sig-full-header-info {
  flex: 1; min-width: 0;
}
.sig-full-header-info strong {
  display: block; font-size: 15px; color: #0a1f44; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sig-full-header-info span {
  font-size: 12px; color: #5f6b7a;
}
.sig-full-actions {
  display: flex; gap: 8px; flex-shrink: 0;
}
.sig-full-body {
  flex: 1; position: relative; overflow: hidden;
  background: #fff;
}
/* Faint horizontal guide line — not for drawing on, just orientation */
.sig-full-body::after {
  content: "";
  position: absolute;
  left: 5%; right: 5%;
  bottom: 30%;
  height: 1px;
  background: rgba(150, 180, 220, 0.35);
  pointer-events: none;
}
#sig-canvas-full {
  display: block;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.sig-full-tip {
  position: absolute; bottom: calc(30% + 8px); left: 5%;
  font-size: 11px; color: rgba(100, 130, 170, 0.7);
  pointer-events: none; user-select: none;
}

/* --- GP, Optician & Pharmacy directory --- */
.dir-tabs {
  display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap;
}
.dir-tab {
  padding: 7px 16px; border-radius: 20px; border: 1.5px solid var(--border);
  background: transparent; cursor: pointer; font-size: 13.5px; font-weight: 500;
  color: var(--ink-muted); display: flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s;
}
.dir-tab:hover { border-color: var(--accent); color: var(--ink); }
.dir-tab-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.dir-tab-active:hover { background: var(--accent); }
.dir-tab-count {
  font-size: 11px; background: rgba(255,255,255,0.25); border-radius: 10px;
  padding: 1px 7px; min-width: 28px; text-align: center;
}
.dir-tab-active .dir-tab-count { background: rgba(255,255,255,0.3); }
.dir-tab:not(.dir-tab-active) .dir-tab-count { background: var(--surface-raised, #f0f2f5); color: var(--ink-muted); }

.dir-search-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }

.dir-table { display: flex; flex-direction: column; gap: 0; }
.dir-table-head {
  display: grid; grid-template-columns: 2fr 2fr 1.2fr 1.5fr auto;
  gap: 8px; padding: 4px 0 8px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-muted);
}
.dir-row {
  display: grid; grid-template-columns: 2fr 2fr 1.2fr 1.5fr auto;
  gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.dir-row:last-of-type { border-bottom: none; }
.dir-add-grid {
  display: grid; grid-template-columns: 2fr 2fr 1.2fr 1.5fr auto;
  gap: 8px; align-items: center;
}
@media (max-width: 800px) {
  .dir-table-head { display: none; }
  .dir-row, .dir-add-grid {
    grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto;
  }
}
