@import url("https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600;700&display=swap");

/* Self-contained document palette (no Tailwind dependency) */
:root {
  --background: #f8f7f4;
  --foreground: #1b1b1f;
  --muted: #f0efec;
  --muted-foreground: #6f6f78;
  --border: #e4e2dd;
}

@supports (color: oklch(50% 0.1 200)) {
  :root {
    --background: oklch(98.5% 0.002 90);
    --foreground: oklch(14.5% 0.015 285);
    --muted: oklch(95% 0.005 90);
    --muted-foreground: oklch(55% 0.015 285);
    --border: oklch(90% 0.005 285);
  }
}

/* Base document styles */
.document {
  --document-rule: var(--border);
  --document-rule-strong: var(--foreground);
  --document-surface: var(--background);
  --document-muted: var(--muted);
  font-family: "Inter Tight", "Helvetica Neue", "Helvetica", "IBM Plex Sans", sans-serif;
  font-size: 9.5pt;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--document-surface);
  padding: 36px 42px 52px;
  max-width: 900px;
  margin: 0 auto;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

@supports (color: color-mix(in oklab, black, white)) {
  .document {
    --document-rule: color-mix(in oklab, var(--foreground) 12%, var(--background));
    --document-rule-strong: color-mix(in oklab, var(--foreground) 30%, var(--background));
    --document-surface: color-mix(in oklab, var(--background) 96%, white);
    --document-muted: color-mix(in oklab, var(--muted) 75%, var(--background));
  }
}

@media screen {
  .document {
    border-radius: 18px;
    border: 1px solid var(--document-rule);
    box-shadow: 0 24px 60px rgba(15, 15, 20, 0.08);
  }
}

@supports (color: color-mix(in oklab, black, white)) {
  @media screen {
    .document {
      box-shadow: 0 24px 60px color-mix(in oklab, var(--foreground) 8%, transparent);
    }
  }
}

.document-section {
  margin-bottom: 14px;
}

.document-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--document-rule);
  position: relative;
}

.document-column {
  min-width: 0;
}

@media (min-width: 640px) {
  .document-columns::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 0.5px);
    width: 1px;
    background: var(--document-rule);
  }

  .document-column {
    padding-inline: 12px;
  }
}

/* Header with company info */
.document-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 48px;
  align-items: start;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--document-rule);
}

.document-branding {
  font-size: 8.75pt;
  color: var(--muted-foreground);
}

.document-branding strong {
  display: block;
  font-size: 11.5pt;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--foreground);
  margin-bottom: 6px;
}

.company-details {
  line-height: 1.5;
}

.document-logo {
  max-height: 60px;
  max-width: 200px;
}

.document-title {
  font-size: 20pt;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--foreground);
  margin-bottom: 6px;
}

.document-meta {
  text-align: right;
  font-size: 8.5pt;
  color: var(--muted-foreground);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.document-meta-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  justify-content: flex-end;
}

.document-meta-label {
  font-size: 6.25pt;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted-foreground);
  font-weight: 600;
}

.document-meta-value {
  font-size: 9pt;
  color: var(--foreground);
  font-weight: 500;
}

/* Address blocks */
.address-block {
  margin-bottom: 4px;
  font-size: 9pt;
  color: var(--foreground);
}

.address-block > div {
  margin-bottom: 1px;
}

.address-block > div:last-child {
  margin-bottom: 0;
}

.address-label {
  font-size: 6.25pt;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted-foreground);
  margin-bottom: 5px;
  font-weight: 600;
}

.address-name {
  font-weight: 600;
  margin-bottom: 3px;
}

.address-contact {
  font-size: 8.25pt;
  color: var(--muted-foreground);
}

/* Line items table */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  border-top: 1px solid var(--document-rule);
  border-bottom: 1px solid var(--document-rule);
  margin: 8px 0;
  font-size: 7.75pt;
}

.line-items-table th {
  border-bottom: 1px solid var(--document-rule);
  padding: 4px 5px;
  text-align: left;
  font-weight: 600;
  font-size: 6.5pt;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted-foreground);
  background: var(--document-muted);
}

.line-items-table td {
  padding: 4px 5px;
  border-bottom: 1px solid var(--document-rule);
  vertical-align: top;
  line-height: 1.2;
}

.line-items-table tr:last-child td {
  border-bottom: 1px solid var(--document-rule);
}

.line-items-table th + th,
.line-items-table td + td {
  box-shadow: inset 1px 0 0 var(--document-rule);
}

.line-items-table .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.line-items-table td.number {
  white-space: nowrap;
}

.line-items-table .col-sku,
.line-items-table .col-qty,
.line-items-table .col-unit,
.line-items-table .col-total,
.line-items-table .col-location {
  white-space: nowrap;
}

.line-items-table .col-sku {
  width: 11ch;
}

.line-items-table .col-qty {
  width: 6ch;
}

.line-items-table .col-unit,
.line-items-table .col-total {
  width: 9ch;
}

.line-items-table .col-location {
  width: 14ch;
}

.line-items-table .col-item {
  width: auto;
  word-break: break-word;
}

.line-item-name {
  font-weight: 600;
}

.line-item-sku {
  margin-top: 1px;
  font-size: 6.5pt;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
}

.document-mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
  letter-spacing: 0.02em;
}

/* Picklist-specific: checkbox column */
.line-items-table .checkbox-cell {
  width: 26px;
  text-align: center;
}

.checkbox-box {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--document-rule-strong);
  border-radius: 4px;
}

/* Summary section */
.document-summary {
  margin-left: auto;
  width: 190px;
  max-width: 100%;
  border: 1px solid var(--document-rule);
  border-radius: 8px;
  background: var(--document-muted);
  padding: 4px 6px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
  font-size: 7.5pt;
  color: var(--foreground);
}

.summary-row span:first-child {
  color: var(--muted-foreground);
}

.summary-row.total {
  font-weight: 600;
  font-size: 8.5pt;
  border-top: 1px solid var(--document-rule-strong);
  margin-top: 3px;
  padding-top: 4px;
}

/* Footer */
.document-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--document-rule);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  font-size: 8pt;
  color: var(--muted-foreground);
}

.footer-block {
  min-width: 0;
}

.footer-label {
  font-size: 6.25pt;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted-foreground);
  margin-bottom: 5px;
  font-weight: 600;
}

.footer-content {
  color: var(--foreground);
  line-height: 1.5;
}

/* Picklist readability */
.document-picklist {
  font-size: 10pt;
}

.document-picklist .line-items-table th {
  font-size: 6.75pt;
}

/* Print-specific adjustments */
@media print {
  .document {
    margin: 0;
    padding: 18px 24px 30px;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
    border: none;
    background: transparent;
  }

  .document-columns {
    break-inside: avoid;
  }

  .document-columns::after {
    display: none;
  }

  .document-summary {
    background: transparent;
  }

  /* Avoid breaking inside table rows */
  .line-items-table tr {
    page-break-inside: avoid;
  }
}
