:root {
  color-scheme: light;
  --ink: #17191d;
  --muted: #676d77;
  --line: #d9dde3;
  --surface: #fff;
  --soft: #f5f6f8;
  --red: #e3062e;
  --red-dark: #bc0024;
  --green: #16834a;
  --amber: #a76700;
}

* { box-sizing: border-box; }

body { margin: 0; }

button, input { font: inherit; }

.sales-app {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 1500px;
  padding: 0 0 30px;
  width: 100%;
}

.sales-hero,
.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(23, 25, 29, .04), 0 10px 28px rgba(23, 25, 29, .055);
}

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

.eyebrow {
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 28px; line-height: 1.05; margin-bottom: 7px; }
h2 { font-size: 21px; line-height: 1.1; margin-bottom: 0; }
.sales-hero p:last-child { color: var(--muted); font-size: 14px; margin-bottom: 0; }

.sales-status {
  background: var(--ink);
  border-radius: 7px;
  color: #fff;
  min-width: 160px;
  padding: 13px 16px;
  text-align: right;
}
.sales-status span, .sales-status strong { display: block; }
.sales-status span { color: #afb5bf; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.sales-status strong { font-size: 17px; margin-top: 3px; }

.tool-card { padding: 20px; }
.section-title { align-items: center; display: flex; gap: 16px; justify-content: space-between; margin-bottom: 16px; }

.primary-button,
.secondary-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 850;
  min-height: 40px;
  padding: 9px 16px;
}
.primary-button { background: var(--red); border-color: var(--red); color: #fff; }
.primary-button:hover { background: var(--red-dark); border-color: var(--red-dark); }
.secondary-button { background: #fff; color: var(--ink); }
.secondary-button:hover { background: var(--soft); }
button:disabled { cursor: not-allowed; opacity: .45; }
.danger-button { color: var(--red); }
.danger-primary-button { background: var(--red); }

.upload-box {
  align-items: center;
  background: var(--soft);
  border: 1px dashed #aeb4be;
  border-radius: 7px;
  cursor: pointer;
  display: grid;
  gap: 4px 14px;
  grid-template-columns: 44px minmax(0, 1fr);
  padding: 18px;
}
.upload-box.dragging { background: #fff0f3; border-color: var(--red); }
.upload-box input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.upload-icon { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 7px; color: var(--red); display: flex; grid-row: 1 / 3; height: 44px; justify-content: center; width: 44px; }
.upload-icon svg { height: 22px; width: 22px; }
.upload-box strong { font-size: 15px; }
.upload-box small { color: var(--muted); font-size: 12px; }

.file-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.file-pill { align-items: center; background: #edf7f1; border: 1px solid #bfddca; border-radius: 5px; color: #17663c; display: inline-flex; font-size: 12px; font-weight: 750; gap: 7px; padding: 7px 9px; }
.file-pill button { background: transparent; border: 0; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; padding: 0 1px; }
.import-message { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.import-message.error { color: var(--red-dark); font-weight: 750; }

.sales-summary { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sales-summary article { background: var(--ink); border-radius: 7px; color: #fff; padding: 14px 16px; }
.sales-summary span { color: #aeb4bd; display: block; font-size: 10px; font-weight: 850; text-transform: uppercase; }
.sales-summary strong { display: block; font-size: 23px; margin-top: 4px; }

.report-actions { display: flex; gap: 8px; }
.report-toolbar { align-items: end; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; display: grid; gap: 14px; grid-template-columns: minmax(220px, 1fr) auto; padding: 12px; }
.search-field span { display: block; font-size: 11px; font-weight: 850; margin-bottom: 5px; }
.search-field input { background: #fff; border: 1px solid #c7ccd4; border-radius: 6px; min-height: 40px; padding: 9px 11px; width: 100%; }
.view-switch { background: #e6e8ec; border: 1px solid #d3d6dc; border-radius: 6px; display: flex; padding: 3px; }
.view-switch button { background: transparent; border: 0; border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 850; min-height: 34px; padding: 7px 13px; }
.view-switch button.active { background: var(--ink); color: #fff; }
.service-note { background: #fff7e8; border: 1px solid #ead5a7; border-left: 3px solid #c58210; border-radius: 6px; color: #6e4b08; font-size: 12px; margin-top: 12px; padding: 10px 12px; }

.product-table { margin-top: 14px; }
.product-table-header,
.product-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 34px 150px minmax(260px, 1fr) minmax(130px, .55fr) 90px 90px;
}
.product-table-header { border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 900; padding: 8px 10px; text-transform: uppercase; }
.product-row { border-bottom: 1px solid #e5e7eb; min-height: 60px; padding: 9px 10px; }
.product-row:hover { background: #fafbfc; }
.product-row.is-service { background: #fffaf0; }
.product-row.is-return { background: #fff1f3; }
.product-check { align-items: center; display: flex; justify-content: center; }
.product-check input { accent-color: var(--red); height: 18px; width: 18px; }
.product-code { font-size: 13px; font-weight: 900; overflow-wrap: anywhere; }
.product-description strong { display: block; font-size: 14px; }
.product-description small { color: var(--muted); display: block; font-size: 11px; margin-top: 3px; }
.product-category { color: var(--muted); font-size: 12px; }
.product-units { font-size: 20px; font-variant-numeric: tabular-nums; font-weight: 900; text-align: right; }
.product-lines { color: var(--muted); font-size: 12px; text-align: right; }
.service-tag, .return-tag { border-radius: 4px; display: inline-block; font-size: 9px; font-weight: 900; margin-left: 6px; padding: 3px 5px; text-transform: uppercase; }
.service-tag { background: #ffebb9; color: #785000; }
.return-tag { background: #ffd8df; color: #a30020; }
.empty-state { color: var(--muted); padding: 30px 14px; text-align: center; }

.sales-modal-backdrop { background: rgba(16, 18, 22, .58); inset: 0; padding: 18px; position: absolute; z-index: 50; }
.sales-modal-backdrop[hidden] { display: none; }
.sales-modal { background: #fff; border-radius: 8px; box-shadow: 0 24px 70px rgba(0, 0, 0, .24); left: 50%; max-width: 470px; padding: 24px; position: absolute; top: var(--modal-center-y, 50vh); transform: translate(-50%, -50%); width: calc(100% - 36px); }
.sales-modal h2 { margin-bottom: 10px; }
.sales-modal > p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

@media (max-width: 760px) {
  .sales-app { gap: 12px; padding-bottom: 22px; }
  .sales-hero { align-items: flex-start; padding: 17px; }
  .sales-hero h1 { font-size: 24px; }
  .sales-status { min-width: 118px; padding: 10px; }
  .tool-card { padding: 15px; }
  .sales-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-title.report-heading { align-items: stretch; flex-direction: column; }
  .report-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .report-toolbar { grid-template-columns: 1fr; }
  .view-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .view-switch button { padding-inline: 5px; }
  .product-table-header { display: none; }
  .product-row { align-items: start; border: 1px solid var(--line); border-radius: 7px; gap: 6px 10px; grid-template-columns: 28px minmax(0, 1fr) 66px; margin-bottom: 8px; padding: 11px; }
  .product-check { grid-row: 1 / 4; padding-top: 2px; }
  .product-code { grid-column: 2; }
  .product-description { grid-column: 2; }
  .product-category { grid-column: 2; }
  .product-units { grid-column: 3; grid-row: 1 / 3; }
  .product-lines { grid-column: 3; grid-row: 3; }
}

@media (max-width: 480px) {
  .sales-hero { display: block; }
  .sales-status { margin-top: 13px; text-align: left; width: 100%; }
  .section-title:not(.report-heading) { align-items: flex-start; }
  .upload-box { grid-template-columns: 38px minmax(0, 1fr); padding: 14px; }
  .upload-icon { height: 38px; width: 38px; }
  .sales-summary strong { font-size: 20px; }
  .report-actions { grid-template-columns: 1fr; }
}

@media print {
  @page { margin: 9mm 10mm; size: A4 portrait; }
  body { background: #fff; }
  .sales-hero, .import-panel, .sales-summary, .report-toolbar, .report-actions, .service-note { display: none !important; }
  .sales-app { display: block; max-width: none; padding: 0; }
  .report-panel { border: 0; box-shadow: none; padding: 0; }
  .report-heading { border-bottom: 2px solid #17191d; margin-bottom: 14px; padding-bottom: 10px; }
  .report-heading .eyebrow { color: #17191d; }
  .product-table { margin-top: 8px; }
  .product-row {
    break-inside: avoid;
    gap: 7px;
    grid-template-columns: 30mm minmax(0, 1fr) 18mm;
    line-height: 1.12;
    min-height: 0;
    padding: 1.6mm 1mm;
  }
  .product-table-header {
    gap: 7px;
    grid-template-columns: 30mm minmax(0, 1fr) 18mm;
    padding: 1.5mm 1mm;
  }
  .product-check { display: none; }
  .product-table-header > span:first-child,
  .product-table-header > span:nth-child(4),
  .product-table-header > span:nth-child(6),
  .product-category,
  .product-lines { display: none; }
  .product-row:not(.included) { display: none; }
  .product-row.is-service { background: transparent; }
  .product-code { font-size: 8pt; grid-column: 1; grid-row: 1; }
  .product-description { grid-column: 2; grid-row: 1; }
  .product-description strong { font-size: 8.2pt; line-height: 1.12; }
  .product-description small { display: none; }
  .product-units { font-size: 10pt; grid-column: 3; grid-row: 1; }
  .service-tag, .return-tag { font-size: 6pt; padding: 1px 3px; }
}
