/* ============================================================
   EMR MD — "Bedside" auth screens
   Every auth screen is a patient monitor.
   Theme tokens live in tokens.css (load it first).
   ============================================================ */

.bedside {
  min-height: 100vh;
  padding: 14px;
  display: flex;
}

/* Serif carries the panel title, Plex Sans carries everything actionable. */
.panel h1 {
  font-family: var(--tech);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -0.012em;
  line-height: 1.22;
}

/* ---------- The device ---------- */

.device {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--screen-2) 0%, var(--screen) 55%, var(--screen) 100%);
  border: 1px solid var(--bezel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 120px var(--vignette),
    0 30px 90px -30px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  position: relative;
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* grid — one size in dark, true ECG paper in light */
.device::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-bold) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-bold) 1px, transparent 1px),
    linear-gradient(var(--grid-fine) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-fine) 1px, transparent 1px);
  background-size:
    var(--grid-bold-size) var(--grid-bold-size),
    var(--grid-bold-size) var(--grid-bold-size),
    var(--grid-fine-size) var(--grid-fine-size),
    var(--grid-fine-size) var(--grid-fine-size);
  pointer-events: none;
}

.device::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(180deg, var(--scan) 0px, var(--scan) 1px, transparent 1px, transparent 3px);
  pointer-events: none;
  z-index: 4;
}

/* ---------- Status strip ---------- */

.strip {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hair);
  background: var(--strip-bg);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--txt-faint);
}

.strip .logo { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--txt); }

.strip .logo .glyph {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-soft);
  border: 1px solid var(--ch-ecg);
  color: var(--ch-ecg);
}

.strip .logo .name {
  font-family: var(--body);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.14em;
}
.strip .logo .name span { color: var(--ch-ecg); }

.strip .sep { width: 1px; height: 16px; background: var(--hair); flex: none; }
.strip .spacer { margin-left: auto; }

.strip .live { display: inline-flex; align-items: center; gap: 7px; color: var(--ch-ecg); white-space: nowrap; }
.strip .live .bulb {
  width: 6px; height: 6px; border-radius: 99px;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: bulb 1.9s ease infinite;
}
@keyframes bulb { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* ---------- Stage ---------- */

.stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 268px;
  min-height: 0;
}

.trace-field {
  grid-area: 1 / 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 8px 0;
  min-height: 0;
}

.lane { position: relative; height: 88px; }

.lane .lane-tag {
  position: absolute;
  left: 20px; top: 4px;
  z-index: 2;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.9;
}

.lane svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.lane .scroll { animation: scroll-trace linear infinite; }
@keyframes scroll-trace {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.lane path {
  fill: none;
  stroke-width: var(--trace-w);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.lane-ecg  .lane-tag, .lane-ecg  path { color: var(--ch-ecg);  stroke: var(--ch-ecg);  filter: drop-shadow(0 0 5px var(--glow-ecg)); }
.lane-spo2 .lane-tag, .lane-spo2 path { color: var(--ch-spo2); stroke: var(--ch-spo2); filter: drop-shadow(0 0 5px var(--glow-spo2)); }
.lane-resp .lane-tag, .lane-resp path { color: var(--ch-resp); stroke: var(--ch-resp); filter: drop-shadow(0 0 5px var(--glow-resp)); }

.lane-ecg  .scroll { animation-duration: 6s; }
.lane-spo2 .scroll { animation-duration: 7.5s; }
.lane-resp .scroll { animation-duration: 13s; }

/* ---------- Vitals rail ---------- */

.rail {
  grid-area: 1 / 2;
  position: relative;
  z-index: 5;
  border-left: 1px solid var(--hair);
  background: var(--strip-bg);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.vital { padding: 11px 2px; border-bottom: 1px solid var(--hair-soft); }
.vital:last-of-type { border-bottom: 0; }

.vital .v-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--txt-faint);
  margin-bottom: 2px;
}
.vital .v-head b { font-weight: 600; }

.vital .v-read { display: flex; align-items: baseline; gap: 7px; }

.vital .v-num {
  font-family: var(--num);
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.vital .v-unit { font-family: var(--mono); font-size: 10.5px; color: var(--txt-faint); letter-spacing: 0.08em; }

.v-ecg  .v-num, .v-ecg  .v-head b { color: var(--ch-ecg); }
.v-spo2 .v-num, .v-spo2 .v-head b { color: var(--ch-spo2); }
.v-nibp .v-num, .v-nibp .v-head b { color: var(--ch-nibp); }
.v-resp .v-num, .v-resp .v-head b { color: var(--ch-resp); }

/* rail footer block — practices or onboarding trace */
.rail-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--hair); }

.rail-foot .r-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--txt-faint);
  margin-bottom: 10px;
}

