:root {
  color-scheme: light;
  --ink: #17332c;
  --muted: #687a75;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --line: #dce6e2;
  --brand: #147a5b;
  --brand-dark: #0f5c45;
  --brand-soft: #e2f4ed;
  --danger: #b43b42;
  --warning: #a56b08;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.page-header, .section-heading, .camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -.04em; }
h2 { font-size: 1.35rem; letter-spacing: -.02em; }
.eyebrow { color: var(--brand); font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; margin-bottom: 4px; }
.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; }

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: .85rem;
  font-weight: 700;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.sync-indicator[data-state="pending"] { background: #fff1d8; color: #7d530b; }
.sync-indicator[data-state="pending"] .sync-dot { background: #d89218; }
.sync-indicator[data-state="offline"] { background: #fde7e8; color: var(--danger); }
.sync-indicator[data-state="offline"] .sync-dot { background: var(--danger); }

.capture-panel, .progress-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgb(24 59 49 / 6%);
}
.capture-panel { margin: 26px 0 20px; padding: 24px; }
.progress-section { padding: 24px; }

label { display: block; margin: 0 0 7px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.location-input, #barcode-input, #review-search, #status-filter {
  width: 100%;
  border: 1px solid #cbd9d4;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.location-input:focus, #barcode-input:focus, #review-search:focus, #status-filter:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(20 122 91 / 14%);
}
.location-input { padding: 12px 14px; margin-bottom: 18px; }
.scan-row { display: grid; grid-template-columns: 1fr 54px; gap: 10px; }
.barcode-form { min-width: 0; }
#barcode-input { height: 54px; padding: 0 16px; font-size: 1.12rem; font-weight: 650; }
.icon-button {
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-button:hover { background: var(--brand-dark); }
.icon-button svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.help { margin-top: 9px; color: var(--muted); font-size: .8rem; }
.capture-message { margin-top: 14px; padding: 10px 12px; border-radius: 9px; background: var(--brand-soft); font-weight: 700; }
.capture-message.error { background: #fde7e8; color: var(--danger); }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-size: .83rem;
  font-weight: 700;
}
.secondary-button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); }
.secondary-button:disabled { opacity: .45; cursor: default; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.summary-card { min-height: 126px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fafcfb; }
.summary-card.accent { background: var(--brand-soft); border-color: #c5e8dc; }
.summary-card > span { color: var(--muted); font-size: .78rem; font-weight: 700; }
.summary-card strong { display: block; margin: 7px 0 2px; font-size: 2rem; line-height: 1; }
.summary-card small { color: var(--muted); }
.status-counts { display: grid; gap: 5px; margin-top: 12px; }
.status-counts b { color: var(--ink); font-size: 1rem; }

.review-toolbar { display: grid; grid-template-columns: auto 1fr 160px; gap: 10px; margin-bottom: 14px; }
.scope-toggle { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.scope-toggle button { border: 0; border-radius: 7px; padding: 7px 10px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; font-size: .8rem; }
.scope-toggle button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgb(20 50 42 / 10%); }
#review-search, #status-filter { min-height: 38px; padding: 8px 11px; font-size: .85rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { padding: 10px 12px; background: #f7faf8; color: var(--muted); text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.product-name { display: block; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.barcode-value { display: block; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 2px; }
.quantity-heading { text-align: center; }
.quantity-control { display: flex; align-items: center; justify-content: center; gap: 8px; }
.quantity-control button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 800; }
.quantity-control button:hover { border-color: var(--brand); }
.quantity-control strong { min-width: 30px; text-align: center; font-size: 1rem; }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; background: #edf1ef; color: var(--muted); }
.status-pill.exists { background: var(--brand-soft); color: var(--brand-dark); }
.status-pill.missing { background: #fde7e8; color: var(--danger); }
.status-pill.pending, .status-pill.retry { background: #fff1d8; color: var(--warning); }
.empty-message { padding: 26px; text-align: center; color: var(--muted); }
.load-more { margin: 12px auto 0; }

.camera-modal {
  width: min(760px, 100%);
  height: min(900px, 100dvh);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #081b17;
  color: #fff;
  overflow: hidden;
}
.camera-modal::backdrop { background: rgb(4 17 13 / 80%); backdrop-filter: blur(4px); }
.camera-header { padding: 14px 18px; background: #102a24; }
.camera-header small { display: block; color: #a8c2b9; }
.camera-header strong { font-size: 1.05rem; }
.close-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgb(255 255 255 / 12%); color: #fff; font-size: 1.8rem; cursor: pointer; }
.reader { width: 100%; min-height: 420px; background: #000; }
.reader video { object-fit: cover !important; }
.camera-feedback { min-height: 64px; display: grid; place-items: center; padding: 14px; text-align: center; font-weight: 750; background: #102a24; transition: background .15s; }
.camera-feedback.success { background: var(--brand); }
.camera-feedback.cooldown { background: #8a610f; }
.camera-feedback.error { background: var(--danger); }

@media (max-width: 720px) {
  .shell { width: min(100% - 20px, 1080px); padding: 18px 0 36px; }
  .capture-panel, .progress-section { padding: 16px; }
  .section-heading { align-items: flex-start; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .status-card { grid-column: 1 / -1; min-height: auto; }
  .status-counts { grid-template-columns: repeat(3, 1fr); }
  .review-toolbar { grid-template-columns: 1fr 1fr; }
  .scope-toggle { grid-column: 1 / -1; }
  .scope-toggle button { flex: 1; }
  #review-search { grid-column: 1 / 2; }
  .camera-modal { width: 100%; height: 100dvh; border-radius: 0; }
  .reader { min-height: calc(100dvh - 130px); }
}

@media (max-width: 520px) {
  .page-header { align-items: flex-start; }
  .sync-indicator { padding: 7px 9px; }
  .summary-grid { grid-template-columns: 1fr; }
  .status-card { grid-column: auto; }
  .table-wrap { border: 0; overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tr { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; }
  td { display: block; padding: 0; border: 0; }
  td:nth-child(1) { grid-column: 1 / -1; }
  td:nth-child(2) { color: var(--muted); }
  td:nth-child(3) { grid-row: 2 / span 2; grid-column: 2; }
  .product-name { max-width: calc(100vw - 70px); }
}
