@font-face {
  font-family: Commissioner;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/Commissioner-Regular.woff2') format('woff2');
}
@font-face {
  font-family: Commissioner;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/Commissioner-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: Onest;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/Onest-Bold.woff2') format('woff2');
}

/* The SPS app's palette and radii (app/lib/core/ui/app_tokens.dart). */
:root {
  --bg: #f7f5f1;
  --card: #ffffff;
  --chip: #f1f0eb;
  --track: #ecebe6;
  --line: #e4e6e3;
  --field-border: #858a86;
  --text1: #1d2327;
  --text2: #3f4549;
  --text3: #646b70;
  --primary: #027f2e;
  --primary-deep: #026226;
  --forest: #0f2a19;
  --success-bg: #e8f5ec;
  --danger: #b23a25;
  --danger-bg: #fbe9e5;
  --warn: #8a6414;
  --warn-bg: #f7eed6;
  --info: #2b5d8f;
  --info-bg: #eef2f8;
  --radius-control: 14px;
  --radius-tile: 12px;
  --radius-sheet: 24px;
  --band-height: 0px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text1);
  font: 400 1rem/1.45 Commissioner, system-ui, sans-serif;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}

.band :focus-visible,
.login h1 :focus-visible {
  outline-color: #fff;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 30rem;
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
}

/* Fields */

label,
legend {
  display: block;
  margin-bottom: 0.3rem;
  padding: 0;
  color: var(--text2);
  font-size: 0.875rem;
  font-weight: 600;
}

input:not([type='radio']):not([type='file']),
textarea,
select {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-control);
  background: var(--card);
  color: inherit;
  font: inherit;
}

textarea {
  height: 100%;
  resize: none;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text2) 50%),
    linear-gradient(135deg, var(--text2) 50%, transparent 50%);
  background-position:
    calc(100% - 1.25rem) 50%,
    calc(100% - 0.95rem) 50%;
  background-size: 0.3rem 0.3rem;
  background-repeat: no-repeat;
}

.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.error {
  color: var(--danger);
  font-size: 0.9375rem;
}

.error:empty {
  display: none;
}

.muted {
  color: var(--text3);
}

.small {
  font-size: 0.875rem;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.primary {
  width: 100%;
  min-height: 3.25rem;
  background: var(--primary);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--primary-deep);
}

.secondary {
  border-color: var(--field-border);
  background: var(--card);
  color: var(--text1);
}

.on-dark {
  background: #fff;
  color: var(--forest);
}

.small-button {
  min-height: 2.75rem;
  padding-inline: 0.8rem;
  font-size: 0.875rem;
}

.link-button {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary-deep);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.link-button:has(input:focus-visible) {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}

.link-button.danger {
  color: var(--danger);
}

.round {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 14%);
  color: #fff;
  cursor: pointer;
}

.round[aria-pressed='true'] {
  background: #fff;
  color: var(--forest);
}

/* The band: the camera while scanning; it folds into the line with the code when a code is read. */

body[data-view='scan'] {
  --band-height: min(50dvh, 25rem);
}

body[data-view='form'] {
  --band-height: 6rem;
}

.band {
  position: relative;
  flex: none;
  height: var(--band-height);
  overflow: hidden;
  background: var(--forest);
  color: #fff;
  transition: height 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.band video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.band.live video {
  opacity: 1;
}

.guide {
  position: absolute;
  top: 44%;
  left: 50%;
  display: none;
  width: min(80%, 22rem);
  height: 38%;
  border: 2px solid #fff;
  border-radius: var(--radius-control);
  box-shadow: 0 0 0 100vmax rgb(15 42 25 / 45%);
  transform: translate(-50%, -50%);
}

.band.live .guide {
  display: block;
}

.camera-off {
  position: absolute;
  inset: 0 0 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 1.25rem;
  text-align: center;
}

.band.live .camera-off,
body[data-view='form'] .camera-off {
  display: none;
}

#torch {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}

.code-line {
  position: absolute;
  inset: 0 0 1.25rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding-inline: 0.75rem;
}

body[data-view='form'] .code-line {
  display: flex;
}

body[data-view='form'] #video,
body[data-view='form'] .guide,
body[data-view='form'] #torch {
  display: none;
}

