/*
 * Graphite Atelier — components for the nood ERP.
 *
 * Built only from tokens.css: no raw colours in this file (the guard rail,
 * scripts/check_graphite.py, enforces it). Three layers, in order:
 *   1. Base elements   — make any page legible on graphite, converted or not.
 *   2. Shell           — sidebar, top bar, user menu, version + feedback modals.
 *                        Keeps every class/id that assets/js/scripts.js and the
 *                        base template's own scripts query.
 *   3. ga-* components — the vocabulary converted pages are built from.
 * The living reference for all of it is /graphite/ (templates/graphite/style.html).
 */

/* ───────────────────────── 1. Base elements ───────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background-color: var(--bg); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.55;
  letter-spacing: .005em;
  color: var(--ink);
  background: radial-gradient(ellipse 48% 24% at 65% -9%, var(--accent-fade), transparent 80%),
              linear-gradient(170deg, var(--bg-2) 0%, var(--bg) 62%, var(--bg-3) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; color: var(--ink); line-height: 1.2; }
h1 { font-size: var(--fs-display); letter-spacing: var(--ls-display); }
h2 { font-size: var(--fs-h2); letter-spacing: -.7px; }
h3 { font-size: var(--fs-h3); letter-spacing: var(--ls-tight); }
h4 { font-size: var(--fs-h4); letter-spacing: -.2px; }
p { margin: 0 0 var(--s-3); }
a { color: var(--accent-4); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-6) 0; }
code, kbd, pre, samp { font-family: var(--mono); font-size: .92em; }
code { background: var(--panel-2); border: 1px solid var(--edge-soft); border-radius: var(--radius-xs); padding: 1px 5px; color: var(--ink-2); }
pre { background: var(--bg-3); border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: var(--s-4); overflow: auto; color: var(--ink-2); }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--radius-xs); padding: 0 5px; font-size: var(--fs-meta); color: var(--ink-2); }
small { font-size: var(--fs-meta); }
strong, b { font-weight: 700; }
img, svg, video, canvas { max-width: 100%; }
::selection { background: var(--accent-strong); color: var(--ink); }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: var(--radius-xs); }

* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Default form controls — dark and legible even on pages not yet converted. */
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
select, textarea {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-height: var(--control-h);
  box-shadow: var(--shadow-control);
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
textarea { min-height: 84px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }  /* --muted-3 measured 3.81:1 */
input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"] { color-scheme: dark; }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; }
input[type="range"] { accent-color: var(--accent); }
input[type="file"] { color: var(--muted); font-size: var(--fs-small); }
input[type="file"]::file-selector-button { margin-right: var(--s-3); padding: 6px 12px; font: inherit; font-weight: 700; cursor: pointer;
  color: var(--ink); background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--radius-sm); }
input[type="file"]::file-selector-button:hover { border-color: var(--accent-edge); }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--panel-2); color: var(--ink); }
label { color: var(--ink-2); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s-4); margin: 0 0 var(--s-4); }
legend { padding: 0 var(--s-2); color: var(--muted); font-size: var(--fs-small); }

/* Default tables — quiet rules, legible on graphite. */
table { border-collapse: collapse; width: 100%; font-size: var(--fs-small); }
th { text-align: left; font-size: var(--fs-label); font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
     color: var(--muted-2); padding: 12px 14px; border-bottom: 1px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--row-line); color: var(--ink-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Tab panes toggled by assets/js/scripts.js (.background-header-nav-tab[data-id]).
   Without these every pane shows at once. */
.background-header-tab-pane { display: none; }
.background-header-tab-pane.active { display: block; }

/* ───────────────────────── 2. Shell ───────────────────────── */

body.base-template {
  /* Paint the sidebar column for the full page height (the sidebar itself is
     sticky at 100vh), so long pages and full-page captures stay continuous. */
  background:
    linear-gradient(90deg, var(--bg-3) 0 var(--sidebar-w), var(--edge) var(--sidebar-w) calc(var(--sidebar-w) + 1px), transparent calc(var(--sidebar-w) + 1px)),
    radial-gradient(ellipse 48% 24% at 65% -9%, var(--accent-fade), transparent 80%),
    linear-gradient(170deg, var(--bg-2) 0%, var(--bg) 62%, var(--bg-3) 100%);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "flag flag" "side top" "side main";
}
.impersonation-bar { grid-area: flag; }
body.base-template > header { grid-area: top; }
body.base-template > aside.sidebar { grid-area: side; }
body.base-template > main { grid-area: main; }

/* Admin "viewing as" bar — loud on purpose, but in the warning family. */
.impersonation-bar {
  position: sticky; top: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; gap: var(--s-4);
  padding: 8px var(--s-4);
  background: var(--warn-bg); color: var(--warn-ink);
  border-bottom: 1px solid var(--warn-edge);
  font-size: var(--fs-small); font-weight: 600;
}
.impersonation-bar form { margin: 0; }

/* Top bar */
body.base-template > header {
  position: sticky; top: 0; z-index: 90;
  display: flex; align-items: center; gap: var(--s-3);
  min-height: var(--topbar-h);
  padding: 0 clamp(20px, 3.4vw, 56px);
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}
.topbar-crumb { flex: 1; min-width: 0; color: var(--muted-2); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--ls-label); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); }
.build-info { display: flex; align-items: center; gap: 6px; }
.build-env { font-size: var(--fs-label); font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 7px; border-radius: var(--radius-xs); border: 1px solid var(--edge); color: var(--muted); }
.build-env--production { color: var(--accent-4); border-color: var(--accent-edge); background: var(--accent-fade); }
.build-env--staging { color: var(--warn-ink); border-color: var(--warn-edge); background: var(--warn-bg); }
.build-sha-btn { font-size: var(--fs-meta); font-weight: 600; color: var(--muted); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-xs); padding: 3px 6px; font-variant-numeric: tabular-nums; }
.build-sha-btn:hover { color: var(--ink); background: var(--hover); border-color: var(--edge-soft); }

