/* Point Close — "Tape & Forecourt" theme.
   Day sheet (light): thermal-paper warmth, petrol-green ink.
   Forecourt night (dark): green-black forecourt, pump-amber actions.
   Verification semantics never shift: green = cross-checked, red = check it. */

:root {
  color-scheme: light;
  --bg: #f3f1ea;
  --panel: #ffffff;
  --tape: #fcfbf5;
  --ink: #17211b;
  --muted: #68746a;
  --line: #e1ded1;
  --line-strong: #cfccbd;
  --primary: #1e6b50;
  --primary-strong: #14513c;
  --primary-soft: #e4f0e9;
  --on-primary: #ffffff;
  --ok: #1e6b50;
  --ok-soft: #e4f0e9;
  --danger: #b3362b;
  --danger-soft: #fbeae6;
  --warn: #8a5a00;
  --input: #fdfcf8;
  --thumb-bg: #edeadf;
  --ring: rgba(30, 107, 80, 0.28);
  --shadow: 0 14px 34px rgba(23, 33, 27, 0.07);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c120f;
  --panel: #131b16;
  --tape: #17211a;
  --ink: #eaf1eb;
  --muted: #93a498;
  --line: #26312a;
  --line-strong: #35443b;
  --primary: #45c4cf;
  --primary-strong: #7cd8e0;
  --primary-soft: #0e262a;
  --on-primary: #071417;
  --ok: #4cc38a;
  --ok-soft: #12291d;
  --danger: #f08072;
  --danger-soft: #331510;
  --warn: #f19e5e;
  --input: #0f1512;
  --thumb-bg: #0f1512;
  --ring: rgba(69, 196, 207, 0.35);
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Barlow, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.app-shell {
  width: min(100%, 660px);
  margin: 0 auto;
  padding: 18px 14px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 9vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

h2 {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  min-width: 74px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 800;
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.theme-toggle {
  min-width: 58px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

/* ---------- Panels ---------- */

.panel,
.loading-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel,
.loading-panel,
.error-box,
.chip-row {
  animation: rise 220ms ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head-buttons {
  display: flex;
  gap: 8px;
}

.photo-count {
  min-width: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

input[type="password"],
input[type="text"],
input[inputmode="numeric"] {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 14px;
  background: var(--input);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* ---------- Photos ---------- */

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

.photo-button {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  margin: 0;
  border: 1.5px dashed var(--primary);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  cursor: pointer;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: left;
  text-transform: none;
}

.photo-button-secondary {
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}

.gallery-icon {
  position: relative;
  width: 26px;
  height: 22px;
  overflow: hidden;
  border: 3px solid currentColor;
  border-radius: 5px;
}

.gallery-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.gallery-icon::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 1px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  background: currentColor;
}

.photo-icon {
  position: relative;
  width: 28px;
  height: 22px;
  border: 3px solid currentColor;
  border-radius: 6px;
}

.photo-icon::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 6px;
  width: 11px;
  height: 5px;
  border-radius: 3px 3px 0 0;
  background: currentColor;
}

.photo-icon::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 8px;
  width: 7px;
  height: 7px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.thumb-grid:empty {
  margin-top: 0;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--thumb-bg);
}

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

.remove-thumb {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(12, 18, 15, 0.82);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

/* ---------- Actions ---------- */

.action-row {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.small-button {
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  transition: transform 120ms ease, filter 120ms ease;
}

.primary-button,
.secondary-button {
  min-height: 56px;
  font-size: 1.02rem;
}

.primary-button {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow);
}

.primary-button:active,
.secondary-button:active,
.small-button:active {
  transform: scale(0.98);
}

.primary-button:disabled {
  filter: saturate(0.35) opacity(0.7);
  transform: none;
}

.secondary-button,
.small-button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}

.secondary-button:disabled,
.small-button:disabled {
  color: var(--muted);
  transform: none;
}

.small-button {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 0.84rem;
}

.small-button-primary {
  border-color: transparent;
  background: var(--primary);
  color: var(--on-primary);
}

.link-button {
  margin: 0;
  border: 0;
  padding: 0;
  background: none;
  color: var(--primary-strong);
  font-size: inherit;
  font-weight: 700;
  text-decoration: underline;
}

/* ---------- Loading ---------- */

.loading-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.94rem;
  font-weight: 800;
}

#loadingPercent {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--primary-strong);
}

.progress-track {
  height: 12px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  background-image: repeating-linear-gradient(
    -55deg,
    rgba(255, 255, 255, 0.22) 0 8px,
    transparent 8px 16px
  );
  background-size: 200% 100%;
  animation: crawl 1.1s linear infinite;
  transition: width 320ms ease;
}

@keyframes crawl {
  to {
    background-position: -23px 0;
  }
}

.loading-panel p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- Errors & chips ---------- */

.error-box {
  margin-top: 12px;
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--panel);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.chip-complete {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-partial {
  color: var(--warn);
}

.chip-missing {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- The tape (results) ---------- */

.results-panel {
  position: relative;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--tape);
  box-shadow: none;
}

.results-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 8px;
  background-image:
    linear-gradient(45deg, var(--tape) 25%, transparent 25%),
    linear-gradient(-45deg, var(--tape) 25%, transparent 25%);
  background-position: 0 0;
  background-size: 14px 16px;
  background-repeat: repeat-x;
}

.verify-summary {
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line-strong);
  color: var(--ok);
  font-size: 0.84rem;
  font-weight: 700;
}

.verify-summary-suspect {
  color: var(--danger);
}

.results-list,
.extracted-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.results-list div,
.extracted-list div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  border-bottom: 1px dashed var(--line);
}