.code {
  overflow: hidden;
  font: 700 clamp(1.3rem, 7vw, 1.75rem) / 1.1 Onest, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* The sheet over the band */

.sheet {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: -1.25rem;
  padding: 1.1rem 1rem 1rem;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--bg);
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input {
  flex: 1;
  min-width: 0;
  font-family: Onest, system-ui, sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#manual-form .error {
  margin-top: 0.4rem;
}

.last-saved {
  display: block;
  padding-block: 0.7rem 0.2rem;
  border-top: 1px solid var(--line);
  color: var(--text2);
  text-decoration: none;
}

/* The product form */

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text2);
  font-size: 0.875rem;
  font-weight: 600;
}

.pill.found {
  background: var(--success-bg);
  color: var(--primary-deep);
}

.pill.missing {
  background: var(--warn-bg);
  color: var(--warn);
}

.pill.info {
  background: var(--info-bg);
  color: var(--info);
}

.note {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-tile);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.9375rem;
}

.identity {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.75rem;
}

.photo-tile {
  position: relative;
  display: block;
  width: 7rem;
  height: 7rem;
  margin: 0;
  overflow: hidden;
  border: 1px dashed var(--field-border);
  border-radius: var(--radius-control);
  background: var(--chip);
  cursor: pointer;
}

.photo-tile:has(input:focus-visible) {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}

.photo-tile:has(img:not([hidden])) {
  border-style: solid;
  border-color: var(--line);
}

.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 100%;
  padding: 0.5rem;
  color: var(--text2);
  font-size: 0.875rem;
  text-align: center;
}

.identity .field textarea {
  flex: 1;
  min-height: 0;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin-top: -0.5rem;
}

.segments {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 0.2rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segments legend:not(.visually-hidden) {
  grid-column: 1 / -1;
}

.segments label {
  position: relative;
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.segments input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segments span {
  display: grid;
  place-items: center;
  min-height: 2.75rem;
  padding: 0.25rem;
  border-radius: var(--radius-tile);
  background: var(--track);
  color: var(--text2);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
}

.segments input:checked + span {
  background: var(--forest);
  color: #fff;
}

.segments input:focus-visible + span {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}

.save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: auto -1rem -1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

/* The base */

.base {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
}

.base-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.stats {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 0.5rem;
  margin: 0;
}

.stats div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  min-width: 0;
}

.stats dt {
  color: var(--text3);
  font-size: 0.8125rem;
  line-height: 1.25;
}

.stats dd {
  margin: 0;
  font: 700 1.375rem/1.25 Onest, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.rows {
  margin: 0 -1rem;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.rows:empty {
  display: none;
}

.rows a {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.thumb {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  overflow: hidden;
  border-radius: var(--radius-tile);
  background: var(--chip);
  color: var(--text3);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-name {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.row-code {
  display: block;
  margin-top: 0.1rem;
  color: var(--text3);
  font: 700 0.875rem/1.3 Onest, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

/* The tabs */

.tabs {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--card);
}

.tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.5rem;
  color: var(--text3);
  font-weight: 600;
  text-decoration: none;
}

.tabs a[aria-current='page'] {
  color: var(--primary-deep);
}

/* Signing in */

.login {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--forest);
}

.login h1 {
  padding: 1.5rem 1rem;
  color: #fff;
  font-size: 2rem;
}

.login-sheet {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--bg);
}

/* The toast */

.toast {
  position: fixed;
  bottom: calc(4.25rem + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 3;
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-control);
  background: var(--primary-deep);
  color: #fff;
  font-weight: 600;
  transform: translateX(-50%);
}

.toast.is-error {
  background: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  .band {
    transition: none;
  }
}