/* Small square icon buttons in the top bar (feedback, mobile menu, page extras) */
.ga-icon-btn, .feedback-trigger-btn, .mobile-menu-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; flex: none;
  color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--edge); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-control);
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.ga-icon-btn:hover, .feedback-trigger-btn:hover, .mobile-menu-btn:hover { color: var(--ink); border-color: var(--accent-edge); }
.mobile-menu-btn { display: none; }

/* Sidebar */
aside.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 100;
  display: flex; flex-direction: column;
  padding: var(--s-6) var(--s-3) var(--s-4);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-3));
  border-right: 1px solid var(--edge);
  overflow: hidden;
}
.ga-brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--s-3) var(--s-6); text-decoration: none; }
.ga-brand:hover { text-decoration: none; }
.ga-brand img { height: 22px; width: auto; display: block; }
.ga-brand small { font-size: var(--fs-label); font-weight: 800; letter-spacing: 1.6px; color: var(--muted-2); padding-top: 4px; }
aside.sidebar > nav { flex: 1; min-height: 0; overflow-y: auto; margin: 0 calc(var(--s-3) * -1); padding: 0 var(--s-3); }
.sidebar-nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar-section-label {
  padding: var(--s-5) var(--s-3) var(--s-2);
  font-size: var(--fs-label); font-weight: 800; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--muted-2);
}
.sidebar-item { position: relative; }
.sidebar-link {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding: 9px var(--s-3); border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--muted); font-size: var(--fs-body); font-weight: 600; text-decoration: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.sidebar-link:hover { color: var(--ink); background: var(--hover); text-decoration: none; }
.sidebar-item:has(> .dropdown-menu) > .sidebar-link::after {
  content: ""; width: 6px; height: 6px; flex: none; margin-right: 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px); opacity: .6; transition: transform var(--t) var(--ease);
}
.sidebar-item:has(> .dropdown-menu.expand) > .sidebar-link::after { transform: rotate(225deg) translateY(-1px); }
.sidebar-item.active > .sidebar-link,
.sidebar-item.permanent-active > .sidebar-link {
  color: var(--ink); background: var(--hover);
  border-color: var(--accent-strong);
  box-shadow: inset 2px 0 0 var(--accent);
}
.dropdown-menu {
  list-style: none; margin: 0; padding: 0 0 0 var(--s-3);
  max-height: 0; overflow: hidden; transition: max-height var(--t-slow) var(--ease);
}
.dropdown-menu.expand { max-height: 520px; padding-top: 2px; padding-bottom: var(--s-1); }
.dropdown-item { margin: 0; }
.dropdown-link {
  display: block; padding: 7px var(--s-3); margin-left: 6px;
  border-left: 1px solid var(--line); color: var(--muted-2); font-size: var(--fs-small); font-weight: 500; text-decoration: none;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.dropdown-link:hover { color: var(--ink); border-left-color: var(--accent); background: var(--hover); text-decoration: none; }
.dropdown-link[aria-current="page"] { color: var(--ink); border-left-color: var(--accent); }

/* User menu at the foot of the sidebar */
.user-button-and-overlay { position: relative; margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--edge); }
.user-avatar-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px var(--s-2); border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-2);
  font-size: var(--fs-small); font-weight: 600; transition: background var(--t) var(--ease);
}
.user-avatar-btn:hover { background: var(--hover); }
.user-avatar-btn .ga-avatar, .user-info-avatar {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm);
  background: var(--accent-soft); border: 1px solid var(--accent-edge); color: var(--accent-4);
  font-size: var(--fs-meta); font-weight: 800; letter-spacing: .4px;
}
.user-avatar-btn .ga-user-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info-overlay {
  position: absolute; left: 0; bottom: calc(100% + 8px); width: 248px; z-index: 120;
  background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--radius);
  box-shadow: var(--shadow-float); padding: var(--s-4);
}
.user-info-content { display: grid; gap: 6px; }
.user-info-avatar { width: 36px; height: 36px; margin-bottom: 4px; }
.user-info-name { font-weight: 700; color: var(--ink); }
.user-info-email { font-size: var(--fs-meta); color: var(--muted-2); overflow-wrap: anywhere; }
.user-info-divider { height: 1px; background: var(--line); margin: var(--s-2) 0; }
.brand-switcher-form { margin: 0 0 var(--s-2); }
.brand-switcher-label { display: block; font-size: var(--fs-meta); color: var(--muted-2); margin-bottom: 4px; }
.brand-switcher-select { width: 100%; }
.overlay-btn {
  display: flex; align-items: center; gap: var(--s-2); width: 100%; text-align: left;
  padding: 8px var(--s-2); border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--ink-2); font-size: var(--fs-small); font-weight: 600;
}
.overlay-btn:hover { background: var(--hover-2); color: var(--ink); }
.overlay-btn-danger { color: var(--bad-ink); }
.logout-confirmation { margin-top: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--line); }
.logout-confirmation p { font-size: var(--fs-small); color: var(--ink-2); margin-bottom: var(--s-2); }
.confirm-btn { padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--bad-edge); background: var(--bad-bg);
  color: var(--bad-ink); font-size: var(--fs-small); font-weight: 700; margin-right: 6px; }
