:root {
  --navy: #0c3038;
  --teal: #1b7d76;
  --teal-deep: #145c58;
  --mint: #a8d5ce;
  --cream: #f8f4ec;
  --ivory: #fffcf6;
  --ink: #1a292e;
  --muted: #5e7076;
  --gold: #c49a4a;
  --coral: #b85444;
  --soft: #e8f3f0;
  --card: #ffffff;
  --blush: #f8ebe6;
  --ok: #1f7a4d;
  --warn: #b07a12;
  --bad: #b85444;
  --line: #d9e3df;
  --fs: 16px;
  --radius: 18px;
  --nav-h: 72px;
  --safe: 12px;
  font-family: "Segoe UI", "Noto Sans Devanagari", "Noto Sans", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  height: 100dvh;
  max-width: 100%;
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: #e7eee9;
  color: var(--ink);
  font-size: var(--fs);
  line-height: 1.35;
  overflow: hidden;
}

button, select { font: inherit; color: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; }

.stage {
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 28px;
  padding: 20px 24px;
  min-width: 0;
}

.judge {
  width: 340px;
  flex: 0 0 340px;
  overflow: auto;
  padding: 8px 4px 24px;
}
.judge h1 {
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--navy);
  margin-bottom: 4px;
}
.judge .lede { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.judge h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-deep);
  margin: 18px 0 8px;
}
.judge p { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .jbtn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  cursor: pointer;
}
.jbtn { border-radius: 12px; text-align: left; width: 100%; }
.chip.on, .jbtn.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.jbtn:hover { border-color: var(--teal); }
.judge .note {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink);
  margin-bottom: 8px;
}

.phone-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.phone {
  width: 390px;
  height: min(844px, calc(100vh - 40px));
  background: var(--cream);
  border: 10px solid #1a2c30;
  border-radius: 40px;
  box-shadow: 0 24px 60px rgba(12, 48, 56, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  flex: 0 0 auto;
}
.notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 118px;
  height: 18px;
  background: #1a2c30;
  border-radius: 12px;
  z-index: 8;
  pointer-events: none;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--cream);
  position: relative;
}
.app.elder { --fs: 17.5px; }
.app.hc {
  --cream: #fff;
  --ivory: #fff;
  --muted: #2b3b40;
  --line: #1a292e;
}
.app.offline-on .offline-banner { display: block; }

