:root {
  --navy: #043368;
  --ink: #1f2d44;
  --muted: #6b7892;
  --muted-2: #3f5170;
  --hairline: #dbe2ee;
  --band: #eef2f8;
  --pale: #cdd6e1;
  --disabled-border: #c8d0de;
  --disabled-text: #aab4c6;
  --chevron: #aebacd;
  --white: #ffffff;
  --scan: #00bdff;
  --ok-green: #1f8a4d;
  --ok-text: #1f6b3a;
  --err-bg: #fbe3dd;
  --err-text: #9c3a26;
  --soft: #8aa563;
  --medium: #d8c468;
  --hard: #c07a6e;
  --app-viewport-height: 100vh;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

html {
  touch-action: manipulation;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  color: var(--ink);
  background: #f4f6fa;
  font-family: "Open Sans", "Helvetica Neue", Arial, sans-serif;
}

#root {
  position: fixed;
  inset: 0;
}

button,
input {
  font: inherit;
}

button {
  border-radius: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

.app-page {
  min-height: var(--app-viewport-height);
  display: grid;
  place-items: center;
  padding: 24px;
}

.phone {
  width: min(100%, 390px);
  height: min(844px, calc(var(--app-viewport-height) - 48px));
  min-height: 680px;
  display: flex;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--navy);
}

.screen {
  width: 100%;
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  background: var(--white);
}

.screen-centered {
  justify-content: center;
  padding: 38px 36px;
}

.top-bar {
  min-height: 52px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  background: var(--white);
}

.top-title {
  min-width: 0;
  color: var(--navy);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-trailing {
  min-width: 44px;
  display: flex;
  justify-content: flex-end;
  padding-right: 12px;
}

.back-placeholder {
  width: 44px;
  height: 44px;
}

.back-button,
.top-icon-button {
  width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
}

.back-button span {
  width: 12px;
  height: 12px;
  border-bottom: 2px solid var(--navy);
  border-left: 2px solid var(--navy);
  transform: rotate(45deg);
}

.patient-bar {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  color: var(--muted-2);
  background: var(--band);
  border-bottom: 1px solid var(--hairline);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
}

.patient-bar strong {
  color: var(--navy);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.patient-bar span:not(.mono-code) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-bar > * + *::before {
  content: "·";
  margin-right: 7px;
  color: var(--chevron);
}

.screen-body {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px 20px;
  -webkit-overflow-scrolling: touch;
}

.bottom-action {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--hairline);
  background: var(--white);
}

.button {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--navy);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.button-primary {
  color: var(--white);
  background: var(--navy);
}

.button-secondary {
  color: var(--navy);
  background: var(--white);
}

.button:disabled {
  color: var(--disabled-text);
  background: var(--white);
  border-color: var(--disabled-border);
  cursor: default;
}

.eyebrow,
.field-label {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.screen-title {
  margin: 5px 0 0;
  color: var(--navy);
  font-size: 21px;
  line-height: 1.15;
}

.helper-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.mono-code {
  font-family: "SF Mono", ui-monospace, monospace;
}

.login-screen {
  gap: 18px;
}

.login-mark {
  width: 138px;
  align-self: center;
  margin-bottom: 4px;
}

.login-mark img {
  width: 100%;
  display: block;
}

.login-heading {
  text-align: center;
}

.login-heading h1 {
  margin: 0;
  color: var(--navy);
  font-size: 24px;
  line-height: 1.1;
}

.login-heading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.login-form,
.form-screen,
.action-stack {
  display: grid;
  gap: 14px;
}

.field-block {
  display: grid;
  gap: 7px;
}

.field-shell {
  min-height: 54px;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--navy);
  background: var(--white);
}

.field-shell input {
  min-width: 0;
  width: 100%;
  height: 52px;
  padding: 0 13px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
  font-weight: 600;
}

.field-shell:focus-within {
  box-shadow: inset 0 -2px 0 var(--navy);
}

.field-action {
  height: 52px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 600;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-row input {
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1.5px solid var(--navy);
  background: var(--white);
  position: relative;
}

.checkbox-row input:checked {
  background: var(--navy);
}

.checkbox-row input:checked::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 7px;
  width: 5px;
  height: 10px;
  border-right: 2px solid var(--white);
  border-bottom: 2px solid var(--white);
  transform: rotate(42deg);
}

.quiet-link {
  justify-self: center;
  padding: 6px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 600;
}

.home-content {
  height: 100%;
  display: grid;
  align-content: center;
  gap: 28px;
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.product-tile {
  min-height: 148px;
  display: grid;
  grid-template-rows: 38px 34px 18px;
  justify-items: center;
  align-content: center;
  gap: 6px;
  color: var(--navy);
  background: var(--white);
  border: 1.5px solid var(--navy);
}

.product-tile-icon {
  height: 38px;
  display: grid;
  place-items: center;
}

.product-tile strong {
  align-self: center;
  font-size: 25px;
  letter-spacing: 0.06em;
  line-height: 1;
}

.product-tile small {
  align-self: start;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.chew-dots {
  display: flex;
  gap: 5px;
}

.chew-dots i {
  width: 10px;
  height: 10px;
  display: block;
}

.dot-soft {
  background: var(--soft);
}

.dot-medium {
  background: var(--medium);
}

.dot-hard {
  background: var(--hard);
}

.platter-icon,
.platter-large {
  border: 1.5px solid var(--navy);
  border-radius: 50%;
  position: relative;
}

.platter-icon {
  width: 34px;
  height: 34px;
}

.platter-large {
  width: 46px;
  height: 46px;
}

.platter-icon::after,
.platter-large::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1.5px dashed var(--pale);
  border-radius: 50%;
}

.home-meta {
  display: grid;
  gap: 10px;
}

.settings-row {
  min-height: 54px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--navy);
  background: var(--white);
  border: 1.5px solid var(--navy);
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}

.settings-row-dashed {
  border-style: dashed;
}

.settings-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.settings-icon,
.raw-dot {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
  font-size: 12px;
}

.raw-dot::after {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--navy);
  border-radius: 50%;
}

