.invoice-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.invoice {
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: clamp(22px, 3.2vw, 40px);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  max-width: 620px;
}

.invoice-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--text-strong);
}

.invoice-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.invoice-logo {
  width: auto;
  max-width: 160px;
  max-height: 58px;
}

.invoice-eyebrow {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.invoice-title {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 800;
  line-height: 1.15;
}

.invoice-number {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 4px 14px;
  text-align: right;
}

.invoice-number span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.invoice-number strong {
  color: var(--text-strong);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.invoice-number strong.invoice-code {
  font-size: 20px;
  max-width: 12px
}

.invoice-parties {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.invoice-parties h2,
.invoice-payment h2,
.invoice-shipping h2 {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.invoice-client-name {
  margin: 0 0 2px;
  color: var(--text-strong);
  font-size: 17px;
  font-weight: 700;
}

.invoice-client-line {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.invoice-client-whatsapp {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.invoice-client-whatsapp:hover {
  text-decoration: underline;
}

.invoice-tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.invoice-facts {
  display: grid;
  gap: 7px;
  margin: 0;
}

.invoice-facts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}

.invoice-facts dt {
  color: var(--text-muted);
}

.invoice-facts dd {
  margin: 0;
  color: var(--text-strong);
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.invoice-payment-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.invoice-payment-list li {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  font-size: 14px;
}

.invoice-payment-list span {
  color: var(--text-muted);
  font-weight: 400;
}

.invoice-fee-breakdown ul {
  align-items: flex-end;
}

.invoice-table-wrap {
  margin: 24px 0;
  overflow-x: auto;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.invoice-table th {
  padding: 10px 12px;
  background: var(--border-soft);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.invoice-table th:first-child {
  width: 46%;
  border-radius: 8px 0 0 8px;
}

.invoice-table th:nth-child(2) {
  width: 12%;
}

.invoice-table th:nth-child(3),
.invoice-table th:nth-child(4) {
  width: 21%;
}

.invoice-table th:last-child {
  border-radius: 0 8px 8px 0;
}

.invoice-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.invoice-table tbody tr:last-child td {
  border-bottom: none;
}

.invoice-table .is-numeric {
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.invoice-product-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.invoice-product-image {
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.invoice-product-details {
  min-width: 0;
}

.invoice-product-reference {
  display: block;
  color: var(--text-strong);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.invoice-cell-muted {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.invoice-transfer-source {
  text-align: center;
}

.invoice-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr);
  gap: 28px;
  align-items: start;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.invoice-shipping--below {
  margin-top: 24px;
}

.invoice-observation {
  white-space: pre-line;
}

.invoice-observation p {
  margin: 0;
}

.invoice-totals {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.invoice-totals div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 14px;
}

.invoice-totals dt {
  color: var(--text-muted);
}

.invoice-totals dd {
  margin: 0;
  color: var(--text-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.invoice-totals .invoice-total-row {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 2px solid var(--text-strong);
  font-size: 18px;
}

.invoice-totals .invoice-total-row dt {
  color: var(--text-strong);
  font-weight: 700;
}

.invoice-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.invoice-footer p {
  margin: 0;
}

.invoice-internal {
  margin-top: 24px;
  max-width: 575px;
}

.invoice-internal-note {
  margin: -8px 0 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.invoice-internal-block {
  margin-bottom: 20px;
}

.invoice-internal-block h2 {
  margin: 0 0 12px;
  color: var(--text-strong);
  font-size: 16px;
}

@media (max-width: 900px) {
  .invoice-bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .invoice-header {
    align-items: flex-start;
    gap: 12px;
  }

  .invoice-number {
    margin-left: auto;
    text-align: right;
  }

  .invoice-parties {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .invoice-parties > section {
    min-width: 0;
  }
}

@media screen and (max-width: 640px) {
  .invoice-table-wrap {
    overflow-x: auto;
    margin: 18px 0;
  }

  .invoice-table {
    table-layout: fixed;
    font-size: 12px;
  }

  .invoice-table th,
  .invoice-table td {
    padding: 5px 3px;
  }

  .invoice-table th {
    font-size: 10px;
    letter-spacing: 0.03em;
    white-space: normal;
  }

  .invoice-table th:first-child {
    width: 44%;
  }

  .invoice-table th:nth-child(2) {
    width: 12%;
  }

  .invoice-table th:nth-child(3),
  .invoice-table th:nth-child(4) {
    width: 22%;
  }

  .invoice-table td {
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .invoice-table .is-numeric {
    white-space: normal;
  }

  .invoice-product-info {
    gap: 5px;
  }

  .invoice-product-image {
    width: 52px;
    height: 52px;
    border-radius: 6px;
  }

  .invoice-product-reference {
    font-size: 12px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .invoice-cell-muted {
    margin-top: 1px;
    font-size: 11px;
    line-height: 1.3;
  }

  .invoice-toolbar {
    gap: 6px;
    margin-bottom: 12px;
  }

  .invoice-toolbar .btn-action {
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 13px;
  }

  .invoice {
    padding: 12px;
    border-radius: 10px;
  }

  .invoice-header {
    gap: 10px;
    padding-bottom: 12px;
    border-bottom-width: 1px;
  }

  .invoice-brand {
    gap: 10px;
  }

  .invoice-logo {
    max-width: 104px;
    max-height: 36px;
  }

  .invoice-eyebrow {
    margin-bottom: 2px;
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  .invoice-title {
    font-size: 20px;
  }

  .invoice-number {
    gap: 2px 10px;
  }

  .invoice-number span {
    font-size: 10px;
  }

  .invoice-number strong {
    font-size: 14px;
  }

  .invoice-number strong.invoice-code {
    font-size: 16px;
  }

  .invoice-parties {
    gap: 14px;
    padding: 12px 0;
  }

  .invoice-parties h2,
  .invoice-payment h2,
  .invoice-shipping h2 {
    margin-bottom: 6px;
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .invoice-client-name {
    margin-bottom: 1px;
    font-size: 15px;
  }

  .invoice-client-line {
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .invoice-tag {
    padding: 0 6px;
    font-size: 10px;
  }

  .invoice-facts {
    gap: 4px;
  }

  .invoice-facts div {
    gap: 6px;
    font-size: 12px;
  }

  .invoice-payment-list li {
    font-size: 13px;
  }

  .invoice-table-wrap {
    margin: 12px 0;
  }

  .invoice-bottom {
    gap: 14px;
    padding-top: 12px;
  }

  .invoice-shipping--below {
    margin-top: 14px;
  }

  .invoice-totals {
    gap: 6px;
    padding: 10px 12px;
  }

  .invoice-totals div {
    gap: 12px;
    font-size: 13px;
  }

  .invoice-totals .invoice-total-row {
    margin-top: 2px;
    padding-top: 8px;
    font-size: 16px;
  }

  .invoice-footer {
    gap: 4px 14px;
    margin-top: 14px;
    padding-top: 10px;
    font-size: 11px;
  }

  .invoice-internal {
    margin-top: 14px;
  }
}

@media print {
  .sidebar,
  .theme-toggle,
  .flash,
  .invoice-toolbar,
  .invoice-internal {
    display: none !important;
  }

  .dashboard-layout {
    display: block;
    background: #ffffff;
  }

  .main-content {
    padding: 0;
  }

  .invoice {
    --surface: #ffffff;
    --surface-alt: #ffffff;
    --text: #111111;
    --text-strong: #000000;
    --text-muted: #555555;
    --border: #c9c9c9;
    --border-soft: #e5e5e5;
    --border-strong: #888888;

    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: #ffffff;
    color: #111111;
  }

  .invoice-logo.logo-dark {
    display: none !important;
  }

  .invoice-logo.logo-light {
    display: block !important;
  }

  .invoice-table th {
    background: #f0f0f0;
  }

  body {
    background: #ffffff;
  }

  @page {
    margin: 14mm;
  }
}