.top {
  flex: 0 0 auto;
  padding: 28px 16px 10px;
  background: var(--navy);
  color: #f4faf8;
  z-index: 3;
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--teal);
  display: grid;
  place-items: center;
}
.logo svg { width: 16px; height: 16px; color: #fff; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.on { background: var(--coral); }
.who { font-size: 12px; color: #c5ddd8; }
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 4px 8px;
}
.offline-banner {
  display: none;
  margin-top: 8px;
  background: #3d4a2a;
  color: #f3e7b4;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 18px;
}

.nav {
  flex: 0 0 var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: var(--ivory);
  padding: 6px 4px 10px;
  z-index: 4;
}
.nav button {
  background: none;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  padding: 10px 2px 6px;
  min-height: 56px;
  cursor: pointer;
  position: relative;
}
.nav button.on { color: var(--teal-deep); font-weight: 700; }
.nav svg { width: 22px; height: 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 { font-size: 15px; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.hero-dose {
  background: var(--navy);
  color: #fff;
  border: 0;
}
.hero-dose h2 { font-size: 22px; line-height: 1.2; margin: 6px 0 10px; letter-spacing: -0.02em; }
.hero-dose .muted { color: #c9ddd8; }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 48px;
  cursor: pointer;
  font-weight: 700;
  width: 100%;
}
.app.elder .btn { min-height: 56px; font-size: 17px; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.gold { background: var(--gold); color: #1a292e; }
.btn.danger { background: var(--coral); color: #fff; }
.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
}
.btn.soft { background: var(--soft); color: var(--teal-deep); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm { min-height: 40px; padding: 8px 10px; font-size: 13px; width: auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}
.pill.ok { background: #e4f6ea; color: var(--ok); }
.pill.warn { background: #fff3d6; color: #8a5b00; }
.pill.bad { background: var(--blush); color: var(--coral); }
.pill.teal { background: var(--soft); color: var(--teal-deep); }
.pill.gray { background: #eef2f1; color: var(--muted); }

.dose-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.dose-item:last-child { border-bottom: 0; padding-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mint); }
.dot.due { background: var(--gold); }
.dot.miss { background: var(--coral); }
.dot.done { background: var(--ok); }

.sample {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
}
.sample:hover, .sample.on { border-color: var(--teal); background: var(--soft); }
.strip {
  width: 54px;
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(90deg, #d7ece8, #f3f7f5 55%, #d7ece8);
  border: 1px solid #b7cdc8;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  flex: 0 0 54px;
}
.strip i {
  width: 8px;
  height: 20px;
  border-radius: 4px;
  background: #f4f0e6;
  border: 1px solid #c9c2b2;
  display: block;
}
.strip.pink { background: linear-gradient(90deg, #f3d0d4, #fff 55%, #f3d0d4); }
.strip.blur { filter: blur(1.4px); opacity: 0.85; }
.pill-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f4f0e6;
  border: 1px solid #c9c2b2;
  flex: 0 0 36px;
}

.viewfinder {
  position: relative;
  height: 220px;
  border-radius: 18px;
  overflow: hidden;
  background: #122326;
  color: #fff;
  margin-bottom: 12px;
}
.viewfinder video, .viewfinder canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}
.vf-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.frame {
  position: absolute;
  inset: 28px 36px;
  border: 2px solid rgba(168, 213, 206, 0.9);
  border-radius: 14px;
  pointer-events: none;
}
.vf-caption {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  font-size: 12px;
  background: rgba(0,0,0,0.45);
  border-radius: 10px;
  padding: 6px 8px;
}
.frames {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 8px 0 12px;
}
.frames span {
  height: 38px;
  border-radius: 8px;
  background: #d5e4e0;
  border: 2px solid transparent;
}
.frames span.sharp { border-color: var(--ok); background: #bfe6cc; }
.frames span.blurry { filter: blur(1px); opacity: 0.6; }

.meter {
  height: 8px;
  background: #e4ece9;
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 0 4px;
}
.meter > i { display: block; height: 100%; background: var(--teal); }
.meter.warn > i { background: var(--gold); }
.meter.bad > i { background: var(--coral); }

.banner {
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 14px;
}
.banner.ok { background: #e4f6ea; color: #135c32; }
.banner.warn { background: #fff3d6; color: #6d4b00; }
.banner.bad { background: var(--blush); color: #7a2e24; }
.banner.teal { background: var(--soft); color: var(--teal-deep); }

.med-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  width: 100%;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  text-align: left;
  cursor: pointer;
}
.med-row:last-child { border-bottom: 0; }
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  flex: 0 0 42px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 8px 6px;
  min-height: 40px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.box-grid {
  display: grid;
  grid-template-columns: 52px repeat(3, 1fr);
  gap: 6px;
  font-size: 11px;
}
.box-grid b { font-size: 10px; color: var(--muted); text-align: center; }
.cell {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 46px;
  padding: 4px;
  cursor: pointer;
}
.cell.on { outline: 2px solid var(--teal); }
.cell small { display: block; font-size: 9px; color: var(--teal-deep); }

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.switch {
  width: 46px;
  height: 26px;
  border-radius: 99px;
  background: #c5d0cd;
  border: 0;
  position: relative;
  cursor: pointer;
  flex: 0 0 46px;
}
.switch.on { background: var(--teal); }
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
}
.switch.on i { left: 23px; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 48, 56, 0.52);
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet {
  background: var(--ivory);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px 28px;
  max-height: 86%;
  overflow: auto;
}
.sheet h2 { font-size: 18px; margin-bottom: 8px; }

.toast {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h) + 12px);
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  z-index: 7;
  font-size: 13px;
  pointer-events: none;
}

.progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 12px;
}
.progress li {
  list-style: none;
  font-size: 13px;
  padding-left: 22px;
  position: relative;
}
.progress li::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint);
  position: absolute;
  left: 4px;
  top: 5px;
}
.progress li.done::before { background: var(--ok); }
.progress li.run::before { background: var(--gold); }

.family-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
}

.kbd {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.kbd button {
  background: var(--soft);
  border: 0;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}

.passport-photo {
  height: 88px;
  border-radius: 14px;
  background: var(--soft);
  display: grid;
  place-items: center;
  margin-bottom: 10px;
}

.emer {
  background: #fff;
  border: 3px solid var(--coral);
  border-radius: 16px;
  padding: 14px;
}
.emer h2 { color: var(--coral); }

.hidden { display: none !important; }

@media (max-width: 860px) {
  .stage { padding: 0; gap: 0; }
  .judge { display: none; }
  .phone-wrap, .phone, .app {
    width: 100%;
    max-width: 100%;
    height: 100%;
  }
  .phone {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .notch { display: none; }
}
