/* ── View page ──────────────────────────────────────────────────────────────── */

.view-layout {
  max-width: 880px;
  margin: 0 auto;
}

.view-drop-card {
  margin-bottom: var(--space-5);
}

.view-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-4);
}

/* ── Invoice paper ─────────────────────────────────────────────────────────── */

.invoice-paper {
  background: #fdf8f0;
  color: #111;
  border-radius: var(--radius-md);
  padding: var(--space-10);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* ── Invoice header ────────────────────────────────────────────────────────── */

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 2px solid #e2e8f0;
}

.inv-type {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: var(--space-1);
}

.inv-id {
  font-size: var(--text-xl);
  font-weight: 700;
  color: #0f172a;
}

.inv-header-right {
  text-align: right;
  color: #475569;
}

.inv-header-right > div {
  margin-bottom: var(--space-1);
}

/* ── Parties ───────────────────────────────────────────────────────────────── */

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}

.inv-party-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: var(--space-2);
}

.inv-party-name {
  font-weight: 600;
  color: #0f172a;
  margin-bottom: var(--space-1);
}

.inv-party > div {
  color: #475569;
}

.inv-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-right: 0.3em;
}

/* ── Line items ────────────────────────────────────────────────────────────── */

.inv-lines-wrap {
  margin-bottom: var(--space-6);
  overflow-x: auto;
}

.inv-lines {
  color: #1e293b;
}

.inv-lines thead th {
  background: #f5ede0;
  color: #64748b;
}

.inv-col-id {
  width: 3rem;
  color: #94a3b8;
}

.inv-col-desc {
  /* takes remaining space */
}

.inv-col-num {
  text-align: right;
  white-space: nowrap;
}

/* ── Totals ────────────────────────────────────────────────────────────────── */

.inv-totals-wrap {
  display: flex;
  justify-content: flex-end;
}

.inv-totals {
  min-width: 280px;
  border-collapse: collapse;
  color: #1e293b;
}

.inv-totals td {
  padding: var(--space-1) var(--space-3);
}

.inv-totals td:first-child {
  color: #475569;
}

.inv-totals td.inv-col-num {
  font-variant-numeric: tabular-nums;
}

.inv-totals tr:first-child td {
  padding-top: var(--space-3);
  border-top: 1px solid #e2e8f0;
}

.inv-totals-payable td {
  padding-top: var(--space-3);
  border-top: 2px solid #e2e8f0;
  font-weight: 700;
  font-size: var(--text-base);
  color: #0f172a;
}

/* ── Invoice paper dark mode ────────────────────────────────────────────────── */

.invoice-paper--dark {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Header */
.invoice-paper--dark .inv-header {
  border-bottom-color: var(--border);
}
.invoice-paper--dark .inv-type {
  color: var(--text-muted);
}
.invoice-paper--dark .inv-id {
  color: var(--text);
}
.invoice-paper--dark .inv-header-right {
  color: var(--text-secondary);
}

/* Parties */
.invoice-paper--dark .inv-party-name {
  color: var(--text);
}
.invoice-paper--dark .inv-party > div {
  color: var(--text-secondary);
}
.invoice-paper--dark .inv-party-label,
.invoice-paper--dark .inv-label {
  color: var(--text-muted);
}

/* Lines */
.invoice-paper--dark .inv-lines {
  color: var(--text);
}
.invoice-paper--dark .inv-lines thead th {
  background: var(--bg-card);
  color: var(--text-muted);
}
.invoice-paper--dark .data-table td {
  color: var(--text-secondary);
}
.invoice-paper--dark .inv-col-id {
  color: var(--text-muted);
}

/* Totals */
.invoice-paper--dark .inv-totals {
  color: var(--text);
}
.invoice-paper--dark .inv-totals td:first-child {
  color: var(--text-secondary);
}
.invoice-paper--dark .inv-totals tr:first-child td {
  border-top-color: var(--border);
}
.invoice-paper--dark .inv-totals-payable td {
  border-top-color: var(--border-light);
  color: var(--text);
}

/* Payment terms */
.invoice-paper--dark .inv-payment-terms {
  color: var(--text-secondary);
}

/* ── Print ─────────────────────────────────────────────────────────────────── */

@media print {
  @page {
    margin: 1.5cm;
  }

  nav,
  .view-drop-card,
  .view-toolbar,
  #view-error {
    display: none !important;
  }

  body {
    background: white;
  }

  .view-layout {
    max-width: 100%;
  }

  .invoice-paper {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    background: #fff;
  }
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .inv-parties {
    grid-template-columns: 1fr;
  }

  .inv-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  .inv-header-right {
    text-align: left;
  }
}
