  :root {
    --bg: #fafbfb;
    --surface: #ffffff;
    --surface-alt: #f4f6f7;
    --border: #e3e8ea;
    --border-strong: #c9d2d5;
    --text: #1a2428;
    --text-muted: #5f6e74;
    --text-subtle: #8b9a9f;
    --accent: #4a9b8e;
    --accent-hover: #3d8275;
    --accent-soft: #e8f3f1;
    --red: #c0433a;
    --red-soft: #fbecea;
    --orange: #d97a2b;
    --orange-soft: #fdf1e4;
    --yellow: #c99a1e;
    --yellow-soft: #fbf3df;
    --green: #4a9b6e;
    --green-soft: #e9f4ee;
    --shadow: 0 1px 2px rgba(26, 36, 40, 0.04), 0 2px 8px rgba(26, 36, 40, 0.04);
    --shadow-lg: 0 4px 16px rgba(26, 36, 40, 0.08);
    --radius: 8px;
    --radius-lg: 12px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
  }
  .screen { display: none; min-height: 100vh; animation: fadeIn 0.25s ease; }
  .screen.active { display: block; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

  .topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
  .brand-mark {
    width: 26px; height: 26px; border-radius: 6px;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 14px; font-weight: 700;
  }
  .brand-name { color: var(--text); }
  .brand-sub { color: var(--text-muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
  .topbar-right { display: flex; align-items: center; gap: 20px; font-size: 13px; color: var(--text-muted); margin-left: auto; }
  .topbar-right .sep { color: var(--border-strong); }
  .logout-btn, .topbar-link {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 13px; font-family: inherit; padding: 0;
  }
  .logout-btn:hover, .topbar-link:hover { color: var(--accent); }

  .container { max-width: 1100px; margin: 0 auto; padding: 32px; }
  .page-title {
    font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
    margin-bottom: 6px; color: var(--text);
  }
  .page-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

  .btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius);
    font-family: inherit; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; border: 1px solid transparent;
  }
  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
  .btn-secondary:hover { background: var(--surface-alt); }
  /* Upload POMR doubles as its own loaded indicator — no separate hanging chip */
  .btn-secondary.btn-loaded { background: var(--accent); color: #fff; border-color: var(--accent); }
  .btn-secondary.btn-loaded:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn-ghost { background: none; color: var(--text-muted); }
  .btn-ghost:hover { color: var(--accent); }
  .btn-large { padding: 14px 28px; font-size: 15px; }

  /* Landing */
  .landing {
    min-height: 100vh;
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, #fafbfb 0%, #f1f5f4 100%);
  }
  .landing-top {
    padding: 20px 40px;
    display: flex; justify-content: space-between; align-items: center;
  }
  .landing-hero {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 20px;
  }
  .landing-mark {
    width: 64px; height: 64px; border-radius: 14px;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 28px; font-weight: 700;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
  }
  /* Hero image banner — full-width band */
  .hero-banner {
    width: 100%;
    height: 320px;
    background: linear-gradient(135deg, #e8f3f1 0%, #d0ebe7 100%);
    overflow: hidden;
    border-bottom: 1px solid var(--border);
  }
  .hero-banner img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
  }
  .landing h1 {
    font-size: 42px; font-weight: 600; letter-spacing: -0.03em;
    margin-bottom: 12px; color: var(--text);
  }
  .landing-tag {
    font-size: 17px; color: var(--text-muted); margin-bottom: 40px;
    max-width: 520px;
  }
  .landing-actions { display: flex; gap: 12px; margin-bottom: 48px; }
  .landing-footer {
    padding: 20px 40px; text-align: center;
    color: var(--text-subtle); font-size: 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  /* Dashboard */
  .dashboard-grid {
    display: grid; grid-template-columns: 1fr 320px; gap: 24px;
  }
  .module-tiles { display: grid; gap: 16px; }
  .tile {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 28px;
    cursor: pointer; transition: all 0.2s;
    display: flex; gap: 20px; align-items: flex-start;
  }
  .tile:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
  .tile-icon {
    width: 48px; height: 48px; border-radius: 10px;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; letter-spacing: 0.04em; flex-shrink: 0;
  }
  .tile-flagship .tile-icon { background: var(--accent); color: white; }
  .tile-body h3 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
  .tile-body p { color: var(--text-muted); font-size: 13px; }
  .tile-flagship { border-color: var(--accent-soft); background: linear-gradient(180deg, #fff 0%, #fafffd 100%); }
  .tile-flagship h3::after {
    content: 'FLAGSHIP';
    font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
    background: var(--accent); color: white;
    padding: 2px 8px; border-radius: 4px;
    margin-left: 10px; vertical-align: middle;
  }
  .side-panel {
    display: flex; flex-direction: column; gap: 16px;
  }
  .session-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
    height: fit-content;
  }
  .session-panel h4 {
    font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 12px;
  }
  .session-item {
    padding: 10px 0; border-bottom: 1px solid var(--border);
    font-size: 13px; color: var(--text);
  }
  .session-item:last-child { border-bottom: none; }
  .session-item .time { color: var(--text-subtle); font-size: 11px; }
  /* Reminder items */
  .reminder-item {
    padding: 10px 12px; border-radius: 8px; margin-bottom: 8px;
    font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
  }
  .reminder-item:last-child { margin-bottom: 0; }
  .reminder-vax { background: var(--yellow-soft); border-left: 3px solid var(--yellow); }
  .reminder-review { background: var(--accent-soft); border-left: 3px solid var(--accent); }
  .reminder-urgent { background: var(--red-soft); border-left: 3px solid var(--red); }
  .reminder-arrival { background: var(--green-soft); border-left: 3px solid var(--green); }
  .reminder-icon { display: none; }
  .reminder-text { flex: 1; }
  .reminder-text strong { display: block; font-size: 12px; font-weight: 600; }
  .reminder-text span { font-size: 11px; color: var(--text-muted); }
  .privacy-note {
    margin-top: 16px; padding: 10px 12px;
    background: var(--accent-soft); color: var(--accent-hover);
    font-size: 11px; border-radius: 6px; line-height: 1.4;
  }

  /* Forms */
  .form-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 28px; margin-bottom: 20px;
  }
  .form-section { margin-bottom: 24px; }
  .form-section:last-child { margin-bottom: 0; }
  .form-section-title {
    font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 14px;
  }
  .form-section-title.required::after {
    content: ' *'; color: var(--red); font-size: 13px;
  }
  .form-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
  .form-row-2 { grid-template-columns: 1fr 1fr; }
  .form-row-1 { grid-template-columns: 1fr; }
  .form-field label {
    display: block; font-size: 12px; color: var(--text-muted);
    margin-bottom: 6px; font-weight: 500;
  }
  .form-field input, .form-field select, .form-field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
    border-radius: 6px; font-family: inherit; font-size: 14px;
    background: var(--surface); color: var(--text);
    transition: border-color 0.15s;
  }
  .form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .form-field textarea { resize: vertical; min-height: 70px; }
  .toggle-group, .multi-group { display: flex; gap: 0; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; width: fit-content; }
  .toggle-btn {
    padding: 9px 22px; background: var(--surface); border: none;
    cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 500;
    color: var(--text-muted); transition: all 0.15s;
  }
  .toggle-btn.active { background: var(--accent); color: white; }
  .chip-input {
    border: 1px solid var(--border-strong); border-radius: 6px;
    padding: 8px; min-height: 42px;
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  }
  .chip {
    background: var(--accent-soft); color: var(--accent-hover);
    padding: 4px 10px; border-radius: 4px; font-size: 12px;
    display: inline-flex; align-items: center; gap: 6px;
  }
  .chip .x { cursor: pointer; opacity: 0.6; }
  .chip-input input {
    border: none; outline: none; flex: 1; min-width: 120px;
    font-family: inherit; font-size: 13px; padding: 4px;
  }
  .form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

  /* "Super" note fields (à la Standard Notes' Super editor) — contenteditable,
     no libraries, NO toolbar: formatting comes from typing. "- " / "* " starts
     a bullet list, "1. " a numbered list, **bold** and *italic* render inline.
     Behaviors bound by initSuperFields(). Real app: Lexical (Super's engine). */
  .rte {
    border: 1px solid var(--border-strong); border-radius: 6px;
    padding: 10px 12px; min-height: 90px; font-size: 14px; font-family: inherit;
    background: var(--surface); line-height: 1.5; color: var(--text);
  }
  .rte:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
  .rte ul, .rte ol { margin: 0; padding-left: 22px; }
  .rte li { margin: 2px 0; }
  .rte p, .rte div { margin: 0 0 4px; }
  .super:empty::before { content: attr(data-placeholder); color: var(--text-subtle); pointer-events: none; }

  /* Tab system */
  .tab-bar {
    display: flex; gap: 0; border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
  }
  .tab-btn {
    padding: 10px 20px; background: none; border: none;
    font-family: inherit; font-size: 14px; font-weight: 500;
    color: var(--text-muted); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: all 0.15s;
  }
  .tab-btn:hover { color: var(--accent); }
  .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
  .tab-pane { display: none; }
  .tab-pane.active { display: block; }

  /* POMR patient lookup bar */
  .pomr-lookup {
    background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 16px;
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
  }
  .pomr-lookup-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
  .pomr-lookup input { flex: 1; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 6px; font-family: inherit; font-size: 13px; }
  .pomr-lookup .pomr-patient-tag {
    background: var(--accent); color: white; padding: 6px 14px;
    border-radius: 6px; font-size: 12px; font-weight: 600;
    display: flex; align-items: center; gap: 8px; cursor: pointer;
  }

  /* Back link */
  .back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-muted); text-decoration: none; font-size: 13px;
    margin-bottom: 16px; cursor: pointer; background: none; border: none;
    font-family: inherit;
  }
  .back-link:hover { color: var(--accent); }

  /* Case recap strip */
  .case-recap {
    background: var(--surface-alt); border-left: 3px solid var(--accent);
    padding: 12px 16px; border-radius: 6px; margin-bottom: 20px;
    font-size: 13px; color: var(--text-muted);
  }
  .case-recap strong { color: var(--text); }

  /* Red flag banner */
  .red-flag-banner {
    background: var(--red-soft); border: 1px solid #e8c2be;
    color: #7a2520; padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 20px; display: flex; gap: 10px; align-items: flex-start;
    font-size: 13px;
  }
  .red-flag-banner strong { display: block; margin-bottom: 2px; }

  /* Differential cards */
  .dx-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px; margin-bottom: 12px;
    cursor: pointer; transition: all 0.15s;
  }
  .dx-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
  .dx-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
  }
  .dx-title { display: flex; align-items: center; gap: 12px; }
  .dx-rank {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface-alt); color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
  }
  .dx-name { font-size: 16px; font-weight: 600; color: var(--text); }
  .dx-meta { display: flex; align-items: center; gap: 12px; }
  .dx-prob { font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
  .confidence-pill {
    padding: 3px 10px; border-radius: 4px; font-size: 11px;
    font-weight: 600; letter-spacing: 0.04em;
  }
  .conf-high { background: var(--green-soft); color: #2d6845; }
  .conf-medium { background: var(--yellow-soft); color: #8a6914; }
  .conf-low { background: var(--surface-alt); color: var(--text-muted); }
  .dx-body { font-size: 13px; color: var(--text-muted); }
  .dx-row { margin: 6px 0; }
  .dx-row strong { color: var(--text); font-weight: 500; }
  .dx-redflag { color: var(--red); font-size: 12px; margin-top: 8px; }

  /* My diagnosis evaluation card */
  .eval-card {
    background: var(--accent-soft); border: 1px solid #b8ddd8;
    border-radius: var(--radius-lg); padding: 20px; margin-top: 16px;
  }
  .eval-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-hover); margin-bottom: 10px; }
  .eval-prob-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
  .eval-prob-big { font-size: 36px; font-weight: 700; color: var(--accent); }
  .eval-verdict { font-size: 15px; font-weight: 600; color: var(--text); }
  .eval-body { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

  /* Drill-down */
  .detail-section { margin-bottom: 20px; }
  .detail-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 6px;
  }
  .detail-body { font-size: 14px; color: var(--text); line-height: 1.6; }
  .workup-list { list-style: none; padding: 0; }
  .workup-list li {
    padding: 8px 12px; background: var(--surface-alt);
    border-radius: 6px; margin-bottom: 6px; font-size: 13px;
    display: flex; align-items: center; gap: 10px;
  }
  .workup-num {
    background: var(--accent); color: white; width: 22px; height: 22px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; flex-shrink: 0;
  }

  /* Treatment reference cards */
  .tx-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
    display: flex; gap: 14px; align-items: flex-start;
  }
  .tx-num {
    background: var(--accent-soft); color: var(--accent); width: 28px; height: 28px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
  }
  .tx-body { flex: 1; }
  .tx-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
  .tx-detail { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
  .tx-ref {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--accent); background: var(--accent-soft);
    padding: 3px 8px; border-radius: 4px; font-weight: 500;
    cursor: pointer;
  }

  /* Drug interactions */
  .interaction-card {
    padding: 16px 18px; border-radius: var(--radius-lg);
    margin-bottom: 12px; border-left: 4px solid;
  }
  .int-contra { background: var(--red-soft); border-color: var(--red); }
  .int-major { background: var(--orange-soft); border-color: var(--orange); }
  .int-minor { background: var(--yellow-soft); border-color: var(--yellow); }
  .int-monitor { background: var(--green-soft); border-color: var(--green); }
  .int-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
  .int-severity { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
  .int-contra .int-severity { color: var(--red); }
  .int-major .int-severity { color: var(--orange); }
  .int-minor .int-severity { color: var(--yellow); }
  .int-monitor .int-severity { color: var(--green); }
  .int-drugs { font-weight: 600; font-size: 14px; color: var(--text); }
  .int-row { font-size: 13px; margin: 4px 0; color: var(--text); }
  .int-row strong { color: var(--text-muted); font-weight: 500; margin-right: 4px; }

  /* Anesthetic protocol */
  .protocol-block {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px; margin-bottom: 12px;
  }
  .protocol-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--accent);
    margin-bottom: 8px;
  }
  .protocol-drug { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
  .protocol-rationale { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
  .protocol-caution {
    font-size: 12px; color: var(--orange); margin-top: 8px;
    background: var(--orange-soft); padding: 8px 10px; border-radius: 6px;
  }
  /* Protocol format placeholder */
  .protocol-format-placeholder {
    border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
    padding: 60px 32px; text-align: center; color: var(--text-muted);
  }
  .protocol-format-placeholder .pf-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
  .protocol-format-placeholder .pf-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
  .protocol-format-placeholder .pf-sub { font-size: 13px; color: var(--text-subtle); }

  /* ===== Anesthetic Protocol — official ANES format (Ximena's template) ===== */
  .anes-fmt { font-size: 13px; }
  .anes-fmt .fmt-band {
    background: var(--accent-soft); color: var(--accent-hover);
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    padding: 8px 12px; border-radius: 6px; margin: 26px 0 14px;
  }
  .anes-fmt .fmt-band:first-of-type { margin-top: 4px; }
  .anes-fmt .fmt-sub { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 16px 0 8px; }
  .fmt-grid { display: grid; gap: 12px 20px; margin-bottom: 6px; }
  .fmt-grid.c4 { grid-template-columns: repeat(4, 1fr); }
  .fmt-grid.c3 { grid-template-columns: repeat(3, 1fr); }
  .fmt-grid.c2 { grid-template-columns: repeat(2, 1fr); }
  .fmt-fld label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
  .fmt-fld input, .fmt-fld select, .fmt-fld textarea {
    width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); font-family: inherit; font-size: 13px; padding: 7px 9px; color: var(--text);
  }
  .fmt-fld textarea { resize: vertical; min-height: 54px; }
  .fmt-fld input:focus, .fmt-fld select:focus, .fmt-fld textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
  /* Ximena's embedded questions / build annotations, surfaced in-context */
  .anes-note {
    display: flex; gap: 8px; align-items: flex-start;
    background: var(--orange-soft); border: 1px dashed #d9a441;
    border-radius: 8px; padding: 8px 12px; margin: 12px 0; font-size: 12px; color: var(--text-muted); line-height: 1.5;
  }
  .anes-note .an-tag { font-weight: 700; color: var(--text); white-space: nowrap; }
  /* time-of-day fields — native picker + one-tap "Now" stamp (value stays editable) */
  .time-wrap { display: flex; gap: 8px; align-items: center; }
  .time-wrap input[type="time"] { flex: 1; }
  .now-btn {
    flex-shrink: 0; border: 1px solid var(--border-strong); background: var(--surface-alt);
    color: var(--text); font-family: inherit; font-size: 12px; font-weight: 600;
    padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap;
    transition: all 0.12s;
  }
  .now-btn:hover { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); }
  /* ASA reference table — row select via circular check buttons (no dropdown) */
  .asa-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 4px; }
  .asa-table td { border: 1px solid var(--border); padding: 6px 10px; color: var(--text); }
  .asa-table td:first-child { width: 46px; font-weight: 700; text-align: center; color: var(--accent-hover); background: var(--surface-alt); }
  .asa-table td.asa-pick { width: 44px; text-align: center; background: var(--surface); }
  .asa-check {
    width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
    border: 2px solid var(--border-strong); background: var(--surface); color: transparent;
    font-size: 14px; font-weight: 700; line-height: 1; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.12s; font-family: inherit;
  }
  .asa-check:hover { border-color: var(--accent); }
  .asa-check.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .asa-table tr.selected td { background: var(--accent-soft); }
  .asa-table tr.selected td:first-child { background: var(--accent-soft); }
  /* simple bordered form-tables (drugs, recovery) */
  .fmt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
  .fmt-table th, .fmt-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
  .fmt-table thead th { background: var(--surface-alt); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 600; }
  .fmt-table td input { width: 100%; box-sizing: border-box; border: none; background: transparent; font-family: inherit; font-size: 12.5px; color: var(--text); padding: 2px; }
  .fmt-table td input:focus { outline: none; background: var(--accent-soft); border-radius: 4px; }
  .fmt-table .rownum { width: 30px; text-align: center; color: var(--text-subtle); background: var(--surface-alt); }
  .fmt-table .rowlbl { background: var(--surface-alt); font-weight: 600; color: var(--text); white-space: nowrap; }
  /* intra-op monitoring chart (graph-paper) + parameter rows */
  .anes-chart-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); max-height: 460px; }
  .anes-chart { border-collapse: collapse; font-size: 11px; min-width: 100%; }
  .anes-chart th, .anes-chart td { border: 1px solid var(--border); text-align: center; height: 22px; min-width: 32px; padding: 0 3px; box-sizing: border-box; }
  .anes-chart thead th { background: var(--surface-alt); font-weight: 600; color: var(--text-muted); position: sticky; top: 0; z-index: 2; }
  .anes-chart .axis { background: var(--surface-alt); font-weight: 600; color: var(--text-subtle); min-width: 42px; position: sticky; left: 0; z-index: 1; }
  .anes-chart thead th.axis { z-index: 3; }
  .anes-chart tbody td:hover { background: var(--accent-soft); cursor: crosshair; }
  .anes-chart tr.param th { text-align: left; background: var(--surface); color: var(--text); font-weight: 600; white-space: nowrap; min-width: 150px; position: sticky; left: 0; z-index: 1; }
  .anes-chart tr.param td:hover { background: var(--surface-alt); cursor: text; }
  /* off-step lanes — a time/value from the finer resolution that holds data keeps
     its own tinted column/row at the coarser view, at its true position */
  .anes-chart thead th.offstep, .anes-chart td.axis.offstep { background: var(--orange-soft); color: #9a6a12; font-style: italic; }
  .anes-chart tbody td.offcell { background: rgba(217, 164, 65, 0.08); }
  .anes-chart tbody td.offcell:hover { background: var(--accent-soft); }
  /* symbol param rows (palpebral / eye / jaw / pulse) — click, don't type */
  .anes-chart tr.param td.pcell-sym { cursor: pointer; font-weight: 700; color: var(--text); user-select: none; }
  .anes-chart tr.param td.pcell-sym:hover { background: var(--accent-soft); cursor: pointer; }
  .anes-chart tr.param th .p-opts { display: block; font-size: 9.5px; font-weight: 500; color: var(--text-subtle); letter-spacing: 0.02em; }
  /* eye-position picker — 3×3 directional pad (8 arrows + ⊙ central), mini-eye icons */
  .eyepick {
    position: absolute; z-index: 80; background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.14); padding: 7px;
    display: none; grid-template-columns: repeat(3, 34px); gap: 4px;
  }
  .eyepick.open { display: grid; }
  .eyepick button {
    width: 34px; height: 30px; border: 1px solid var(--border); border-radius: 7px;
    background: var(--surface); cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center; transition: all 0.12s;
  }
  .eyepick button:hover { border-color: var(--accent); background: var(--accent-soft); }
  .eyepick button.current { background: var(--accent); border-color: var(--accent); }
  .eyepick button.current .mini-eye { border-color: #fff; }
  .eyepick button.current .mini-eye i { background: #fff; }
  .eyepick .mini-eye { display: block; width: 20px; height: 13px; border: 1.5px solid var(--text-muted); border-radius: 50%; position: relative; }
  .eyepick .mini-eye i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--text); top: 50%; left: 50%; transform: translate(-50%, -50%); }
  .eyepick .mini-eye.n  i { top: 18%; }
  .eyepick .mini-eye.s  i { top: 82%; }
  .eyepick .mini-eye.w  i { left: 20%; }
  .eyepick .mini-eye.e  i { left: 80%; }
  .eyepick .mini-eye.nw i { top: 22%; left: 24%; }
  .eyepick .mini-eye.ne i { top: 22%; left: 76%; }
  .eyepick .mini-eye.sw i { top: 78%; left: 24%; }
  .eyepick .mini-eye.se i { top: 78%; left: 76%; }
  .eyepick .ep-clear { grid-column: 1 / -1; width: auto; height: 24px; font-family: inherit; font-size: 11px; color: var(--text-muted); }
  /* 🖨 prints the FULL official record — all three tabs, no tab chrome */
  @media print {
    .anes-fmt .tab-pane { display: block !important; }
    .anes-fmt .tab-bar { display: none !important; }
  }
  /* keys legend = clickable pen palette: arm a key, plot it on the chart, click again to release */
  .anes-keys { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 10px; font-size: 11.5px; color: var(--text-muted); }
  .anes-keys .k {
    display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px;
    background: var(--surface); font-family: inherit; font-size: 11.5px; color: var(--text-muted);
    transition: all 0.12s; user-select: none;
  }
  .anes-keys .k:hover { border-color: var(--accent); }
  .anes-keys .k b { color: var(--text); font-weight: 700; }
  .anes-keys .k .sym { font-weight: 700; font-size: 12px; }
  .anes-keys .k.armed { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 2px var(--accent-soft); }
  .anes-keys .k.armed b, .anes-keys .k.armed .sym { color: #fff; }
  .anes-keys-hint { flex-basis: 100%; font-size: 11px; color: var(--text-subtle); margin-top: 2px; }
  .anes-keys-hint b { color: var(--accent-hover); }
  /* plotted marks inside chart cells (several keys can share a coordinate) */
  .anes-chart td .mark { font-weight: 700; font-size: 11px; line-height: 1; padding: 0 1px; }
  .anes-chart.armed tbody tr:not(.param) td:not(.axis) { cursor: crosshair; }

  /* Legal documents */
  .doc-list-item {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
  }
  .doc-list-item:last-child { border-bottom: none; }
  .doc-name { font-weight: 500; font-size: 14px; margin-bottom: 3px; }
  .doc-meta { font-size: 12px; color: var(--text-subtle); }
  .doc-badge {
    font-size: 12px; padding: 3px 8px; border-radius: 4px; font-weight: 500; white-space: nowrap;
  }
  .doc-current { background: var(--green-soft); color: var(--green); }
  .doc-renew { background: var(--yellow-soft); color: var(--yellow); }
  .doc-expired { background: var(--red-soft); color: var(--red); }

  /* Upload mini */
  .upload-mini {
    border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
    padding: 28px 20px; text-align: center; background: var(--surface);
    cursor: pointer; transition: border-color 0.15s, background 0.15s;
  }
  .upload-mini:hover { border-color: var(--accent); background: var(--accent-soft); }

  /* Imaging studies — D11-DASH-4 (radiology / ultrasound upload + interpretation + HITL AI read-assist) */
  .img-toolbar { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 12px; align-items: end; margin: 12px 0 24px; }
  @media (max-width: 760px) { .img-toolbar { grid-template-columns: 1fr 1fr; } }
  .img-study { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
  .img-study-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
  .img-study-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .img-modality { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 10px; border-radius: 4px; white-space: nowrap; }
  .mod-us { background: #eaf1fb; color: #3a5e96; }
  .mod-rad { background: var(--accent-soft); color: var(--accent-hover); }
  .mod-ct { background: var(--orange-soft); color: var(--orange); }
  .img-study-title { font-size: 15px; font-weight: 600; color: var(--text); }
  .img-study-sub { font-size: 12px; color: var(--text-subtle); }
  .img-study-body { display: grid; grid-template-columns: 220px 1fr; gap: 22px; padding: 18px; }
  @media (max-width: 760px) { .img-study-body { grid-template-columns: 1fr; } }
  .img-frame { background: #10171a; border: 1px solid var(--border-strong); border-radius: var(--radius); aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #6c8086; cursor: pointer; transition: border-color 0.15s; }
  .img-frame:hover { border-color: var(--accent); }
  .img-frame .if-icon { font-size: 46px; opacity: 0.85; }
  .img-frame .if-label { font-size: 11px; letter-spacing: 0.04em; }
  .img-frame .if-meta { font-size: 10px; color: #46585d; }
  .img-col label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
  .img-col textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 6px; font-family: inherit; font-size: 13px; line-height: 1.5; background: var(--surface); color: var(--text); resize: vertical; min-height: 84px; }
  .img-col textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .img-ai { background: var(--accent-soft); border: 1px solid #b8ddd8; border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; }
  .img-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .img-ai-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-hover); display: flex; align-items: center; gap: 8px; }
  .img-ai-model { font-size: 11px; color: var(--text-subtle); }
  .img-ai-body { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-top: 10px; }
  .img-ai-body .aif { margin: 6px 0; }
  .img-ai-body .aif strong { color: var(--text); font-weight: 600; }
  .img-ai-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
  .img-ai-actions .btn { font-size: 12px; padding: 7px 12px; }
  .img-ai-disc { font-size: 11px; color: var(--text-subtle); margin-top: 10px; font-style: italic; }
  .img-ai-trigger { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .img-ai-trigger .hint { font-size: 11px; color: var(--text-subtle); }

  /* Disclaimer */
  .disclaimer {
    background: var(--surface-alt); border: 1px solid var(--border);
    padding: 12px 16px; border-radius: 6px;
    font-size: 12px; color: var(--text-muted); line-height: 1.5;
    margin-top: 24px; display: flex; gap: 10px; align-items: flex-start;
  }
  .disclaimer-icon { flex-shrink: 0; opacity: 0.5; }

  /* Emergency */
  .category-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--red-soft); color: var(--red);
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    padding: 4px 10px; border-radius: 4px; margin-left: 10px; vertical-align: middle;
  }
  .triage-group { display: flex; gap: 8px; }
  .triage-btn {
    flex: 1; padding: 12px 10px; border: 2px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); cursor: pointer; font-family: inherit;
    font-weight: 700; font-size: 13px; color: var(--text-muted);
    text-align: center; transition: all 0.15s; letter-spacing: 0.02em;
  }
  .triage-btn .t-sub { display: block; font-size: 11px; font-weight: 400; margin-top: 3px; color: var(--text-subtle); }
  .triage-btn.active.t-red    { background: var(--red-soft);    border-color: var(--red);    color: var(--red); }
  .triage-btn.active.t-orange { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }
  .triage-btn.active.t-yellow { background: var(--yellow-soft); border-color: var(--yellow); color: #8a6914; }
  .triage-btn.active.t-green  { background: var(--green-soft);  border-color: var(--green);  color: var(--green); }
  .triage-btn.active .t-sub { color: inherit; opacity: 0.85; }

  /* Primary survey (A·B·C·D·E) rows */
  .survey-row {
    display: grid; grid-template-columns: 150px 200px 1fr; gap: 14px; align-items: center;
    padding: 12px 0; border-bottom: 1px solid var(--border);
  }
  .survey-row:last-child { border-bottom: none; }
  .survey-label { font-weight: 600; font-size: 13px; color: var(--text); }
  .survey-label span { display: block; font-size: 11px; font-weight: 400; color: var(--text-subtle); margin-top: 2px; }

  /* Resuscitation / interventions log (modeled on the workbook MAR) */
  .resus-log { width: 100%; border-collapse: collapse; font-size: 13px; }
  .resus-log th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--border);
  }
  .resus-log td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
  .resus-log tr:last-child td { border-bottom: none; }
  .resus-log input {
    width: 100%; border: 1px solid transparent; background: transparent;
    font-family: inherit; font-size: 13px; padding: 6px 8px; border-radius: 6px; color: var(--text);
  }
  .resus-log input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px var(--accent-soft); }
  .resus-time { font-variant-numeric: tabular-nums; color: var(--text-muted); white-space: nowrap; padding-left: 10px; }
  .resus-row-del { color: var(--text-subtle); cursor: pointer; text-align: center; font-size: 15px; width: 28px; }
  .resus-row-del:hover { color: var(--red); }

  /* Hospitalization — patient header grid */
  .hosp-header {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px 24px; margin-bottom: 20px;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 24px;
  }
  .hosp-field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin-bottom: 3px; }
  .hosp-field .v { font-size: 14px; color: var(--text); font-weight: 500; }
  .hosp-field .v.hl { background: #fdf6c8; padding: 1px 6px; border-radius: 4px; display: inline-block; }
  .hosp-days { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent-hover); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 4px; }

  /* Clinical Records — consolidated read-only patient file (D11-DASH-2) */
  .ro-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); background: var(--surface-alt); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
  .rec-headcard { display: flex; gap: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 20px; }
  .rec-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; flex-shrink: 0; }
  .rec-photo-img { width: 120px; height: 120px; border-radius: var(--radius-lg); background: var(--accent-soft); border: 1px dashed var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 48px; color: var(--accent); overflow: hidden; }
  .rec-photo-img img { width: 100%; height: 100%; object-fit: cover; }
  .rec-photo .btn { font-size: 11px; padding: 5px 10px; }
  .rec-headinfo { flex: 1; min-width: 0; }
  .rec-petname { font-size: 24px; font-weight: 700; color: var(--text); margin: 2px 0; }
  .rec-petline { font-size: 14px; color: var(--text-muted); margin: 0 0 12px; }
  .rec-ownerline { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; color: var(--text); }
  .rec-ownerline strong { color: var(--text-subtle); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 6px; }
  .rec-flag { margin-top: 14px; display: inline-block; font-size: 12px; font-weight: 600; color: var(--red); background: var(--red-soft); border: 1px solid var(--red); border-radius: var(--radius); padding: 6px 12px; }
  .rec-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 24px; margin-bottom: 6px; }
  .rec-subtitle { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 16px 0 8px; letter-spacing: 0.03em; text-transform: uppercase; }
  .rec-subtitle:first-of-type { margin-top: 2px; }
  .rec-pomr-list { display: flex; flex-direction: column; gap: 10px; }
  .rec-pomr-row { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
  .rec-pomr-row:hover { border-color: var(--border-strong); }
  .rec-pomr-date { font-size: 13px; font-weight: 700; color: var(--text); width: 116px; flex-shrink: 0; }
  .rec-pomr-date span { display: block; font-size: 10px; font-weight: 500; color: var(--text-subtle); letter-spacing: 0.04em; margin-top: 2px; }
  .rec-pomr-body { flex: 1; min-width: 0; }
  .rec-pomr-type { font-size: 12px; font-weight: 600; color: var(--accent-hover); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }
  .rec-pomr-sum { font-size: 13px; color: var(--text-muted); line-height: 1.45; }

  /* MAR grid — frozen med columns + horizontally scrolling time slots */
  .mar-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
  .mar { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
  .mar th, .mar td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); height: 44px; box-sizing: border-box; }
  .mar thead th { background: var(--surface-alt); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; text-align: center; }
  .mar tbody tr:last-child td { border-bottom: none; }
  /* frozen (sticky) med-info columns */
  .mar .sticky-col { position: sticky; z-index: 2; text-align: left; }
  .mar thead .sticky-col { z-index: 3; }
  .mar .c-cod  { left: 0;     min-width: 84px; }
  .mar .c-med  { left: 84px;  min-width: 150px; }
  .mar .c-dose { left: 234px; min-width: 90px; }
  .mar .c-conc { left: 324px; min-width: 90px; }
  .mar .c-qty  { left: 414px; min-width: 78px; border-right: 2px solid var(--border-strong); } /* the "línea divisoria" */
  /* editable MAR cells — freq dropdown + inline add-medication row */
  .mar td select, .mar td input {
    width: 100%; border: 1px solid transparent; background: transparent;
    font-family: inherit; font-size: 13px; padding: 5px 6px; border-radius: 6px; color: var(--text);
  }
  .mar td select:focus, .mar td input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px var(--accent-soft); }
  .mar td select { cursor: pointer; }
  .freq-select { font-weight: 700; font-size: 11px; letter-spacing: 0.04em; color: var(--accent-hover); }
  .mar-add-row td { background: var(--surface-alt); }
  .mar-add-row input::placeholder { color: var(--text-subtle); }
  .mar-add-btn { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 7px 14px; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
  .mar-add-btn:hover { background: var(--accent-hover); }
  .freq-badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-hover); }
  /* day grouping + slots */
  .mar .day-start { border-left: 2px solid var(--border-strong); }
  .mar .slot { text-align: center; min-width: 50px; }
  .tick {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 6px; cursor: pointer;
    font-size: 14px; border: 1.5px solid var(--border-strong); color: var(--text-subtle);
    background: var(--surface); transition: all 0.12s; user-select: none;
  }
  .tick.given  { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 700; }
  .tick.missed { background: var(--red-soft);   border-color: var(--red);   color: var(--red);   font-weight: 700; }
  .tick.sched:hover { border-color: var(--accent); color: var(--accent); }
  .tick.now { box-shadow: 0 0 0 2px var(--accent); border-color: var(--accent); }
  .slot-na { color: var(--text-subtle); opacity: 0.4; }
  .mar-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
  .mar-legend span { display: inline-flex; align-items: center; gap: 6px; }
  .mar-legend .lg { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--border-strong); display: inline-block; }
  .lg.lg-given { background: var(--green-soft); border-color: var(--green); }
  .lg.lg-sched { background: var(--surface); }
  .lg.lg-missed { background: var(--red-soft); border-color: var(--red); }
  .lg.lg-now { box-shadow: 0 0 0 2px var(--accent); border-color: var(--accent); }

  /* Collapsible (admission belongings) */
  .collapsible { border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 20px; overflow: hidden; }
  .collapsible-head {
    padding: 14px 18px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; font-weight: 600; color: var(--text); background: var(--surface-alt);
  }
  .collapsible-head .chev { transition: transform 0.15s; color: var(--text-muted); }
  .collapsible.open .collapsible-head .chev { transform: rotate(90deg); }
  .collapsible-body { display: none; padding: 18px; }
  .collapsible.open .collapsible-body { display: block; }
  /* Intake accordion — tight group of house collapsibles; grids sit flush inside (outer collapsible owns the chrome) */
  .intake-accordion { margin-bottom: 6px; }
  .intake-accordion .collapsible { margin-bottom: 8px; }
  .intake-accordion .collapsible:last-child { margin-bottom: 0; }
  .intake-accordion .collapsible-body .rec-grid { border: none; background: transparent; padding: 0; margin-bottom: 0; }
  .collap-hint { font-weight: 400; color: var(--text-muted); margin-left: 8px; font-size: 12px; }
  .collap-hint.warn { color: var(--red); font-weight: 600; }
  /* Navigation hamburger — upper-LEFT of the topbar (left of the brand mark),
     on every inner screen. Menu = full module navigation, role-gated; injected
     by buildNavMenus() from NAV_MODULES so it lives in ONE place. */
  .nav-menu-wrap { position: relative; display: inline-flex; }
  .nav-burger {
    background: transparent; border: 1px solid var(--border); border-radius: 8px;
    width: 34px; height: 30px; cursor: pointer; font-size: 15px; line-height: 1;
    color: var(--text); font-family: inherit; display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, border-color 0.12s;
  }
  .nav-burger:hover { background: var(--surface-alt); border-color: var(--accent); }
  .nav-menu {
    display: none; position: absolute; top: calc(100% + 8px); left: 0; z-index: 600;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: 0 10px 28px rgba(45,42,38,0.14); padding: 6px; min-width: 230px;
  }
  .nav-menu.open { display: block; }
  .nav-menu-item {
    display: block; width: 100%; text-align: left; background: transparent; border: none;
    padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text);
    font-family: inherit; white-space: nowrap;
  }
  .nav-menu-item:hover { background: var(--surface-alt); }
  .nav-menu-item.primary { font-weight: 600; }
  .nav-menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }

  /* Edge navigation arrows — browser-style history surfaced at the viewport
     edges: ‹ left = back, › right = forward. Auto-hide: fade in when the
     mouse nears that edge (or Alt+←/→), fade out otherwise. Injected by
     buildEdgeNav(); visibility ruled by updateEdgeNav(). */
  #edge-back { left: 10px; }
  #edge-fwd { right: 10px; }

  /* Modal (discharge reminder) */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(26, 36, 40, 0.45);
    display: none; align-items: center; justify-content: center; z-index: 2000; padding: 20px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface); border-radius: var(--radius-lg); padding: 28px;
    max-width: 460px; width: 100%; box-shadow: var(--shadow-lg);
  }
  .modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 10px; }
  .modal-list { list-style: none; padding: 0; margin: 16px 0; }
  .modal-list li { padding: 10px 12px; background: var(--yellow-soft); border-left: 3px solid var(--yellow); border-radius: 6px; margin-bottom: 8px; font-size: 13px; }
  .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

  /* Login */
  .login-wrap {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: linear-gradient(180deg, #fafbfb 0%, #f1f5f4 100%); padding: 20px;
  }
  .login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 36px; width: 100%; max-width: 400px;
  }
  .login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
  .login-brand .landing-mark { margin-bottom: 0; }
  .login-brand h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
  .login-brand p { font-size: 13px; color: var(--text-muted); }
  .login-field { margin-bottom: 14px; }
  .login-forgot { display: block; text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 16px; }
  .login-forgot strong { color: var(--text); font-weight: 600; }
  .demo-roles {
    margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border-strong);
    text-align: center;
  }
  .demo-roles .demo-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); margin-bottom: 10px; }
  .demo-roles .btn { font-size: 12px; padding: 7px 12px; }

  /* Users & access (clinic admin) */
  .admin-badge {
    display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
    padding: 3px 10px; border-radius: 4px; vertical-align: middle;
    background: var(--orange-soft); color: var(--orange);
  }
  .perm-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 28px; }
  .perm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
  .perm-card h4 { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
  .perm-card .perm-sub { font-size: 11px; color: var(--text-subtle); margin-bottom: 8px; }
  .perm-card ul { margin: 0 0 0 16px; font-size: 12px; color: var(--text-muted); }
  .perm-card li { margin-bottom: 3px; }
  .users-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .users-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
  .users-head h3 { font-size: 15px; font-weight: 600; }
  .users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .users-table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); padding: 10px 20px; background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
  }
  .users-table td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .users-table tr:last-child td { border-bottom: none; }
  .users-table .u-name { font-weight: 600; }
  .users-table .u-email { color: var(--text-muted); font-size: 12px; }
  .role-badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 3px 10px; border-radius: 4px; white-space: nowrap; }
  .role-admin { background: var(--orange-soft); color: var(--orange); }
  .role-dr { background: var(--accent-soft); color: var(--accent-hover); }
  .role-recep { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
  .status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
  .status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
  .status-active { color: var(--green); } .status-active::before { background: var(--green); }
  .status-disabled { color: var(--red); } .status-disabled::before { background: var(--red); }
  .status-invited { color: var(--yellow); } .status-invited::before { background: var(--yellow); }
  .u-action {
    background: none; border: 1px solid var(--border-strong); border-radius: 5px;
    padding: 5px 10px; font-family: inherit; font-size: 11px; color: var(--text-muted);
    cursor: pointer; margin-right: 6px; white-space: nowrap;
  }
  .u-action:hover { border-color: var(--accent); color: var(--accent); }
  .u-action.danger:hover { border-color: var(--red); color: var(--red); }
  .audit-note { font-size: 11px; color: var(--text-subtle); margin-top: 14px; }
  .temp-pass-box {
    background: var(--yellow-soft); border: 1px dashed var(--yellow); border-radius: 6px;
    padding: 12px 14px; margin-top: 14px; font-size: 13px;
  }
  .temp-pass-box code { font-family: 'SF Mono', Menlo, monospace; font-weight: 700; font-size: 14px; letter-spacing: 0.05em; }

  /* POMR — critical-flag icon (flickers until acknowledged) + popovers */
  .flag-fab {
    position: absolute; top: 34px; right: 32px;
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--yellow-soft); border: 1px solid var(--yellow);
    font-size: 20px; line-height: 1; cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
    animation: flagFlicker 1.1s ease-in-out infinite;
    z-index: 500;
  }
  .flag-fab.seen { animation: none; }
  .flag-fab:hover { border-color: var(--orange); }
  .flag-count {
    position: absolute; top: -7px; right: -7px;
    background: var(--red); color: white; font-size: 10px; font-weight: 700;
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg);
  }
  @keyframes flagFlicker {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(201, 154, 30, 0.45); }
    50% { opacity: 0.4; box-shadow: 0 0 0 7px rgba(201, 154, 30, 0); }
  }
  .pop-panel {
    position: absolute; display: none; z-index: 600;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 16px; width: 380px; max-width: 90vw; font-size: 13px; text-align: left;
  }
  .pop-panel.open { display: block; animation: fadeIn 0.15s ease; }
  .flag-pop { top: 84px; right: 32px; border-top: 3px solid var(--red); max-height: 55vh; overflow-y: auto; }
  .pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .pop-head strong { font-size: 13px; }
  .pop-close { background: none; border: none; cursor: pointer; color: var(--text-subtle); font-size: 17px; padding: 0 2px; line-height: 1; font-family: inherit; }
  .pop-close:hover { color: var(--text); }
  .flag-item { background: var(--red-soft); border-left: 3px solid var(--red); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; line-height: 1.5; }
  .flag-item:last-child { margin-bottom: 0; }
  .clip-wrap { position: relative; display: inline-flex; }
  .clip-btn {
    width: 38px; height: 38px; border-radius: 6px;
    background: var(--surface); border: 1px solid var(--border-strong);
    font-size: 17px; cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
  }
  .clip-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
  .clip-btn img { width: 22px; height: 22px; display: block; pointer-events: none; }
  .clip-pop {
    top: calc(100% + 8px); right: 0; width: 460px; border-top: 3px solid var(--accent);
    padding: 0; max-height: min(480px, 60vh); flex-direction: column;
  }
  .clip-pop.open { display: flex; }
  .clip-pop .pop-head { padding: 14px 16px 10px; margin-bottom: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .clip-scroll { overflow-y: auto; padding: 10px 12px 12px; }
  .clip-foot { padding: 8px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-subtle); flex-shrink: 0; }
  .clip-year { margin-bottom: 2px; }
  .clip-year-head {
    width: 100%; background: none; border: none; font-family: inherit; cursor: pointer;
    display: flex; align-items: baseline; gap: 7px; padding: 6px 6px; text-align: left;
    font-size: 12px; font-weight: 700; color: var(--text); border-radius: 4px;
  }
  .clip-year-head:hover { background: var(--surface-alt); }
  .clip-year-head .chev { transition: transform 0.15s; font-size: 9px; color: var(--text-subtle); flex-shrink: 0; }
  .clip-year.open .clip-year-head .chev { transform: rotate(90deg); }
  .clip-rollup { font-weight: 400; color: var(--text-muted); font-size: 12px; }
  .clip-year-body { display: none; padding: 2px 6px 8px 22px; color: var(--text-muted); line-height: 1.7; font-size: 13px; }
  .clip-year.open .clip-year-body { display: block; }

  /* Reception — front desk */
  .recep-results-note { font-size: 12px; color: var(--text-subtle); margin: 8px 0 0; }
  .check-in-pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 4px; background: var(--green-soft); color: var(--green); }

  /* Calendar — clinic-wide scheduler */
  .cal-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
  .cal-toolbar .cal-date { font-weight: 600; font-size: 15px; }
  .cal-grid { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .cal-grid th { background: var(--surface-alt); padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--border); }
  .cal-grid td { border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); padding: 4px 6px; vertical-align: top; height: 52px; }
  .cal-grid td.cal-hour { width: 70px; color: var(--text-subtle); font-size: 11px; padding-top: 8px; border-left: none; background: var(--surface-alt); }
  .cal-appt { border-radius: 6px; padding: 5px 8px; font-size: 11.5px; line-height: 1.35; background: var(--accent-soft); border-left: 3px solid var(--accent); margin-bottom: 3px; }
  .cal-appt strong { font-size: 12px; }
  .cal-appt .cal-sub { color: var(--text-muted); }
  .cal-appt.cal-surgery { background: var(--yellow-soft); border-left-color: var(--yellow); }
  .cal-appt.cal-conflict { background: var(--red-soft); border-left-color: var(--red); }
  .cal-appt.cal-er { background: var(--red-soft); border-left-color: var(--red); }
  .cal-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); margin-top: 10px; }
  .cal-legend .lgd { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

  /* POMR — patient list (bars; fields separated by divider lines) */
  .pt-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 20px; }
  .pt-bar {
    display: flex; align-items: stretch; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); cursor: pointer; overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .pt-bar:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
  .pt-bar.active { border-color: var(--accent); background: var(--accent-soft); }
  .pt-bar .pt-cell {
    padding: 12px 16px; font-size: 13px; display: flex; flex-direction: column; justify-content: center;
    border-left: 1px solid var(--border); min-width: 0;
  }
  .pt-bar .pt-cell:first-child { border-left: none; }
  /* Column proportions — shared by header row and bars so labels line up with fields */
  .pt-name { flex: 1.1; }
  .pt-breed { flex: 1.4; }
  .pt-age { flex: 0.55; white-space: nowrap; }
  .pt-owner { flex: 1.1; }
  .pt-phone { flex: 1; white-space: nowrap; }
  .pt-bar .pt-name { font-weight: 600; font-size: 14px; }
  .pt-bar .pt-breed, .pt-bar .pt-age, .pt-bar .pt-phone { color: var(--text-muted); }
  .pt-head { display: flex; padding: 0 1px; }
  .pt-head .pt-cell { padding: 0 16px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); border-left: none; }

  /* Rx — issue & print */
  .rx-doc { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 22px 26px; background: var(--surface); font-size: 13px; }
  .rx-doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--accent); padding-bottom: 12px; margin-bottom: 14px; }
  .rx-doc-head .rx-clinic { font-weight: 700; font-size: 15px; }
  .rx-doc-head .rx-clinic-sub { font-size: 11.5px; color: var(--text-muted); }
  .rx-symbol { font-size: 26px; font-weight: 700; color: var(--accent); font-family: Georgia, serif; }
  .rx-lines { margin: 12px 0; }
  .rx-lines li { margin: 0 0 8px 18px; }
  .rx-sig-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 26px; gap: 20px; }
  .rx-sig-block { text-align: center; font-size: 12px; color: var(--text-muted); }
  .rx-sig-line { border-top: 1px solid var(--text); width: 220px; margin-bottom: 4px; padding-top: 4px; font-weight: 600; color: var(--text); }
  .rx-audit-note { font-size: 11.5px; color: var(--text-subtle); margin-top: 12px; }
  .rx-signed-banner { background: var(--green-soft); border: 1px solid #c2e0cf; color: #2f7048; padding: 10px 14px; border-radius: 6px; font-size: 12.5px; display: none; margin-top: 14px; }

  /* Dev nav */

  /* D11-POMR-8 — minimum-AI-dataset markers */
  label.ai-min::after { content: " ✦"; color: var(--accent); font-size: 11px; }
  .ai-min-legend { font-size: 12px; color: var(--text-subtle); margin: 10px 0 0; }
  .ai-min-legend .ai-min-mark { color: var(--accent); }

  /* D11-DDX-1 — read-only POMR context loaded into My Diagnosis */
  .ro-block { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; color: var(--text-muted); line-height: 1.7; }
  .ro-block strong { color: var(--text); }
  .ro-badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; background: var(--surface-alt); border: 1px solid var(--border); color: var(--text-subtle); border-radius: 4px; padding: 2px 8px; margin-left: 8px; }
  input[readonly].ro { background: var(--surface-alt); color: var(--text-muted); cursor: default; }

