/* Only the chrome. Everything inside a screen uses design.css — the prototype's
   own stylesheet — so screens look like what was designed rather than like a
   second design system maintained in parallel. */
html,body{height:100%}
.app{min-height:100vh}
/* The sidebar, taken from the prototype: dark navy, the bird mark, small caps
   group labels, tight rounded buttons. The values are its own — var(--side-bg) for the
   panel, var(--side-edge) for the edge, var(--side-active) behind the active item — rather than
   approximations of them. */
.side{display:flex;flex-direction:column;overflow-y:auto;scrollbar-width:none;
  background:var(--side-bg);color:var(--side-text);padding:14px 10px;border-right:1px solid var(--side-edge)}
.side::-webkit-scrollbar{width:0;height:0}
.sidefoot-live{margin-top:auto}

.side .brand{display:flex;gap:9px;align-items:center;padding:7px 8px 14px;text-decoration:none;color:inherit;border-radius:9px}
.side .brand:hover .brandtext b{text-decoration:underline}
.side .brand:focus-visible{outline:2px solid var(--side-text-strong);outline-offset:2px}
/* Which deployment this is, under the logo. Production stays quiet; anything else
   is marked, and its sidebar gets a coloured top edge that still shows when the
   sidebar is collapsed to the icon rail. */
.envbadge{display:inline-block;margin-top:3px;font-size:10px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;
  color:var(--side-text-muted)}
.envbadge[data-env="staging"],.envbadge[data-env="preview"],.envbadge[data-env="local"]{
  color:var(--side-note);border:1px solid currentColor;border-radius:999px;padding:1px 7px;width:max-content}
.side[data-env="staging"],.side[data-env="preview"],.side[data-env="local"]{box-shadow:inset 0 3px 0 var(--side-note)}
.side .brand .bird{width:26px;height:auto;display:block;opacity:.95;border-radius:0}
.brandtext{display:flex;flex-direction:column;line-height:1.25}
.brandtext b{font-size:14px;font-weight:700;color:var(--side-text-strong);letter-spacing:.005em}
.brandtext span{font-size:11px;color:var(--side-text-muted)}

.navgroup{color:var(--side-label);font-size:9px;text-transform:uppercase;letter-spacing:.12em;
  padding:14px 9px 5px;font-weight:600}
#navList button{display:flex;align-items:center;width:100%;border:0;background:transparent;
  color:var(--side-text);padding:7px 9px;border-radius:3px;text-align:left;cursor:pointer;margin:1px 0;
  min-height:36px;font:inherit;font-size:13px;
  transition:background .12s ease,color .12s ease}
#navList button:hover{background:var(--side-hover);color:var(--side-text-strong)}
#navList button.on{background:var(--side-active);color:var(--side-text-active)}
#navList button .dot{margin-left:auto;width:6px;height:6px;border-radius:50%;
  background:var(--side-dot);opacity:.9;float:none}
.sidefoot-live{display:flex;align-items:center;gap:8px;padding:10px 9px;
  border-top:1px solid var(--side-edge);font-size:11px;color:var(--side-text-muted)}
.sidefoot-live .btn{background:transparent;color:var(--side-text);
  border:1px solid var(--side-border);border-radius:4px;height:28px;padding:0 10px;font-size:11.5px}
.sidefoot-live .btn:hover{background:var(--side-hover);color:var(--side-text-active)}
#mode{color:var(--side-text-muted)}

.topbar-live{display:flex;align-items:center;gap:14px;flex-wrap:wrap;
  padding:10px 22px;border-bottom:1px solid var(--line);background:var(--panel)}
.findwrap{position:relative}
#patHits{display:none;position:absolute;top:calc(100% + 5px);left:0;z-index:60;min-width:270px;
  background:var(--panel);border:1px solid var(--line);border-radius:10px;overflow:hidden;
  box-shadow:var(--shadow)}
#patHits button{display:block;width:100%;text-align:left;border:0;background:transparent;
  font:inherit;font-size:13px;padding:8px 11px;cursor:pointer;color:inherit}
#patHits button:hover{background:var(--brand2)}

#screenHost iframe.legacy{width:100%;height:calc(100vh - 128px);border:0;display:block;background:transparent}
.miss{color:var(--bad);font-weight:650}
.code-ish{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12.5px}
.tracker-kpi b.bad{color:var(--bad)}
.tracker-kpi b.warn{color:var(--warn)}

/* Layout. design.css carries several .app and .content rules from different
   stages of the prototype; the last one wins and centres content in a 1200px
   column that was right for a standalone page and wrong here. These come after
   it on purpose. */