.confirm-btn-cancel { border-color: var(--edge); background: transparent; color: var(--ink-2); }

/* Main content column */
body.base-template > main {
  min-width: 0; width: 100%; max-width: var(--content-max);
  padding: var(--s-2) clamp(20px, 3.4vw, 56px) 80px;
}

/* Mobile: sidebar becomes an off-canvas drawer (JS: #mobile-menu-btn, .mobile-open) */
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 99; background: var(--scrim); }
@media (max-width: 920px) {
  body.base-template { background: linear-gradient(170deg, var(--bg-2) 0%, var(--bg) 62%, var(--bg-3) 100%); grid-template-columns: minmax(0, 1fr); grid-template-areas: "flag" "top" "main"; }
  .mobile-menu-btn { display: inline-grid; }
  aside.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 84vw); height: auto;
    transform: translateX(-102%); transition: transform var(--t-slow) var(--ease); box-shadow: var(--shadow-float);
  }
  aside.sidebar.mobile-open { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.base-template > header { padding: 0 var(--s-4); }
  body.base-template > main { padding: var(--s-2) var(--s-4) 64px; }
}
@media (max-width: 480px) {
  .build-env { display: none; }
}

/* Version history modal (markup + logic in base.html) */
.version-modal-overlay, .feedback-modal {
  position: fixed; inset: 0; z-index: 400; align-items: center; justify-content: center; padding: var(--s-4);
  background: var(--scrim);
}
.version-modal {
  width: min(760px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow-float); overflow: hidden;
}
.version-modal-header { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); }
.version-modal-title { font-size: var(--fs-h4); font-weight: 700; color: var(--ink); flex: 1; }
.version-modal-filters { display: inline-flex; gap: 2px; padding: 3px; background: var(--hover); border: 1px solid var(--edge-soft); border-radius: var(--radius-sm); }
.vfilter-btn { border: 0; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: var(--radius-xs); font-size: var(--fs-meta); font-weight: 700; }
.vfilter-btn:hover { color: var(--ink); }
.vfilter-active { background: var(--panel-3); color: var(--ink); }
.version-modal-close, .feedback-modal-close { border: 0; background: transparent; color: var(--muted); font-size: 16px; width: 30px; height: 30px; border-radius: var(--radius-sm); }
.version-modal-close:hover, .feedback-modal-close:hover { background: var(--hover-2); color: var(--ink); }
.version-search-row { padding: var(--s-3) var(--s-6); border-bottom: 1px solid var(--line); }
.version-search-input { width: 100%; }
.version-modal-body { overflow-y: auto; padding: var(--s-2) var(--s-6) var(--s-6); }
.version-modal-loading, .version-no-notes, .version-empty { color: var(--muted-2); font-size: var(--fs-small); padding: var(--s-5) 0; }
.version-entry { padding: var(--s-5) 0; border-bottom: 1px solid var(--row-line); }
.version-entry:last-child { border-bottom: 0; }
.version-entry-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.version-tag { font-weight: 700; color: var(--ink); }
.version-env-badge, .version-bump-badge, .version-risk-badge, .version-migrations-badge {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: var(--radius-xs);
  font-size: var(--fs-label); font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  background: var(--info-bg); border: 1px solid var(--info-edge); color: var(--info-ink);
}
.version-env-badge--production { background: var(--accent-fade); border-color: var(--accent-edge); color: var(--accent-4); }
.version-env-badge--staging, .version-risk-badge--medium, .version-migrations-badge { background: var(--warn-bg); border-color: var(--warn-edge); color: var(--warn-ink); }
.version-risk-badge--low { background: var(--ok-bg); border-color: var(--ok-edge); color: var(--ok-ink); }
.version-risk-badge--high { background: var(--bad-bg); border-color: var(--bad-edge); color: var(--bad-ink); }
.version-meta, .version-snapshot-meta, .version-dev-meta, .version-lineage { display: flex; flex-wrap: wrap; gap: var(--s-2); font-size: var(--fs-meta); color: var(--muted-2); }
.version-snapshot-label { font-weight: 700; color: var(--ink); }
.version-base-ver, .version-short-sha, .version-commit-sha { font-family: var(--mono); font-size: var(--fs-meta); color: var(--muted); }
.version-reltime { color: var(--muted-3); }
.version-title { font-size: var(--fs-h4); font-weight: 700; color: var(--ink); margin: var(--s-2) 0 4px; }
.version-summary { color: var(--ink-2); font-size: var(--fs-small); line-height: 1.6; }
.version-section-label, .version-rec-label { margin: var(--s-4) 0 6px; font-size: var(--fs-label); font-weight: 800; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--muted-2); }
.version-highlights, .version-subbullets { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: var(--fs-small); line-height: 1.6; }
.version-highlights li { margin: 3px 0; }
.version-highlights li strong { color: var(--ink); }
.version-subbullets li { color: var(--muted); }
.version-risk-area { display: grid; gap: 6px; }
.version-risk-row { display: flex; flex-wrap: wrap; gap: 6px; }
.version-risk-context, .version-readiness { font-size: var(--fs-small); color: var(--muted); }
.version-recommendation { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); border-left: 2px solid var(--accent); background: var(--accent-fade); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: var(--fs-small); color: var(--ink-2); }
.version-pending-header { font-weight: 700; color: var(--ink); padding: var(--s-4) 0 var(--s-2); }
.version-commit { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--s-3); row-gap: 2px; padding: var(--s-2) 0; border-bottom: 1px solid var(--row-line); font-size: var(--fs-small); }
.version-commit-msg { color: var(--ink-2); }
.version-commit-meta { grid-column: 2; color: var(--muted-2); font-size: var(--fs-meta); }
.version-files-toggle { grid-column: 2; color: var(--accent-4); font-size: var(--fs-meta); font-weight: 600; cursor: pointer; }
.version-files-toggle:hover { text-decoration: underline; }
.version-files-list { grid-column: 2; font-family: var(--mono); font-size: var(--fs-meta); color: var(--muted); }

