/* SanaLogs Inventory — liquid glass over MEDEVAC backdrop
   Theme: Nomad Health blue→violet (#3B82F6 → #8B5CF6) + X-Sim glass */
:root {
  --brand-a: #3B82F6;
  --brand-b: #8B5CF6;
  --grad-primary: linear-gradient(135deg, #3B82F6, #8B5CF6);
  --bg-ink: #070A18;

  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-bg-hover: rgba(255, 255, 255, 0.12);
  --glass-bg-solid: rgba(16, 20, 40, 0.92);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-border-hover: rgba(255, 255, 255, 0.30);
  --glass-blur: saturate(150%) blur(14px);
  --glass-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);

  --text: #E6EAF5;
  --text-2: rgba(230, 234, 245, 0.75);
  --muted: #93A0BC;
  --primary: #3B82F6;
  --primary-hover: #5c96f7;
  --success: #34D399;
  --alert: #F87171;
  --warn: #F59E0B;
  --radius: 16px;
  --radius-sm: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-ink);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
/* MEDEVAC backdrop — fixed layer + brand halos + dark veil so glass reads */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(115deg, rgba(59, 130, 246, 0.10) 0%, rgba(139, 92, 246, 0.10) 100%),
    linear-gradient(180deg, rgba(7, 10, 24, 0.46) 0%, rgba(7, 10, 24, 0.20) 42%,
      rgba(7, 10, 24, 0.26) 68%, rgba(7, 10, 24, 0.90) 78%, rgba(7, 10, 24, 0.98) 100%),
    url('/bg-medevac.jpg') center / cover no-repeat,
    var(--bg-ink);
}
a { color: var(--brand-a); text-decoration: none; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

/* layout */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: rgba(5, 8, 20, 0.55);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--grad-primary); font-weight: 700; font-size: 16px; color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}
.brand .name { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand .sub { font-size: 11px; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; font-weight: 500; font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-item:hover { color: var(--text); background: var(--glass-bg-hover); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.28), rgba(139, 92, 246, 0.28));
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.25);
}
.nav-item .ico { width: 20px; text-align: center; }
.nav-sep { margin: 10px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: rgba(147, 160, 188, 0.6); }
.nav-bottom { margin-top: auto; }

.main { flex: 1; padding: 26px 30px; max-width: 1600px; min-width: 0; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.main-col > .main { flex: 1 0 auto; width: 100%; }
.app-foot { flex: none; padding: 16px 30px 22px; border-top: 1px solid rgba(255, 255, 255, .08); color: var(--muted); font-size: 12px; line-height: 1.8; }
.app-foot a { color: #9bbcf5; text-decoration: none; } .app-foot a:hover { text-decoration: underline; }
.app-foot-links { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 12.5px; font-weight: 600; } .app-foot-links span { opacity: .5; }
.app-foot.auth { padding: 16px 0 0; border-top: 0; text-align: center; } .app-foot.auth .app-foot-links { justify-content: center; }
@media (max-width: 900px) { .app-foot { padding: 14px 14px 20px; } }
@media print { .app-foot { display: none; } }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* glass cards */
.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  padding: 20px;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.card::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.02) 45%, transparent 100%);
  pointer-events: none; z-index: 0;
}
.card > * { position: relative; z-index: 1; }
.card:hover { border-color: var(--glass-border-hover); }

.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 4px; }
.card.clickable { cursor: pointer; transition: transform 0.12s, border-color 0.2s; }
.card.clickable:hover { border-color: rgba(139, 92, 246, 0.55); transform: translateY(-2px); }
.card.clickable:active { transform: none; }
.stat .num {
  font-size: 32px; font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat.alert .num { background: none; -webkit-text-fill-color: currentcolor; color: var(--alert); }
.stat.warn .num { background: none; -webkit-text-fill-color: currentcolor; color: var(--warn); }
.stat.ok .num { background: none; -webkit-text-fill-color: currentcolor; color: var(--success); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 0; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  background: var(--grad-primary); color: #fff;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.40);
  transition: filter 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.12); box-shadow: 0 6px 22px rgba(99, 102, 241, 0.55); }
.btn.ghost {
  background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-hover); filter: none; }
.btn.success { background: linear-gradient(135deg, #10B981, #34D399); box-shadow: 0 4px 16px rgba(52, 211, 153, 0.35); }
.btn.danger { background: linear-gradient(135deg, #DC2626, #F87171); box-shadow: 0 4px 16px rgba(248, 113, 113, 0.35); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* forms */
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); font: inherit; font-size: 14px;
  background: rgba(6, 8, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18); color: var(--text);
}
input::placeholder, textarea::placeholder { color: rgba(147, 160, 188, 0.55); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-b);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22);
}
select option { background: #10142a; color: var(--text); }
input[type="checkbox"] { width: auto; accent-color: var(--brand-b); }
input[type="radio"] { width: auto; padding: 0; margin: 0; flex: none; accent-color: var(--brand-b); }
.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; padding: 9px 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--glass-border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); vertical-align: middle; color: var(--text-2); }
td strong { color: var(--text); }
tr:hover td { background: rgba(255, 255, 255, 0.03); }

/* badges */
.badge { display: inline-block; padding: 2.5px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge.green { background: rgba(52, 211, 153, 0.14); color: #4ade80; border-color: rgba(52, 211, 153, 0.30); }
.badge.red { background: rgba(248, 113, 113, 0.14); color: #f87171; border-color: rgba(248, 113, 113, 0.30); }
.badge.blue { background: rgba(59, 130, 246, 0.15); color: #7cb1f9; border-color: rgba(59, 130, 246, 0.32); }
.badge.amber { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border-color: rgba(245, 158, 11, 0.30); }
.badge.gray { background: rgba(147, 160, 188, 0.12); color: var(--muted); border-color: rgba(147, 160, 188, 0.25); }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(4, 6, 16, 0.60);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--glass-bg-solid);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.modal h2 { margin-bottom: 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 430px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.auth-tabs .tab {
  flex: 1; text-align: center; padding: 9px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--muted); border: 1px solid var(--glass-border); font-size: 14px; font-weight: 500;
  background: var(--glass-bg);
  transition: background 0.15s, color 0.15s;
}
.auth-tabs .tab:hover { background: var(--glass-bg-hover); color: var(--text); }
.auth-tabs .tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.30), rgba(139, 92, 246, 0.30));
  border-color: rgba(139, 92, 246, 0.5);
}

/* misc */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mb { margin-bottom: 14px; }
.mt { margin-top: 14px; }
.error-msg { color: var(--alert); font-size: 13.5px; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--glass-bg-solid);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); border-left: 3px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 13px 18px; font-size: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.2s ease;
}
.toast.err { border-left-color: var(--alert); }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.sig-canvas { background: rgba(255, 255, 255, 0.93); border-radius: var(--radius-sm); width: 100%; height: 120px; touch-action: none; cursor: crosshair; }
.scan-box { font-size: 22px; padding: 16px; text-align: center; letter-spacing: 1px; }
.scan-result { text-align: center; padding: 18px 0; }
.scan-result .big { font-size: 26px; font-weight: 700; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: end; }
.filters label.field { margin-bottom: 0; min-width: 150px; }

/* mobile top bar + hamburger drawer */
.topbar { display: none; }
.hamburger {
  background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text);
  font-size: 20px; line-height: 1; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer;
}
.side-backdrop {
  display: none; position: fixed; inset: 0; z-index: 140;
  background: rgba(4, 6, 16, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.side-backdrop.show { display: block; }

/* mobile modals: stack form rows, tighten padding, keep tables scrollable */
@media (max-width: 640px) {
  .modal-back { padding: 10px; align-items: flex-end; }
  .modal { padding: 18px 14px; max-height: 94vh; border-radius: 14px; }
  .modal .form-row { flex-direction: column; gap: 0; }
  .modal .form-row > * { width: 100%; }
  .modal .modal-actions { flex-wrap: wrap; }
  .modal h2 { font-size: 17px; }
  .modal table input { min-width: 70px; }
  /* Header controls get their own lines instead of being crushed between the
     filter chip and the action button. The inline width="auto"/"180px" set on the
     selects and the search box has to be overridden, hence !important. */
  .page-head .actions { width: 100%; }
  .page-head .actions > * { flex: 1 1 100%; min-width: 0; }
  .page-head .actions select,
  .page-head .actions input {
    width: auto !important;
    min-width: 0;
    box-sizing: border-box;
  }
  .page-head .actions select { flex: 1 1 calc(50% - 4px); }   /* two filters share a line */
  .page-head .actions input { flex: 1 1 100%; }
  .page-head .actions .btn { justify-content: center; }
}

@media (max-width: 860px) {
  #app { flex-direction: column; }
  .topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 130;
    padding: 10px 14px;
    background: rgba(5, 8, 20, 0.75);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
  }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 262px;
    transform: translateX(-105%); transition: transform 0.25s ease;
    z-index: 150; background: rgba(5, 8, 20, 0.92);
  }
  .sidebar.open { transform: none; box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5); }
  .main { padding: 18px 14px; }
}
@media print {
  .sidebar, .page-head .actions, .filters, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
  .card { background: #fff; border-color: #ccc; box-shadow: none; }
  .card::after { display: none; }
  th, td { color: #000; }
}

/* lots modal rows — stacked layout, phone-safe */
.lot-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.lot-info { flex: 1; min-width: 0; }
.lot-qty { width: 72px; flex-shrink: 0; text-align: center; }

/* mobile inventory cards — collapsed rows, tap to expand */
.inv-cards { display: none; }
.inv-card { padding: 14px 16px; }
.inv-card-head { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.inv-card-name { flex: 1; min-width: 0; }
.inv-card-stock { font-size: 22px; font-weight: 700; flex-shrink: 0; }
.inv-card-stock.low { color: var(--alert); }
.inv-card-min { font-size: 13px; font-weight: 500; color: var(--muted); }
.inv-card-body { display: none; padding-top: 12px; margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.inv-card.open .inv-card-body { display: block; }
@media (max-width: 860px) {
  .inv-cards { display: flex; flex-direction: column; gap: 10px; }
  .inv-table-card { display: none; }
}

/* kit checklists + seal display */
.check-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04); transition: border-color 0.15s, background 0.15s;
}
.check-item input[type="checkbox"] { width: 22px; height: 22px; flex-shrink: 0; }
.check-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.check-item.checked { border-color: rgba(52, 211, 153, 0.55); background: rgba(52, 211, 153, 0.08); }
.seal-check {
  text-align: center; padding: 14px; border: 1px dashed rgba(245, 158, 11, 0.5);
  border-radius: var(--radius-sm); background: rgba(245, 158, 11, 0.06);
}
.seal-no { font-size: 24px; font-weight: 700; letter-spacing: 2px; }
.kit-mine { border-color: rgba(59, 130, 246, 0.55); box-shadow: 0 0 22px rgba(59, 130, 246, 0.18); }

.sig-view { cursor: pointer; }
.sig-view:hover { filter: brightness(1.3); }

/* svg icon sizing */
.ico svg { width: 17px; height: 17px; display: block; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.badge svg { width: 11px; height: 11px; vertical-align: -1.5px; }
.badge.sig-view { display: inline-flex; align-items: center; gap: 4px; }

/* mobile: date filters stack in a 2-col grid instead of mashing */
@media (max-width: 640px) {
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
  .filters label.field { min-width: 0; width: 100%; }
  .filters select, .filters input { width: 100%; min-width: 0; }
  .filters .btn { grid-column: 1 / -1; justify-content: center; }
}
input[type="date"] { min-width: 0; -webkit-appearance: none; appearance: none; }

/* swipe hint above horizontally scrollable tables (mobile) */
.scroll-hint {
  text-align: center; font-size: 11.5px; color: var(--muted);
  letter-spacing: 0.5px; padding: 2px 0 8px;
  transition: opacity 0.35s;
}
.scroll-hint.fade { opacity: 0; }
.scroll-hint .sh-l, .scroll-hint .sh-r {
  display: inline-block; color: var(--brand-b); font-weight: 700;
  animation: shNudge 1.3s ease-in-out infinite;
}
.scroll-hint .sh-l { animation-name: shNudgeL; }
@keyframes shNudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
@keyframes shNudgeL { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-4px); } }

/* portrait runway backdrop on phones — heavy bottom fade doubles as the
   content ground and hides the pavement threshold area */
@media (max-width: 640px) {
  body::before {
    background:
      linear-gradient(115deg, rgba(59, 130, 246, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%),
      linear-gradient(180deg, rgba(7, 10, 24, 0.44) 0%, rgba(7, 10, 24, 0.20) 40%,
        rgba(7, 10, 24, 0.42) 64%, rgba(7, 10, 24, 0.94) 80%, rgba(7, 10, 24, 0.98) 100%),
      url('/bg-medevac-mobile.jpg') center top / cover no-repeat,
      var(--bg-ink);
  }
}

/* shopping list quantity stepper */
.qty-step { display: inline-flex; align-items: center; gap: 8px; }
.qty-step .btn { min-width: 32px; justify-content: center; padding: 4px 8px; }
.qty-val { min-width: 26px; text-align: center; font-weight: 600; }


/* crisp icon rendering */
.ico svg, .btn svg, .badge svg { shape-rendering: geometricPrecision; }


/* brand tile now renders the app icon */
.brand img.logo { object-fit: contain; background: none; box-shadow: none; padding: 0; }

/* lot row quantity stepper */
.lot-row .qty-step { flex-shrink: 0; gap: 6px; }
.lot-row .lot-qty { width: 64px; }

/* Save reserves its slot so +/- never shift under a repeat tap */
.lot-row .lot-save {
  visibility: hidden;
  flex-shrink: 0;
  min-width: 58px;
  justify-content: center;
}
.lot-row .lot-save.on { visibility: visible; }

/* Quick Scan: search-by-name results */
.pick-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }
.pick-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; padding: 10px 12px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px; color: var(--text); font: inherit; cursor: pointer;
}
.pick-row:hover { background: rgba(255,255,255,.08); border-color: rgba(139,92,246,.5); }
.pick-row:active { transform: translateY(1px); }