.app{display:grid;grid-template-columns:240px minmax(0,1fr);min-height:100vh;width:100%}
.main{min-width:0;width:100%;display:flex;flex-direction:column}
.content{max-width:none;margin:0;padding:18px 24px 48px;width:100%}
.table-wrap{max-width:100%;overflow-x:auto}

/* design.css is several of the prototype's <style> blocks concatenated, and two
   of them belong to standalone preview pages rather than the app: one sets
   body{max-width:46em;margin:2em auto}, which is what squeezed the whole app
   into a 644px column. Undo the page-document styling; keep the app styling. */
body{max-width:none;margin:0;padding:0;font:14px/1.55 'Source Sans 3',system-ui,-apple-system,Segoe UI,Arial,sans-serif;color:var(--ink);background:var(--bg)}
h1{font-size:inherit;margin:0}

/* Scope. design.css defines .scope-band for the patient case; the practice
   variant is the same component in a neutral colour so the two read as a pair. */
.scope-band{display:flex!important;align-items:center;gap:8px;margin-bottom:14px;
  padding:7px 12px;border-radius:9px;background:var(--brand2);border:1px solid var(--scope-edge);
  font-size:12px;font-weight:650;color:var(--brand-ink)}
.scope-band.practice{background:var(--scope-practice-bg);border-color:var(--scope-practice-edge);color:var(--scope-practice-ink)}
#patbar[data-scope="practice"]{display:none}

/* The medication grid is entirely styled by design.css — the prototype's own
   rules. An earlier hand-rolled grid left .mg-* overrides here, and because
   .mg-drawn means the drawn-amount input in the real markup and meant a dose
   cell in mine, every recorded dose rendered as a blue box instead of a number. */
.card{position:relative}

/* Developer panel */
#devBtn{width:26px;height:26px;border-radius:50%;border:1px solid var(--line);
  background:var(--panel);color:var(--muted);font:inherit;font-size:13px;font-weight:700;
  cursor:pointer;line-height:1;margin-left:auto}
#devBtn:hover{border-color:var(--brand);color:var(--brand-text)}
#devBtn[aria-expanded="true"]{background:var(--brand);color:var(--on-brand);border-color:transparent}
#devPanel{position:fixed;right:18px;bottom:18px;z-index:70;width:min(430px,calc(100vw - 36px));
  max-height:60vh;overflow:auto;background:var(--panel);border:1px solid var(--line);
  border-radius:12px;padding:14px 16px;box-shadow:var(--shadow-pop)}
#devPanel table{width:100%}
#devPanel td{padding:5px 8px;border-bottom:1px solid var(--line);vertical-align:top;font-size:12.5px}
#devPanel td:first-child{white-space:nowrap;color:var(--muted);width:130px}

/* ── Shared layout primitives ──────────────────────────────────────────────
   Screens were reaching for inline styles for the same four or five shapes.
   Naming them keeps the look consistent and means a spacing change happens
   once rather than in sixteen files. */
.grid-auto{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px}
.grid-auto.narrow{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}
.actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.actions.spaced{margin:14px 0 30px}
.stack{display:flex;flex-direction:column;gap:10px}
.inline{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.grow{flex:1}
.right{margin-left:auto}
.note-line{font-size:12.5px;color:var(--muted)}
.ok-text{color:var(--ok)}
.bad-text{color:var(--bad)}
.warn-text{color:var(--warn)}
.w-sm{min-width:150px}
.w-md{min-width:200px}
.w-lg{min-width:260px}
.field input,.field select,.field textarea{width:100%}
.field .label{display:block;margin-bottom:4px}
.scroll-x{overflow-x:auto}
.mt{margin-top:12px}
.mt-sm{margin-top:8px}
.mb{margin-bottom:12px}
.clickable{cursor:pointer}
.w-tick{width:34px}
.nowrap{white-space:nowrap}

/* ── Touch ─────────────────────────────────────────────────────────────────
   A tablet in a surgery is used with a gloved finger, at arm's length, often
   one-handed. Three things follow: targets get bigger, nothing depends on
   hover, and the nav stops being a 240px column that eats a third of a 10"
   screen. These rules key off pointer type rather than width, so a touchscreen
   laptop gets them and a small window on a desktop does not. */
@media (pointer: coarse) {
  .btn, .seg-option, .chip, #navList button, .toggle-chip,
  select, input[type="text"], input[type="search"], input[type="password"], input:not([type]) {
    min-height: 44px;
  }
  .btn.small, .seg-option { padding: 0 16px; font-size: 14px }
  .segmented.compact { gap: 6px }
  .segmented.compact .seg-option { border-radius: 10px }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px }
  /* a checkbox in a table row is hard to hit; give it the whole cell */
  .table td:has(> input[type="checkbox"]) { padding: 10px 14px }
  .table td, .table th { padding: 12px 10px }
  .mg-drop, .mg-add { min-width: 44px; min-height: 40px }
  #devBtn { width: 40px; height: 40px }
  /* hover styling never arrives on touch, so selected state must be visible */
  .seg-option.selected, .chip.on, #navList button.on { box-shadow: inset 0 0 0 2px currentColor }
}

