/* Governsure SOP assistant: shared design tokens and components.
   Calm, mostly neutral surfaces (Notion); instant press feedback, short
   ease-out motion, system type (Apple / Emil Kowalski). */
:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --surface: #F7F7F5;
  --surface-2: #FFFFFF;
  --text: #1F1F1E;
  --text-2: #6B6A66;
  --text-3: #9B9A96;
  --border: rgba(55, 53, 47, 0.12);
  --border-strong: rgba(55, 53, 47, 0.22);
  --hover: rgba(55, 53, 47, 0.06);
  --press: rgba(55, 53, 47, 0.1);
  --skeleton: rgba(55, 53, 47, 0.07);
  --scrim: rgba(15, 15, 15, 0.32);
  --chrome: rgba(255, 255, 255, 0.78);

  /* Safety colours: never replaced by a pharmacy's brand colour */
  --warn-bg: #FBF3DB; --warn-text: #7A4A04; --warn-border: #EBD9A6;
  --danger-bg: #FDEBEC; --danger-text: #9F2F2D; --danger-border: #F3C5C4;
  --ok-text: #2F6B3B;

  /* Brand colour (set per pharmacy by script) */
  --brand: #0F766E; --brand-tint: #E2F0EE; --brand-soft: #EDF5F4; --brand-text: #0F766E;
  --gs: #0E4A3B; /* Governsure Evergreen */

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --radius: 10px;
  --radius-lg: 14px;
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #191919; --surface: #202020; --surface-2: #252525;
    --text: #EDEDEC; --text-2: #A3A29E; --text-3: #7B7A76;
    --border: rgba(255, 255, 255, 0.1); --border-strong: rgba(255, 255, 255, 0.18);
    --hover: rgba(255, 255, 255, 0.06); --press: rgba(255, 255, 255, 0.1);
    --skeleton: rgba(255, 255, 255, 0.07); --scrim: rgba(0, 0, 0, 0.55);
    --chrome: rgba(25, 25, 25, 0.78);
    --warn-bg: #3A2E12; --warn-text: #F1D18A; --warn-border: #5A4719;
    --danger-bg: #3B1B1B; --danger-text: #F4A9A7; --danger-border: #5E2A29;
    --ok-text: #8FD19E;
    --gs: #DDEFE7;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; text-size-adjust: 100%; }
body { font-size: 1rem; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.125rem; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--text-2); }
.small { font-size: 0.8125rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Buttons: feedback on press, not on release */
button, .btn {
  font: inherit; font-size: 0.9375rem; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
  -webkit-tap-highlight-color: transparent; text-decoration: none; white-space: nowrap;
}
button:active, .btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { button:hover, .btn:hover { background: var(--hover); } }
.btn-primary { background: var(--brand); border-color: transparent; color: #fff; font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .btn-primary:hover { background: var(--brand); filter: brightness(1.08); } }
.btn-dark { background: var(--text); color: var(--bg); border-color: transparent; font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .btn-dark:hover { background: var(--text); opacity: 0.88; } }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 0.8125rem; border-radius: 8px; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

input, select, textarea {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 9px 12px; min-height: 42px; width: 100%;
}
textarea { resize: none; }
label.field { display: grid; gap: 6px; font-size: 0.875rem; font-weight: 500; }
.field-error { color: var(--danger-text); font-size: 0.8125rem; min-height: 1.1em; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Skeletons: only shown if loading takes >300ms (see JS) */
.skeleton { background: var(--skeleton); border-radius: 6px; position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--hover), transparent);
  animation: shimmer 1.2s var(--ease-out) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* Enter animation, short and ease-out */
.enter { animation: enter 220ms var(--ease-out) both; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }

/* Toast with undo */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 20px; display: flex; justify-content: center; pointer-events: none; z-index: 60; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px;
  background: var(--text); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 12px; font-size: 0.9375rem;
  transition: transform 400ms ease, opacity 400ms ease;
  @starting-style { transform: translateY(16px); opacity: 0; }
}
.toast.leaving { transform: translateY(16px); opacity: 0; transition-duration: 200ms; }
.toast button { min-height: 32px; background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 35%, transparent); font-weight: 600; }

/* Sheet (slides up, closes down: same path in and out) */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; opacity: 0; transition: opacity 260ms ease; }
.scrim.open { opacity: 1; }
.scrim:not(.open) { pointer-events: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 720px; max-height: 88vh; z-index: 50;
  background: var(--surface-2); border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform 420ms var(--ease-drawer);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}
.sheet.open { transform: translateY(0); }
.sheet.closing { transition-duration: 260ms; }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.sheet-body { overflow: auto; padding: 18px 20px 32px; overscroll-behavior: contain; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--text-2); white-space: nowrap; }
.pill-warn { background: var(--warn-bg); color: var(--warn-text); }
.pill-brand { background: var(--brand-tint); color: var(--brand-text); }

.powered { font-size: 0.75rem; color: var(--text-3); text-align: center; }
.powered b { color: var(--text-2); font-weight: 600; letter-spacing: 0.01em; }
/* Governsure shield beside "Powered by": small, unaltered brand mark */
.gs-mark { display: inline-flex; vertical-align: -2px; margin: 0 3px 0 4px; }
.gs-mark img { width: 12px; height: 12px; display: block; }
.powered-inline { display: inline-flex; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .skeleton::after { display: none; }
  .sheet, .toast, button, .btn { transition: opacity 200ms ease !important; }
  button:active, .btn:active { transform: none; }
  .sheet { transform: none; opacity: 0; pointer-events: none; }
  .sheet.open { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-transparency: reduce) { :root { --chrome: var(--bg); } }
@media (prefers-contrast: more) { :root { --border: var(--border-strong); --text-2: var(--text); } }
