:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #647269;
  --paper: #f6f7f2;
  --surface: #ffffff;
  --line: #dfe5dd;
  --green: #176b4d;
  --green-dark: #0d4e37;
  --green-soft: #e5f3ec;
  --amber: #9a5c0a;
  --red: #ad3434;
  --shadow: 0 12px 36px rgba(23, 33, 27, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.site-header { height: 68px; display: flex; align-items: center; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.site-header, .page-shell { padding-inline: clamp(20px, 4vw, 72px); }
.brand { display: inline-flex; gap: 11px; align-items: center; text-decoration: none; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--green); color: white; font-size: 12px; letter-spacing: .06em; }
.account-nav { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.account-nav a, .link-button { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.account-nav form { margin: 0; }
.link-button { padding: 0; border: 0; background: none; }
.header-user { color: var(--ink); font-weight: 750; }
.page-shell { max-width: 1600px; margin: 0 auto; padding-top: 42px; padding-bottom: 80px; }

.auth-shell { min-height: calc(100vh - 190px); display: grid; place-items: center; }
.auth-card { width: min(100%, 440px); display: grid; gap: 16px; padding: 32px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card h1 { font-size: 38px; }
.auth-card label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.auth-card input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); }
.form-success { color: var(--green); }

.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: clamp(32px, 7vw, 100px); align-items: center; padding: clamp(32px, 6vw, 72px); border-radius: 30px; background: linear-gradient(135deg, #e2efe7 0%, #f7f4e9 78%); border: 1px solid #d8e2d8; }
.eyebrow { margin: 0 0 10px; color: var(--green); text-transform: uppercase; font-weight: 800; font-size: 12px; letter-spacing: .13em; }
h1 { margin: 0; max-width: 780px; font-size: clamp(36px, 5vw, 68px); line-height: .98; letter-spacing: -.055em; }
.lede { max-width: 700px; color: var(--muted); font-size: clamp(16px, 2vw, 20px); line-height: 1.6; }
.upload-panel { display: grid; gap: 14px; padding: 26px; background: rgba(255,255,255,.9); border: 1px solid white; border-radius: 22px; box-shadow: var(--shadow); }
.upload-panel label, .toolbar label, .classification-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
input[type=file], select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); }
.primary, .secondary { border: 0; border-radius: 11px; padding: 12px 18px; font-weight: 750; }
.primary { background: var(--green); color: white; }
.primary:hover { background: var(--green-dark); }
.secondary { background: var(--green-soft); color: var(--green-dark); }
.form-error, .error-text { color: var(--red); }

.task-section { margin-top: 48px; }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 24px; }
.count-pill { padding: 3px 9px; border-radius: 20px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 800; }
.task-list { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.task-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 18px; align-items: center; padding: 18px 20px; text-decoration: none; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: #fbfcf9; }
.task-row span:first-child { display: grid; gap: 4px; min-width: 0; }
.task-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row small { color: var(--muted); }
.task-count { font-variant-numeric: tabular-nums; color: var(--muted); }
.status { display: inline-flex; width: fit-content; padding: 5px 9px; border-radius: 99px; background: #edf0ec; color: #546158; font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.status-review, .status-completed, .status-classified { background: var(--green-soft); color: var(--green); }
.status-failed, .status-error { background: #f9e5e2; color: var(--red); }
.status-downloading, .status-classifying, .status-parsing { background: #fff0d8; color: var(--amber); }
.empty-state { display: grid; place-items: center; gap: 7px; min-height: 180px; border: 1px dashed #cbd4ca; border-radius: 18px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }

.breadcrumb { display: flex; gap: 8px; margin-bottom: 24px; color: var(--muted); font-size: 13px; }
.breadcrumb a { color: var(--green); }
.task-hero { display: flex; justify-content: space-between; gap: 24px; align-items: end; }
.task-hero h1 { font-size: clamp(32px, 5vw, 58px); overflow-wrap: anywhere; }
.task-export-stack { display: grid; justify-items: end; gap: 8px; }
.task-export-controls { display: flex; justify-content: flex-end; }
.export-blocker { min-height: 20px; display: flex; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 12px; }
.export-blocker a { color: var(--red); }
.progress-card { margin: 30px 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(23,33,27,.04); }
.progress-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.progress-track { height: 7px; margin-top: 14px; border-radius: 20px; background: #e7ebe6; overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .3s ease; }
.review-status-summary { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.toolbar { position: sticky; top: 80px; z-index: 10; display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.toolbar form { display: flex; gap: 12px; }
.toolbar .reason-toggle { margin-left: auto; }
.reason-toggle .secondary[aria-pressed="true"] { background: var(--green); color: white; }
.toolbar select { min-width: 220px; }
.visible-count { color: var(--muted); font-size: 13px; }

.record-grid { display: grid; gap: 18px; align-items: start; }
#record-stream { min-height: 1px; }
.record-grid.size-small { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.record-grid.size-medium { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.record-grid.size-large { grid-template-columns: repeat(auto-fill, minmax(390px, 1fr)); }
.record-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 26px rgba(23,33,27,.055); }
.image-frame { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; background: #e9ece7; overflow: hidden; }
.image-frame img { width: 100%; height: 100%; object-fit: contain; }
.image-placeholder { color: var(--muted); font-size: 13px; }
.row-badge { position: absolute; top: 10px; right: 10px; padding: 5px 8px; border-radius: 8px; background: rgba(23,33,27,.82); color: white; font-size: 11px; font-weight: 750; }
.card-body { display: grid; gap: 13px; padding: 16px; }
.retailer { margin: 0; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reason { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.48; }
.source-badge { width: fit-content; padding: 4px 7px; border-radius: 7px; background: #edf0ec; color: var(--muted); text-transform: uppercase; font-size: 9px; font-weight: 850; letter-spacing: .08em; }
.source-human { background: #e7ecfb; color: #39599b; }
.record-error { display: grid; gap: 4px; padding: 10px; border-radius: 10px; background: #fbeceb; color: var(--red); font-size: 12px; }
.retry-state { display: grid; gap: 4px; padding: 10px; border-radius: 10px; background: #fff0d8; color: var(--amber); font-size: 12px; }

@media (max-width: 760px) {
  .site-header, .page-shell { padding-inline: 16px; }
  .page-shell { padding-top: 24px; }
  .hero { grid-template-columns: 1fr; padding: 28px 20px; border-radius: 22px; }
  .task-hero { align-items: start; flex-direction: column; }
  .toolbar, .toolbar form { align-items: stretch; flex-direction: column; }
  .toolbar { position: static; }
  .toolbar select { min-width: 0; }
  .task-row { grid-template-columns: 1fr auto; }
  .task-row .task-count { display: none; }
  .record-grid.size-large { grid-template-columns: 1fr; }
  .header-user { display: none; }
  .account-nav { gap: 10px; }
}