/* Feedback widget (partials core/_feedback_trigger.html + _feedback_modal.html) */
.feedback-modal-backdrop { position: absolute; inset: 0; }
.feedback-modal-panel {
  position: relative; width: min(520px, 100%); max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow-float); padding: var(--s-6);
}
.feedback-modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.feedback-modal-title { font-size: var(--fs-h4); font-weight: 700; }
#feedback-form { display: grid; gap: var(--s-3); }
#feedback-form label { display: grid; gap: 6px; font-size: var(--fs-small); font-weight: 600; }
#feedback-form textarea { width: 100%; }
.feedback-kind-toggle { display: inline-flex; gap: 2px; padding: 3px; background: var(--hover); border: 1px solid var(--edge-soft); border-radius: var(--radius-sm); }
.feedback-kind-toggle label { display: inline-flex !important; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--radius-xs); cursor: pointer; }
.feedback-kind-toggle label:has(input:checked) { background: var(--panel-3); color: var(--ink); }
.feedback-field-hint { font-weight: 400; color: var(--muted-2); }
.feedback-dropzone { position: relative; display: grid; place-items: center; min-height: 86px; padding: var(--s-4); text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm); color: var(--muted-2); font-size: var(--fs-small); cursor: pointer; }
.feedback-dropzone:hover, .feedback-dropzone.is-dragover { border-color: var(--accent); color: var(--ink-2); background: var(--accent-fade); }
.feedback-dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.feedback-preview { display: flex; gap: var(--s-3); align-items: center; }
.feedback-preview-img { width: 72px; height: 54px; object-fit: cover; border-radius: var(--radius-xs); border: 1px solid var(--edge); }
.feedback-preview-meta { display: grid; gap: 4px; min-width: 0; font-size: var(--fs-meta); color: var(--muted); }
.feedback-preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feedback-preview-btn { border: 0; background: none; color: var(--accent-4); font-size: var(--fs-meta); font-weight: 700; padding: 0 8px 0 0; }
.feedback-modal-actions { display: flex; justify-content: flex-end; }
.feedback-modal-status { font-size: var(--fs-small); color: var(--muted); margin: 0; }

/* ───────────────────────── 3. ga-* components ───────────────────────── */

/* Page header: eyebrow, title, one-line purpose, actions on the right */
.ga-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5); margin: var(--s-4) 0 var(--s-7); flex-wrap: wrap; }
.ga-page-head > div:first-child { min-width: 0; max-width: 760px; }
.ga-page-head h1 { margin: var(--s-2) 0 var(--s-2); }
.ga-page-head p { margin: 0; color: var(--muted); font-size: var(--fs-body); line-height: 1.65; max-width: 650px; }
.ga-page-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.ga-page-head .kb-back-btn {   /* core/_back_button.html as a quiet text link above the page title */
  display: inline-flex; align-items: center; gap: 4px; min-height: 0; padding: 0; border: 0; background: none;
  color: var(--accent-4); font-size: var(--fs-small); font-weight: 600; text-decoration: none; cursor: pointer;
}
.ga-page-head .kb-back-btn:hover { color: var(--ink); background: none; text-decoration: underline; text-underline-offset: 3px; }
.ga-eyebrow, .ga-kicker { display: block; font-size: var(--fs-label); font-weight: 800; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--muted-2); }
.ga-section-title { margin: var(--s-8) 0 var(--s-4); font-size: var(--fs-h3); font-weight: 600; letter-spacing: var(--ls-tight); }