.results-list div {
  min-height: 50px;
}

.results-list div:last-child,
.extracted-list div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dd {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.04rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.results-list dd {
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 700;
}

.verdict-mark {
  display: inline-block;
  margin-right: 2px;
  font-family: Barlow, ui-sans-serif, system-ui, sans-serif;
  font-weight: 800;
}

.verdict-verified {
  color: var(--ok);
}

.verdict-suspect {
  color: var(--danger);
}

.results-list .row-suspect {
  margin: 2px -8px;
  border-bottom: 1px dashed var(--danger);
  border-radius: 10px;
  padding: 0 8px;
  background: var(--danger-soft);
}

.results-list .row-suspect dd {
  color: var(--danger);
}

/* ---------- Extracted details ---------- */

.extracted-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
}

.extracted-summary + .extracted-list {
  margin-top: 12px;
}

.extracted-list dd {
  font-size: 0.94rem;
}

.section-subhead {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.calculation-list div {
  grid-template-columns: 1fr;
  align-items: start;
  gap: 4px;
  padding: 8px 0;
}

.calculation-list dd {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
}

#modelUsed {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 500;
}

.warning-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--warn);
  font-size: 0.88rem;
  font-weight: 600;
}

.warning-list:empty {
  margin: 0;
}

/* ---------- Camera ---------- */

.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #000;
}

.camera-overlay[hidden] {
  display: none;
}

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

.camera-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.camera-overlay.flash::before {
  opacity: 0.75;
  transition: none;
}

.camera-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}

.camera-count {
  color: #fff;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  font-weight: 600;
}

.camera-top-buttons {
  display: flex;
  gap: 8px;
}

.camera-chrome-button {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

.camera-bottom {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 14px 16px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}

.camera-strip {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  overflow-x: auto;
}

.camera-strip:empty {
  display: none;
}

.camera-strip-thumb {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  padding: 0;
  background: #000;
}

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

.camera-shutter {
  width: 76px;
  height: 76px;
  border: 5px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  transition: background 120ms ease, transform 120ms ease;
}

.camera-shutter:active {
  background: #fff;
  transform: scale(0.94);
}

.camera-shutter:disabled {
  opacity: 0.4;
}

.camera-hint {
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---------- Copy mode ---------- */

.copy-mode {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: var(--bg);
}

.copy-mode[hidden] {
  display: none;
}

.copy-mode-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
}

.copy-mode-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.copy-mode-label {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 4.6vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.copy-mode-value {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(3rem, 16vw, 5.6rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  word-break: break-word;
}

.copy-mode-badge {
  margin: 0;
  min-height: 1.3em;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.copy-mode-badge-verified {
  color: var(--ok);
}

.copy-mode-badge-suspect {
  color: var(--danger);
}

.copy-mode-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.copy-mode-nav {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
}

body.no-scroll {
  overflow: hidden;
}

/* ---------- Utilities & responsive ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (min-width: 600px) {
  .app-shell {
    padding-top: 30px;
  }

  .panel,
  .loading-panel {
    padding: 20px;
  }
}

@media (max-width: 380px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .loading-panel,
  .error-box,
  .chip-row {
    animation: none;
  }

  .progress-bar {
    animation: none;
    transition: none;
  }

  .primary-button,
  .secondary-button,
  .small-button {
    transition: none;
  }

  .primary-button:active,
  .secondary-button:active,
  .small-button:active {
    transform: none;
  }
}