/* Lots modal: inline edit pane for a saved lot */
.lot-edit {
  margin: -4px 0 12px; padding: 12px 14px;
  background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px;
}
.lot-edit .field { margin-bottom: 8px; }
@media (max-width: 640px) {
  .lot-edit .form-row { display: block; }
}

/* destructive ghost button (kit delete) — reads as dangerous without shouting */
.btn.ghost.danger {
  background: transparent;
  box-shadow: none;
  color: #F87171;
  border-color: rgba(248, 113, 113, .45);
}
.btn.ghost.danger:hover {
  background: rgba(248, 113, 113, .12);
  border-color: rgba(248, 113, 113, .75);
}

/* shopping list: supplier group heading rows */
.grp-row td {
  padding-top: 16px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.grp-row:first-child td { padding-top: 4px; }

/* ---------- Flights tab ---------- */
.fl-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.fl-mapcard { padding: 0; overflow: hidden; position: relative; }
#flMap { height: calc(100vh - 190px); min-height: 420px; background: #0b0f1e; }
.fl-status { position: absolute; left: 0; right: 0; bottom: 0; z-index: 500; padding: 8px 12px;
  background: rgba(5, 8, 20, .72); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--glass-border); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.fl-status .fl-attr { margin-left: auto; opacity: .8; font-size: 10px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fl-attr-btn { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--glass-border); background: rgba(255,255,255,.06); color: var(--muted); font-size: 11px; line-height: 1; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.fl-attr-full { display: none; white-space: normal; }
.fl-status.credits .fl-attr-full { display: inline; }
.fl-status.credits .fl-attr-short { display: none; }
.fl-stale { color: var(--warn); }
.fl-list { max-height: calc(100vh - 190px); overflow-y: auto; padding: 10px; }
.fl-handle { display: none; }
.fl-sheet-close, .fl-sheet-title { display: none; }
.fl-sec { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 6px 6px; }
.fl-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; margin-bottom: 6px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px; color: var(--text); font: inherit; cursor: pointer; }
.fl-row:hover { background: rgba(255,255,255,.08); border-color: rgba(139,92,246,.5); }
.fl-row.aei { border-color: rgba(59,130,246,.45); background: linear-gradient(135deg, rgba(59,130,246,.14), rgba(139,92,246,.14)); }
.fl-only-mobile { display: none; }
#flFollow.on { border-color: rgba(139,92,246,.7); background: rgba(139,92,246,.18); }

/* markers */
.fm { display: flex; flex-direction: column; align-items: center; color: #C4B5FD; }
.fm-aei { color: #fff; filter: drop-shadow(0 0 8px rgba(139,92,246,.9)) drop-shadow(0 0 2px rgba(0,0,0,.9)); }
.fm-ground { opacity: .6; }
.fm-ghost { opacity: .45; }
.fm-ghost svg { filter: grayscale(.4); }
.fl-tails { display: inline-flex; gap: 6px; }
.fl-tail { position: relative; padding-left: 20px !important; }
.fl-tail::before { content: ''; position: absolute; left: 9px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #64748B; }
.fl-tail.fl-tail-air::before { background: #22C55E; box-shadow: 0 0 6px #22C55E; }
.fm-sel { filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 10px rgba(245,158,11,.95)); z-index: 2000 !important; opacity: 1 !important; }
.fm-sel svg { position: relative; z-index: 1; }
.fm-ring { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 2px solid #F59E0B; pointer-events: none;
  animation: fm-pulse 1.6s ease-out infinite; }
@keyframes fm-pulse { 0% { transform: scale(.45); opacity: .95; } 100% { transform: scale(1.35); opacity: 0; } }
.fl-detail { display: none; padding: 12px 14px; margin: 0 0 6px; border-bottom: 1px solid var(--glass-border); position: relative; }
.fl-detail.open { display: block; }
.fl-detail-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.fl-detail-close:hover { color: var(--text); }
.fl-wxtime { color: var(--muted); }
.fl-sec-sm { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 8px 0 4px; }
.fl-faa { margin: 8px 0; }
.fl-faa > summary { cursor: pointer; list-style: none; }
.fl-faa > summary::-webkit-details-marker { display: none; }
.fl-faa > summary::after { content: ' ▾'; }
.fl-faa[open] > summary::after { content: ' ▴'; }
.fl-faa-owner { padding: 8px 10px; margin-bottom: 8px; border-radius: 10px; background: rgba(147,197,253,.08); border: 1px solid rgba(147,197,253,.2); font-size: 13px; }
.fl-faa .fcard-grid { margin-bottom: 8px; }
.fl-legs { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.fl-leg-row { display: flex; flex-direction: column; font-size: 13px; padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.04); position: relative; }
.fl-leg-row.clickable { cursor: pointer; }
.fl-leg-row.clickable:hover, .fl-leg-row.clickable:focus { background: rgba(255,255,255,.08); outline: none; }
.fl-leg-row.picked { box-shadow: inset 3px 0 0 #F59E0B; background: rgba(245,158,11,.1); }
.fl-leg-row.loading::after { content: ''; position: absolute; right: 8px; top: 8px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(147,197,253,.35); border-top-color: #93C5FD; animation: fl-rot .9s linear infinite; }
.fl-aptname { display: inline-block; margin-left: 4px; font-size: 11px; font-weight: 500; color: var(--muted); vertical-align: baseline; }
.fl-arrow { color: var(--muted); font-weight: 400; margin: 0 2px; }
.fl-spin { animation: fl-rot .9s linear infinite; color: #93C5FD; flex: 0 0 auto; }
@keyframes fl-rot { to { transform: rotate(360deg); } }
.fl-spinline { display: flex; align-items: center; gap: 8px; }
.fl-search input.busy { background-image: none; box-shadow: 0 0 0 1px rgba(147,197,253,.5) inset; }
.fl-delay { color: #FCD34D; font-weight: 600; }
.fl-statusline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.fl-warn { padding: 8px 10px; border-radius: 10px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.35); color: #FCD34D; }
.fl-cruise { margin: 6px 0 8px; padding: 8px 10px; border-radius: 10px; background: rgba(147,197,253,.08); border: 1px solid rgba(147,197,253,.2); }
.fl-itin { list-style: none; margin: 0 0 10px; padding: 0; position: relative; }
.fl-itin li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 6px; margin: 0 -6px; border-radius: 8px; position: relative; cursor: pointer; }
.fl-itin li:hover, .fl-itin li:focus { background: rgba(147,197,253,.08); outline: none; }
.fl-itin li.picked .fl-itin-n { box-shadow: 0 0 0 2px #F59E0B; }
.fl-itin li + li::before { content: ''; position: absolute; left: 10px; top: -8px; height: 12px; border-left: 2px solid rgba(147,197,253,.3); }
.fl-itin-n { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font: 700 11px/1 Inter, system-ui, sans-serif; color: #93C5FD; border: 2px solid #93C5FD; background: rgba(9,12,28,.9); }
.fl-itin li.done .fl-itin-n { opacity: .45; }
.fl-itin li.done .fl-itin-txt { opacity: .6; }
.fl-itin li.now .fl-itin-n { background: #93C5FD; color: #0b1020; box-shadow: 0 0 8px rgba(147,197,253,.8); }
.fl-itin-txt { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
/* numbered cruise stops: Leaflet forces display:block on the marker box, so the
   circle and centring live on the inner span */
.fl-stop { background: none; border: 0; }
.fl-stop span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #0b1020; background: #93C5FD; border: 2px solid #fff; font: 800 12px/1 Inter, system-ui, sans-serif; box-shadow: 0 0 0 2px rgba(9,12,28,.9), 0 2px 6px rgba(0,0,0,.7); }
.fl-stop.now span { background: #3B82F6; color: #fff; box-shadow: 0 0 0 2px rgba(9,12,28,.9), 0 0 12px rgba(59,130,246,1); }
.fl-stop.done span { background: rgba(147,197,253,.55); color: rgba(11,16,32,.85); }
.fm-ship { color: #93C5FD; }
.fm-moored { opacity: .55; }
.fm-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); width: max-content; padding: 2px 8px; border-radius: 999px;
  font: 600 11px/1.2 Inter, system-ui, sans-serif; white-space: nowrap; color: #fff; background: linear-gradient(90deg, #3B82F6, #8B5CF6); box-shadow: 0 2px 8px rgba(0,0,0,.5); }

/* leaflet on dark glass */
.leaflet-container { font: inherit; }
.leaflet-control-zoom a { background: rgba(5,8,20,.85) !important; color: var(--text) !important; border-color: var(--glass-border) !important; }
.fpop .leaflet-popup-content-wrapper { background: rgba(9, 12, 28, .92); color: var(--text); border: 1px solid var(--glass-border);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.6); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.fpop .leaflet-popup-tip { background: rgba(9, 12, 28, .92); }
.fpop .leaflet-popup-content { margin: 12px 14px; overflow-wrap: anywhere; }
.fpop .leaflet-popup-close-button { color: var(--muted) !important; }
.fcard-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 15px; }
.fcard-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 13px; }
.fcard-grid b { min-width: 0; overflow-wrap: anywhere; }
.fcard-grid span { color: var(--muted); }
.badge.purple { background: rgba(139,92,246,.18); color: #C4B5FD; border-color: rgba(139,92,246,.4); }
.badge.sky { background: rgba(147,197,253,.16); color: #93C5FD; border-color: rgba(147,197,253,.4); }

@media (max-width: 860px) {
  .fl-wrap { grid-template-columns: 1fr; }
  #flMap { height: calc(100vh - 210px); min-height: 360px; }
  .fl-only-mobile { display: inline-flex; }
  .fl-list { position: fixed; left: 0; right: 0; bottom: 0; z-index: 140; max-height: 70vh; border-radius: 16px 16px 0 0;
    transform: translateY(calc(100% - 44px)); transition: transform .25s ease; background: rgba(5,8,20,.96); }
  .fl-list.open { transform: none; }
  .fl-list.half { transform: translateY(max(0px, calc(100% - 42vh))); }
  .fl-list.half #flList { display: none; }
  .fl-sheet-bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 6px 4px 6px 10px; margin: -10px -10px 6px; cursor: pointer;
    border-bottom: 1px solid var(--glass-border); position: relative; }
  .fl-handle { display: block; position: absolute; left: 50%; top: 5px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: rgba(255,255,255,.35); }
  .fl-sheet-title { display: inline; padding-top: 8px; }
  .fl-sheet-close { display: inline-flex; margin-top: 6px; }
  /* toolbar: compact buttons in a wrapping row, search on its own line */
  .page-head .fl-actions > * { flex: 0 0 auto; }
  .page-head .fl-actions .fl-search { flex: 1 1 100%; width: 100%; min-width: 100%; }
  .page-head .fl-actions .fl-search input { width: 100%; }
  .page-head .fl-actions .fl-tails { display: inline-flex; }
  .page-head .fl-actions .btn { padding: 6px 12px; }
}
.fl-sheet-bar { display: none; }
@media (max-width: 860px) { .fl-sheet-bar { display: flex; } }
.fl-leg { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 6px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.07); border-radius: 10px; }
/* flights: legend + radar toggle */
.fl-legend { background: rgba(5,8,20,.82); border: 1px solid var(--glass-border); border-radius: 10px; padding: 8px 10px; color: var(--text);
  font: 11px/1.7 Inter, system-ui, sans-serif; backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); margin: 10px 10px 0 0 !important; }
.fl-legend .lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -3px; margin-right: 7px; }
.fl-legend .lg-aei { background: linear-gradient(135deg,#3B82F6,#8B5CF6); box-shadow: 0 0 6px rgba(139,92,246,.9); }
.fl-legend .lg-jet { background: #C4B5FD; }
.fl-legend .lg-heli { background: #C4B5FD; border-radius: 50%; position: relative; }
.fl-legend .lg-heli::before, .fl-legend .lg-heli::after { content: ''; position: absolute; left: -2px; right: -2px; top: 6px; height: 2px; background: #0b1020; }
.fl-legend .lg-heli::after { transform: rotate(90deg); }
.fl-legend .lg-ground { background: rgba(196,181,253,.35); }
.fl-legend .lg-ship { background: rgba(147,197,253,.28); border: 2px solid #93C5FD; border-radius: 4px 4px 7px 7px; }
.fl-legend .lg-route { width: 18px; height: 3px; border-radius: 2px; background: #C4B5FD; vertical-align: 2px; }
.fl-legend .lg-plan { width: 18px; height: 0; border-top: 2px dashed #C4B5FD; vertical-align: 2px; }
/* lit state for every Flights toolbar toggle (Radar, Planes, Ships, tail follow) */
.fl-actions .btn.on, #flWx.on { border-color: rgba(96,165,250,.8); background: rgba(59,130,246,.2); color: #fff; }
.fl-actions .btn { transition: background .15s, border-color .15s; }
.fl-legend { position: relative; padding-right: 26px; }
.fl-legend-btn { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 6px; border: 1px solid var(--glass-border); background: rgba(255,255,255,.06);
  color: var(--text); font: 700 13px/1 Inter, system-ui, sans-serif; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.fl-legend-btn:hover { background: rgba(255,255,255,.14); }
.fl-legend.collapsed { padding: 0; width: 26px; height: 26px; }
.fl-legend.collapsed .fl-legend-btn { top: 3px; right: 3px; }
@media (max-width: 860px) { .fl-legend { display: none; } }
.fl-search { position: relative; }
.fl-listen { position: relative; }
.fl-listen-menu { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 1200; width: 340px; max-width: calc(100vw - 32px); padding: 6px;
  background: rgba(9,12,28,.96); border: 1px solid var(--glass-border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.6); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.fl-listen-menu.open { display: block; }
.fl-listen-note { padding: 6px 10px 8px; }
.fl-listen-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.fl-listen-row:hover { background: rgba(255,255,255,.06); }
.fl-listen-txt { display: flex; flex-direction: column; min-width: 0; }
.fl-listen-go { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: #fff; padding: 6px 10px; border-radius: 999px; background: linear-gradient(90deg, #3B82F6, #8B5CF6); white-space: nowrap; }
.fl-listen-row:active .fl-listen-go { filter: brightness(1.15); }
.fl-atc-link { color: #93C5FD; text-decoration: none; }
.fl-atc-link:hover { text-decoration: underline; }
@media (max-width: 860px) { .fl-listen-menu { right: auto; left: 0; } }
.fl-search input { width: 220px; padding: 7px 10px; font-size: 13px; }
.fl-search-res { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 1200; min-width: 300px; max-width: 360px; max-height: 340px; overflow: auto;
  background: rgba(9,12,28,.96); border: 1px solid var(--glass-border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.6); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); padding: 6px; }
.fl-search-res.open { display: block; }
.fl-search-hit { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; background: none; border: 0; border-radius: 8px; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.fl-search-hit:hover, .fl-search-hit:focus { background: rgba(255,255,255,.06); outline: none; }
.fl-search-txt { display: flex; flex-direction: column; min-width: 0; }
.fl-search-txt strong, .fl-search-txt .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) { .fl-search, .fl-search input { width: 100%; } .fl-search-res { max-width: none; right: 0; } }

/* ---------------- cabinet sheet ---------------- */
/* shelf picker */
.cab-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 320px; overflow: auto; }
.cab-opt { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.03); cursor: pointer; }
.cab-opt:hover { background: rgba(255,255,255,.07); }
.cab-opt input { flex: none; }

/* the sheet itself — white paper, on screen and on the page */
#cabSheetOut { position: fixed; inset: 0; z-index: 900; overflow: auto; background: #111522; padding: 0 0 60px; }
.cab-bar { position: sticky; top: 0; z-index: 2; display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 20px; background: rgba(12,16,28,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.1); }
.cab-paper, .cab-paper strong, .cab-paper b { color: #11151f; }
.cab-paper { background: #fff; max-width: 8.5in; margin: 22px auto; padding: 0.5in 0.55in;
  box-shadow: 0 10px 40px rgba(0,0,0,.45); font-size: 11.5px; line-height: 1.4; }
.cab-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
  border-bottom: 2px solid #11151f; padding-bottom: 10px; margin-bottom: 16px; }
.cab-head h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; color: #11151f; }
.cab-org { font-size: 12px; color: #444c5e; margin-top: 2px; }
.cab-meta { text-align: right; font-size: 10.5px; color: #333a49; }
.cab-meta div { margin-bottom: 2px; }
.cab-meta span { color: #7a8396; display: inline-block; min-width: 54px; text-align: right; margin-right: 6px; }
.cab-block { margin-bottom: 18px; break-inside: auto; }
.cab-block h2 { font-size: 13px; margin: 0 0 5px; padding: 4px 8px; background: #eef1f6; color: #11151f;
  border-left: 3px solid #3B82F6; display: flex; justify-content: space-between; align-items: baseline; }
.cab-sub { font-size: 10px; font-weight: 400; color: #5b6372; }
.cab-none { font-size: 10.5px; color: #7a8396; font-style: italic; margin: 2px 0 0 10px; }
.cab-table { width: 100%; border-collapse: collapse; }
.cab-table th { text-align: left; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em;
  color: #5b6372; border-bottom: 1px solid #c9cfdb; padding: 4px 6px; font-weight: 600; }
.cab-table td { padding: 4px 6px; border-bottom: 1px solid #e6e9f0; color: #11151f; vertical-align: top; }
.cab-table tr.cab-cont td { border-top: 0; }
.cab-item strong { display: block; font-weight: 600; color: #11151f; }   /* paper, not the dark theme's text colour */
.cab-sku { font-size: 9.5px; color: #7a8396; }
.cab-num { text-align: right; width: 48px; }
.cab-count { width: 68px; border-left: 1px solid #e6e9f0; }
.cab-table td.cab-count { border-bottom: 1px solid #c9cfdb; }
.x-soon { color: #8a5a00; font-weight: 600; }
.x-exp { color: #a21f1f; font-weight: 700; }
.cab-flag { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .03em;
  padding: 0 4px; margin-left: 4px; border: 1px solid currentColor; border-radius: 3px; }
.cab-foot { display: flex; gap: 28px; margin-top: 26px; padding-top: 12px; border-top: 1px solid #c9cfdb; }
.cab-sign { flex: 1; font-size: 10px; color: #5b6372; }
.cab-sign i { display: block; border-bottom: 1px solid #11151f; height: 20px; }

@media print {
  body.cab-open > #root { display: none !important; }
  #cabSheetOut { position: static; background: #fff; padding: 0; overflow: visible; }
  .cab-bar { display: none !important; }
  .cab-paper { box-shadow: none; margin: 0; max-width: none; padding: 0; }
  .cab-block { break-inside: avoid; }
  .cab-table thead { display: table-header-group; }      /* repeat headers on every page */
  .cab-table tr { break-inside: avoid; }
  @page { margin: 0.5in; }
}

/* manage shelves (Settings) */
.shelf-row { display: flex; align-items: center; gap: 8px; padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,.07); }
.shelf-row .shelf-name { flex: 1; min-width: 0; }
.shelf-n { flex: none; width: 62px; text-align: right; }
.shelf-row .btn { flex: none; }

/* ---------------- patient care reports: the list (inside the app) ---------------- */
.pcr-banner { margin: 0 0 10px; padding: 7px 12px; border-radius: 6px; font-size: 12.5px;
  background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .35); color: #FDE68A; }
.pcr-net { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.pcr-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pcr-dot.on { background: #34D399; } .pcr-dot.wait { background: #FBBF24; } .pcr-dot.off { background: #94A3B8; }
/* the list scrolls sideways inside its card rather than widening the page, and drops the
   least useful columns on a phone */
.pcr-listcard { min-width: 0; overflow: hidden; }
.pcr-listcard .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 700px) {
  #pcrTable th:nth-child(4), #pcrTable td:nth-child(4), #pcrTable th:nth-child(5), #pcrTable td:nth-child(5),
  #pcrTable th:nth-child(9), #pcrTable td:nth-child(9) { display: none; }
}
.pcr-row { cursor: pointer; }
.pcr-voidwhy { white-space: normal; min-width: 220px; max-width: 420px; overflow-wrap: anywhere; }
.pcr-row:hover td { background: rgba(255, 255, 255, .04); }
.pcr-pct { position: relative; display: inline-block; width: 62px; height: 17px; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, .09); vertical-align: middle; }
.pcr-pct i { position: absolute; left: 0; top: 0; bottom: 0; background: #b45309; }
.pcr-pct.full i { background: #15803d; }
.pcr-pct b { position: relative; display: block; text-align: center; font-size: 11px; line-height: 17px; color: #fff; }
.rep-logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.rep-logo { height: 40px; background: #fff; border-radius: 6px; padding: 3px 8px; }
.pcr-sigpad { background: #fff; border-radius: 4px; margin: 6px 0 4px; border: 1px solid #c5ccd6; }
.pcr-sigpad canvas { display: block; width: 100%; aspect-ratio: 3 / 1; touch-action: none; cursor: crosshair;
  background: linear-gradient(to bottom, transparent 78%, #c9cfdb 78%, #c9cfdb calc(78% + 1px), transparent calc(78% + 1px)); }

/* ---------------- patient care reports: the charting workspace ----------------
   A chart opens full screen in its own flat, dense skin: no glass, no gradients, square
   corners, label-left fields, pick buttons, grids. Day is the default; Night is for the cabin. */
.pw { --bg: #ebe8f5; --panel: #fff; --head: #f1f2f9; --sub: #f7f8fc; --line: #c4c9d9; --line2: #e0e3ee; --text: #1b2033; --dim: #5a6178;
  --in: #fff; --bar: #1c2146; --bar2: #33287a; --rail: #e2dff1; --blue: #3f5fe0; --blue-d: #2f48b8; --violet: #6f4fe0; --green: #2a8540; --red: #c5282c; --amber: #a86200;
  --sel: #e7ebff; --chip: #eef0f8; --shadow: 0 8px 22px rgba(20, 30, 45, .22);
  position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 13px/1.35 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
.pw[data-theme="night"] { --bg: #12111b; --panel: #171c22; --head: #1e252d; --sub: #141920; --line: #313a45; --line2: #242b34; --text: #e2e7ed; --dim: #8f9cab;
  --in: #10151a; --bar: #0b0d1c; --bar2: #1c1640; --rail: #171523; --blue: #5273ea; --blue-d: #3f5cc9; --violet: #8366ee; --green: #2f9247; --red: #d64045; --amber: #d08a1c;
  --sel: #1a2a3f; --chip: #222a33; --shadow: 0 8px 22px rgba(0, 0, 0, .6); }
body.pw-open { overflow: hidden; }
.pw button { font-family: inherit; }
.pw svg { flex: none; }

/* toolbar */
.pw-bar { display: flex; align-items: stretch; gap: 12px; padding: 5px 8px; background: linear-gradient(90deg, var(--bar) 0%, var(--bar) 45%, var(--bar2) 100%); color: #fff; flex: none; }
.pw-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.pw-tb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 56px; height: 40px; padding: 2px 8px;
  border: 0; border-radius: 6px; background: #3b4859; color: #fff; font-size: 10.5px; font-weight: 600; line-height: 1.15; cursor: pointer; white-space: nowrap; }
.pw-tb:hover { filter: brightness(1.12); }
.pw-tb:disabled { opacity: .6; cursor: default; }
.pw-tb { background: linear-gradient(180deg, #4d5b70 0%, #303b4a 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(0, 0, 0, .3); text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.pw-tb:active { box-shadow: inset 0 2px 3px rgba(0, 0, 0, .3); }
.pw-tb.save { background: linear-gradient(180deg, #3fae5b 0%, #227636 100%); } .pw-tb.blue { background: linear-gradient(180deg, #5878f0 0%, #3148b9 100%); }
.pw-tb.gray { background: linear-gradient(180deg, #73819a 0%, #485469 100%); } .pw-tb.close { background: linear-gradient(180deg, #e2494d 0%, #ab1f23 100%); }
.pw-tb.rsi { background: linear-gradient(180deg, #ea9a2c 0%, #b9620b 100%); }
.pw-flag { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: #1a232e; background: #f2b33d; padding: 2px 6px; border-radius: 6px; margin-right: 4px; }
.pw-pt { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); column-gap: 14px; align-items: center; padding: 0 4px; border-left: 1px solid #3b4859; padding-left: 12px; }
.pw-pt-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-pt-meta { grid-column: 1; font-size: 11.5px; color: #b6c2d0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-pt-run { margin-left: 10px; color: #8fa0b3; }
.pw-pt-al { grid-column: 2; grid-row: 1 / span 2; justify-self: start; font-size: 12px; padding: 3px 8px; border-radius: 6px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-pt-al b { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; margin-right: 6px; opacity: .85; }
.pw-pt-al.has { background: #c5282c; color: #fff; } .pw-pt-al.none { background: #2a8540; color: #fff; } .pw-pt-al.unk { background: #3b4859; color: #c9d3de; }

/* rail */
.pw-body { flex: 1; display: flex; min-height: 0; }
.pw-rail { width: 212px; flex: none; background: var(--rail); border-right: 1px solid var(--line); overflow: auto; }
.pw-find { display: flex; align-items: center; gap: 6px; margin: 8px; padding: 0 7px; height: 28px; background: var(--in); border: 1px solid var(--line); border-radius: 6px; color: var(--dim); }
.pw-find input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.pw-findres { margin: 0 8px; }
.pw-findres button { display: block; width: 100%; text-align: left; padding: 5px 7px; border: 1px solid var(--line); border-top: 0; background: var(--panel); color: var(--text); cursor: pointer; font-size: 12px; }
.pw-findres button:first-child { border-top: 1px solid var(--line); }
.pw-findres button:hover { background: var(--sel); }
.pw-findres small { display: block; color: var(--dim); font-size: 10.5px; }
.pw-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 9px 9px 8px; border: 0; border-bottom: 1px solid var(--line);
  border-left: 5px solid var(--line); background: transparent; color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.pw-nav:first-child { border-top: 1px solid var(--line); }
.pw-nav.need { border-left-color: var(--red); animation: pwneed 7s ease-in-out infinite; } .pw-nav.ok { border-left-color: var(--green); box-shadow: inset 8px 0 10px -8px rgba(42, 160, 80, .5); }
@keyframes pwneed { 0%, 8%, 16%, 100% { box-shadow: inset 6px 0 8px -7px rgba(225, 45, 50, .32); } 4%, 12% { box-shadow: inset 12px 0 12px -8px rgba(235, 50, 55, .68); } }
@keyframes pwneedb { 0%, 8%, 16%, 100% { box-shadow: inset 0 -6px 8px -7px rgba(225, 45, 50, .32); } 4%, 12% { box-shadow: inset 0 -12px 12px -8px rgba(235, 50, 55, .68); } }
@keyframes pwbadge { 0%, 8%, 16%, 100% { box-shadow: 0 0 0 0 rgba(235, 50, 55, 0); } 4%, 12% { box-shadow: 0 0 6px 1px rgba(235, 50, 55, .5); } }
@media (prefers-reduced-motion: reduce) { .pw-nav.need { animation: none !important; box-shadow: inset 8px 0 10px -8px rgba(225, 45, 50, .5); } .pw-nav-n { animation: none !important; } }
.pw-nav:hover { background: var(--sel); }
.pw-nav.on { background: linear-gradient(90deg, var(--blue) 0%, var(--violet) 100%); color: #fff; font-weight: 600; }
.pw-nav-l i { font-style: normal; font-size: 11px; opacity: .75; margin-left: 3px; }
.pw-nav-n { min-width: 19px; height: 18px; padding: 0 4px; display: grid; place-items: center; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; }
.pw-nav-ok { color: var(--green); display: grid; filter: drop-shadow(0 0 2px rgba(42, 160, 80, .5)); } .pw-nav.on .pw-nav-ok { color: #fff; filter: drop-shadow(0 0 2px rgba(255, 255, 255, .5)); }
.pw-nav-n { animation: pwbadge 7s ease-in-out infinite; }

/* main + panels */
.pw-main { flex: 1; min-width: 0; overflow: auto; padding: 10px 12px 18px; }
.pw-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; margin-bottom: 10px; }
.pw-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; padding: 4px 8px 4px 10px; background: var(--head); border-bottom: 1px solid var(--line); }
.pw-panel > header h2 { margin: 0; font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: 0; }
.pw-ptools { display: flex; align-items: center; gap: 6px; }
.pw-pbody { padding: 10px 12px; }
.pw-panel.flush > .pw-pbody { padding: 0; }
.pw-panel.editor { border-color: var(--blue); }
.pw-panel.editor > header { background: var(--sel); }
.pw-note { font-size: 11px; color: var(--dim); }
.pw-empty { padding: 14px; color: var(--dim); font-size: 12.5px; }
.pw-none { color: var(--dim); font-size: 12px; font-style: italic; }
.pw-sub { margin: 12px 0 6px; font-size: 12px; font-weight: 700; }
.pw-sub span { font-weight: 400; color: var(--dim); margin-left: 6px; }

/* fields: label on the left, control on the right */
.pw-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(370px, 1fr)); gap: 6px 26px; }
.pw-row { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px; align-items: start; min-width: 0; }
.pw-row > label { padding-top: 6px; text-align: right; font-size: 12px; color: var(--dim); }
.pw-row.wide { grid-column: 1 / -1; }
.pw-row.flash > .pw-ctl, .pw-sys.flash { animation: pwflash 1.6s ease-out; }
@keyframes pwflash { 0%, 40% { box-shadow: 0 0 0 3px #f2b33d; } 100% { box-shadow: 0 0 0 3px transparent; } }
.pw-ctl { min-width: 0; }
.pw-static { padding-top: 6px; }
.pw-in { width: 100%; height: 28px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--in); color: var(--text); font: inherit; box-shadow: none; }
textarea.pw-in { height: auto; min-height: 52px; padding: 5px 7px; resize: vertical; line-height: 1.4; }
select.pw-in { padding-right: 4px; }
.pw-in.num { max-width: 130px; }
.pw-in:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.pw-in:disabled { background: var(--sub); color: var(--text); opacity: 1; -webkit-text-fill-color: var(--text); }
.pw-up { text-transform: uppercase; }
.pw[data-theme="night"] .pw-in { color-scheme: dark; }
.pw-dt, .pw-air, .pw-inline, .pw-sigline { display: flex; gap: 6px; align-items: center; }
.pw-dt .pw-in { max-width: 210px; }
.pw-air .pw-in { max-width: 130px; flex: none; }
.pw-hint { font-size: 12px; color: var(--dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-inline { align-items: flex-start; margin-top: 8px; }
.pw-inline textarea { flex: 1; }

/* buttons */
.pw-btn { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--head); color: var(--text);
  font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.pw-btn:hover { background: var(--sel); }
.pw-btn.primary { background: linear-gradient(180deg, var(--blue) 0%, var(--blue-d) 100%); border-color: var(--blue-d); color: #fff; }
.pw-btn.primary:hover { background: var(--blue-d); }
.pw-btn.save { background: var(--green); border-color: var(--green); color: #fff; }
.pw-btn.danger { color: var(--red); }
.pw-btn:disabled { opacity: .55; cursor: default; }
.pw-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 2px 0 6px; }
.pw-foot .pw-btn { height: 30px; padding: 0 14px; }

/* pick buttons: a handful of answers shown, not hidden in a dropdown */
.pw-seg { display: inline-flex; flex-wrap: wrap; gap: 0; }
.pw-seg button { height: 28px; padding: 0 11px; margin: 0 -1px -1px 0; border: 1px solid var(--line); background: var(--in); color: var(--text); font-size: 12px; cursor: pointer; }
.pw-seg button:first-child { border-radius: 6px 0 0 6px; } .pw-seg button:last-child { border-radius: 0 6px 6px 0; }
.pw-seg button:hover { background: var(--sel); }
.pw-seg button.on { background: var(--blue); border-color: var(--blue-d); color: #fff; font-weight: 600; position: relative; }
.pw-seg button.on.ok { background: var(--green); border-color: var(--green); }
.pw-seg button.on.bad { background: var(--red); border-color: var(--red); }
.pw-seg button:disabled { cursor: default; opacity: .85; }

/* tags: chosen values as chips, a search box, and the common answers one tap away */
.pw-taglist { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pw-tag { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding-right: 9px; background: var(--chip); border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; }
.pw-tag button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; background: #4b5868; color: #fff; cursor: pointer; }
.pw-tag button svg { width: 12px; height: 12px; }
.pw-tag:not(:has(button)) { padding-left: 9px; }
.pw-tagin { flex: 1; min-width: 220px; }
.pw-quickpicks { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 5px; }
.pw-quickpicks span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); margin-right: 2px; }
.pw-quickpicks button { height: 22px; padding: 0 8px; border: 1px dashed var(--line); border-radius: 6px; background: transparent; color: var(--text); font-size: 11.5px; cursor: pointer; }
.pw-quickpicks button:hover { border-style: solid; background: var(--sel); }
.pw[data-theme="night"] .pw-quickpicks button { border: 1.5px dashed #8fa0b6; color: #f1f5f9; background: rgba(143, 160, 182, .1); }

/* suggestions */
.pw-sug { position: fixed; z-index: 6; display: none; overflow: auto; background: var(--panel); border: 1px solid var(--blue); border-radius: 6px; box-shadow: var(--shadow); }
.pw-sug-i { display: flex; align-items: baseline; gap: 8px; padding: 5px 9px; font-size: 12.5px; cursor: pointer; border-bottom: 1px solid var(--line2); }
.pw-sug-i:hover, .pw-sug-i.act { background: var(--sel); }
.pw-sug-i b { font-weight: 700; }
.pw-sug-i small { color: var(--dim); font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-sug-i em { margin-left: auto; font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--green); }
.pw-sug-foot { padding: 5px 9px; font-size: 11px; color: var(--dim); background: var(--sub); }

/* assessment: one line per system */
.pw-sys { border-bottom: 1px solid var(--line2); }
.pw-sys:last-child { border-bottom: 0; }
.pw-sys-head { display: grid; grid-template-columns: 168px auto minmax(0, 1fr); gap: 10px; align-items: center; padding: 4px 10px 4px 6px; }
.pw-sys-name { display: flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 2px; text-align: left; }
.pw-sys-name svg { color: var(--dim); transition: transform .12s; }
.pw-sys.open .pw-sys-name svg { transform: rotate(90deg); }
.pw-sys-sum { font-size: 12px; color: var(--red); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-sys > .pw-form { padding: 9px 12px 12px; background: var(--sub); border-top: 1px solid var(--line2); }

/* grids */
.pw-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pw-grid th { padding: 5px 8px; text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--dim); background: var(--head); border-bottom: 1px solid var(--line); white-space: nowrap; }
.pw-grid td { padding: 5px 8px; border-bottom: 1px solid var(--line2); color: var(--text); vertical-align: middle; }
.pw-grid .n { text-align: right; } .pw-grid .act { text-align: right; width: 1%; white-space: nowrap; } .pw-grid .when { white-space: nowrap; color: var(--dim); }
.pw-grid tr[data-selrow] { cursor: pointer; }
.pw-grid tr[data-selrow]:hover td { background: var(--sub); }
.pw-grid tr.sel td { background: var(--sel); }
.pw-grid tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.pw-grid tfoot td { font-weight: 700; background: var(--head); border-bottom: 0; }
.pw-grid.plain td { padding: 6px 8px; }
.pw-pta { display: inline-block; padding: 0 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; background: var(--amber); color: #fff; border-radius: 6px; }

/* the activity log: a monitor trend — one colour per parameter, the same ones a bedside monitor uses */
/* vitals follow the day / night setting: one colour per parameter, dark on light by day, bright on black at night */
.pw { --mon-bg: #eef1f5; --mon-tile: #fff; --mon-line: #c3cad4; --mon-head: #f0f3f6; --mon-dim: #586474; --mon-text: #1a232e; --mon-sub: #46525f; --mon-hover: #f1f6fc; --mon-sel: #e1eefc; --mon-abn: #c5282c;
  --v-hr: #15803d; --v-bp: #1a232e; --v-map: #46525f; --v-spo2: #0369a1; --v-etco2: #6d28d9; --v-resp: #a16207; --v-tmp: #c2410c; }
.pw[data-theme="night"] { --mon-bg: #06080b; --mon-tile: #0d1217; --mon-line: #1c242e; --mon-head: #0c1015; --mon-dim: #7f8b9a; --mon-text: #dfe6ee; --mon-sub: #b9c4d0; --mon-hover: #0f151c; --mon-sel: #13223a; --mon-abn: #991b1b;
  --v-hr: #4ADE80; --v-bp: #F4F7FF; --v-map: #CBD5E1; --v-spo2: #38BDF8; --v-etco2: #C4B5FD; --v-resp: #FACC15; --v-tmp: #FB923C; }
.pw-flowwrap { background: var(--mon-tile); overflow: auto; }
.pw-gridwrap { overflow-x: auto; }
.pw-flow { width: 100%; border-collapse: collapse; font: 12.5px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.pw-flow th { padding: 5px 9px; text-align: right; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--mon-head); color: var(--mon-dim); border-bottom: 1px solid var(--mon-line); white-space: nowrap; }
.pw-flow td { padding: 5px 9px; text-align: right; color: var(--mon-text); border-bottom: 1px solid var(--line2); white-space: nowrap; }
.pw-flow th:nth-child(-n+2), .pw-flow td.when, .pw-flow td.what, .pw-flow td.txt, .pw-flow th:nth-last-child(-n+3) { text-align: left; }
.pw-flow td.what, .pw-flow td.txt { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--mon-sub); }
.pw-flow td.when b { color: var(--mon-text); font-weight: 600; } .pw-flow td.when small { color: var(--mon-dim); margin-left: 6px; }
.pw-flow .v-hr { color: var(--v-hr); } .pw-flow .v-bp { color: var(--v-bp); } .pw-flow .v-map { color: var(--v-map); } .pw-flow .v-spo2 { color: var(--v-spo2); }
.pw-flow .v-etco2 { color: var(--v-etco2); } .pw-flow .v-resp { color: var(--v-resp); } .pw-flow .v-pt_tmp { color: var(--v-tmp); }
.pw-flow td[class^="v-"] { font-weight: 600; }
.pw-flow td.abn { background: var(--mon-abn); color: #fff; font-weight: 700; }
.pw-flow tr { cursor: pointer; }
.pw-flow tbody tr:hover td:not(.abn) { background: var(--mon-hover); }
.pw-flow tr.sel td:not(.abn) { background: var(--mon-sel); }
.pw-flow tr.sel td:first-child { box-shadow: inset 3px 0 0 #3b8ee6; }
.pw-monitor { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 5px; padding: 6px; margin-bottom: 8px; background: var(--mon-bg); border: 1px solid var(--line2); border-radius: 4px; }
.pw-tile { position: relative; display: block; padding: 4px 7px 3px; background: var(--mon-tile); border: 1px solid var(--mon-line); border-radius: 6px; cursor: text; color: var(--c, var(--mon-text)); }
.pw-tile-l { display: block; font: 700 9px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .08em; opacity: .9; }
.pw-tile input { display: block; width: 100%; margin: 0; padding: 0; border: 0; outline: 0; background: transparent; color: inherit; box-shadow: none; height: auto;
  font: 600 17px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.pw-tile input::placeholder { color: currentColor; opacity: .28; }
.pw-tile input[readonly] { opacity: .8; }
.pw-tile-u { position: absolute; right: 6px; bottom: 4px; font: 600 9px ui-monospace, Menlo, Consolas, monospace; opacity: .7; }
.pw-tile-f { position: absolute; right: 6px; top: 4px; font: 700 9px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; color: #fff; }
.pw-tile.abn { border-color: #ef4444; box-shadow: inset 0 0 0 1px #ef4444; }
.pw-tile.abn .pw-tile-f { background: #dc2626; padding: 0 4px; border-radius: 1px; }
.pw-tile:focus-within { border-color: #3b8ee6; }
.t-hr { --c: var(--v-hr); } .t-sys, .t-dia { --c: var(--v-bp); } .t-map { --c: var(--v-map); } .t-spo2 { --c: var(--v-spo2); } .t-etco2 { --c: var(--v-etco2); } .t-resp { --c: var(--v-resp); } .t-pt_tmp { --c: var(--v-tmp); }

/* activity log layout: the trend on the left, add-entry tools on the right */
.pw-split { display: flex; gap: 10px; align-items: flex-start; }
.pw-split-main { flex: 1; min-width: 0; }
.pw-quick { width: 204px; flex: none; position: sticky; top: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.pw-quick h3 { margin: 0; padding: 8px 10px; font-size: 13px; font-weight: 700; background: var(--head); border-bottom: 1px solid var(--line); }
.pw-quick button { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 9px; border: 0; border-bottom: 1px solid var(--line2); background: transparent; color: var(--text); font-size: 12px; text-align: left; cursor: pointer; }
.pw-quick button:last-child { border-bottom: 0; }
.pw-quick button:hover { background: var(--sel); }
.pw-quick button svg { width: 13px; height: 13px; color: var(--blue); }
.pw-quick-sel { padding: 6px; border-bottom: 1px solid var(--line2); }
.pw-quick button .pw-cs { margin-left: auto; }
.pw-cs { display: inline-block; padding: 0 5px; font-size: 10px; font-weight: 700; letter-spacing: .04em; line-height: 16px; background: #7a3fb0; color: #fff; border-radius: 4px; vertical-align: 1px; }
.pw-dim { color: var(--dim); }
.pw-conc { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pw-own { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; width: 100%; }
.pw-own .pw-in { width: 240px; max-width: 100%; }
.pw-units { display: flex; flex-wrap: wrap; gap: 4px; }
.pw-units button { height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--head); color: var(--text); font-size: 11.5px; cursor: pointer; }
.pw-units button:hover { background: var(--blue); border-color: var(--blue-d); color: #fff; }
.pw-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pw-amt { display: flex; gap: 6px; max-width: 300px; } .pw-amt input { flex: 1; min-width: 0; } .pw-amt select { width: 104px; flex: none; }
.pw-csline { margin-top: 8px; font-size: 12px; color: var(--dim); }
.pcr-asktext { display: block; width: 100%; margin: 0 0 14px; padding: 7px 9px; border: 1px solid #c4c9d9; border-radius: 6px; font: inherit; font-size: 13.5px; color: #1b2033; background: #fff; resize: vertical; }
.pw-seg button b { font-weight: 700; margin-right: 2px; }
/* the missing items on a section, ringed in red for a few seconds after its red count is tapped */
.pw-miss { outline: 2px solid rgba(230, 45, 50, .95); outline-offset: 2px; border-radius: 6px; box-shadow: 0 0 10px 2px rgba(230, 45, 50, .5); }
.pw-finding .pw-nav-n { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--red); }
tr.pw-miss { outline-offset: -2px; }
/* written by Anthony and not edited by a person yet: a purple glow, like a missing box but his */
.pw .pw-ai:not(tr):not(.pw-sys-head) { border-color: #8b5cf6 !important; box-shadow: 0 0 0 2px rgba(139, 92, 246, .45), 0 0 14px 2px rgba(139, 92, 246, .5); border-radius: 6px; }
.pw tr.pw-ai > td { background: rgba(139, 92, 246, .12); }
.pw tr.pw-ai > td:first-child { box-shadow: inset 4px 0 0 #8b5cf6; }
.pw .pw-sys-head.pw-ai { box-shadow: inset 4px 0 0 #8b5cf6; }
/* Anthony AI: a floating bubble in the bottom right corner of a draft chart, with a soft glow */
.pw-ai-fab { position: absolute; right: 16px; bottom: 56px; z-index: 6; width: 54px; height: 54px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; cursor: pointer; color: #fff;
  background: radial-gradient(circle at 30% 28%, #b79bff 0%, #8b5cf6 46%, #6a35d1 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35) inset, 0 6px 16px rgba(72, 38, 160, .38), 0 0 22px 4px rgba(139, 92, 246, .5); animation: pw-ai-breathe 3.6s ease-in-out infinite; -webkit-tap-highlight-color: transparent; }
.pw-ai-fab[hidden] { display: none; }
.pw-travel { padding: 8px 12px 10px; border-top: 1px solid var(--line2); font-size: 12.5px; color: var(--dim); }
.pw-travel[hidden] { display: none; }
.pw-ai-fab svg { width: 26px; height: 26px; }
.pw-ai-fab:hover { filter: brightness(1.08); }
.pw-ai-fab i { position: absolute; inset: -5px; border-radius: 50%; border: 3px solid transparent; pointer-events: none; }
.pw-ai-fab.busy { cursor: default; }
.pw-ai-fab.busy i { border-top-color: #fff; border-right-color: rgba(255, 255, 255, .45); animation: pw-ai-spin .9s linear infinite; }
@keyframes pw-ai-breathe { 0%, 100% { box-shadow: 0 0 0 1px rgba(255, 255, 255, .35) inset, 0 6px 16px rgba(72, 38, 160, .38), 0 0 16px 2px rgba(139, 92, 246, .38); } 50% { box-shadow: 0 0 0 1px rgba(255, 255, 255, .35) inset, 0 6px 16px rgba(72, 38, 160, .38), 0 0 30px 8px rgba(139, 92, 246, .62); } }
@keyframes pw-ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pw-ai-fab { animation: none; } }
@media (max-width: 900px) { .pw-ai-fab { right: 12px; bottom: 112px; } }
.pw-ai-pick { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid #e3e7ee; cursor: pointer; }
.pw-ai-pick input { margin-top: 2px; flex: none; }
.pw-ai-pick b { display: block; font-size: 13.5px; }
.pw-ai-pick small { display: block; font-size: 12px; color: #586474; line-height: 1.4; }
.modal.pw-ai-modal { max-width: 620px; display: flex; flex-direction: column; }
.pw-ai-thread { display: flex; flex-direction: column; gap: 8px; min-height: 120px; max-height: 46vh; overflow-y: auto; margin: 0 0 10px; padding: 10px; border: 1px solid #e3def4; border-radius: 6px; background: #faf8ff; }
.pw-ai-hello { font-size: 13px; line-height: 1.5; color: #586474; }
.pw-ai-msg { align-self: flex-start; max-width: 92%; padding: 8px 11px; border: 1px solid #e3def4; border-radius: 10px 10px 10px 3px; background: #fff; font-size: 13.5px; line-height: 1.5; color: #1a232e; }
.pw-ai-msg.me { align-self: flex-end; border-color: #cbbcf3; border-radius: 10px 10px 3px 10px; background: #efe9ff; white-space: pre-wrap; }
.pw-ai-msg.wait { color: #586474; font-style: italic; }
.pw-ai-msg.bad { border-color: #f0b4b6; background: #fdecec; color: #a11d21; font-weight: 600; }
.pw-ai-did { margin-top: 8px; padding: 5px 8px; border-radius: 5px; background: #efe9ff; color: #4b2aa3; font-size: 12px; font-weight: 600; }
.pw-ai-modal .pw-ai-chips { margin-bottom: 8px; }
.pw-ai-modal .pw-ai-fine { margin-top: 0; padding-top: 0; border-top: 0; }
@media (max-width: 640px) { .pw-ai-thread { max-height: 38vh; } }
.pw-ai-sec { padding: 4px 0 2px; }
.pw-ai-sec + .pw-ai-sec { margin-top: 14px; padding-top: 12px; border-top: 2px solid #e3e7ee; }
.pw-ai-sec h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #6a35d1; }
.pw-ai-sec .pcr-asktext { margin-bottom: 8px; font-size: 15px; }
.pw-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pw-ai-chips button { padding: 5px 10px; border: 1px solid #cbbcf3; border-radius: 14px; background: #f5f1ff; color: #4b2aa3; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.pw-ai-chips button:hover { background: #ebe3ff; }
.modal .modal-actions.pw-ai-askrow { margin-top: 8px; }
.pw-ai-ans { margin-top: 10px; padding: 10px 12px; border: 1px solid #cbbcf3; border-radius: 6px; background: #faf8ff; font-size: 13.5px; line-height: 1.5; color: #1a232e; max-height: 46vh; overflow-y: auto; }
.pw-ai-ans[hidden] { display: none; }
.pw-ai-ans.wait { color: #586474; font-style: italic; }
.pw-ai-ans.bad { border-color: #f0b4b6; background: #fdecec; color: #a11d21; font-weight: 600; }
.pw-ai-text { white-space: pre-wrap; }
.pw-ai-src { margin-top: 8px; padding-top: 8px; border-top: 1px solid #e3def4; font-size: 12px; color: #586474; }
.pw-ai-care { margin-top: 8px; font-size: 12px; font-weight: 600; color: #7a5200; }
.pw-ai-fine { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e3e7ee; font-size: 12px; line-height: 1.45; color: #586474; }
.pw-nav-n { cursor: pointer; }
.pw-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding: 10px; }
.pw-photo { border: 1px solid var(--line); border-radius: 6px; background: var(--sub); overflow: hidden; }
.pw-photo-img { display: block; width: 100%; height: 170px; padding: 0; border: 0; background: #10141b; cursor: zoom-in; position: relative; }
.pw-photo-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pw-photo-gone { display: none; position: absolute; inset: 0; padding: 14px; color: #c9d1dc; font-size: 12px; align-items: center; justify-content: center; text-align: center; }
.pw-photo.gone img { display: none; } .pw-photo.gone .pw-photo-gone { display: flex; }
.pw-photo-meta { display: flex; flex-direction: column; gap: 5px; padding: 7px; align-items: stretch; }
.pw-photo-meta small { color: var(--dim); font-size: 11.5px; }
.pw-photo-meta .pw-btn { align-self: flex-start; }
.pcr-photobig { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto 8px; border-radius: 4px; }
.pcr-ask { white-space: pre-line; font-size: 13.5px; line-height: 1.45; margin-bottom: 14px; }
body.pw-open .modal .btn.danger { background: #c5282c; border-color: #9f1d21; }
.pw-mednarc { margin-top: 6px; }
.pw-rsi { position: absolute; inset: 0; z-index: 20; display: none; flex-direction: column; background: #0b1016; }
.pw-rsi-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 8px; background: #1d2632; color: #fff; font-size: 13px; }
.pw-rsi iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.pw-kinds { margin-bottom: 10px; }
.pw-kinds:last-child { margin-bottom: 0; }
.pw-kinds h4 { margin: 0 0 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); }
.pw-kinds div { display: flex; flex-wrap: wrap; gap: 5px; }
.pw-kinds button { height: 28px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--in); color: var(--text); font-size: 12.5px; cursor: pointer; }
.pw-kinds button:hover { background: var(--blue); border-color: var(--blue-d); color: #fff; }

/* signatures, review, sending */
.pw-sigimg, .pw-sigcell img { height: 56px; width: 250px; max-width: 100%; object-fit: contain; object-position: left center; background: #fff; border: 1px solid var(--line2); border-radius: 4px; padding: 1px 5px; flex: none; }
.pw-sigline .pw-in { max-width: 320px; }
.pw-sigrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line2); }
.pw-sigcell { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.pw-sigcell label { font-size: 12px; color: var(--dim); }
.pw-sendrow { display: flex; gap: 16px; align-items: flex-start; }
.pw-big { flex: none; width: 92px; padding: 8px 0; text-align: center; background: var(--red); color: #fff; border-radius: 4px; }
.pw-big.full { background: var(--green); }
.pw-big b { display: block; font-size: 26px; line-height: 1.1; } .pw-big span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
.pw-sendtext { min-width: 0; } .pw-sendtext p { margin: 0 0 6px; }
.pw-todo { margin: 0; padding: 0; list-style: none; columns: 2; column-gap: 24px; }
.pw-todo li { break-inside: avoid; padding: 1px 0; }
.pw-todo button, .pw-vallist button { border: 0; background: transparent; color: var(--blue); font-size: 12.5px; cursor: pointer; padding: 1px 0; text-align: left; }
.pw-todo button:hover { text-decoration: underline; }
.pw-todo em, .pw-vallist em { margin-left: 6px; font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--red); }
.pw-notei { padding: 6px 0; border-bottom: 1px solid var(--line2); white-space: pre-wrap; }
.pw-notei small { display: block; color: var(--dim); font-size: 11px; }
.pw-notice { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; margin-bottom: 10px; border: 1px solid var(--blue); border-left-width: 4px; border-radius: 4px; background: var(--sel); font-size: 12.5px; }
.pw-notice svg { margin-top: 1px; color: var(--blue); }
.pw-notice.bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--panel)); } .pw-notice.bad svg { color: var(--red); }

/* status bar */
.pw-status { position: relative; display: flex; align-items: center; gap: 14px; height: 40px; flex: none; background: var(--head); border-top: 1px solid var(--line); padding-right: 12px; }
.pw-val { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 9px; align-items: center; height: 100%; padding: 0 12px; border: 0; background: var(--red); color: #fff; cursor: pointer; text-align: left; }
.pw-val { position: relative; z-index: 1; box-shadow: 0 0 10px 1px rgba(225, 45, 50, .4); } .pw-val b { text-shadow: 0 0 6px rgba(255, 255, 255, .4); }
.pw-val.full { background: var(--green); box-shadow: 0 0 10px 1px rgba(42, 160, 80, .45); }
.pw-val b { grid-row: 1 / span 2; font-size: 19px; font-weight: 700; }
.pw-val span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.pw-val i { display: none; } .pw-val small { font-size: 10.5px; opacity: .9; }
.pw-sync { flex: 1; min-width: 0; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-sync.wait { color: var(--amber); } .pw-sync.bad { color: var(--red); } .pw-sync.ok { color: var(--green); }
.pw-st { font-size: 12px; color: var(--dim); white-space: nowrap; }
.pw-st b { margin-left: 6px; padding: 2px 8px; border-radius: 6px; color: #fff; background: #56637a; }
.pw-st .c-amber { background: var(--amber); } .pw-st .c-red { background: var(--red); } .pw-st .c-green { background: var(--green); } .pw-st .c-blue { background: var(--blue); }
.pw-vallist { position: absolute; left: 0; bottom: 40px; z-index: 5; width: 330px; max-height: 55vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.pw-vallist header { display: flex; justify-content: space-between; padding: 7px 10px; background: var(--head); border-bottom: 1px solid var(--line); font-size: 12px; }
.pw-vallist button { display: flex; justify-content: space-between; width: 100%; padding: 5px 10px; border-bottom: 1px solid var(--line2); color: var(--text); }
.pw-vallist button:hover { background: var(--sel); }
.pw-vallist .pw-none { padding: 10px; }

/* the signature dialog, restyled to match while a chart is open */
body.pw-open .modal-back { z-index: 320; background: rgba(15, 20, 28, .6); backdrop-filter: none; -webkit-backdrop-filter: none; }
body.pw-open .modal { background: #fff; color: #1a232e; border: 1px solid #c3cad4; border-radius: 3px; box-shadow: 0 12px 30px rgba(20, 30, 45, .35); backdrop-filter: none; -webkit-backdrop-filter: none; }
body.pw-open .modal::before, body.pw-open .modal::after { display: none; }
body.pw-open .modal h2 { color: #1a232e; font-size: 15px; }
body.pw-open .modal .muted { color: #586474; }
body.pw-open .modal .btn { background: #3f5fe0; border: 1px solid #2f48b8; border-radius: 6px; box-shadow: none; color: #fff; font-size: 12.5px; padding: 6px 14px; }
body.pw-open .modal .btn.ghost { background: #f0f3f6; border-color: #c3cad4; color: #1a232e; }
/* dialogs over a chart are white: their fields are too, and on a phone they sit in the middle of the screen, not at the bottom */
body.pw-open .modal input:not([type="radio"]):not([type="checkbox"]), body.pw-open .modal select, body.pw-open .modal textarea { background: #fff; color: #1a232e; border: 1px solid #aeb7c3; border-radius: 4px; }
body.pw-open .modal input::placeholder, body.pw-open .modal textarea::placeholder { color: #8a94a3; }
body.pw-open .modal input[type="radio"], body.pw-open .modal input[type="checkbox"] { width: 18px; height: 18px; accent-color: #3f5fe0; }
body.pw-open .modal-back { align-items: center; }
body.pw-open .toast { z-index: 330; }

/* narrower screens: the rail becomes a strip, labels sit above their fields */
@media (max-width: 900px) {
  .pw-body { flex-direction: column; }
  .pw-rail { width: auto; display: flex; align-items: stretch; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; flex: none; }
  .pw-rail::-webkit-scrollbar { display: none; }
  .pw-find, .pw-findres { display: none; }
  #pwNav { display: flex; }
  .pw-nav { width: auto; white-space: nowrap; border-left: 0; border-bottom: 4px solid var(--line); border-right: 1px solid var(--line); padding: 9px 11px; }
  .pw-nav:first-child { border-top: 0; }
  .pw-nav.need { border-bottom-color: var(--red); animation-name: pwneedb; } .pw-nav.ok { border-bottom-color: var(--green); box-shadow: inset 0 -8px 10px -8px rgba(42, 160, 80, .5); }
  .pw-form { grid-template-columns: 1fr; }
  .pw-row { grid-template-columns: 1fr; gap: 2px; }
  .pw-row > label { text-align: left; padding-top: 0; }
  .pw-split { flex-direction: column; align-items: stretch; }
  .pw-split-main { width: 100%; }
  .pw-quick-sel { width: 100%; }
  .pw-own .pw-in { width: 100%; }
  .pw-quick { width: 100%; position: static; display: flex; flex-wrap: wrap; order: -1; }
  .pw-quick { padding: 0 4px 5px 0; } .pw-quick h3 { margin-right: -4px; width: calc(100% + 4px); }
  .pw-quick button { width: auto; border: 1px solid var(--line); border-radius: 6px; margin: 4px 0 0 4px; }
  .pw-quick button:last-child { border-bottom: 1px solid var(--line); }
  .pw[data-theme="night"] .pw-quick button { border-color: #56637a; }
  .pw-sys-head { grid-template-columns: 1fr; gap: 3px; }
  .pw-tb span { display: none; } .pw-tb { min-width: 40px; }
  .pw-flag { display: none; }
  .pw-pt { grid-template-columns: 1fr; } .pw-pt-al { grid-column: 1; grid-row: auto; }
  .pw-todo { columns: 1; }
  .pw-in.num, .pw-dt .pw-in { max-width: none; }
}
/* phones: the patient strip gets its own line under the buttons, and the log is tightened so the vital signs fit across */
.pw-when-what { display: none; }
@media (max-width: 640px) {
  .pw-bar { flex-wrap: wrap; gap: 5px 8px; justify-content: space-between; }
  .pw-pt { order: 3; flex: 0 0 100%; border-left: 0; padding: 4px 2px 1px; border-top: 1px solid rgba(255, 255, 255, .14); grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; }
  .pw-pt-al { grid-column: 2; grid-row: 1 / span 2; justify-self: end; max-width: 46vw; }
  .pw-flow { font-size: 11.5px; }
  .pw-flow th, .pw-flow td { padding: 5px 4px; }
  .pw-flow th:first-child, .pw-flow td.when { padding-left: 8px; }
  .pw-flow th:nth-child(2), .pw-flow td.what { display: none; }
  .pw-flow td.when { white-space: normal; min-width: 96px; max-width: 120px; }
  .pw-flow td.when b { white-space: nowrap; } .pw-flow td.when small { white-space: nowrap; margin-left: 4px; }
  .pw-when-what { display: block; font: 11px/1.25 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--mon-sub); }
  .pw-flow th { letter-spacing: .02em; }
  .pw-status { height: auto; min-height: 40px; gap: 8px; align-items: stretch; padding-right: 8px; }
  .pw-sync { white-space: normal; font-size: 11px; line-height: 1.25; align-self: center; padding: 3px 0; }
  .pw-st { align-self: center; }
}

/* ---------- Medical Direction (pcr-md.js) ----------
   The blue button sits at the foot of the left rail, a little above Completion; on narrow
   screens, where the rail is a strip along the top, it sits above the status bar with a margin around it.
   Its window covers the chart the way RSI Assist does. Flat, dense, the chart's own colours. */
.pw-md-btn { position: relative; z-index: 2; display: flex; align-items: center; gap: 8px; align-self: stretch; height: 40px; flex: none; margin: 8px 8px 10px; padding: 0 12px;
  border: 1px solid var(--blue-d); border-radius: 6px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 700; text-align: left; cursor: pointer; }
.pw-md-btn[hidden], .pw-md-btn [hidden], .pw-md [hidden] { display: none !important; }
.pw-md-btn:hover { background: var(--blue-d); }
.pw-md-btn:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }
.pw-md-btn-t { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 5px; white-space: nowrap; overflow: hidden; }
.pw-md-btn-c { display: none; font-size: 11.5px; font-weight: 600; }
.pw-md-btn.call .pw-md-btn-c { display: inline; }
.pw-md-btn.call .pw-md-btn-c::before { content: "\00b7\00a0"; }
.pw-md-btn.call { animation: pwmdcall 1.8s ease-in-out infinite; }
@keyframes pwmdcall { 0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0); } 50% { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .8); } }
.pw-md-n { flex: none; min-width: 21px; height: 21px; padding: 0 6px; display: grid; place-items: center; border-radius: 11px; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; box-shadow: 0 0 0 2px #fff; }
@media (min-width: 901px) {
  .pw-md-btn { position: absolute; left: 8px; bottom: 52px; width: 196px; margin: 0; }      /* its own button, clear of Completion below it */
  .pw.pw-has-md .pw-rail { padding-bottom: 64px; }
  .pw-md-btn-t { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.2; }
  .pw-md-btn.call .pw-md-btn-c::before { content: none; }
}
/* the same count beside a run number in the chart list (outside the workspace, so its colour is written out) */
.pw-md-listrun { white-space: nowrap; }
.pw-md-listn { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: #3f5fe0; color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px; }

.pw-md { position: absolute; inset: 0; z-index: 22; display: none; flex-direction: column; background: var(--bg); color: var(--text); }
.pw-md-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 8px; background: var(--bar); color: #fff; flex: none; }
.pw-md-title { min-width: 0; display: flex; align-items: baseline; gap: 10px; padding-left: 4px; }
.pw-md-title b { font-size: 15px; white-space: nowrap; }
.pw-md-title span { min-width: 0; font-size: 12px; color: #b6c2d0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-md-bar .pw-tb span { display: block; }
.pw-md-body { flex: 1; min-height: 0; display: flex; }
.pw-md-off { flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; font-size: 15px; color: var(--dim); }

/* conversation */
.pw-md-chat { flex: 1; min-width: 0; min-height: 0; width: 100%; max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.pw-md.incall .pw-md-chat { flex: none; width: 380px; max-width: none; margin: 0; border-right: 0; }
.pw-md-banner { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--blue); color: #fff; font-size: 12.5px; font-weight: 600; flex: none; }
.pw-md-banner span { flex: 1; min-width: 0; }
.pw-md-banner .pw-btn { border-color: #fff; background: #fff; color: var(--blue-d); font-weight: 700; }
.pw-md-note { display: flex; align-items: flex-start; gap: 8px; padding: 6px 10px; background: var(--red); color: #fff; font-size: 12.5px; flex: none; }
.pw-md-note span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pw-md-note button { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: rgba(0, 0, 0, .22); color: #fff; cursor: pointer; }
.pw-md-thread { flex: 1; min-height: 0; overflow: auto; padding: 8px 10px 2px; -webkit-overflow-scrolling: touch; }
.pw-md-none { padding: 18px 6px; color: var(--dim); font-size: 12.5px; text-align: center; }
.pw-md-e { margin-bottom: 6px; padding: 5px 9px 6px; background: var(--sub); border: 1px solid var(--line2); border-left: 3px solid var(--line); border-radius: 6px; }
.pw-md-e.mine { background: var(--sel); border-left-color: var(--blue); }
.pw-md-e.sys { background: transparent; border-style: dashed; border-left-style: solid; }
.pw-md-e-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; font-size: 12px; }
.pw-md-e-h time { margin-left: auto; color: var(--dim); font-size: 11px; white-space: nowrap; }
.pw-md-role { padding: 0 6px; border-radius: 6px; background: #56637a; color: #fff; font-size: 10.5px; font-weight: 700; line-height: 16px; }
.pw-md-role.r-md { background: var(--violet); } .pw-md-role.r-qa { background: var(--blue); }
.pw-md-e-b { margin-top: 3px; font-size: 13px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.pw-md-e-b.dim { color: var(--dim); font-style: italic; }
.pw-md-file { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 5px; color: var(--dim); }
.pw-md-file-t { flex: 1 1 170px; min-width: 0; color: var(--text); }
.pw-md-file-t b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.pw-md-file-t small { color: var(--dim); font-size: 11.5px; }
.pw-md .pw-btn { height: 30px; flex: none; }
.pw-md-net { flex: none; padding: 0 10px; font-size: 11.5px; color: var(--amber); }
.pw-md-net:empty, .pw-md-ups:empty, .pw-md-callmsg:empty, .pw-md-tile-x:empty, .pw-md-tile-n em:empty { display: none; }
.pw-md-net:not(:empty) { padding: 3px 10px; }
.pw-md-up { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-top: 1px solid var(--line2); font-size: 12px; }
.pw-md-up b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-md-up i { flex: none; width: 90px; height: 6px; border-radius: 3px; background: var(--line2); overflow: hidden; }
.pw-md-up i em { display: block; height: 100%; background: var(--blue); }
.pw-md-up span { flex: none; min-width: 34px; text-align: right; color: var(--dim); }
.pw-md-up.err { flex-wrap: wrap; } .pw-md-up.err span { flex: 1 1 100%; order: 3; min-width: 0; text-align: left; color: var(--red); }
.pw-md-compose { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; background: var(--head); border-top: 1px solid var(--line); flex: none; }
.pw-md-compose textarea.pw-in { flex: 1; min-width: 0; min-height: 66px; max-height: 160px; }
.pw-md-compose-b { display: flex; flex-direction: column; gap: 6px; flex: none; }
.pw-md-compose-b .pw-btn { justify-content: center; }

/* video call: dark in both themes, like the picture it frames */
.pw-md-callpane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #0b1016; color: #fff; }
.pw-md-grid { flex: 1; min-height: 0; display: grid; gap: 4px; padding: 4px; grid-template-columns: repeat(var(--c, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.pw-md-grid[data-n="2"], .pw-md-grid[data-n="3"], .pw-md-grid[data-n="4"] { --c: 2; }
.pw-md-grid[data-n="5"], .pw-md-grid[data-n="6"] { --c: 3; }
.pw-md-tile { position: relative; min-height: 0; overflow: hidden; background: #151c25; border: 1px solid #263140; border-radius: 6px; }
.pw-md-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.pw-md-tile.mirror video { transform: scaleX(-1); }
.pw-md-tile.tap { cursor: pointer; }
.pw-md-tile-x { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; font-size: 12.5px; color: #b6c2d0; background: #151c25; }
.pw-md-tile-n { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); display: flex; gap: 6px; align-items: baseline; padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .66); font-size: 11.5px; white-space: nowrap; overflow: hidden; }
.pw-md-tile-n b { overflow: hidden; text-overflow: ellipsis; } .pw-md-tile-n span { color: #b6c2d0; } .pw-md-tile-n em { font-style: normal; color: #ffc65c; }
.pw-md-callmsg { flex: none; padding: 5px 10px; text-align: center; font-size: 12px; background: #3a2a08; color: #ffd98a; }
.pw-md-ctl { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 8px; background: #111820; border-top: 1px solid #263140; }
.pw-md-cb { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 78px; height: 46px; padding: 2px 10px; border: 1px solid #3a4658; border-radius: 6px; background: #232d3a; color: #fff; font-size: 11px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.pw-md-cb:hover { background: #2d3a4b; }
.pw-md-cb.on { background: #a86200; border-color: #a86200; }
.pw-md-cb.leave { background: #c5282c; border-color: #c5282c; }
.pw-md-cb:disabled { opacity: .5; cursor: default; }
.pw-md-cb { position: relative; }
.pw-md-cb.lit { background: #f4f6f8; border-color: #f4f6f8; color: #10161d; }
.pw-md-cbn { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #c5282c; color: #fff; font-size: 10.5px; font-style: normal; font-weight: 700; line-height: 18px; text-align: center; }
.pw-md-cbn[hidden] { display: none; }
/* the conversation folded away during a call */
.pw-md.incall.nochat .pw-md-chat { display: none; }
/* screen light: the picture sits in a white surround that lights whoever is in front of the screen */
.pw-md.incall.light .pw-md-callpane { background: #fff; }
.pw-md.incall.light .pw-md-grid { padding: 9vh 9vw; }
.pw-md.incall.light .pw-md-tile { border-color: #d5dbe2; }

/* a picture opened from the thread */
.pw-md-view { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; background: #0b1016; }
.pw-md-view header { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #1d2632; color: #fff; flex: none; }
.pw-md-view header b { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-md-view-b { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; overflow: auto; }
.pw-md-view-b img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pw-md-view-x { max-width: 420px; text-align: center; color: #b6c2d0; font-size: 13px; }

@media (prefers-reduced-motion: reduce) { .pw-md-btn.call { animation: none; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .8); } }
@media (max-width: 900px) {
  .pw-md-body { flex-direction: column; }
  .pw-md-chat { border-left: 0; border-right: 0; }
  .pw-md.incall .pw-md-callpane { flex: none; height: 46%; min-height: 236px; }
  .pw-md.incall .pw-md-chat { flex: 1; width: 100%; }
  .pw-md .pw-btn { height: 34px; }
  .pw-md-cb { min-width: 60px; padding: 2px 8px; }
  .pw-md-compose textarea.pw-in { min-height: 74px; }
}
/* a call on a phone with the conversation folded away: the picture fills the screen, your own sits in a corner, the controls float over it */
@media (max-width: 900px) {
  .pw-md.incall.nochat .pw-md-bar { display: none; }
  .pw-md.incall.nochat .pw-md-callpane { position: relative; flex: 1; height: auto; min-height: 0; }
  .pw-md.incall.nochat .pw-md-grid { position: relative; gap: 2px; padding: 0; --c: 1; }
  .pw-md.incall.nochat .pw-md-grid[data-n="5"], .pw-md.incall.nochat .pw-md-grid[data-n="6"] { --c: 2; }
  .pw-md.incall.nochat .pw-md-tile { border: 0; border-radius: 0; }
  .pw-md.incall.nochat .pw-md-tile video { object-fit: cover; }
  .pw-md.incall.nochat .pw-md-tile-n { left: 12px; top: calc(12px + env(safe-area-inset-top)); bottom: auto; max-width: 62%; }
  .pw-md.incall.nochat .pw-md-grid:not([data-n="1"]) .pw-md-tile.self { position: absolute; z-index: 2; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 27%; max-width: 128px; aspect-ratio: 3 / 4;
    border: 1px solid rgba(255, 255, 255, .4); border-radius: 12px; box-shadow: 0 6px 22px rgba(0, 0, 0, .5); }
  .pw-md.incall.nochat .pw-md-grid:not([data-n="1"]) .pw-md-tile.self video { object-fit: cover; }
  .pw-md.incall.nochat .pw-md-grid:not([data-n="1"]) .pw-md-tile.self .pw-md-tile-n { left: 4px; top: auto; bottom: 4px; max-width: calc(100% - 8px); font-size: 10.5px; padding: 1px 6px; }
  .pw-md.incall.nochat .pw-md-grid:not([data-n="1"]) .pw-md-tile.self .pw-md-tile-n span { display: none; }
  .pw-md.incall.nochat .pw-md-ctl { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; flex-wrap: nowrap; gap: 10px; padding: 26px 8px calc(16px + env(safe-area-inset-bottom));
    border-top: 0; background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .62)); pointer-events: none; }
  .pw-md.incall.nochat .pw-md-cb { pointer-events: auto; flex: none; min-width: 0; width: 50px; height: 50px; padding: 0; border-radius: 50%; border-color: rgba(255, 255, 255, .2);
    background: rgba(38, 46, 58, .74); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  .pw-md.incall.nochat .pw-md-cb.on { background: #a86200; border-color: #a86200; }
  .pw-md.incall.nochat .pw-md-cb.lit { background: #f4f6f8; border-color: #f4f6f8; }
  .pw-md.incall.nochat .pw-md-cb.leave { background: #c5282c; border-color: #c5282c; }
  .pw-md.incall.nochat .pw-md-cb > span { display: none; }
  .pw-md.incall.nochat .pw-md-cb svg { width: 22px; height: 22px; }
  .pw-md.incall.nochat .pw-md-cb[hidden] { display: none; }
  .pw-md.incall.nochat .pw-md-cbn { top: -3px; right: -3px; }
  .pw-md.incall.nochat .pw-md-callmsg { position: absolute; z-index: 3; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); border-radius: 8px; }
  .pw-md.incall.nochat.light .pw-md-grid { padding: 20vh 9vw 24vh; }
  .pw-md.incall.nochat.light .pw-md-tile { border-radius: 14px; }
  .pw-md.incall.nochat.light .pw-md-ctl { background: none; }
}
/* a sideways picture on an upright phone (or the reverse) is shown whole, never cropped to a strip */
@media (max-width: 900px) and (orientation: portrait) { .pw-md.incall.nochat .pw-md-grid .pw-md-tile.wide:not(.self) video { object-fit: contain; } }
@media (max-width: 900px) and (orientation: landscape) {
  .pw-md.incall.nochat .pw-md-grid .pw-md-tile:not(.wide):not(.self) video { object-fit: contain; }
  .pw-md.incall.nochat .pw-md-grid[data-n="3"] { --c: 2; }
  .pw-md.incall.nochat .pw-md-grid[data-n="4"], .pw-md.incall.nochat .pw-md-grid[data-n="5"], .pw-md.incall.nochat .pw-md-grid[data-n="6"] { --c: 3; }
  .pw-md.incall.nochat .pw-md-grid:not([data-n="1"]) .pw-md-tile.self { width: 18%; aspect-ratio: 4 / 3; }
}

/* Settings: every section is a closed drawer until it is opened */
.set-list { display: flex; flex-direction: column; gap: 16px; max-width: 880px; }
.set-sec > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; margin: -20px; padding: 20px; }
.set-sec > summary::-webkit-details-marker { display: none; }
.set-sec > summary h2 { margin: 0; }
.set-sec > summary svg { flex: none; color: var(--muted, #9aa3c0); transition: transform .15s ease; }
.set-sec[open] > summary svg { transform: rotate(90deg); }
.set-sec[open] > summary { margin-bottom: 0; }
.set-body .field { margin-bottom: 16px; }
.set-body .check-row { margin-bottom: 14px; }
.set-body h3 { margin-top: 24px; }
.set-body > .btn, .set-body > .form-row { margin-top: 6px; }

/* tail numbers as bubbles: typed one at a time, each with an x to remove it */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 46px; padding: 8px 10px; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: var(--radius-sm); background: rgba(6, 8, 20, 0.55); cursor: text; }
.chips:focus-within { border-color: var(--brand-b); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px; border-radius: 99px; background: linear-gradient(135deg, rgba(59, 130, 246, .28), rgba(139, 92, 246, .28)); border: 1px solid rgba(139, 92, 246, .45); font-size: 13.5px; font-weight: 600; letter-spacing: .02em; }
.chip button { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: inherit; cursor: pointer; }
.chip button:hover { background: rgba(239, 68, 68, .6); }
.chips .chip-in { flex: 1; min-width: 130px; width: auto; height: 30px; padding: 0 2px; border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none; }

/* idle lock: covers everything, including an open chart and its dialogs */
.lock-back { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(5, 7, 18, .97); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.lock-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.lock-card .brand { justify-content: center; } .lock-card h2 { margin: 4px 0 0; text-align: center; } .lock-card p { margin: 0; text-align: center; }
.lock-card #lockIn { font-size: 18px; letter-spacing: .2em; text-align: center; }
.lock-card .btn { justify-content: center; }
body.is-locked > :not(.lock-back) { visibility: hidden; }
/* two-step sign-in setup */
.mfa-qr { width: 190px; max-width: 100%; background: #fff; border-radius: 10px; padding: 6px; line-height: 0; }
.mfa-qr svg { width: 100%; height: auto; display: block; }
.mfa-codes { margin: 0 0 14px; padding: 12px 14px; border-radius: 10px; background: rgba(6, 8, 20, .55); border: 1px solid rgba(255, 255, 255, .18); font: 15px/1.7 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; user-select: all; -webkit-user-select: all; }
/* on a host that holds patient records the Social Security number shows as dots unless it is being typed */
body.secure [data-k="patient.ssn"]:not(:focus) { -webkit-text-security: disc; }

/* Medical Direction: the briefing sits above the conversation. Medical direction or QA write it; crew read it. */
.pw-md-brief { flex: none; max-height: 46%; display: flex; flex-direction: column; background: var(--sub); border-bottom: 2px solid var(--blue); }
.pw-md-brief > header { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 6px 10px; background: var(--head); border-bottom: 1px solid var(--line); flex: none; }
.pw-md-brief > header b { font-size: 13px; }
.pw-md-brief-by { flex: 1; min-width: 0; font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-md-brief > header .pw-btn { height: 24px; padding: 0 9px; font-size: 12px; }
.pw-md-brief-b { overflow: auto; padding: 8px 10px 10px; -webkit-overflow-scrolling: touch; }
.pw-md-brief-t { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.45; color: var(--text); }
.pw-md-brief-none { font-size: 12.5px; color: var(--dim); }
.pw-md-brief-f { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line2); }
.pw-md-brief-f .pw-md-file { color: var(--text); }
.pw-md-brief-b textarea { width: 100%; min-height: 120px; resize: vertical; }
.pw-md-brief-a { display: flex; gap: 6px; margin-top: 6px; }

/* a value shown where a field would be, for things this person cannot change */
.readonly-val { padding: 9px 12px; border-radius: var(--radius-sm); border: 1px dashed rgba(255, 255, 255, 0.18); font-size: 14px; color: var(--text); }