/* Surfaces — primary (card), focal (hero), secondary (flat), tertiary (unboxed + rule) */
.ga-card {
  position: relative; min-width: 0;
  background: linear-gradient(165deg, var(--card-top) 0%, var(--card-bottom) 100%);
  border: 1px solid var(--edge); border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.ga-card--hero { background: linear-gradient(117deg, var(--hero-1) 0%, var(--hero-2) 52%, var(--hero-3) 100%); box-shadow: var(--shadow-hero); overflow: hidden; }
.ga-card--flat { background: var(--panel); box-shadow: var(--shadow-flat); }
.ga-pad { padding: var(--s-7) var(--s-8); }
.ga-pad-sm { padding: var(--s-5) var(--s-6); }
.ga-unboxed { border-top: 1px solid var(--line); padding-top: var(--s-5); min-width: 0; }
.ga-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.ga-card-head h3 { margin: 6px 0 4px; font-size: var(--fs-h3); }
.ga-card-head p { margin: 0; color: var(--muted); font-size: var(--fs-small); }
.ga-card > .ga-table-wrap { border-top: 1px solid var(--line); }
.ga-divider { height: 1px; background: var(--line); margin: var(--s-5) 0; border: 0; }

/* Layout helpers — proportional columns that reflow instead of squeezing */
.ga-grid { display: grid; gap: var(--s-5); }
.ga-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ga-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ga-grid--auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.ga-split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(250px, .72fr); gap: var(--s-8); align-items: start; }
.ga-stack { display: grid; gap: var(--s-5); }
.ga-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.ga-spacer { flex: 1; }
@media (max-width: 1050px) { .ga-split { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); } .ga-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .ga-grid--2, .ga-grid--3 { grid-template-columns: minmax(0, 1fr); } .ga-pad { padding: var(--s-5) var(--s-5); } }

/* Big numbers */
.ga-figure { font-size: clamp(44px, 5vw, 64px); font-weight: 600; letter-spacing: -2.6px; line-height: 1; color: var(--ink); white-space: nowrap; }
.ga-figure small, .ga-figure .ga-unit { font-size: .5em; letter-spacing: -.5px; color: var(--accent-4); font-weight: 600; }
.ga-number { font-size: 23px; font-weight: 600; letter-spacing: -.5px; line-height: 1.2; color: var(--ink); white-space: nowrap; }
.ga-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ga-delta-up { color: var(--ok-ink); }
.ga-delta-down { color: var(--bad-ink); }

/* Stat strip: the row of supporting metrics under a focal surface */
.ga-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); border-top: 1px solid var(--edge); background: var(--strip-bg); }
.ga-stat { padding: var(--s-5) var(--s-7); min-width: 0; border-right: 1px solid var(--edge); }
.ga-stat:last-child { border-right: 0; }
.ga-stat-label { font-size: var(--fs-small); color: var(--muted); }
.ga-stat .ga-number { margin: 8px 0 4px; display: block; }
.ga-stat-note { font-size: var(--fs-meta); color: var(--muted-2); }
@media (max-width: 700px) { .ga-stat { border-right: 0; border-bottom: 1px solid var(--edge); } .ga-stat:last-child { border-bottom: 0; } }

/* Buttons — three levels: primary (accent lift), secondary (neutral box), text (contextual) */
.ga-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--control-h); padding: 0 14px;
  font-size: var(--fs-body); font-weight: 700; line-height: 1; white-space: nowrap; text-decoration: none;
  color: var(--ink); background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-control); cursor: pointer;
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease), filter var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.ga-btn:hover { border-color: var(--accent-edge); text-decoration: none; }
.ga-btn:active { transform: translateY(1px); }
.ga-btn--primary { color: var(--ink); background: linear-gradient(180deg, var(--primary-top), var(--primary-bottom)); border-color: var(--accent-edge); box-shadow: var(--shadow-primary); }
.ga-btn--primary:hover { filter: brightness(1.08); }
.ga-btn--text { background: transparent; border-color: transparent; box-shadow: none; color: var(--accent-4); padding: 0 8px; font-size: var(--fs-small); }
.ga-btn--text:hover { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.ga-btn--danger { color: var(--bad-ink); border-color: var(--bad-edge); background: var(--bad-bg); }
.ga-btn--sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-small); }
.ga-btn:disabled, .ga-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
.ga-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.ga-link { color: var(--accent-4); font-weight: 600; font-size: var(--fs-small); }

/* Segmented control / tabs */
.ga-seg { display: inline-flex; gap: 3px; padding: 3px; background: var(--seg-bg); border: 1px solid var(--edge); border-radius: var(--radius-sm); }
.ga-seg > button, .ga-seg > a { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: var(--radius-xs); font-size: var(--fs-small); font-weight: 700; text-decoration: none; }
.ga-seg > button:hover, .ga-seg > a:hover { color: var(--ink); text-decoration: none; }
.ga-seg > .is-active, .ga-seg > .active, .ga-seg > [aria-selected="true"], .ga-seg > [aria-current="page"] { background: var(--panel-3); color: var(--ink); }
.ga-tabs { display: flex; gap: var(--s-6); border-bottom: 1px solid var(--line); margin-bottom: var(--s-6); overflow-x: auto; }
.ga-tabs > a, .ga-tabs > button { border: 0; background: none; padding: var(--s-3) 0; margin-bottom: -1px; color: var(--muted); font-weight: 600; font-size: var(--fs-body); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.ga-tabs > a:hover, .ga-tabs > button:hover { color: var(--ink); text-decoration: none; }
.ga-tabs > .is-active, .ga-tabs > .active, .ga-tabs > [aria-selected="true"], .ga-tabs > [aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Form fields */
.ga-field { display: grid; gap: 6px; min-width: 0; }
.ga-field > label, .ga-label { font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.ga-hint { font-size: var(--fs-meta); color: var(--muted-2); }
.ga-error { font-size: var(--fs-meta); color: var(--bad-ink); }
.ga-field.has-error input, .ga-field.has-error select, .ga-field.has-error textarea { border-color: var(--bad-edge); }
.ga-form { display: grid; gap: var(--s-5); max-width: 720px; }
.ga-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s-4); }
.ga-form-actions { display: flex; gap: var(--s-2); justify-content: flex-end; padding-top: var(--s-2); }
.ga-search { min-width: 220px; }
.ga-check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-small); color: var(--ink-2); cursor: pointer; }
.ga-toolbar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* Data table — real comparisons. Wrap it so it scrolls instead of squeezing. */
.ga-table-wrap { position: relative; overflow-x: auto; min-width: 0; }  /* relative: keeps .ga-sr-only headers inside the scroller on phones */
.ga-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.ga-table th { padding: 13px var(--s-6); background: var(--table-head-bg); border-bottom: 1px solid var(--line); white-space: nowrap; }
.ga-table td { padding: 15px var(--s-6); color: var(--ink-2); border-bottom: 1px solid var(--row-line); }
.ga-table tbody tr { transition: background var(--t-fast) var(--ease); }
.ga-table tbody tr:hover { background: var(--accent-fade); }
.ga-table tbody tr.is-selected { background: var(--accent-soft); }
.ga-table .ga-num, .ga-table th.ga-num { text-align: right; }
.ga-table .ga-row-name { color: var(--ink); font-weight: 600; min-width: 170px; }
.ga-scroll-hint { display: none; margin: 0 var(--s-6) var(--s-3); color: var(--muted-2); font-size: var(--fs-meta); }
@media (max-width: 700px) { .ga-scroll-hint { display: block; } }
.ga-table--dense th { padding: 10px var(--s-4); }
.ga-table--dense td { padding: 9px var(--s-4); }
.ga-table th[aria-sort] { cursor: pointer; }
.ga-table th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent-4); }
.ga-table th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent-4); }
.ga-table tfoot td { font-weight: 700; color: var(--ink); border-top: 1px solid var(--line-2); border-bottom: 0; }
.ga-sticky-head th { position: sticky; top: 0; z-index: 1; background: var(--panel); }