.roster li {
  list-style: none;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 0;
  font-size: 12.5px;
  color: var(--txt-dim);
}
.roster li .tick { width: 3px; height: 15px; border-radius: 2px; background: var(--txt-faint); flex: none; }
.roster li.is-default { color: var(--txt); }
.roster li.is-default .tick { background: var(--ch-ecg); box-shadow: 0 0 8px var(--glow-ecg); }
.roster li .flag { margin-left: auto; font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; color: var(--ch-ecg); }

/* small log lines in rail */
.logline {
  list-style: none;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--txt-faint);
}
.logline li { display: flex; gap: 8px; }
.logline li b { font-weight: 500; color: var(--txt-dim); }
.logline li.on b { color: var(--ok); }

/* ---------- Access panel ---------- */

.panel-wrap {
  grid-area: 1 / 1;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 26px clamp(20px, 5vw, 72px);
  overflow-y: auto;
  min-height: 0;
}

.panel {
  width: 100%;
  max-width: 392px;
  border-radius: 16px;
  padding: 30px 30px 26px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-line);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
  box-shadow: var(--panel-shadow);
  animation: panel-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.panel--wide { max-width: 440px; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.p-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ch-ecg);
  margin-bottom: 14px;
}
.p-eyebrow::after {
  content: "";
  flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--ch-ecg), transparent);
  opacity: 0.5;
}

.panel h1 {
  font-family: var(--tech);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.015em;
  margin-bottom: 7px;
}

.p-sub { font-size: 13.5px; color: var(--txt-dim); margin-bottom: 22px; line-height: 1.5; }
.p-sub strong { color: var(--txt); font-weight: 600; }


/* ---------- Fields ---------- */

.f { margin-bottom: 16px; }

.f label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--txt-dim);
  margin-bottom: 7px;
}
.f label a { color: var(--ch-spo2); text-decoration: none; }
.f label a:hover { text-decoration: underline; }

.wrap { position: relative; }

.f input[type="text"],
.f input[type="email"],
.f input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--body);
  font-size: 14.5px;
  color: var(--txt);
  background: var(--field-bg);
  border: 1px solid var(--field-line);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.f input::placeholder { color: var(--txt-faint); }

.f input:focus {
  border-color: var(--ch-ecg);
  background: var(--field-focus-bg);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.f .eye {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  border: 0; background: none;
  color: var(--txt-faint);
  cursor: pointer;
  padding: 6px; border-radius: 7px;
  display: grid; place-items: center;
}
.f .eye:hover { color: var(--ch-ecg); background: var(--tint-soft); }

.f-help { font-size: 12px; color: var(--txt-faint); margin-top: 6px; }

.p-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px;
  color: var(--txt-dim);
  margin: 4px 0 20px;
  cursor: pointer;
}
.p-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--ch-ecg); flex: none; }

/* password strength — reads as a signal-quality bar */
.strength { display: flex; gap: 5px; margin-top: 8px; }
.strength i { flex: 1; height: 4px; border-radius: 99px; background: var(--hair); transition: background 0.25s ease; }
.strength[data-score="1"] i:nth-child(-n+1) { background: var(--bad); }
.strength[data-score="2"] i:nth-child(-n+2) { background: var(--ch-resp); }
.strength[data-score="3"] i:nth-child(-n+3) { background: var(--ch-spo2); }
.strength[data-score="4"] i { background: var(--ch-ecg); }

/* ---------- Buttons ---------- */

.p-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 13px 18px;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--btn-txt);
  background: var(--btn-bg);
  border: 0; border-radius: 10px;
  cursor: pointer; text-decoration: none;
  box-shadow: var(--btn-shadow);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.p-btn:hover { filter: brightness(1.07); }
.p-btn:active { transform: translateY(1px); }

.p-alt {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 12px 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--txt-dim);
  background: transparent;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.p-alt:hover { color: var(--txt); border-color: var(--txt-faint); background: var(--tint-soft); }

.p-quiet {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ch-ecg);
  background: none; border: 0;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 7px;
}
.p-quiet:hover { background: var(--brand-soft); }

.p-hr { height: 1px; background: var(--hair); margin: 20px 0 16px; }

.p-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12.5px;
  color: var(--txt-faint);
}
.p-foot a { color: var(--ch-spo2); text-decoration: none; }
.p-foot a:hover { text-decoration: underline; }

/* ---------- OTP: code-entry keys ---------- */

.otp-row { display: flex; gap: 9px; justify-content: space-between; margin: 6px 0 20px; }

