/*
 * Billing group print layout — loaded only by layouts/billing_print.html.erb
 */

:root {
  --ink: #1a1f2b;
  --ink-muted: #5a6473;
  --ink-faint: #8a93a3;
  --line: #d6d9df;
  --line-light: #e6e8ec;
  --surface: #ffffff;
  --surface-muted: #fafbfc;
  --accent: #137a4a;
  --accent-dark: #0f6239;
  --accent-soft: #e8f5ec;
  --accent-border: #b8dfc8;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif;
  color: var(--ink);
  line-height: 1.45;
  background: #eef1f5;
}

.no-print {
  display: block;
}

.print-toolbar {
  max-width: 14in;
  margin: 16px auto 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

.print-toolbar__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.print-toolbar__btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.print-toolbar__btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.sheet {
  background: var(--surface);
  box-shadow: 0 2px 24px rgba(26, 31, 43, 0.12);
  margin: 0 auto 24px;
}

.sheet--summary {
  max-width: 8.5in;
  padding: 0.55in 0.6in 0.65in;
  display: flex;
  flex-direction: column;
  min-height: 11in;
}

.sheet--detail {
  max-width: 14in;
  padding: 0.25in;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--accent);
}

.brand-row img {
  height: 28px;
  width: auto;
}

.brand-row__meta {
  text-align: right;
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.6;
}

.doc-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.doc-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.kpi {
  border: 1px solid var(--line-light);
  padding: 12px 14px;
  background: white;
}

.kpi__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.kpi__value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.kpi--hero {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.kpi--hero .kpi__value {
  color: var(--accent-dark);
  font-size: 26px;
}

.calc-section {
  margin: 20px 0;
}

.calc-section h3 {
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.calc-block {
  border: 1px solid var(--line-light);
  background: var(--surface-muted);
  padding: 14px 16px;
}

.calc-block--wide {
  grid-column: 1 / -1;
}

.math-stack {
  display: grid;
  gap: 6px;
}

.math-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: baseline;
  font-size: 12px;
}

.math-row__label {
  color: var(--ink-muted);
}

.math-row__value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 8.5em;
  text-align: right;
}

.math-row--operator .math-row__label {
  font-weight: 600;
  color: var(--ink);
}

.math-row--result {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.math-row--result .math-row__label,
.math-row--result .math-row__value {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
}

.footer-line {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line-light);
  font-size: 10px;
  color: var(--ink-faint);
  text-align: center;
  flex-shrink: 0;
}

.detail-head {
  margin-bottom: 6px;
}

.detail-head h2 {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 700;
}

.detail-head p {
  margin: 0;
  font-size: 9px;
  color: var(--ink-muted);
}

.table-wrap {
  overflow: hidden;
}

table.detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 6.75pt;
}

table.detail-table col.col-id { width: 6.5%; }
table.detail-table col.col-owner { width: 9%; }
table.detail-table col.col-address { width: 8.5%; }
table.detail-table col.col-lbs { width: 3.2%; }
table.detail-table col.col-account { width: 6.5%; }
table.detail-table col.col-type { width: 2.8%; }
table.detail-table col.col-closing { width: 4.2%; }
table.detail-table col.col-num { width: 4.35%; }

table.detail-table thead th {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  padding: 2px 2px;
  vertical-align: bottom;
  font-size: 6pt;
  font-weight: 700;
  color: var(--ink-muted);
  line-height: 1.1;
}

table.detail-table thead th span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.detail-table tbody td {
  border-bottom: 1px solid var(--line-light);
  padding: 1px 2px;
  vertical-align: top;
  line-height: 1.1;
}

tr.community-row td {
  background: var(--accent-soft);
  border-top: 1px solid var(--accent-border);
  border-bottom: 1px solid var(--accent-border);
  padding: 3px 4px;
  font-size: 6.5pt;
  font-weight: 600;
  color: var(--accent-dark);
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.text {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.text-wrap {
  white-space: normal;
  word-break: break-word;
}

td.muted {
  color: var(--ink-faint);
}

@page summary {
  size: letter portrait;
  margin: 0.5in 0.55in;
}

@page detail {
  size: legal landscape;
  margin: 0.25in;
}

.print-summary {
  page: summary;
}

.print-detail {
  page: detail;
  page-break-before: always;
}

@media print {
  body {
    background: white;
  }

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

  .sheet {
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .sheet--summary {
    min-height: 10in;
  }

  thead {
    display: table-header-group;
  }

  .sheet--detail {
    font-size: 6.75pt;
  }

  table.detail-table tbody tr {
    break-inside: avoid;
  }

  tr.community-row {
    break-after: avoid;
  }

  tr {
    break-inside: avoid;
  }
}