/* Editorial ledger — the default list: plain rows, strong title, quiet metadata */
.ga-ledger { padding: 0 var(--s-8); }
.ga-ledger-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-7) 0 var(--s-5); }
.ga-ledger-head h3 { margin: 0; }
.ga-ledger-head p { margin: 6px 0 0; font-size: var(--fs-small); color: var(--muted); }
.ga-ledger-items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--row-line); }
.ga-ledger-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-5);
  padding: 16px 1px; border-bottom: 1px solid var(--row-line); color: var(--ink); text-decoration: none;
  transition: background var(--t-fast) var(--ease), padding var(--t-fast) var(--ease);
}
.ga-ledger-items > :last-child .ga-ledger-row, .ga-ledger-items > .ga-ledger-row:last-child { border-bottom: 0; }
a.ga-ledger-row:hover, button.ga-ledger-row:hover { background: var(--hover); padding-left: 10px; padding-right: 10px; text-decoration: none; }
.ga-ledger-row.is-selected { background: var(--accent-fade); padding-left: 10px; padding-right: 10px; }
button.ga-ledger-row { width: 100%; border: 0; border-bottom: 1px solid var(--row-line); background: transparent; text-align: left; font: inherit; }
.ga-ledger-main { min-width: 0; display: grid; gap: 4px; }
.ga-ledger-title { font-weight: 600; font-size: var(--fs-body); color: var(--ink); }
.ga-ledger-sub, .ga-ledger-meta { font-size: var(--fs-meta); font-weight: 500; color: var(--muted-2); }
.ga-ledger-meta { flex: none; white-space: nowrap; text-align: right; }
@media (max-width: 700px) { .ga-ledger { padding: 0 var(--s-5); } }

/* Definition list — key/value detail panels */
.ga-dl { margin: 0; border-top: 1px solid var(--line); }
.ga-dl > div { display: flex; justify-content: space-between; gap: var(--s-4); padding: 12px 0; border-bottom: 1px solid var(--line); }
.ga-dl dt { font-size: var(--fs-small); color: var(--muted-2); }
.ga-dl dd { margin: 0; font-size: var(--fs-small); color: var(--ink-2); text-align: right; overflow-wrap: anywhere; }

/* Tags and status — neutral by default; colour only when it encodes real state, always with text */
.ga-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: var(--radius-xs);
  font-size: var(--fs-label); font-weight: 700; letter-spacing: .2px; line-height: 1.5; white-space: nowrap;
  background: var(--info-bg); border: 1px solid var(--info-edge); color: var(--info-ink);
}
.ga-tag--accent { background: var(--accent-soft); border-color: var(--accent-edge); color: var(--accent-4); }
.ga-tag--ok { background: var(--ok-bg); border-color: var(--ok-edge); color: var(--ok-ink); }
.ga-tag--warn { background: var(--warn-bg); border-color: var(--warn-edge); color: var(--warn-ink); }
.ga-tag--bad { background: var(--bad-bg); border-color: var(--bad-edge); color: var(--bad-ink); }
.ga-dot { width: 7px; height: 7px; border-radius: 2px; display: inline-block; background: currentColor; flex: none; }

/* Notes and alerts */
.ga-note { padding: var(--s-3) var(--s-4); border-left: 2px solid var(--accent); background: var(--accent-fade); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2); font-size: var(--fs-small); line-height: 1.65; }
.ga-note--warn { border-left-color: var(--warn); background: var(--warn-bg); }
.ga-note--bad { border-left-color: var(--bad); background: var(--bad-bg); }
.ga-note--ok { border-left-color: var(--ok); background: var(--ok-bg); }

