/* Printable invoice — matches Invoice 8.pdf layout */
.invoice-page {
  --inv-ink: #222;
  --inv-muted: #777;
  --inv-line: #ddd;
  --inv-head: #555;
  background: #fff;
  color: var(--inv-ink);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  width: 800px;
  max-width: 100%;
  margin: 0 auto;
  padding: 48px 52px 56px;
  box-sizing: border-box;
}

/* Design presets (extend with .invoice-design-* in future) */
.invoice-page.invoice-design-standard1 {}

.invoice-page.invoice-page-declined {
  position: relative;
  opacity: 0.72;
}

.invoice-page.invoice-page-declined::after {
  content: "DECLINED";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 4.5rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(100, 116, 139, 0.28);
  transform: rotate(-18deg);
}

.invoice-page.invoice-page-declined .title,
.invoice-page.invoice-page-declined .number {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(100, 116, 139, 0.7);
}

.invoice-page.invoice-page-draft {
  position: relative;
}

.invoice-page.invoice-page-draft::after {
  content: "DRAFT";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 5rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: rgba(100, 116, 139, 0.26);
  transform: rotate(-28deg);
  z-index: 2;
}

.invoice-import-preview {
  margin-top: 0.5rem;
  border: 1px solid var(--line, #ddd);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.invoice-import-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  background: #fff;
}

.invoice-import-preview iframe {
  display: block;
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: #fff;
}

.invoice-import-declined .section-title {
  text-decoration: line-through;
  opacity: 0.75;
}

.invoice-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.invoice-logo {
  max-width: 240px;
  max-height: 140px;
  object-fit: contain;
  display: block;
}

.invoice-logo-fallback {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #333;
}

.invoice-title-block {
  text-align: right;
}

.invoice-title-block .title {
  font-size: 42px;
  font-weight: 700;
  color: #9a9a9a;
  letter-spacing: 0.02em;
  line-height: 1;
  margin: 0;
}

.invoice-title-block .number {
  margin-top: 6px;
  font-size: 16px;
  color: #666;
}

.invoice-meta {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 40px;
  align-items: flex-start;
}

.invoice-from {
  max-width: 320px;
}

.invoice-right {
  min-width: 280px;
  max-width: 340px;
}

.invoice-from .company {
  font-weight: 700;
  margin: 0 0 2px;
}

.invoice-from .reg,
.invoice-from .addr-label {
  color: var(--inv-muted);
  margin: 0;
}

.invoice-from .addr {
  margin: 0;
  white-space: pre-line;
}

.invoice-dates {
  min-width: 240px;
  margin-top: 8px;
}

.invoice-dates .row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 0;
}

.invoice-dates .label {
  color: var(--inv-muted);
  text-align: right;
  flex: 1;
}

.invoice-dates .value {
  text-align: right;
  min-width: 110px;
  font-weight: 500;
}

.balance-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ececec;
  padding: 10px 14px;
  margin-top: 10px;
  font-weight: 700;
}

.bill-to {
  margin-bottom: 28px;
  min-height: 140px;
}

.bill-to-right {
  margin-top: 0;
  margin-bottom: 24px;
  min-height: 140px;
}

.invoice-right .invoice-dates {
  margin-top: 8px;
}

.bill-to .label {
  font-weight: 700;
  margin-bottom: 10px;
}

.bill-to .name {
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.4;
}

