/*
 * Novatide Warehouse — phone app styles.
 * Mobile-first (360–430 px), one-handed, gloves: every target ≥ 48 px, the
 * main actions 56–64 px; high contrast for bright docks and dim aisles.
 * Neutral palette with one accent (blue); status colours are semantic only.
 * Inputs are ≥ 16 px so iOS never zooms the page when a field gets focus.
 */

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --text: #101418;
  --muted: #4b5563;
  --border: #c9d0d7;
  --border-strong: #8a96a3;

  --accent: #0b57d0;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecfb;
  --accent-strong: #0842a0;

  --ok: #135c27;
  --ok-bg: #e2f3e7;
  --ok-strong: #1a7f37;
  --danger: #a1201a;
  --danger-bg: #fde7e6;
  --danger-strong: #b3261e;
  --danger-btn: #b3261e;
  --warn: #6b4100;
  --warn-bg: #fff2d1;
  --warn-strong: #f0a500;
  --warn-ink: #1d1300;
  --info-bg: #e3ecfb;

  --focus: #0b57d0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 24, 0.08), 0 4px 12px rgba(16, 20, 24, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --surface: #182027;
    --surface-2: #212b34;
    --text: #eef2f6;
    --muted: #aab5c0;
    --border: #34414d;
    --border-strong: #5d6d7c;

    --accent: #7cacf8;
    --accent-ink: #0a1a33;
    --accent-soft: #1c3253;
    --accent-strong: #a8c7fa;

    --ok: #8fdc9f;
    --ok-bg: #123320;
    --ok-strong: #3fb760;
    --danger: #ffb4ab;
    --danger-bg: #461412;
    --danger-strong: #e5534b;
    --warn: #ffd27a;
    --warn-bg: #3b2a05;
    --info-bg: #1c3253;

    --focus: #a8c7fa;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);

    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

p,
h1,
h2,
h3 {
  margin: 0;
}

