/* Customer portal, invoices and billing badges (public portal + admin). */
.portal-narrow { max-width: 520px; }
.portal { gap: 36px; padding-top: 32px; }
.portal-section { display: flex; flex-direction: column; gap: 16px; }
.portal .section-head { align-items: baseline; }
.portal .actions form, .pay-box form, .portal-hero form { margin: 0; }
.right { text-align: right; }

/* Navy account band, like the About band on the homepage */
.portal-hero { background: var(--navy); color: #fff; }
.portal-hero-inner { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; padding-top: 36px; padding-bottom: 32px; }
.portal-hero-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.portal-eyebrow { display: inline-flex; align-items: center; gap: 10px; color: var(--navy-soft); }
.portal-eyebrow .dot { width: 10px; height: 10px; background: var(--red); transform: skewX(-12deg); }
.portal-name { margin: 0; font-family: var(--display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: clamp(32px, 5vw, 56px); line-height: 1; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.portal-hero .btn-ghost { min-height: 40px; background: transparent; }
.portal-hero .btn-ghost:hover { background: #fff; color: var(--navy); }

/* Timing-tower tiles */
.tower { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.tower-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; background: var(--surf); border: 1px solid var(--line); border-left: 5px solid var(--navy); border-radius: 10px; padding: 18px 20px; }
.tower-tile .label { color: var(--muted); font-size: 11px; }
.tower-tile .btn { margin-top: 6px; }
.tower-figure { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 38px; line-height: 1.05; }
.tower-date { font-size: 28px; }
.tower-tile.is-due { border-left-color: var(--red); background: #fff; }
.tower-tile.is-due .tower-figure { color: var(--red-ink); }
.tower-tile.is-clear { border-left-color: #2F8F4E; }

/* Invoice rows */
.inv-list { display: flex; flex-direction: column; gap: 10px; }
.inv-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(160px, 2fr) auto auto; align-items: center; gap: 8px 20px; padding: 14px 18px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: 10px; color: var(--ink); text-decoration: none; }
.inv-row:hover { border-color: var(--ink); color: var(--ink); }
.inv-row.is-paid { border-left-color: #2F8F4E; background: var(--surf); }
.inv-num { display: flex; flex-direction: column; }
.inv-num .label { font-size: 10px; color: var(--muted); }
.inv-num strong { font-family: var(--mono); font-weight: 500; font-size: 15px; }
.inv-amt { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 24px; }
@media (max-width: 640px) { .inv-row { grid-template-columns: 1fr auto; } .inv-date { grid-column: 1 / -1; order: 3; } .inv-row .btn { grid-column: 1 / -1; order: 4; } }

/* Race rows, like a TV guide */
.race-list { display: flex; flex-direction: column; }
.race-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 12px 20px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.race-date { display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--navy); color: #fff; border-radius: 8px; padding: 6px 0; line-height: 1; }
.race-date strong { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 28px; line-height: 1.05; }
.race-date .label { font-size: 10px; color: var(--navy-soft); }
.race-row.rs-hidden .race-date { background: var(--red); }
.race-row.rs-hidden .race-date .label { color: #FFD9D9; }
.race-row.rs-paid .race-date { background: var(--navy); }
.race-what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.race-what strong { font-size: 16px; }
.race-when { color: var(--navy); font-weight: 500; }
.race-bill { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.race-price { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 20px; }
@media (max-width: 640px) { .race-row { grid-template-columns: 56px minmax(0, 1fr); } .race-bill { grid-column: 2; align-items: flex-start; text-align: left; } }

.tag-paid { background: #E8F5EC; color: #14532D; border: 1px solid #9BCFAA; }
.tag-due { background: #FFF6DB; color: #6B4E00; border: 1px solid #E8CF7A; }

.pay-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; border: 2px solid var(--navy); border-radius: 10px; background: #F5F6FF; }
.pay-box p { margin: 4px 0 0; }
.btn-paypal { background: #FFC439; color: #111; font-weight: 700; min-width: 220px; }
.btn-paypal:hover { background: #F2BA36; color: #111; }

/* Public pages don't load admin.css, so tables are styled here too. */
.portal .table-scroll { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.portal .table { width: 100%; border-collapse: collapse; font-size: 15px; }
.portal .table th { text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--surf); padding: 10px 14px; }
.portal .table td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.portal .nowrap, .invoice-doc .nowrap { white-space: nowrap; }

/* The invoice itself (screen and print). */
.invoice-doc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: clamp(20px, 4vw, 44px); display: flex; flex-direction: column; gap: 28px; max-width: 900px; }
.invoice-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; }
.invoice-from { margin-top: 8px; font-size: 14px; color: var(--muted); }
.invoice-from strong { color: var(--ink); }
.invoice-meta { display: flex; flex-direction: column; gap: 2px; font-size: 14px; text-align: right; }
.invoice-meta .muted { display: inline-block; min-width: 60px; }
.invoice-word { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 34px; line-height: 1; margin-bottom: 8px; }
.invoice-status { margin-top: 8px; font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; font-weight: 500; }
.status-paid { color: #14532D; }
.status-open { color: var(--red-ink); }
.status-void { color: var(--muted); text-decoration: line-through; }
.invoice-to { display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.invoice-to .label { font-size: 11px; letter-spacing: 0.08em; margin-bottom: 4px; }
.invoice-lines { width: 100%; border-collapse: collapse; font-size: 15px; }
.invoice-lines th { text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--ink); padding: 8px 10px; }
.invoice-lines th.right { text-align: right; }
.invoice-lines td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.invoice-lines tfoot td { border-bottom: 0; padding-top: 8px; padding-bottom: 4px; }
.invoice-notes p { margin: 0 0 8px; }
.invoice-foot { margin: 0; border-top: 1px solid var(--line); padding-top: 16px; }

@media print {
  .site-header, .site-footer, .no-print, .admin-header, .admin-sub, .admin-title, .skip { display: none !important; }
  .page, .admin-main { padding: 0 !important; }
  .invoice-doc { border: 0; padding: 0; max-width: none; }
  body { font-size: 12pt; }
  a { color: inherit; text-decoration: none; }
}

/* Admin bits */
.import-billing { flex-basis: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.import-billing .fieldset { width: 100%; }
.money-input { max-width: 140px; }
.race-pick td { vertical-align: middle; }
.race-pick input[type="checkbox"] { width: 20px; height: 20px; }
.billing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form .field { flex: 1 1 220px; }
.copy-box { font-family: var(--mono); font-size: 14px; background: var(--surf); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; word-break: break-all; }
.status-ok { color: #14532D; font-weight: 600; }
.status-bad { color: var(--red-ink); font-weight: 600; }
.big-money { font-size: 15px; } .big-money strong { font-family: var(--display); font-size: 30px; font-weight: 800; }
.money-input { font: inherit; font-size: 15px; padding: 8px 10px; min-height: 40px; border: 1px solid var(--line2); border-radius: 6px; background: #fff; width: 100%; }

/* Viewership stats (portal + admin) */
.stats-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 14px 16px; background: var(--surf); border: 1px solid var(--line); border-radius: 10px; }
.stats-range .field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.stats-range .field span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stats-range input[type="date"] { font: inherit; font-size: 15px; padding: 7px 10px; min-height: 40px; border: 1px solid var(--line2); border-radius: 6px; background: #fff; }
.stats-range-note { flex: 1 1 220px; text-align: right; align-self: center; }
.stats-tower .tower-figure { font-size: 32px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.stat-card p { margin: 0; }
.stat-card-title { margin: 0; font-family: var(--display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 18px; }
.bar-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bar-list li { display: grid; grid-template-columns: minmax(90px, 9em) 1fr 3.6em; align-items: center; gap: 10px; font-size: 14px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--surf); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--navy); border-radius: 5px; }
.bar-value { text-align: right; font-family: var(--mono); font-size: 13px; }
.stats-races { margin-top: 8px; }
.stats-admin { display: flex; flex-direction: column; gap: 20px; margin-top: 16px; }