/* Empty, loading, error states — they keep the page's hierarchy */
.ga-empty { display: grid; place-items: center; gap: 6px; padding: var(--s-10) var(--s-5); text-align: center; color: var(--muted); }
.ga-empty strong { color: var(--ink-2); font-size: var(--fs-h4); font-weight: 600; }
.ga-empty p { max-width: 420px; margin: 0; font-size: var(--fs-small); }
.ga-skeleton { display: block; height: 12px; border-radius: var(--radius-xs); background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: ga-shimmer 1.4s ease-in-out infinite; }
@keyframes ga-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Charts — container, header, footer, legend; Chart.js styling lives in assets/js/graphite/charts.js */
.ga-chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-3); }
.ga-chart-head h3 { margin: 6px 0 4px; }
.ga-chart-head p { margin: 0; font-size: var(--fs-small); color: var(--muted); }
.ga-chart { position: relative; width: 100%; height: 220px; margin-top: var(--s-5); min-width: 0; }
.ga-chart--tall { height: 300px; }
.ga-chart canvas { width: 100% !important; height: 100% !important; }
.ga-chart-foot { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: 6px; color: var(--muted-2); font-size: var(--fs-label); }
.ga-legend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-top: var(--s-3); color: var(--muted); font-size: var(--fs-meta); }
.ga-legend span { display: inline-flex; align-items: center; gap: 7px; }
.ga-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* Modal (pages) */
.ga-modal-backdrop { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: var(--s-4); background: var(--scrim); }
.ga-modal { width: min(560px, 100%); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow-float); }
.ga-modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); }
.ga-modal-head h3 { font-size: var(--fs-h4); }
.ga-modal-body { padding: var(--s-6); }
.ga-modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); }

/* Toast and tooltip */
.ga-toast { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 500; min-width: 240px; max-width: 360px; padding: var(--s-3) var(--s-4);
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--accent-edge); border-radius: var(--radius-sm); box-shadow: var(--shadow-float); font-size: var(--fs-small);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease); }
.ga-toast.is-shown { opacity: 1; transform: none; pointer-events: auto; }
.ga-tooltip { position: absolute; z-index: 450; padding: 7px 10px; max-width: 280px; background: var(--panel-3); color: var(--ink); border: 1px solid var(--edge);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-float); font-size: var(--fs-meta); line-height: 1.5; pointer-events: none; }

/* Pagination */
.ga-pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); color: var(--muted-2); font-size: var(--fs-small); }

/* Text utilities */
.ga-muted { color: var(--muted); }
.ga-meta { color: var(--muted-2); font-size: var(--fs-meta); font-weight: 500; }
.ga-ink { color: var(--ink); }
.ga-accent { color: var(--accent-4); }
.ga-mono { font-family: var(--mono); }
.ga-nowrap { white-space: nowrap; }
.ga-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ga-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ───────────────────────── 4. Standalone pages ─────────────────────────
 * Pages outside the ERP shell: onboarding wizard, login/2FA, clinic portal,
 * public pages. They include templates/graphite/_head.html.                */

/* Centred single-card layout (onboarding, login, 2FA, invites) */
.ga-auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s-8) var(--s-4); }
.ga-auth-card { width: min(520px, 100%); padding: var(--s-8) var(--s-8) var(--s-7); }
.ga-auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s-7); }
.ga-auth-brand img { height: 20px; width: auto; }
.ga-auth-brand small { font-size: var(--fs-label); font-weight: 800; letter-spacing: 1.6px; color: var(--muted-2); padding-top: 4px; }
.ga-auth-card h1 { font-size: 24px; letter-spacing: -.7px; margin: 0 0 var(--s-2); }
.ga-auth-card .ga-lede { color: var(--muted); font-size: var(--fs-body); line-height: 1.65; margin: 0 0 var(--s-5); }
.ga-auth-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-top: var(--s-6); }
.ga-auth-card form input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
@media (max-width: 480px) { .ga-auth-card { padding: var(--s-6) var(--s-5); } }

/* Step progress (wizard) */
.ga-steps { display: flex; align-items: center; gap: 6px; margin-bottom: var(--s-5); }
.ga-steps i { width: 28px; height: 3px; border-radius: 2px; background: var(--line); }
.ga-steps i.is-done { background: var(--accent); }
.ga-steps span { margin-left: auto; font-size: var(--fs-label); font-weight: 800; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--muted-2); }

/* QR codes always sit on a paper tile: dark modules on graphite won't scan reliably */
.ga-qr { display: inline-block; background: var(--ink); padding: 10px; border-radius: var(--radius-sm); line-height: 0; }
.ga-qr svg { width: 130px; height: auto; display: block; }
.ga-qr--large svg { width: 180px; }
.ga-qr-grid { display: flex; flex-wrap: wrap; gap: var(--s-6); }

/* Secrets, one-time codes, recovery codes */
.ga-secret-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.ga-secret { font-family: var(--mono); font-size: var(--fs-body); letter-spacing: .08em; padding: 8px 10px; word-break: break-all; }
.ga-code-input { font-family: var(--mono) !important; font-size: 22px !important; letter-spacing: .3em; width: 210px !important; }
.ga-code-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2) var(--s-4); padding: var(--s-4) var(--s-5);
  background: var(--bg-3); border: 1px solid var(--edge); border-radius: var(--radius-sm); }