.bill-to .address {
  white-space: pre-line;
  line-height: 1.5;
  margin-top: 3px;
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.inv-table thead th {
  background: var(--inv-head);
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 9px 12px;
}

.inv-table thead th.num {
  text-align: right;
}

.inv-table tbody td {
  padding: 12px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.inv-table tbody td.num {
  text-align: right;
  white-space: nowrap;
}

.inv-bottom {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 18px;
}

.terms .label {
  color: var(--inv-muted);
  margin-bottom: 4px;
}

.terms .body {
  white-space: pre-line;
  max-width: 340px;
}

.totals {
  min-width: 240px;
}

.totals .row {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  padding: 5px 0;
}

.totals .row.total {
  font-weight: 700;
  border-top: 1px solid #eee;
  margin-top: 4px;
  padding-top: 10px;
}

.totals .label {
  color: var(--inv-muted);
  text-align: right;
  flex: 1;
}

.totals .value {
  text-align: right;
  min-width: 100px;
}

.created-by {
  margin-top: 10px;
  padding-top: 0;
  border-top: 0;
  color: var(--inv-muted);
  font-size: 12px;
  text-align: center;
  width: 100%;
}

.created-by a {
  color: #374151;
  text-decoration: none;
}

.created-by a:hover {
  text-decoration: underline;
}

.inv-disclaimer {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid #eee;
  color: var(--inv-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: left;
  width: 100%;
}

.inv-disclaimer p {
  margin: 0 0 0.45rem;
}

.inv-disclaimer-title {
  margin: 0 0 0.35rem;
  color: #111827;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.inv-disclaimer-link {
  margin: 0;
}

.inv-disclaimer-link a {
  color: #374151;
  font-weight: 600;
  text-decoration: underline;
}

.crypto-pay {
  margin-top: 1rem;
}

.crypto-pay-locked .crypto-pay-meta {
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
}

.digital-share-wrap {
  width: min(800px, calc(100% - 2rem));
  margin: 0.75rem auto;
  padding: 0;
}

.digital-share-card .section-title {
  font-size: 1.05rem;
}

.digital-share-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0.75rem 0;
}

.digital-share-form label {
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.digital-share-form select {
  min-width: 8rem;
  width: auto;
}

.digital-share-new {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.digital-share-new label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.digital-share-copy-row {
  display: flex;
  gap: 0.5rem;
}

.digital-share-copy-row input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.digital-share-list {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.digital-share-list .label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.digital-share-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.digital-share-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  font-size: 0.85rem;
  padding: 0.35rem 0;
  color: var(--muted);
}

.digital-share-list li .btn {
  margin-left: auto;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
}

.digital-share-list li.is-expired {
  opacity: 0.55;
}

.share-body {
  background: var(--bg);
  min-height: 100vh;
}

.share-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: var(--topbar-bg);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.share-banner-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.share-banner-warn {
  color: #c2410c;
}

html[data-theme="dark"] .share-banner-warn {
  color: #fdba74;
}

.share-banner-ok {
  color: #15803d;
}

html[data-theme="dark"] .share-banner-ok {
  color: #86efac;
}

.share-fill-card {
  padding-top: 1rem;
  padding-bottom: 0;
}

.crypto-pay-label {
  font-weight: 700;
  margin: 0.25rem 0;
}

.crypto-pay-meta {
  color: var(--inv-muted);
  margin-bottom: 0.25rem;
}

.crypto-pay-address,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  word-break: break-all;
  line-height: 1.4;
}

.crypto-pay-address .addr-check {
  color: var(--inv-ink);
  font-weight: 700;
  background: rgba(15, 118, 110, 0.14);
  border-radius: 2px;
  padding: 0 1px;
}

.crypto-pay-warn {
  margin: 0.55rem 0 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.crypto-pay-qr {
  display: block;
  margin-top: 0.75rem;
  width: 140px;
  height: 140px;
  border: 1px solid #eee;
  border-radius: 4px;
}

.pay-from-block {
  margin-top: 0.5rem;
}

.invoice-actions {
  width: min(800px, calc(100% - 2rem));
  margin: 1rem auto 0.5rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .invoice-page {
    padding: 1.25rem 1rem 1.5rem;
    width: calc(100% - 1rem);
  }

  .invoice-top {
    flex-direction: column;
    gap: 1rem;
  }

  .invoice-title-block {
    text-align: left;
  }

  .invoice-title-block .title {
    font-size: 2rem;
  }

  .invoice-meta {
    flex-direction: column;
    gap: 1.25rem;
  }

  .invoice-from,
  .invoice-right {
    max-width: none;
    min-width: 0;
  }

  .invoice-dates {
    min-width: 0;
  }

  .inv-bottom {
    flex-direction: column;
    gap: 1.25rem;
  }

  .terms .body,
  .totals {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .invoice-actions {
    width: calc(100% - 1.25rem);
  }

  .invoice-actions .btn,
  .invoice-actions form {
    flex: 1 1 calc(50% - 0.4rem);
  }

  .invoice-actions form .btn {
    width: 100%;
  }

  .inv-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media print {
  body {
    background: #fff !important;
  }
  .topbar,
  .invoice-actions,
  .flash,
  .no-print {
    display: none !important;
  }
  .wrap {
    width: auto;
    margin: 0;
  }
  .invoice-page {
    width: 100%;
    padding: 0;
    box-shadow: none;
  }
  @page {
    margin: 14mm;
  }
}