.version-line {
  color: var(--disabled-text);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
}

.list-screen,
.confirm-screen,
.chew-screen,
.brux-screen,
.upload-screen {
  display: grid;
  gap: 18px;
}

.section-heading-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.quiet-chip,
.status-pill {
  padding: 5px 8px;
  color: var(--navy);
  background: var(--band);
  border: 1px solid var(--hairline);
  font-size: 11px;
  font-weight: 700;
}

.status-pill-ok {
  color: var(--ok-text);
}

.plain-list {
  display: grid;
  border-top: 1px solid var(--hairline);
}

.list-row,
.patient-row {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  color: var(--ink);
  background: var(--white);
  border: 0;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
}

.row-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-time {
  width: 42px;
  color: var(--navy);
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
}

.patient-row strong,
.list-row span:first-child {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.patient-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.row-chevron {
  width: 8px;
  height: 8px;
  border-top: 1.5px solid var(--chevron);
  border-right: 1.5px solid var(--chevron);
  transform: rotate(45deg);
}

.empty-state {
  min-height: 190px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 24px;
  color: var(--muted);
  background: var(--band);
  border: 1px dashed var(--pale);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

.empty-state-small {
  min-height: 140px;
}

.empty-state p {
  margin: 0;
}

.empty-title {
  color: var(--navy);
  font-size: 17px;
  font-weight: 700;
}

.patient-entry-footer {
  display: grid;
  gap: 10px;
}

.patient-entry-footer p {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
}

.tertiary-button {
  min-height: 44px;
  color: var(--navy);
  background: var(--white);
  border: 1px dashed var(--pale);
  font-weight: 700;
}

.patient-card {
  padding: 18px;
  border: 1.5px solid var(--navy);
}

.patient-card h2 {
  margin: 0 0 18px;
  color: var(--navy);
  font-size: 21px;
  line-height: 1.2;
}

.patient-card dl {
  display: grid;
  gap: 13px;
  margin: 0;
}

.patient-card div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 9px;
}

.patient-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.patient-card dd {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1.5px solid var(--navy);
}

.segment {
  min-height: 48px;
  color: var(--navy);
  background: var(--white);
  border: 0;
  border-right: 1px solid var(--hairline);
  font-size: 13px;
  font-weight: 700;
}

.segment:last-child {
  border-right: 0;
}

.segment-active {
  background: var(--band);
  box-shadow: inset 0 -3px 0 var(--navy);
}

.progress-badge {
  padding: 5px 9px;
  color: var(--navy);
  border: 1px solid var(--hairline);
  background: var(--band);
  font-size: 12px;
  font-weight: 700;
}

.grid-labels,
.brux-labels {
  display: grid;
  align-items: end;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.grid-labels {
  grid-template-columns: 0 repeat(3, 1fr);
}

.brux-labels {
  grid-template-columns: 0 repeat(2, 1fr);
}

.chew-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.chew-cell {
  min-height: 104px;
  display: grid;
  grid-template-rows: 7px 1fr auto;
  overflow: hidden;
  color: var(--disabled-text);
  background: var(--white);
  border: 1px dashed var(--pale);
  position: relative;
}

.chew-cell-done {
  color: var(--ink);
  border: 1.5px solid var(--navy);
}

.cell-strip,
.status-strip {
  background: var(--slot-color);
}

.cell-preview {
  background: linear-gradient(180deg, #edf0eb 0%, #eef1ee 60%, #ffffff 60%);
}

.cell-code {
  padding: 9px 4px;
  color: inherit;
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
}

.cell-state {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--ok-green);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.brux-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.brux-cell {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--navy);
  background: var(--white);
  border: 1.5px solid var(--navy);
}

.brux-cell strong {
  font-size: 15px;
}

.capture-screen {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  margin: -24px -20px;
}

.capture-status {
  min-height: 55px;
  display: grid;
  grid-template-columns: 7px repeat(3, 1fr);
  border-bottom: 1px solid var(--hairline);
}

.capture-status-field {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border-right: 1px solid var(--hairline);
}

.capture-status-field:last-child {
  border-right: 0;
}

.capture-status-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.capture-status-field strong {
  color: var(--ink);
  font-size: 13px;
}

.camera-preview {
  min-height: 390px;
  background: #222621;
  position: relative;
  overflow: hidden;
}

.camera-video,
.camera-snapshot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-snapshot {
  z-index: 0;
}

.camera-preview-frozen .camera-video {
  visibility: hidden;
}

.camera-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 1;
}

.camera-preview::before,
.camera-preview::after {
  content: "";
  position: absolute;
  inset: -40px 72px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  transform: rotate(29deg);
  z-index: 1;
  pointer-events: none;
}

.camera-preview::after {
  transform: rotate(-29deg);
}

.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: rgba(255, 255, 255, 0.75);
  z-index: 2;
}