/* ---- Responsive layout ------------------------------------------------
     1100px and up   full sidebar (240px)
     700-1099px      icon rail (64px). The expand button opens the full sidebar
                     over the content; picking a screen closes it.
     below 700px     no sidebar. The menu button in the top bar opens it as a
                     drawer; Esc, the backdrop or picking a screen closes it.
   design.css (the prototype) has its own rail and hide rules at 1100px and
   700px; these come later and replace them. shell.js toggles .nav-open. */
.navtoggle{display:none;align-items:center;justify-content:center;width:40px;height:40px;
  border:0;border-radius:8px;background:transparent;color:inherit;cursor:pointer;font-size:16px}
.side .navtoggle{color:var(--side-text)}
.side .navtoggle:hover{background:var(--side-hover);color:var(--side-text-strong)}
.scrim{display:none}

/* A form field's grid had no explicit column, so its one column grew to fit a
   row of option buttons instead of letting them wrap, and pushed the page wider
   than a tablet (Anesthesia, "Pre-op antibiotic"). */
.quick-field{grid-template-columns:minmax(0,1fr)}
.quick-field>*{min-width:0}

@media (max-width: 1099px) {
  .app{grid-template-columns:64px minmax(0,1fr)}
  .main{grid-column:2}   /* stays put when the expanded sidebar leaves the grid */
  .side{width:64px;padding:10px 8px;overflow-x:hidden}
  .side .navtoggle{display:inline-flex;margin:0 auto 6px}
  .app:not(.nav-open) .brandtext,
  .app:not(.nav-open) #navList .lbl,
  .app:not(.nav-open) #whoami,
  .app:not(.nav-open) #lockBtn .lbl{display:none}
  .app:not(.nav-open) .side .brand{justify-content:center;padding:4px 0 10px}
  .app:not(.nav-open) .navgroup{font-size:0;height:1px;padding:0;margin:8px 10px;background:var(--side-edge)}
  .app:not(.nav-open) #navList button{justify-content:center;padding:0}
  .app:not(.nav-open) #navList button .ico{margin-right:0;font-size:15px;width:auto}
  .app:not(.nav-open) #navList button .dot{position:absolute;margin:0 0 14px 18px}
  .app:not(.nav-open) .sidefoot-live{flex-direction:column;gap:6px;padding:8px 0}
  .app:not(.nav-open) .sidefoot-live [data-appearance-toggle]{margin-left:0}
  .app:not(.nav-open) #lockBtn{width:28px;padding:0;justify-content:center}

  /* expanded: the full sidebar floats over the content */
  .app.nav-open .side{position:fixed;left:0;top:0;bottom:0;width:240px;height:100vh;z-index:200;
    box-shadow:var(--shadow-pop);padding:14px 10px}
  .app.nav-open .side .navtoggle{margin:0 0 6px auto}
  .app.nav-open .scrim{display:block;position:fixed;inset:0;z-index:150;background:rgba(0,0,0,.35)}

  .content{padding:14px 16px 60px}
  .grid-auto{grid-template-columns:1fr}
}

@media (max-width: 699px) {
  .app{display:block}
  .side{display:flex;position:fixed;left:0;top:0;bottom:0;width:260px;height:100vh;z-index:200;
    transform:translateX(-100%);transition:transform .2s ease;box-shadow:none}
  .app.nav-open .side{transform:none;box-shadow:var(--shadow-pop);width:260px}
  .side .navtoggle{display:none}
  #menuBtn{display:inline-flex;position:fixed;top:8px;left:8px;z-index:120;
    background:var(--side-bg);color:var(--side-text-strong);box-shadow:var(--shadow-pop)}
  .main{padding-top:56px}
  .content{padding:14px}
}
@media (max-width: 699px) and (prefers-reduced-motion: reduce) { .side{transition:none} }

/* Momentum scrolling and no accidental zoom on a double tap. */
.table-wrap, .mg-scroll, #screenHost, .side { -webkit-overflow-scrolling: touch }
button, .seg-option, .chip { touch-action: manipulation }

/* An editable table. The cell is the input — a separate text copy underneath
   meant reading two things and trusting they agreed. */
