:root {
  --bg: #f4f6f8; --surface: #ffffff; --ink: #14202b; --muted: #55646f; --line: #c9d2da;
  --brand: #0b5c8a; --brand-ink: #ffffff; --ok: #12633a; --ok-bg: #dff3e7;
  --warn: #8a5a00; --warn-bg: #fff1cc; --bad: #9b1c1c; --bad-bg: #fbe0e0; --crit: #7a1f4d; --crit-bg: #f6e3ee;
  --radius: 10px; --tap: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
a { color: var(--brand); }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.nav { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: .25rem; padding: 0 1rem; flex-wrap: wrap; }
.nav .brand { font-weight: 700; font-size: 1.15rem; margin-right: 1rem; padding: .75rem 0; }
.nav a { color: var(--brand-ink); text-decoration: none; padding: .85rem .8rem; border-bottom: 3px solid transparent; }
.nav a.active, .nav a:hover { border-bottom-color: #fff; }
.nav .spacer { flex: 1; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.grid { display: grid; gap: 1rem; }
.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
input, select, textarea { width: 100%; font: inherit; padding: .6rem .7rem; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid #7fb6dd; outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 1.25rem; height: 1.25rem; padding: 0; }
.btn { font: inherit; font-weight: 600; border: 2px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: .6rem 1rem; border-radius: 8px; cursor: pointer; min-height: 44px; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small { min-height: 34px; padding: .25rem .65rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.tag { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; margin: 0 .25rem .25rem 0; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 6px; font-weight: 700; font-size: .85rem; }
.b-ok { background: var(--ok-bg); color: var(--ok); } .b-warn { background: var(--warn-bg); color: var(--warn); } .b-bad { background: var(--bad-bg); color: var(--bad); }
.b-crit { background: var(--crit-bg); color: var(--crit); } .b-draft { background: #e6e9ec; color: #333; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.filters { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1rem; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; background: var(--surface); margin-bottom: 1rem; }
.fieldset > h2 { margin-bottom: .75rem; }
.two { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.checks label { display: flex; align-items: center; gap: .35rem; font-weight: 500; margin: 0; }
.block { border: 1px dashed var(--line); border-radius: 8px; padding: .8rem; margin-bottom: .75rem; background: #fbfcfd; }
.vitals { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.vitals label { font-size: .8rem; color: var(--muted); }
.login { max-width: 420px; margin: 8vh auto; }
#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #14202b; color: #fff; padding: .7rem 1.1rem; border-radius: 8px; display: none; z-index: 50; max-width: 90vw; }
#toast.show { display: block; } #toast.error { background: var(--bad); }
.bar { height: 22px; background: var(--brand); border-radius: 4px; min-width: 2px; }
.barrow { display: grid; grid-template-columns: 180px 1fr 40px; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.stat { text-align: center; } .stat .n { font-size: 2rem; font-weight: 800; }

/* Run Console */
body.run { background: #0f1720; color: #fff; }
.console { min-height: 100vh; display: grid; gap: .75rem; padding: .75rem; grid-template-columns: 1.1fr 1.4fr .8fr; }
.console .col { background: #17222e; border: 1px solid #2b3a49; border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; gap: .7rem; }
.console h2 { color: #bfe0f5; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .04em; }
.stagebar { font-size: 1.5rem; font-weight: 800; }
.vitals-big { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.vitals-big .v { background: #0f1720; border: 1px solid #2b3a49; border-radius: 8px; padding: .4rem .6rem; }
.vitals-big .v span { display: block; font-size: .8rem; color: #9fb3c4; }
.vitals-big .v b { font-size: 1.9rem; }
.cue { background: #0f1720; border-left: 4px solid #5aa9d6; padding: .5rem .7rem; border-radius: 4px; white-space: pre-wrap; }
.console .btn { min-height: var(--tap); font-size: 1.05rem; }
.console .btn.secondary { background: #17222e; color: #bfe0f5; border-color: #5aa9d6; }
.console .btn.ghost { color: #fff; border-color: #44566a; }
.rub { width: 100%; text-align: left; display: grid; grid-template-columns: 64px 1fr; gap: .6rem; align-items: center; min-height: var(--tap); padding: .6rem .7rem; border-radius: 10px; border: 3px solid #44566a; background: #0f1720; color: #fff; font: inherit; cursor: pointer; margin-bottom: .55rem; }
.rub .st { font-weight: 800; font-size: .8rem; text-align: center; padding: .35rem 0; border-radius: 6px; background: #2b3a49; }
.rub.s-Done { border-color: #3fb27f; } .rub.s-Done .st { background: #3fb27f; color: #04210f; }
.rub.s-DoneLate { border-color: #e0b13a; } .rub.s-DoneLate .st { background: #e0b13a; color: #2a1c00; }
.rub.crit { border-left-width: 10px; border-left-color: #d46aa6; }
.rub .tagc { font-size: .75rem; font-weight: 800; color: #f2b6d8; display: block; }
.timer { font-size: 3.6rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; }
.console textarea, .console input { background: #0f1720; color: #fff; border-color: #44566a; }
.console details { background: #0f1720; border: 1px solid #44566a; border-radius: 8px; padding: .5rem .7rem; }
.console summary { cursor: pointer; font-weight: 700; min-height: 36px; display: flex; align-items: center; }
.legend { font-size: .8rem; color: #9fb3c4; }
.phases { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.phases button { flex: 1; min-width: 150px; }
.phases .on { background: var(--brand); color: #fff; }
.timeline { border-left: 3px solid var(--line); padding-left: .9rem; }
.timeline .ev { margin-bottom: .6rem; }
.sig { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2.5rem; }
.sig div { border-top: 1px solid #000; padding-top: .3rem; font-size: .85rem; }

@media (max-width: 900px) { .console { grid-template-columns: 1fr; } .barrow { grid-template-columns: 110px 1fr 36px; } }
@media print {
  body { background: #fff; } .nav, .noprint, #toast { display: none !important; }
  .wrap { max-width: none; padding: 0; } .card, .fieldset { border: 1px solid #999; break-inside: avoid; }
  body { font-size: 11pt; } @page { margin: 14mm; }
}

/* Facilitator dock (Run Console) */
.console .dock { grid-column: 1 / -1; }
.dockd summary { font-size: 1.05rem; }
.pill { display: inline-block; margin-left: .6rem; padding: .1rem .6rem; border-radius: 999px; background: #44566a; font-size: .8rem; font-weight: 700; }
.pill.on { background: #3fb27f; color: #04210f; }
.dockgrid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: .6rem; }
.dockgrid label { color: #bfe0f5; font-size: .85rem; }
.dockgrid select, .dockgrid input { min-height: 44px; }
.stps { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: .5rem 0; }
.stp { display: grid; grid-template-columns: 52px 56px 1fr 56px; gap: .4rem; align-items: center; }
.stp b { text-align: center; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stp .btn { min-height: 48px; padding: 0; font-size: 1.4rem; }
.exprs { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.exprs .btn { min-height: 44px; font-size: .95rem; }
.faceprev { width: 130px; margin: 0 auto; }
.face { width: 100%; height: auto; display: block; }
.monlog { margin-top: .5rem; color: #9fb3c4; min-height: 1.2rem; }
.chest { transform-origin: 100px 230px; animation: breathe 3.5s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.035) translateY(-2px); } }
.gasp { animation: gasp 1.4s ease-in-out infinite; transform-origin: 100px 174px; }
@keyframes gasp { 0%, 100% { transform: scaleY(.7); } 50% { transform: scaleY(1.1); } }
@media (prefers-reduced-motion: reduce) { .chest, .gasp { animation: none; } }

/* Patient monitor window */
body.mon { background: #000; overflow: hidden; }
.monw { height: 100vh; display: grid; grid-template-columns: 230px 1fr; gap: .6rem; padding: .6rem; position: relative; }
.mon-left { background: #0b1118; border: 1px solid #1d2b38; border-radius: 10px; padding: .7rem; display: flex; flex-direction: column; gap: .6rem; }
.facebig { width: 100%; }
.bubble { background: #fff; color: #111; border-radius: 12px; padding: .6rem .8rem; font-size: 1.15rem; font-weight: 600; position: relative; }
.mon-main { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: .5rem; min-height: 0; }
.mon-screen { background: #000; border: 2px solid #1d2b38; border-radius: 8px; display: grid; grid-template-columns: 1fr 250px; min-height: 0; position: relative; }
.mon-screen.flash { background: #fff; }
.traces { display: grid; grid-template-rows: 2.2fr 1fr 1fr; min-height: 0; border-right: 1px solid #1d2b38; }
.tr { position: relative; min-height: 0; border-bottom: 1px solid #10202c; }
.tr canvas { width: 100%; height: 100%; display: block; }
.lbl { position: absolute; left: 8px; top: 4px; font: 700 .9rem system-ui; z-index: 1; }
.g { color: #35e06f; } .c { color: #3ad0ff; } .y { color: #ffd23a; } .w { color: #fff; }
.nums { display: grid; grid-template-rows: repeat(5, 1fr); min-height: 0; }
.nb { padding: .2rem .7rem; border-bottom: 1px solid #10202c; display: flex; flex-direction: column; justify-content: center; }
.nb span { font-size: .8rem; opacity: .9; } .nb b { font-size: clamp(2rem, 6vh, 3.8rem); line-height: 1; font-variant-numeric: tabular-nums; }
.nb b.nibpv { font-size: clamp(1.4rem, 4.2vh, 2.6rem); } .nb small { font-size: .75rem; opacity: .85; }
.alarms { position: absolute; left: 0; right: 250px; top: 0; display: flex; flex-wrap: wrap; gap: .3rem; padding: .3rem .4rem .3rem 3.6rem; pointer-events: none; }
.al { font-weight: 800; font-size: 1rem; padding: .1rem .6rem; border-radius: 4px; }
.al.crit { background: #d71920; color: #fff; animation: blink 1s steps(2) infinite; } .al.warn { background: #ffd23a; color: #000; } .al.mute { background: #44566a; color: #fff; }
@keyframes blink { 50% { opacity: .55; } }
.mon-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; color: #bfe0f5; }
.defib { background: #1a1f26; border: 2px solid #38424e; border-radius: 10px; padding: .6rem; display: grid; gap: .5rem; }
.dmodes, .dctl { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.dbtn { font: 700 1rem system-ui; min-height: 56px; min-width: 64px; padding: .4rem 1rem; border-radius: 8px; border: 2px solid #5a6b7c; background: #26303a; color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.dbtn:disabled { opacity: .4; cursor: not-allowed; } .dbtn.on { background: #0b5c8a; border-color: #7fb6dd; }
.dbtn.charge { background: #b98a00; border-color: #ffd23a; color: #111; } .dbtn.shock { background: #7a1f1f; border-color: #d46a6a; } .dbtn.shock.armed { background: #d71920; border-color: #fff; animation: blink 0.8s steps(2) infinite; }
.dbtn.sync.on { background: #1d7d4a; }
.djoule { font-size: 1.6rem; min-width: 5.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.dl { color: #9fb3c4; font-size: .85rem; font-weight: 700; }
.padsw { display: flex; align-items: center; gap: .4rem; font-weight: 700; padding: .5rem .8rem; border: 2px solid #5a6b7c; border-radius: 8px; margin: 0; cursor: pointer; min-height: 56px; }
.padsw.on { border-color: #3fb27f; color: #8be3b4; } .padsw input { width: 1.4rem; height: 1.4rem; }
.dmsg { background: #0b1118; border-left: 4px solid #5aa9d6; padding: .5rem .7rem; border-radius: 4px; min-height: 2.6rem; font-size: 1.05rem; }
.startov { position: absolute; inset: 0; background: rgba(0,0,0,.88); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; z-index: 5; color: #fff; }
@media (max-width: 900px) { .monw { grid-template-columns: 1fr; overflow: auto; height: auto; min-height: 100vh; } .mon-left { flex-direction: row; align-items: center; } .facebig { width: 120px; flex: none; } body.mon { overflow: auto; } .mon-screen { min-height: 60vh; } }