.ga-code-grid span { font-family: var(--mono); font-size: 14px; letter-spacing: .1em; color: var(--ink); }

/* Clinic portal: a narrow, quiet column with no ERP chrome (clinics are not ERP users) */
.ga-portal { max-width: 52rem; margin: 0 auto; padding: var(--s-8) var(--s-5) var(--s-12); }
.ga-portal-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  padding-bottom: var(--s-5); margin-bottom: var(--s-8); border-bottom: 1px solid var(--line); }
.ga-portal-head h1 { font-size: 22px; letter-spacing: -.6px; display: flex; align-items: center; gap: 12px; }
.ga-portal-head img { height: 20px; width: auto; }
.ga-portal-head .ga-meta a { color: var(--accent-4); }
/* Legacy portal class names, kept until the portal pages are converted (Wave 5) */
.ga-portal .pill { display: inline-flex; padding: 3px 8px; border-radius: var(--radius-xs); font-size: var(--fs-label); font-weight: 700;
  background: var(--info-bg); border: 1px solid var(--info-edge); color: var(--info-ink); }
.ga-portal .pill.active, .ga-portal .pill.redeemed { background: var(--accent-soft); border-color: var(--accent-edge); color: var(--accent-4); }
.ga-portal .msg { padding: var(--s-3) var(--s-4); border-left: 2px solid var(--accent); background: var(--accent-fade); margin-bottom: var(--s-4);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2); }
.ga-portal .msg.error { border-left-color: var(--warn); background: var(--warn-bg); }
.ga-portal .card { background: linear-gradient(165deg, var(--card-top), var(--card-bottom)); border: 1px solid var(--edge); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: var(--s-6); }
.ga-portal button:not(.ga-btn) { min-height: var(--control-h); padding: 0 14px; font-weight: 700; color: var(--ink);
  background: linear-gradient(180deg, var(--primary-top), var(--primary-bottom)); border: 1px solid var(--accent-edge); border-radius: var(--radius-sm); }

/* ───────────────────────── 5. Shared ERP widgets ─────────────────────────
 * Patterns used by more than one page that predate the rebrand. Class names
 * are load-bearing (assets/js/scripts.js and other pages query them).       */

/* {% tip %} popovers (templates/core/_tip.html; JS: initCoreTips in scripts.js) */
.core-tip, .core-tip-panel, .core-tip-panel * { text-transform: none; letter-spacing: normal; }
.core-tip { position: relative; display: inline-flex; vertical-align: middle; }
.core-tip-icon {
  width: 18px; height: 18px; padding: 0; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--muted-2);
  font-size: var(--fs-label); font-weight: 800; line-height: 1;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.core-tip-icon:hover { color: var(--ink); border-color: var(--accent-edge); }
.core-tip-icon:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.core-tip-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 300; width: 300px; max-width: calc(100vw - 32px);
  background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--radius-sm); box-shadow: var(--shadow-float);
  text-align: left; font-weight: 400; white-space: normal;
}
.core-tip-panel-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.core-tip-panel-title { font-size: var(--fs-small); font-weight: 700; color: var(--ink); }
.core-tip-panel-close { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; border-radius: var(--radius-xs); }
.core-tip-panel-close:hover { color: var(--ink); background: var(--hover-2); }
.core-tip-panel-body { padding: 12px 14px; font-size: var(--fs-small); color: var(--ink-2); line-height: 1.55; }
.core-tip-panel-body p { margin: 0 0 6px; }
.core-tip-panel-body p:last-child { margin-bottom: 0; }
.core-tip-panel-body strong { color: var(--ink); }
.core-tip-panel-footer { padding: 8px 14px; border-top: 1px solid var(--line); text-align: right; }
.core-tip-got-it { min-height: 28px; padding: 0 12px; font-size: var(--fs-small); font-weight: 700; color: var(--ink);
  background: linear-gradient(180deg, var(--primary-top), var(--primary-bottom)); border: 1px solid var(--accent-edge); border-radius: var(--radius-sm); }
.core-tip-got-it:hover { filter: brightness(1.08); }
/* In the top bar a tip is a utility icon like .ga-icon-btn, and opens leftward. */
.topbar-actions .core-tip-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--panel-2); border-color: var(--edge);
  color: var(--muted); font-size: var(--fs-body); box-shadow: var(--shadow-control); }
.topbar-actions .core-tip-icon:hover { color: var(--ink); border-color: var(--accent-edge); }
.topbar-actions .core-tip-panel { left: auto; right: 0; }

/* Legacy name for .ga-sr-only (used in markup across apps) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Rendered reply prose (apps.support reply_format); colour-free, inherits its container's ink */
.reply-body { white-space: normal; overflow-wrap: break-word; max-width: 72ch; }
.reply-body > :first-child { margin-top: 0; }
.reply-body > :last-child { margin-bottom: 0; }
.reply-body p { margin: 0 0 .7em; }
.reply-body ul, .reply-body ol { margin: 0 0 .7em; padding-left: 1.6em; }
.reply-body li { margin: 0 0 .25em; }
.reply-body a { color: var(--accent-4); text-decoration: underline; text-underline-offset: 2px; }
.reply-body blockquote { margin: 0 0 .7em; padding-left: .85em; border-left: 2px solid var(--line-2); color: inherit; }
.reply-body pre { margin: 0 0 .7em; white-space: pre-wrap; overflow-x: auto; }
