/* The mobile app. Classes are prefixed "osm-"; colours come from the module's --ost-* tokens
   (themed by the host). Touch targets are at least 48px; inputs are 16px so phones do not zoom. */

.osm-app {
  position: fixed;
  inset: 0;
  /* Above the host's chrome and floating buttons: the app takes the screen. */
  z-index: 100000;
  background: rgb(0 0 0 / 0.6);
  display: flex;
  justify-content: center;
  overscroll-behavior: contain;
}
.osm-frame {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 100%;
  background: var(--ost-bg);
  color: var(--ost-text);
  font-size: 16px;
  box-shadow: 0 0 40px rgb(0 0 0 / 0.5);
}
.osm-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.osm-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  border-bottom: 1px solid var(--ost-border);
  background: var(--ost-surface);
}
.osm-head h1 {
  flex: 1;
  font-size: 19px !important;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.osm-head-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--ost-primary);
  color: var(--ost-primary-ink);
}
.osm-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}
.osm-body > *,
.osm-form > *,
.osm-stack > * {
  flex-shrink: 0;
}
.osm-foot {
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px);
  border-top: 1px solid var(--ost-border);
  background: var(--ost-surface);
}
.osm-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.osm-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.osm-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.osm-inline .osm-input {
  flex: 1;
}
.osm-small {
  font-size: 14px;
}
.osm-muted {
  color: var(--ost-muted);
}
.osm-lead {
  color: var(--ost-muted);
  margin: 0 !important;
}
.osm-h {
  margin: 6px 0 -4px !important;
}
.osm-link {
  background: none;
  border: 0;
  color: var(--ost-primary);
  font: inherit;
  padding: 8px 0;
  cursor: pointer;
  text-align: left;
}

/* Buttons */
.osm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.osm-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.osm-btn-primary {
  background: var(--ost-primary);
  color: var(--ost-primary-ink);
}
.osm-btn-ghost {
  background: var(--ost-surface-2);
  color: var(--ost-text);
  border-color: var(--ost-border);
}
.osm-btn-danger {
  background: transparent;
  color: var(--ost-red);
  border-color: var(--ost-red);
}
.osm-round {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--ost-border);
  background: var(--ost-surface-2);
  color: var(--ost-text);
  cursor: pointer;
}
.osm-round-solid {
  background: var(--ost-primary);
  color: var(--ost-primary-ink);
  border-color: transparent;
}
.osm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Scan field */
.osm-scanbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 14px;
  border-radius: 16px;
  border: 2px solid var(--ost-primary);
  background: var(--ost-surface);
}
.osm-scanbar > .ost-icon {
  color: var(--ost-primary);
}
.osm-app .osm-scanbar input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ost-text);
  font-size: 17px;
  font-family: ui-monospace, monospace;
}
.osm-scanbar-go,
.osm-scanbar-cam {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
}
.osm-scanbar-go {
  background: var(--ost-surface-2);
  color: var(--ost-text);
}
.osm-scanbar-cam {
  background: var(--ost-primary);
  color: var(--ost-primary-ink);
}

/* Camera */
.osm-camera {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: #000;
}
.osm-camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.osm-camera-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72vw, 320px);
  height: min(50vw, 220px);
  transform: translate(-50%, -50%);
  border: 3px solid var(--ost-primary);
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.45);
}
.osm-camera-top {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.osm-camera-hint {
  flex: 1;
  color: #fff;
  text-align: center;
  font-weight: 600;
  text-shadow: 0 1px 3px #000;
}
.osm-camera-last {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ost-green);
  color: #000;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

/* Tiles and rows */
.osm-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.osm-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 116px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--ost-border);
  background: var(--ost-surface);
  color: var(--ost-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.osm-tile:active,
.osm-row:active {
  transform: scale(0.98);
}
.osm-tile small {
  color: var(--ost-muted);
  font-size: 13px;
}
.osm-tile-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
}
.osm-list {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--ost-border);
  background: var(--ost-surface);
  overflow: hidden;
}
.osm-list:empty {
  display: none;
}
.osm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--ost-border);
  background: transparent;
  color: var(--ost-text);
  font: inherit;
  text-align: left;
}
.osm-row:last-child {
  border-bottom: 0;
}
button.osm-row {
  cursor: pointer;
}
.osm-row-on {
  background: color-mix(in srgb, var(--ost-primary) 14%, transparent);
}
.osm-row-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ost-surface-2);
  color: var(--ost-muted);
  flex-shrink: 0;
}
.osm-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.osm-row-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.osm-row-sub {
  color: var(--ost-muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.osm-row-right {
  flex-shrink: 0;
  font-weight: 700;
}
.osm-row-chev,
.osm-row-check {
  color: var(--ost-muted);
}
.osm-row-check {
  color: var(--ost-primary);
}
.osm-pick-list {
  max-height: 320px;
  overflow-y: auto;
}
.osm-code {
  color: var(--ost-muted);
  font-size: 13px;
}
.osm-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ost-surface-2);
  color: var(--ost-text);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.osm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 12px;
  color: var(--ost-muted);
  text-align: center;
}
.osm-empty .ost-icon {
  font-size: 40px;
}

