:root {
  color-scheme: light dark;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #5f6b7a;
  --border: #d8dee8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --danger-bg: #fef2f2;
  --danger-text: #991b1b;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.report-card {
  width: min(100%, 480px);
  background: var(--card);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.header-block {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 6vw, 2.35rem);
  line-height: 1.1;
}

h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 1rem;
}

.time-line {
  min-height: 1.4rem;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

form {
  display: grid;
  gap: 18px;
}

.field-group {
  padding: 0;
  margin: 0;
  border: 0;
}

legend,
label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.95rem;
  font-weight: 750;
}

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

.stock-option {
  position: relative;
  margin: 0;
}

.stock-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.stock-option span {
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  font-weight: 800;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.stock-option input:focus-visible + span,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.stock-option input:checked + span {
  color: #ffffff;
  border-color: transparent;
}

.stock-in input:checked + span {
  background: var(--green);
}

.stock-out input:checked + span {
  background: var(--red);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  padding: 12px 14px;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

.products-section {
  display: grid;
  gap: 12px;
}

.products-section[hidden] {
  display: none;
}

.section-heading,
.product-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  padding-top: 2px;
}

.section-heading .eyebrow {
  margin-bottom: 4px;
}

#productCount {
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 6px 10px;
}

.product-list {
  display: grid;
  gap: 14px;
}

.product-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
  padding: 14px;
}

.product-card .preview-box {
  min-height: 150px;
}

.remove-product-button[hidden] {
  display: none;
}

.add-product-button {
  width: 100%;
}

.remember-field {
  position: relative;
}

.suggestion-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
  padding: 6px;
}

.suggestion-list[hidden] {
  display: none;
}

.suggestion-button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}

.suggestion-button:hover,
.suggestion-button:focus-visible {
  background: rgba(37, 99, 235, 0.12);
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.label-row span,
.help-text {
  color: var(--muted);
  font-size: 0.82rem;
}

.photo-field {
  display: grid;
  gap: 10px;
}

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

.secondary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--primary);
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.ghost-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}

.preview-box {
  display: grid;
  min-height: 170px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
}

.preview-box img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #0f172a;
}

.preview-box img[hidden] {
  display: none;
}

.camera-panel {
  display: grid;
  gap: 12px;
}

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

#cameraPreview {
  width: 100%;
  max-height: 320px;
  border-radius: 8px;
  background: #0f172a;
  object-fit: cover;
}

.offline-banner,
.form-message {
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 750;
}

.offline-banner {
  margin-bottom: 16px;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.form-message {
  display: none;
  margin: 0;
}

.form-message.show {
  display: block;
}

.form-message.error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.form-message.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.submit-button {
  position: relative;
  display: inline-flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 850;
  transition: background 160ms ease, transform 160ms ease;
}

.submit-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.submit-button:active:not(:disabled) {
  transform: translateY(1px);
}

.submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.submit-button.loading .spinner {
  display: inline-block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 430px) {
  .app-shell {
    align-items: start;
    padding: 12px;
  }

  .report-card {
    padding: 18px;
  }

  .grid-2,
  .photo-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --card: #172033;
    --text: #f8fafc;
    --muted: #b8c1d1;
    --border: #334155;
    --danger-bg: #3f1518;
    --danger-text: #fecaca;
    --success-bg: #0f3527;
    --success-text: #a7f3d0;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  }
}