a {
  color: var(--accent);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
a,
input,
.tile,
.choice,
.keypad-key {
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 24px;
  height: 24px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

.small .icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

/* ── Shell ─────────────────────────────────────────────────────────────── */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 6px calc(12px + env(safe-area-inset-left, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.appbar-back {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  margin-left: -6px;
}

.appbar-back:active {
  background: var(--surface-2);
}

.appbar-back .icon {
  width: 28px;
  height: 28px;
}

.appbar-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.appbar-brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-title:focus {
  outline: none;
}

.wh-chip {
  flex: none;
  min-height: 44px;
  min-width: 64px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.wh-chip.is-editable::after {
  content: " ▾";
  font-size: 14px;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px calc(16px + env(safe-area-inset-right, 0px)) 24px calc(16px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main:focus {
  outline: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack:empty {
  display: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer {
  margin-top: auto;
  padding: 16px 0 4px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.btn-lg {
  min-height: 56px;
  font-size: 18px;
}

.btn-xl {
  min-height: 64px;
  font-size: 20px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-btn);
  color: #ffffff;
}

.btn-warn {
  background: var(--warn-strong);
  color: var(--warn-ink);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding-left: 10px;
  padding-right: 10px;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
  filter: brightness(0.94);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.is-busy {
  opacity: 0.75;
  cursor: progress;
}

.btn.is-busy::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

.btn.is-busy .icon {
  display: none;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Lists and rows ────────────────────────────────────────────────────── */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list > li + li {
  border-top: 1px solid var(--border);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
}

.row-link {
  cursor: pointer;
}

.row-link:active {
  background: var(--surface-2);
}

.row-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.row > .icon {
  color: var(--muted);
}

.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-title {
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-sub,
.row-meta {
  font-size: 15px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row-meta.is-danger {
  color: var(--danger);
}

.row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.qty-big {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.plain-list {
  margin: 0;
  padding-left: 20px;
}

.plain-list li + li {
  margin-top: 4px;
}

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
}

.chip {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.chip-accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
}

.chip-ok,
.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.chip-warn,
.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--accent-strong);
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.chip-ok,
.chip-warn {
  border-color: transparent;
  white-space: normal;
}

/* ── Banners, loading, empty ───────────────────────────────────────────── */

.banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid;
}

.banner-title {
  font-size: 18px;
  font-weight: 800;
}

.banner-info {
  background: var(--info-bg);
  border-color: var(--accent);
}

.banner-ok {
  background: var(--ok-bg);
  border-color: var(--ok-strong);
}

.banner-warn {
  background: var(--warn-bg);
  border-color: var(--warn-strong);
}

.banner-danger {
  background: var(--danger-bg);
  border-color: var(--danger-strong);
}

.banner .btn {
  align-self: stretch;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 16px;
  color: var(--muted);
}

.spinner {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  list-style: none;
}

.form-error {
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.form-error:empty {
  display: none;
}

/* ── Fields ────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
}

.text-input,
.scan-input {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
}

.text-input:focus,
.scan-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 0;
}

.details dt {
  color: var(--muted);
  font-weight: 600;
}

.details dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ── Home ──────────────────────────────────────────────────────────────── */

.hello {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hello-name {
  font-size: 26px;
  font-weight: 800;
}

.wh-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.wh-card-name {
  font-size: 22px;
  font-weight: 800;
}

.attention {
  background: var(--warn-bg);
  border: 2px solid var(--warn-strong);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 124px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.tile:active {
  border-color: var(--accent);
  background: var(--surface-2);
}

.tile-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tile-icon .icon {
  width: 30px;
  height: 30px;
}

.tile-issues .tile-icon {
  background: var(--warn-bg);
  color: var(--warn);
}

.tile-label {
  font-size: 20px;
  font-weight: 800;
}

.tile-hint {
  font-size: 15px;
  color: var(--muted);
}

/* ── Login and sign-in link ────────────────────────────────────────────── */

.login {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.login-app {
  font-size: 24px;
  font-weight: 800;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 8px 0;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
}

.pin-dot.is-filled {
  background: var(--text);
  border-color: var(--text);
}

.link-page {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.link-status {
  font-size: 24px;
}

.link-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Keypads (quantity sheet and PIN) ──────────────────────────────────── */

.keypad-grid,
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.keypad-key {
  min-height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
}

.keypad-key:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.keypad-key.is-fn {
  font-size: 20px;
  color: var(--muted);
}

.keypad-key .icon {
  width: 30px;
  height: 30px;
}

.keypad-top {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  gap: 8px;
}

.keypad-step {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.keypad-step .icon {
  width: 28px;
  height: 28px;
}

.keypad-display {
  min-height: 72px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: var(--surface-2);
  overflow: hidden;
}

.keypad-value {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.keypad-value.is-placeholder {
  color: var(--muted);
}

.keypad-value.is-selected {
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0 6px;
}

.keypad-unit {
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
}

.keypad-message {
  min-height: 1.4em;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.keypad-message.is-error {
  color: var(--danger);
}

.keypad-message.is-warn {
  color: var(--warn);
}

.keypad-note {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--info-bg);
  font-size: 16px;
}

.keypad-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.keypad-extra .btn {
  flex: 1;
}

@media (max-height: 700px) {
  .keypad-key {
    min-height: 54px;
  }

  .keypad-step,
  .keypad-display {
    min-height: 60px;
  }

  .keypad-value {
    font-size: 32px;
  }
}

/* ── Scanner ───────────────────────────────────────────────────────────── */

.scanner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scanner-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000000;
}

.scanner.is-compact .scanner-viewport {
  aspect-ratio: 16 / 9;
}

.scanner-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The frame marks the region that is decoded (centre 80% × 50% of the picture). */
.scanner-frame {
  position: absolute;
  inset: 25% 10%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.scanner-line {
  position: absolute;
  top: 50%;
  left: 6%;
  right: 6%;
  height: 2px;
  background: #ff3b30;
  box-shadow: 0 0 8px #ff3b30;
}

.scanner.is-busy .scanner-frame {
  border-color: #ffd60a;
}

.scanner-tools {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 8px;
}

.scanner-tool {
  min-height: 48px;
  min-width: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.scanner-tool.is-on {
  background: #ffd60a;
  color: #1d1300;
}

.scanner-status {
  font-size: 16px;
  color: var(--muted);
}

.scanner-status:empty {
  display: none;
}

.scanner-status.is-warn {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
}

.scan-entry {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scan-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

.scan-entry-row {
  display: flex;
  gap: 8px;
}

.scan-input {
  flex: 1;
  min-width: 0;
}

.scan-go {
  min-width: 72px;
  min-height: 56px;
}

/* ── Document and item lines ───────────────────────────────────────────── */

.doc-number {
  font-size: 24px;
  font-weight: 800;
}

.doc-partner {
  font-size: 18px;
  font-weight: 600;
}

.claim-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.line {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  scroll-margin: 80px 0 96px;
}

.line-btn {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.line-btn:disabled {
  cursor: default;
}

.line-btn > .icon {
  color: var(--muted);
}

.line-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.line-desc {
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.line-code {
  font-size: 15px;
  color: var(--muted);
}

.line-reason {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

.line-stock {
  font-size: 15px;
  color: var(--muted);
}

.line-stock.is-warn {
  color: var(--warn);
  font-weight: 800;
}

.line-qty {
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.line-qty-main {
  font-size: 18px;
  white-space: nowrap;
}

.line-qty-main strong {
  font-size: 26px;
}

.line-qty-uom {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.progress {
  width: 96px;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease-out;
}

.line.is-done {
  border-color: var(--ok-strong);
}

.line.is-done .progress-fill {
  background: var(--ok-strong);
}

.line.is-over {
  border-color: var(--warn-strong);
}

.line.is-blocked {
  border-style: dashed;
  background: var(--surface-2);
}

.line.is-blocked .line-desc,
.line.is-blocked .line-qty {
  opacity: 0.6;
}

.line.is-highlight {
  box-shadow: 0 0 0 3px var(--accent);
}

/* ── Choices, tabs, tables ─────────────────────────────────────────────── */

.choice-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.choice:active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.choice > .icon {
  color: var(--muted);
}

.choice-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.choice-label {
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.choice-sub {
  font-size: 15px;
  color: var(--muted);
}

.choice-note {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.choice-tile {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 14px;
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.choice-tile.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.choice-tile-code {
  font-size: 22px;
  font-weight: 800;
}

.choice-tile-name {
  font-size: 15px;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.tab {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.marker {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: all;
  -webkit-user-select: all;
}

.item-name {
  font-size: 22px;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.stock-table th,
.stock-table td {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.stock-table td.is-key {
  font-weight: 800;
}

.stock-table th:first-child {
  text-align: left;
}

.stock-table thead th {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
}

.stock-table tr.is-current {
  background: var(--accent-soft);
  font-weight: 800;
}

.stock-table .is-negative {
  color: var(--danger);
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-results {
  min-height: 120px;
}

/* ── Result panel ──────────────────────────────────────────────────────── */

.status-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 20px;
  border: 3px solid;
  border-radius: 18px;
  text-align: center;
}

.status-icon {
  width: 56px;
  height: 56px;
  stroke-width: 2.5;
}

.status-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
}

.status-lead,
.status-doc {
  font-size: 22px;
  font-weight: 800;
}

.status-hint {
  font-size: 16px;
}

.status-ok {
  background: var(--ok-bg);
  border-color: var(--ok-strong);
  color: var(--ok);
}

.status-danger {
  background: var(--danger-bg);
  border-color: var(--danger-strong);
  color: var(--danger);
}

/* Uncertain: a solid amber panel nobody can mistake for "done" or "failed". */
.status-warn {
  background: var(--warn-strong);
  border-color: #a86f00;
  color: var(--warn-ink);
}

.status-info {
  background: var(--info-bg);
  border-color: var(--accent);
  color: var(--text);
}

.status-neutral {
  background: var(--surface);
  border-color: var(--border);
}

/* ── Action bar (sticky bottom) ────────────────────────────────────────── */

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 78%, rgba(0, 0, 0, 0));
}

.actionbar:empty {
  display: none;
}

.actionbar .actionbar-main {
  flex: 1;
}

.actionbar-static {
  position: static;
  background: none;
}

/* ── Bottom sheets (<dialog>) ──────────────────────────────────────────── */

dialog.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 94vh;
  max-height: 94dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

dialog.sheet::backdrop {
  background: rgba(10, 14, 18, 0.55);
}

.sheet-panel {
  max-height: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0 12px;
}

.sheet-titles {
  flex: 1;
  min-width: 0;
}

.sheet-title {
  font-size: 22px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.sheet-subtitle {
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.sheet-close {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.sheet-content,
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet-message {
  font-size: 18px;
}

.sheet-foot {
  position: sticky;
  bottom: calc(-16px - env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 0 0;
  background: var(--surface);
}

.sheet-foot > :only-child {
  grid-column: 1 / -1;
}

/* ── Update ready bar (stays until Reload is tapped) ───────────────────── */

.update-banner {
  position: sticky;
  top: max(64px, calc(60px + env(safe-area-inset-top, 0px)));
  z-index: 19;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px calc(12px + env(safe-area-inset-right, 0px)) 10px calc(12px + env(safe-area-inset-left, 0px));
  background: var(--info-bg);
  border-bottom: 2px solid var(--accent);
  font-weight: 600;
}

.update-banner-text {
  flex: 1;
  min-width: 0;
}

.update-banner-action {
  flex: none;
}

/* ── Toasts ────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}

.toast {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #1f2933;
  color: #ffffff;
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  animation: toast-in 0.16s ease-out;
}

.toast-ok {
  background: #135c27;
}

.toast-danger {
  background: #9b1c15;
}

.toast-warn {
  background: #f0a500;
  color: #1d1300;
}

.toast-text {
  flex: 1;
  overflow-wrap: anywhere;
}

.toast-action {
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid currentColor;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-weight: 800;
  cursor: pointer;
}

.toast.is-leaving {
  opacity: 0;
  transition: opacity 0.18s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.noscript {
  padding: 16px;
}

/* ── Larger screens and motion preferences ─────────────────────────────── */

@media (min-width: 700px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  dialog.sheet {
    margin: auto;
  }

  .sheet-panel {
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
