@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500;600&family=Montserrat:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --ink: #0b3d91;
  --gold: #b8963e;
  --gold-light: #e8c97a;
  --gold-pale: #fdf6e3;
  --muted: #6b6b6b;
  --border: #e0d6c2;
  --bg: #fafaf8;
  --white: #ffffff;
  --accent-red: #c0392b;
  --success: #2e7d32;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  font-family: 'Montserrat', sans-serif;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
}

.invoice-wrapper {
  width: 100%;
  max-width: 900px;
}

.print-btn {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.print-btn button {
  background: var(--gold);
  color: white;
  border: none;
  padding: 10px 28px;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}

.invoice {
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: 0 4px 40px rgba(0,0,0,0.06);
}

.invoice-header {
  background: var(--ink);
  padding: 44px 52px 36px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.agency-brand .agency-name {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  color: var(--white);
  line-height: 1.2;
}

.agency-brand .tagline {
  font-size: 11px;
  color: var(--gold-light);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 6px;
}

.agency-brand .agency-contact {
  margin-top: 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  line-height: 1.8;
}

.agency-logo {
  display: inline-block;
  margin-bottom: 12px;
  margin-right: 14px;
}

.agency-logo img {
  height: 56px;
  width: auto;
  display: block;
}

.invoice-badge {
  text-align: right;
}

.invoice-badge .label {
  font-family: 'Playfair Display', serif;
  font-size: 42px;
  color: var(--gold);
  line-height: 1;
}

.invoice-badge .inv-number,
.invoice-badge .inv-date {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: rgba(255,255,255,0.95);
  margin-top: 8px;
  letter-spacing: 0.06em;
  font-weight: 600;
  display: block;
  text-align: right;
}

.gold-bar { height: 3px; background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%); }

.bill-section {
  padding: 36px 52px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.bill-to-block .section-label,
.notes-section .note-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 10px;
}

.bill-to-block .client-name {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 4px;
}

.bill-to-block .client-address {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

.campaign-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.campaign-meta .meta-row {
  display: flex;
  width: 340px;
  justify-content: flex-end;
  gap: 20px;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--muted);
}

.campaign-meta .meta-row span:first-child {
  width: 130px;
  text-align: right;
  font-weight: 600;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.campaign-meta .meta-row span:last-child {
  width: 190px;
  text-align: left;
  flex-shrink: 0;
}

.table-section { padding: 0 52px 32px; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 28px;
}

thead tr { border-bottom: 2px solid var(--ink); }

thead th {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 0 0 12px;
  text-align: left;
}

thead th:last-child,
thead th:nth-child(3),
thead th:nth-child(4) { text-align: right; }

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 16px 0;
  font-size: 14px;
  vertical-align: top;
}

tbody td:last-child,
tbody td:nth-child(3),
tbody td:nth-child(4) { text-align: right; }

.service-name { font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.service-desc { font-size: 12px; color: var(--muted); }

.totals-section {
  padding: 0 52px 40px;
  display: flex;
  justify-content: flex-end;
}

.totals-box {
  width: 340px;
  background: var(--gold-pale);
  border: 1px solid var(--border);
  padding: 24px 28px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.totals-row:last-of-type { border-bottom: none; }

.totals-row.grand {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 2px solid var(--gold);
  border-bottom: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
}

.totals-row.grand .gr-val {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--gold);
}

.totals-row .label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.totals-row .val {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}

.payment-section {
  padding: 0 52px 40px;
  display: flex;
  gap: 20px;
}

.payment-card {
  flex: 1;
  border: 1px solid var(--border);
  padding: 20px 22px;
}

.payment-card .card-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.payment-card .card-value {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--ink);
}

.payment-card.due .card-value { color: var(--accent-red); }
.payment-card.pending .card-value { color: var(--gold); }

.payment-card .card-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.payment-card.settled .card-value { color: var(--success); }

.notes-section {
  padding: 24px 52px;
  border-top: 1px solid var(--border);
  background: #f5f4f0;
}

.notes-section p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.invoice-footer {
  background: var(--ink);
  padding: 18px 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.invoice-footer .footer-left {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  color: var(--gold-light);
}

.invoice-footer .footer-right {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  max-width: 50%;
  text-align: right;
}

.invoice-footer .footer-right a {
  color: #fff8dc;
  text-decoration: none;
  word-break: break-word;
}

.invoice-footer .footer-right a:hover {
  text-decoration: underline;
}

.invoice-status {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.15);
  color: #fff;
}

@page {
  size: A4 portrait;
  margin: 6mm 8mm;
}

@media print {
  html, body {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    min-height: auto !important;
  }

  .print-btn, .no-print {
    display: none !important;
  }

  .invoice-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .invoice {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .invoice-header {
    padding: 24px 32px 20px !important;
  }

  .bill-section {
    padding: 20px 32px !important;
  }

  .table-section {
    padding: 0 32px 16px !important;
  }

  table {
    margin-top: 14px !important;
  }

  tbody td {
    padding: 10px 0 !important;
  }

  .totals-section {
    padding: 0 32px 20px !important;
  }

  .totals-box {
    padding: 14px 18px !important;
  }

  .totals-row {
    padding: 4px 0 !important;
  }

  .payment-section {
    padding: 0 32px 20px !important;
  }

  .payment-card {
    padding: 12px 16px !important;
  }

  .notes-section {
    padding: 16px 32px !important;
  }

  .invoice-footer {
    padding: 12px 32px !important;
  }

  tr, .payment-card, .totals-box, .notes-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