.corner-tl {
  top: 16px;
  left: 16px;
  border-top: 1.5px solid;
  border-left: 1.5px solid;
}

.corner-tr {
  top: 16px;
  right: 16px;
  border-top: 1.5px solid;
  border-right: 1.5px solid;
}

.corner-bl {
  left: 16px;
  bottom: 16px;
  border-bottom: 1.5px solid;
  border-left: 1.5px solid;
}

.corner-br {
  right: 16px;
  bottom: 16px;
  border-right: 1.5px solid;
  border-bottom: 1.5px solid;
}

.plate-frame {
  position: absolute;
  top: 22%;
  left: 13%;
  right: 13%;
  bottom: 22%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  border: 1.5px dashed rgba(255, 255, 255, 0.7);
  z-index: 2;
}

.calibration-dot {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--scan);
  border-radius: 50%;
  background: rgba(0, 189, 255, 0.3);
}

.calibration-dot-missing {
  background: transparent;
  border-color: #d39a9a;
  outline: 1px dashed var(--err-text);
  outline-offset: 3px;
}

.scan-chips {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 16px;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 3;
}

.scan-chip {
  padding: 5px 9px;
  background: var(--white);
  font-size: 11px;
  font-weight: 700;
}

.scan-chip-ok {
  color: var(--ok-text);
}

.scan-chip-error {
  color: var(--err-text);
  background: var(--err-bg);
}

.capture-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.upload-steps {
  display: grid;
  gap: 20px;
  padding: 12px 0;
}

.upload-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
}

.step-dot {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--disabled-text);
  border: 1.5px solid var(--disabled-border);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.step-dot-done {
  color: var(--white);
  background: var(--navy);
  border-color: var(--navy);
}

.upload-step strong,
.upload-step small {
  display: block;
}

.upload-step strong {
  color: var(--ink);
  font-size: 16px;
}

.upload-step small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.upload-result {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--hairline);
  font-size: 13px;
  line-height: 1.45;
}

.upload-result strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.upload-result p {
  margin: 0;
}

.upload-result-ok {
  color: var(--ok-text);
  background: #f0f8f3;
}

.upload-result-error {
  color: var(--err-text);
  background: var(--err-bg);
}

.demo-state-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.demo-state-row legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.demo-state-row button {
  min-height: 34px;
  color: var(--muted);
  background: var(--white);
  border: 1px dashed var(--pale);
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 440px), (max-height: 720px) {
  .app-page {
    display: block;
    padding: 0;
  }

  .phone {
    width: 100vw;
    min-height: var(--app-viewport-height);
    height: var(--app-viewport-height);
    border: 0;
  }
}

@media (max-height: 760px) and (min-width: 441px) {
  .phone {
    min-height: calc(var(--app-viewport-height) - 32px);
    height: calc(var(--app-viewport-height) - 32px);
  }

  .app-page {
    padding: 16px;
  }
}
