/* Billing pages. Money in tabular figures; overdue in red, money received in green. */
.stat-ok .stat-n { color: var(--ok); }
.callout-info { background: var(--accent-soft); color: var(--ink); font-size: 0.88rem; }
.button.small { padding: 6px 12px; font-size: 0.86rem; }
.muted { color: var(--muted); }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.amount-lg { font-family: var(--font-display); font-size: 1.4rem; }
.amount-in { color: var(--ok); }
.amount-out { color: var(--muted); }
.item > .amount { margin-left: auto; align-self: center; }
.item > form.inline { align-self: center; }
.tile-word { font-size: 1.35rem; }
.tile-hot { border-color: color-mix(in srgb, var(--hot) 35%, var(--line)); }
.tile-hot .tile-s { color: var(--hot); font-weight: 600; }
.tag-cost { background: var(--citrus-soft); color: var(--citrus-ink); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.bill-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.bill-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.bill-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bill-table tbody tr:last-child td { border-bottom: 0; }
.bill-table td:first-child, .bill-table td.d { white-space: nowrap; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill-table tr.is-nocharge td { color: var(--muted); }

.inv-state { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; letter-spacing: 0; text-transform: none; vertical-align: middle; }
.inv-draft { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }
.inv-sent { background: var(--accent-soft); color: var(--accent); }
.inv-partial { background: var(--citrus-soft); color: var(--citrus-ink); }
.inv-overdue { background: var(--hot-soft); color: var(--hot); }
.inv-paid { background: var(--ok-soft); color: var(--ok); }
.item > .inv-state { align-self: center; }

.timer { display: inline-flex; align-items: center; gap: 8px; }
.timer-face { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.timer.is-running .timer-face { color: var(--hot); }
.timer.is-running .timer-face::before { content: "● "; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .timer.is-running .timer-face::before { animation: none; } }
.flat-fee { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

.trust-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.trust-form .input:nth-of-type(3) { grid-column: span 2; }
.trust-form .button { justify-self: start; }
.ledger .item { padding: 8px 0; }

.keeper-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 6px; margin-bottom: 10px; }
.keeper-row .input:first-of-type { grid-column: span 2; font-weight: 600; }
.input-short { max-width: 110px; }
#rates .field { margin-top: 10px; }
#rates .button { margin-top: 10px; }

.bill-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 8px; }
.bill-kpis div { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.bill-kpis dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; color: var(--muted); }
.bill-kpis dd { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.bill-kpis dd.sub { font: 600 0.78rem var(--font-body); color: var(--muted); }
.bill-kpis dd.is-hot { color: var(--hot); }

/* The invoice, drawn like the Word version */
.inv-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.invoice-paper { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 44px 52px; margin-bottom: 18px;
  font-family: "Times New Roman", Times, serif; font-size: 11pt; line-height: 1.35; min-width: 0; overflow-x: auto; }
@media (max-width: 600px) { .invoice-paper { padding: 22px 16px; } }
.invoice-paper p { margin: 0; }
.inv-letterhead { text-align: center; padding-bottom: 8px; border-bottom: 1px solid #333; margin-bottom: 18px; color: #555; font-size: 10pt; }
.inv-firm { font-size: 16pt; font-weight: bold; color: #111; }
.inv-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; }
.inv-h { font-size: 14pt; font-weight: bold; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px !important; }
.inv-label { font-weight: bold; }
.inv-meta { margin: 0; display: grid; gap: 2px; min-width: 220px; }
.inv-meta div { display: flex; justify-content: space-between; gap: 16px; }
.inv-meta dt { font-weight: bold; }
.inv-meta dd { margin: 0; }
.inv-due { border-top: 1px solid #333; padding-top: 4px; margin-top: 4px; font-size: 12pt; }
.inv-re { margin: 18px 0 6px !important; }
.invoice-paper h3 { font-size: 12pt; margin: 18px 0 6px; }
.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.inv-table th, .inv-table td { border: 1px solid #999; padding: 4px 6px; vertical-align: top; text-align: left; }
.inv-table th { background: #ededed; font-size: 10pt; }
.inv-table td.d { white-space: nowrap; }
.inv-table tfoot td { font-weight: bold; }
.inv-summary { margin-top: 18px; max-width: 440px; margin-left: auto; }
.inv-summary tr.strong td { font-weight: bold; }
.inv-summary tr.total td { background: #ededed; font-size: 12pt; }
.inv-foot { margin-top: 12px !important; font-size: 10pt; color: #444; }

.pay-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.pay-option { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); display: grid; gap: 6px; align-content: start; justify-items: start; }
.pay-option .trust-form { margin-top: 0; width: 100%; }
.pay-list { margin-top: 12px; }

.paybox { max-width: 440px; margin: 8px auto; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.pay-amount { font-family: var(--font-display); font-size: 2.4rem; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; }
.pay-form { display: grid; gap: 10px; margin: 16px 0; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-btn { width: 100%; padding: 12px; }

@media print {
  .rail, .sections, .matter-head, .inv-bar, .callout, .flash, .no-print, .preview-banner { display: none !important; }
  .app, .layout { display: block; }
  .page { padding: 0; max-width: none; }
  body { background: #fff; }
  .invoice-paper { border: 0; box-shadow: none; padding: 0; }
}