.table.editable td[contenteditable]{cursor:text;border-radius:4px}
.table.editable td[contenteditable]:hover{background:var(--brand2)}
.table.editable td[contenteditable]:focus{outline:2px solid var(--brand);
  outline-offset:-2px;background:var(--panel)}
.table.editable td:empty::after{content:'—';color:var(--muted)}

/* The drawn-up quantity is a choice between a few standard vials, so it is
   offered as one. The text box stays for anything unusual. */
.mg-drawnpick{display:flex;gap:3px;margin-top:3px;flex-wrap:wrap}
.mg-drawnpick button{border:1px solid var(--line);background:var(--panel);
  color:var(--muted);border-radius:4px;font:inherit;font-size:10.5px;line-height:1;
  padding:3px 6px;cursor:pointer;min-height:0}
.mg-drawnpick button:hover{border-color:var(--brand);color:var(--brand-text)}
.mg-drawnpick button.on{background:var(--brand);border-color:transparent;color:var(--on-brand)}
.mg-pop .presets button{cursor:pointer}
.mg-pop .presets button:hover{background:var(--brand);border-color:transparent;color:var(--on-brand)}
@media (pointer: coarse){
  .mg-drawnpick button{min-height:32px;padding:6px 10px;font-size:12px}
  .mg-pop .presets button{min-height:44px;padding:0 16px;font-size:15px}
}

/* Contrast (WCAG AA 4.5:1). The signed-in name used design.css .tiny (#555759),
   2.1:1 on the navy panel; the scope band used brand blue on its own tint, 4.0:1. */
.sidefoot-live #whoami{color:var(--side-text)}
.scope-band{color:var(--brand-ink)}

/* Icons (Font Awesome Free, solid; served from web/vendor/fontawesome). They take
   the text colour, so they follow the theme. Fixed width keeps labels aligned. */
#navList button .ico{width:18px;margin-right:9px;text-align:center;flex:none;font-size:13px;opacity:.85}
#navList button.on .ico{opacity:1}

/* Sidebar footer: name, appearance toggle, Lock. The toggle is icon-only, so
   appearance.js keeps its aria-label and title current. */
.sidefoot-live [data-appearance-toggle]{margin-left:auto;width:28px;padding:0;display:inline-flex;
  align-items:center;justify-content:center}

/* User menu under your name: profile, password and security, lock, sign out. */
.usermenu-wrap{min-width:0;flex:1}            /* the menu is placed against the whole footer */
.usermenu-btn{display:flex;align-items:center;gap:7px;width:100%;min-width:0;background:transparent;border:0;border-radius:8px;
  padding:6px 6px;cursor:pointer;color:var(--side-text);text-align:left;font:inherit}
.usermenu-btn:hover,.usermenu-btn[aria-expanded="true"]{background:var(--side-hover);color:var(--side-text-active)}
.usermenu-btn .lbl{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:inherit;flex:1}
.usermenu-btn .chev{font-size:10px;opacity:.7}
.usermenu{position:absolute;left:6px;right:6px;bottom:calc(100% + 4px);z-index:40;background:var(--panel);color:var(--ink);
  border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow);padding:6px}
.usermenu a,.usermenu button{display:flex;gap:9px;align-items:center;width:100%;padding:8px 10px;border-radius:7px;border:0;
  background:transparent;color:var(--ink);font:inherit;font-size:13px;text-decoration:none;cursor:pointer;text-align:left}
.usermenu a:hover,.usermenu button:hover,.usermenu a:focus-visible,.usermenu button:focus-visible{background:var(--bb-blue-a12);outline:none}
.usermenu i{width:16px;text-align:center;color:var(--ink-3)}
@media (max-width: 1099px) {
  /* icon rail: just the person icon, and the menu opens beside the rail */
  .app:not(.nav-open) .usermenu-btn .lbl,.app:not(.nav-open) .usermenu-btn .chev{display:none}
  .app:not(.nav-open) .usermenu-btn{justify-content:center}
  .app:not(.nav-open) .usermenu{position:fixed;left:72px;right:auto;bottom:12px;width:260px}
}
/* The footer (your name, the user menu, Lock) stays at the bottom of the sidebar
   even when the menu above it is longer than the screen. */
/* bottom: minus the sidebar's own bottom padding, so nothing shows beneath it */
.sidefoot-live{position:sticky;bottom:-18px;margin-bottom:-18px;padding-bottom:28px;z-index:5;background:inherit}   /* also the menu's anchor */
@media (max-width: 1099px) { .app:not(.nav-open) .sidefoot-live{bottom:-10px;margin-bottom:-10px;padding-bottom:18px} }
