:root {
  color-scheme: light;
  --receipt-red: #e4002b;
  --receipt-ink: #15171d;
  --receipt-muted: #69707d;
  --receipt-line: #dfe3ea;
  --receipt-soft: #f5f6f8;
  --receipt-good: #15803d;
  --receipt-warn: #b45309;
  --receipt-bad: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f3f4f6;
  color: var(--receipt-ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.receipt-app {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.receipt-hero,
.tool-card {
  background: #fff;
  border: 1px solid var(--receipt-line);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.receipt-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-top: 4px solid var(--receipt-red);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--receipt-red);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.receipt-hero p:last-child {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--receipt-muted);
  font-weight: 700;
}

.receipt-status {
  min-width: 160px;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--receipt-soft);
  text-align: right;
}

.receipt-status span {
  display: block;
  color: var(--receipt-muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.receipt-status strong {
  display: block;
  margin-top: 4px;
  font-size: 2rem;
}

.receipt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.8fr);
  gap: 18px;
}

.tool-card {
  padding: 20px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.upload-box {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  background: #f8fafc;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-box span {
  color: var(--receipt-red);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.upload-box strong {
  font-size: 1.2rem;
}

.upload-box small,
.product-meta,
.scan-message {
  color: var(--receipt-muted);
  font-weight: 700;
}

.receipt-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.receipt-summary article {
  padding: 14px;
  border: 1px solid var(--receipt-line);
  border-radius: 14px;
  background: #fff;
}

.receipt-summary span {
  display: block;
  color: var(--receipt-muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.receipt-summary strong {
  display: block;
  margin-top: 5px;
  font-size: 1.55rem;
}

.scan-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: #111318;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
}

.scan-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfd5de;
  border-radius: 12px;
  padding: 0 13px;
  background: #fff;
  color: var(--receipt-ink);
  font-weight: 800;
}

input:focus {
  border-color: var(--receipt-red);
  box-shadow: 0 0 0 4px rgba(228, 0, 43, 0.12);
  outline: none;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  background: var(--receipt-red);
  color: #fff;
}

.secondary-button {
  background: #f8fafc;
  border-color: var(--receipt-line);
  color: var(--receipt-ink);
}

.danger-button {
  border-color: #fecdd3;
  background: #fff1f2;
  color: var(--receipt-bad);
}

.danger-primary-button {
  background: var(--receipt-bad);
  color: #fff;
}

.receipt-modal-backdrop {
  position: absolute;
  top: var(--receipt-modal-top, 0);
  right: 0;
  left: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--receipt-modal-height, 100vh);
  padding: 18px;
  background: rgba(16, 16, 16, 0.56);
}

.receipt-modal-backdrop[hidden] {
  display: none;
}

.receipt-modal-card {
  width: min(100%, 520px);
  padding: 22px;
  border: 1px solid var(--receipt-line);
  border-top: 4px solid var(--receipt-red);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

.receipt-modal-card h2 {
  margin: 0;
  color: var(--receipt-ink);
  font-size: 1.45rem;
  line-height: 1.1;
}

.receipt-modal-copy {
  margin: 10px 0 18px;
  color: var(--receipt-muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.receipt-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.scan-message {
  min-height: 28px;
  margin: 14px 0 0;
}

.scan-message.good {
  color: var(--receipt-good);
}

.scan-message.warn {
  color: var(--receipt-warn);
}

.scan-message.bad {
  color: var(--receipt-bad);
}

.receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

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

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

.finish-card,
.finish-details {
  background: #fff;
  border: 1px solid var(--receipt-line);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.finish-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-left: 6px solid #cbd5e1;
}

.finish-card h2,
.finish-card p {
  margin-bottom: 0;
}

.finish-card-good {
  border-color: #22c55e;
  background: #dcfce7;
}

.finish-card-warn {
  border-color: #f59e0b;
  background: #ffedd5;
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.finish-details {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.finish-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.finish-summary article {
  padding: 12px;
  border: 1px solid var(--receipt-line);
  border-radius: 14px;
  background: #f8fafc;
}

.finish-summary span {
  display: block;
  color: var(--receipt-muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.finish-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

.finish-issues {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.finish-issue-group {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--receipt-line);
}

.finish-issue-group h3 {
  margin: 0;
  font-size: 1rem;
}

.finish-issue-group p {
  margin: 0;
  color: var(--receipt-muted);
  font-weight: 800;
}

.finish-issue-group article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.finish-issue-group article span {
  color: var(--receipt-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.finish-issue-group article b {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
}

.finish-issue-group.missing {
  background: #fef3c7;
  border-color: #fbbf24;
}

.finish-issue-group.excess {
  background: #fee2e2;
  border-color: #fca5a5;
}

.product-search {
  min-width: min(360px, 100%);
}

.product-table {
  display: grid;
  gap: 10px;
}

.empty-state {
  margin: 0;
  padding: 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: var(--receipt-muted);
  text-align: center;
  font-weight: 800;
}

.product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px 148px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--receipt-line);
  border-left: 5px solid #cbd5e1;
  border-radius: 14px;
  background: #fff;
}

.product-row.complete {
  border-left-color: var(--receipt-good);
  border-color: #86efac;
  background: #dcfce7;
}

.product-row.partial {
  border-left-color: var(--receipt-warn);
  border-color: #fbbf24;
  background: #fef3c7;
}

.product-row.excess {
  border-left-color: var(--receipt-bad);
  border-color: #fca5a5;
  background: #fee2e2;
}

.product-title {
  display: grid;
  gap: 5px;
}

.product-title strong {
  font-size: 1rem;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
}

.product-count {
  text-align: right;
}

.product-count strong {
  display: block;
  font-size: 1.55rem;
}

.product-count span {
  color: var(--receipt-muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.product-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.product-actions button {
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--receipt-ink);
  font-weight: 900;
  cursor: pointer;
}

@media (max-width: 760px) {
  .receipt-app {
    padding: 14px;
  }

  .receipt-hero,
  .section-title,
  .receipt-grid,
  .scan-form,
  .product-row {
    grid-template-columns: 1fr;
  }

  .receipt-hero,
  .section-title {
    display: grid;
  }

  .receipt-status {
    width: 100%;
    text-align: left;
  }

  .receipt-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finish-card,
  .finish-issues {
    grid-template-columns: 1fr;
  }

  .finish-card {
    display: grid;
  }

  .finish-actions {
    justify-content: stretch;
  }

  .finish-actions button {
    width: 100%;
  }

  .finish-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-count {
    text-align: left;
  }
}