/* ---- app additions (server-rendered build) ---- */
.inline-form { display: inline; margin: 0; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 14px 0 0; border: 1px solid var(--border); background: var(--surface-alt); }
.flash-ok { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); }
.flash-error { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.flash-warn { border-color: var(--orange); background: var(--orange-soft); color: var(--orange); }
.nav-menu-item { display: block; width: 100%; text-decoration: none; color: inherit; box-sizing: border-box; }
.coming-soon-wrap { position: relative; }
.coming-soon-wrap > .coming-soon-content { pointer-events: none; opacity: .45; filter: grayscale(.4); user-select: none; }
.coming-soon-banner { position: sticky; top: 64px; z-index: 5; margin: 0 auto 14px; max-width: 720px; text-align: center; padding: 12px 18px; border-radius: 10px; background: var(--surface); border: 1px solid var(--accent); color: var(--accent-hover); font-weight: 600; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.coming-soon-banner small { display: block; font-weight: 400; color: var(--text-muted); margin-top: 3px; }
.reveal-once { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; padding: 12px; background: var(--surface-alt); border: 1px dashed var(--border-strong); border-radius: 8px; word-break: break-all; user-select: all; }
.form-error { color: var(--red); font-size: 12px; margin-top: 4px; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.chip .chip-x { background: none; border: 0; padding: 0 0 0 2px; cursor: pointer; color: inherit; font-size: 13px; line-height: 1; opacity: .7; }
.chip .chip-x:hover { opacity: 1; }
.ro-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 600; background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); vertical-align: middle; }