/* Forms */
.osm-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.osm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.osm-field > span {
  font-size: 14px;
  font-weight: 600;
  color: var(--ost-muted);
}
.osm-field > small {
  color: var(--ost-muted);
  font-size: 13px;
}
/* Prefixed with .osm-app to win over the host's form resets ([type="search"] etc.). */
.osm-app .osm-input,
.osm-app .osm-legacy-field .ost-input {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--ost-border);
  background: var(--ost-surface);
  color: var(--ost-text);
  font: inherit;
  font-size: 16px;
}
textarea.osm-input {
  min-height: 90px;
}
.osm-app .osm-input:focus {
  outline: 2px solid var(--ost-primary);
  outline-offset: -1px;
}
.osm-legacy-field .ost-field > span {
  font-size: 14px;
  font-weight: 600;
  color: var(--ost-muted);
}
.osm-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.osm-check input {
  width: 22px;
  height: 22px;
  accent-color: var(--ost-primary);
}
.osm-seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--ost-surface-2);
  overflow-x: auto;
}
.osm-seg button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ost-muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
  cursor: pointer;
}
.osm-seg .osm-seg-on {
  background: var(--ost-surface);
  color: var(--ost-text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
}
.osm-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.osm-stepper button {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  border: 1px solid var(--ost-border);
  background: var(--ost-surface-2);
  color: var(--ost-text);
  cursor: pointer;
  touch-action: manipulation;
}
.osm-app .osm-stepper input {
  flex: 1;
  min-width: 0;
  height: 60px;
  border-radius: 16px;
  border: 1px solid var(--ost-border);
  background: var(--ost-surface);
  color: var(--ost-text);
  text-align: center;
  font-size: 26px;
  font-weight: 800;
}
.osm-stepper-unit {
  color: var(--ost-muted);
}

/* Item */
.osm-hero,
.osm-photo-pick img,
.osm-photo-pick .osm-hero-none {
  border-radius: 16px;
  overflow: hidden;
  background: var(--ost-surface-2);
}
.osm-hero img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
}
.osm-hero-none {
  display: grid;
  place-items: center;
  height: 140px;
  color: var(--ost-muted);
}
.osm-hero-none .ost-icon {
  font-size: 48px;
}
.osm-photo-pick {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  align-items: center;
}
.osm-photo-pick img,
.osm-photo-pick .osm-hero-none {
  width: 110px;
  height: 110px;
  object-fit: cover;
}
.osm-title {
  font-size: 22px !important;
  margin: 0 !important;
}
.osm-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -6px;
}
.osm-label {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed var(--ost-border);
}
.osm-label .ost-qr {
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}
.osm-problem {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ost-red) 15%, transparent);
  color: var(--ost-text);
}
.osm-problem > .ost-icon {
  color: var(--ost-red);
}
.osm-problem p {
  margin: 0 !important;
}
.osm-problem-limit {
  background: color-mix(in srgb, var(--ost-amber) 18%, transparent);
}
.osm-problem-limit > .ost-icon {
  color: var(--ost-amber);
}

/* Counts */
.osm-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.osm-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--ost-surface-2);
  overflow: hidden;
}
.osm-bar span {
  display: block;
  height: 100%;
  background: var(--ost-green);
  transition: width 0.2s;
}
.osm-ok {
  color: var(--ost-green);
}
.osm-pos {
  color: var(--ost-amber);
}
.osm-neg {
  color: var(--ost-red);
}
.osm-sheet-back {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgb(0 0 0 / 0.55);
  display: flex;
  align-items: flex-end;
}
.osm-sheet {
  width: 100%;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  border-radius: 20px 20px 0 0;
  background: var(--ost-surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.osm-sheet h2 {
  font-size: 18px !important;
}

/* Toasts */
.osm-toasts {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 86px);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.osm-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.4);
}
.osm-toast-ok {
  background: var(--ost-green);
  color: #000;
}
.osm-toast-err {
  background: var(--ost-red);
  color: #000;
}