.otp-box {
  width: 100%;
  height: 62px;
  text-align: center;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--ch-ecg);
  background: var(--field-bg);
  border: 1px solid var(--field-line);
  border-radius: 10px;
  outline: none;
  caret-color: var(--ch-ecg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.otp-box:focus {
  border-color: var(--ch-ecg);
  background: var(--field-focus-bg);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.otp-box.filled {
  border-color: var(--ch-ecg);
  background: var(--brand-soft);
  box-shadow: 0 0 14px -4px var(--glow-ecg);
}

.resend-line { text-align: center; font-size: 12.5px; color: var(--txt-dim); margin-top: 16px; }
.resend-line .countdown { font-family: var(--mono); color: var(--txt); }
.resend-line a { color: var(--ch-spo2); text-decoration: none; }
.resend-line a:hover { text-decoration: underline; }

/* ---------- Notices, pills, badges ---------- */

.bnote {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; line-height: 1.45;
  border-radius: 10px;
  padding: 12px 13px;
  margin-bottom: 20px;
  border: 1px solid;
}
.bnote svg { flex: none; margin-top: 2px; }
.bnote-info { background: var(--tint-soft); border-color: var(--hair); color: var(--txt-dim); }
.bnote-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.bnote-good { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid;
  margin-bottom: 16px;
}
.pill-wait { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.pill-good { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.pill .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.pill-wait .dot { animation: bulb 1.4s ease infinite; }

/* mail / lock plates */
.plate {
  width: 64px; height: 64px;
  margin: 2px auto 18px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: var(--tint-soft);
  border: 1px solid var(--hair);
  color: var(--ch-spo2);
}

.lock-plate {
  width: 72px; height: 72px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: grid; place-items: center;
  font-family: var(--num);
  font-size: 24px; font-weight: 700; letter-spacing: 0.06em;
  background: var(--ok-soft);
  border: 1px solid var(--ch-ecg);
  color: var(--ch-ecg);
}

/* success ring */
.success-ring {
  width: 68px; height: 68px;
  margin: 2px auto 18px;
  border-radius: 99px;
  background: var(--ok-soft);
  border: 1px solid var(--ok);
  display: grid; place-items: center;
}
.success-ring .check-path {
  stroke: var(--ok);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: check-draw 0.6s 0.2s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
@keyframes check-draw { to { stroke-dashoffset: 0; } }

/* ---------- Progress steps ---------- */

.steps { list-style: none; margin: 6px 0 22px; }

.steps li { position: relative; padding: 0 0 20px 32px; font-size: 13.5px; }
.steps li:last-child { padding-bottom: 0; }

.steps li::before {
  content: "";
  position: absolute; left: 9px; top: 23px; bottom: 2px;
  width: 2px; background: var(--hair);
}
.steps li:last-child::before { display: none; }
.steps li.done::before { background: var(--ok); opacity: 0.55; }

.steps .step-icon {
  position: absolute; left: 0; top: 0;
  width: 20px; height: 20px;
  border-radius: 99px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  background: var(--tint-soft);
  border: 1px solid var(--hair);
  color: var(--txt-faint);
}
.steps li.done .step-icon { background: var(--ok); border-color: var(--ok); color: var(--btn-txt); }
.steps li.doing .step-icon { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.steps li.doing .step-icon::after {
  content: ""; width: 7px; height: 7px; border-radius: 99px;
  background: var(--warn);
  animation: bulb 1.4s ease infinite;
}

.steps .step-title { font-weight: 600; }
.steps .step-sub { font-size: 12px; color: var(--txt-faint); }

/* ---------- Keyline footer ---------- */

.keyline {
  position: relative;
  z-index: 5;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--hair);
  background: var(--strip-bg);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--txt-faint);
}
.keyline .spacer { margin-left: auto; }
.keyline .key { display: inline-flex; align-items: center; gap: 6px; }
.keyline .key .swatch { width: 14px; height: 3px; border-radius: 2px; }
.key-ecg  .swatch { background: var(--ch-ecg); }
.key-spo2 .swatch { background: var(--ch-spo2); }
.key-nibp .swatch { background: var(--ch-nibp); }
.key-resp .swatch { background: var(--ch-resp); }
.keyline a { color: var(--txt-dim); text-decoration: none; }
.keyline a:hover { color: var(--ch-ecg); }

/* ---------- Focus visibility ---------- */

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--ch-ecg);
  outline-offset: 2px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1120px) {
  .stage { grid-template-columns: 1fr 224px; }
  .vital .v-num { font-size: 31px; }
}

@media (max-width: 880px) {
  .bedside { padding: 0; }
  .device { border-radius: 0; border: 0; }
  .stage { grid-template-columns: 1fr; }
  .rail { display: none; }
  .trace-field { min-height: 640px; }
  .lane { height: 72px; }
  .panel-wrap { justify-content: center; padding: 24px 16px; }
  .panel, .panel--wide { max-width: 440px; }
  .hide-sm { display: none !important; }
}

@media (max-width: 520px) {
  .panel, .panel--wide { padding: 24px 20px 22px; }
  .panel h1 { font-size: 22px; }
  .otp-box { height: 54px; font-size: 20px; }
  .otp-row { gap: 6px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .lane .scroll { animation: none; }
  .strip .live .bulb,
  .pill-wait .dot,
  .steps li.doing .step-icon::after { animation: none; }
  .panel { animation: none; }
  .success-ring .check-path { animation: none; stroke-dashoffset: 0; }
  * { transition: none !important; }
}
