/* ==========================================================================
   Solar Exit Group — Rep Portal (paysheets)
   Extends css/site.css tokens. Navy · Gold · Fraunces + Satoshi
   ========================================================================== */

[hidden] { display: none !important; }

.portal-body { background: var(--cream); min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- slim header ---------- */
.portal-header {
  background: var(--navy);
  border-bottom: 1px solid var(--line-dark);
}
.portal-header .bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 0; color: #fff;
}
.portal-brand {
  display: flex; align-items: center; gap: .75rem;
  color: #fff; text-decoration: none; min-width: 0;
}
.portal-brand .logo-mark { width: 38px; flex: none; color: #fff; }
.portal-brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.portal-brand-name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem;
  letter-spacing: -0.01em; white-space: nowrap;
}
.portal-brand-sub {
  font-size: .6875rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold-text); font-weight: 700; white-space: nowrap;
}
.portal-header-right { display: flex; align-items: center; gap: 1rem; flex: none; }
.portal-who { font-size: .875rem; color: #C6CEE2; white-space: nowrap; }
.portal-who strong { color: #fff; font-weight: 600; }
.btn-signout {
  background: transparent; border: 1px solid rgba(255,255,255,.28); color: #fff;
  padding: .5rem 1rem; border-radius: var(--r-md); font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease);
}
.btn-signout:hover { border-color: var(--gold); background: rgba(255,255,255,.06); }

/* ---------- main ---------- */
.portal-main { flex: 1; padding: clamp(2rem, 5vw, 4rem) 0 clamp(3rem, 6vw, 5rem); }

/* ---------- sign-in ---------- */
.signin-shell { display: flex; justify-content: center; }
.signin-card {
  width: 100%; max-width: 430px; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-2); padding: clamp(1.75rem, 4vw, 2.5rem);
}
.signin-card h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: .5rem;
}
.signin-card .sub { color: var(--body-dim); font-size: .9375rem; margin-bottom: 1.75rem; }

.field { margin-bottom: 1.125rem; }
.field label {
  display: block; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--ink); margin-bottom: .5rem;
}
.field input {
  width: 100%; padding: .875rem 1rem; background: var(--cream);
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 1rem; color: var(--ink); transition: border-color .2s var(--ease), background .2s var(--ease);
}
.field input:focus { background: #fff; border-color: var(--navy-3); }
.field input::placeholder { color: #9AA0AE; }
.field-hint { font-size: .8125rem; color: var(--body-dim); margin-top: .5rem; }

.form-alert {
  display: none; margin-bottom: 1.125rem; padding: .8rem 1rem;
  border-radius: var(--r-md); background: rgba(179, 38, 30, .07);
  border: 1px solid rgba(179, 38, 30, .3); color: #8E1D17;
  font-size: .9062rem; line-height: 1.5;
}
.form-alert.show { display: block; }

.signin-help {
  margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line);
  font-size: .875rem; color: var(--body-dim); line-height: 1.6;
}
.signin-help a { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--gold); }

/* ---------- dashboard head ---------- */
.dash-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap; margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
}
.dash-head h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); margin-bottom: .4rem; }
.dash-head .meta { font-size: .875rem; color: var(--body-dim); }
.dash-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: clamp(.875rem, 2vw, 1.25rem); margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
}
.kpi-grid.has-debt { grid-template-columns: repeat(4, 1fr); }
.kpi {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: clamp(1.125rem, 2.4vw, 1.625rem);
}
.kpi.kpi-primary { background: var(--navy); border-color: var(--navy); }
.kpi.kpi-debt { background: #FDF8F7; border-color: #E4CFCF; }
.kpi-label {
  font-size: .6875rem; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; color: var(--body-dim); margin-bottom: .625rem;
}
.kpi.kpi-primary .kpi-label { color: var(--gold-text); }
.kpi-value {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.6rem, 3.4vw, 2.35rem); line-height: 1.05;
  letter-spacing: -0.02em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kpi.kpi-primary .kpi-value { color: #fff; }
.kpi.kpi-debt .kpi-value { color: #8F2222; }
.kpi.kpi-debt .kpi-label { color: #8F2222; }
.kpi-note { font-size: .8125rem; color: var(--body-dim); margin-top: .5rem; }
.kpi.kpi-primary .kpi-note { color: #A7B1CA; }

/* ---------- table ---------- */
.panel {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1.125rem clamp(1.125rem, 2.4vw, 1.75rem);
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 1.1875rem; }
.panel-head .count { font-size: .8125rem; color: var(--body-dim); }

.table-scroll { overflow-x: auto; }
table.paysheet { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.paysheet th, table.paysheet td {
  padding: .8125rem clamp(.375rem, .75vw, .8125rem);
  text-align: left; white-space: nowrap;
}
table.paysheet th {
  font-size: .65rem; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 700; color: var(--body-dim);
  background: var(--cream-2); border-bottom: 1px solid var(--line);
}
table.paysheet td { border-bottom: 1px solid var(--line); color: var(--body); }
table.paysheet tbody tr:last-child td { border-bottom: 0; }
table.paysheet tbody tr:hover td { background: rgba(16,27,54,.02); }
table.paysheet td.customer {
  color: var(--ink); font-weight: 600; white-space: normal;
  min-width: 8.5rem; overflow-wrap: break-word;
  padding-left: clamp(1rem, 2vw, 1.5rem);
}
table.paysheet th:first-child { padding-left: clamp(1rem, 2vw, 1.5rem); }
table.paysheet th:last-child, table.paysheet td:last-child { padding-right: clamp(1rem, 2vw, 1.5rem); }
table.paysheet td.num, table.paysheet th.num {
  text-align: right; font-variant-numeric: tabular-nums;
}
table.paysheet td.payout { color: var(--ink); font-weight: 700; }
table.paysheet td.charge { color: #8F2222; font-weight: 600; }

.pill {
  display: inline-block; padding: .25rem .625rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.pill-paid { background: rgba(31,122,77,.1); color: #17603C; }
.pill-pending { background: rgba(201,162,74,.16); color: #7A5F1E; }
.pill-hold { background: rgba(16,27,54,.08); color: var(--navy-2); }

tfoot.paysheet-foot td {
  background: var(--cream-2); border-top: 1px solid var(--line);
  font-weight: 700; color: var(--ink); padding: 1rem clamp(.75rem, 1.6vw, 1.25rem);
}

/* ---------- empty / loading ---------- */
.empty { padding: clamp(2.5rem, 6vw, 4rem) 1.5rem; text-align: center; }
.empty svg { width: 40px; height: 40px; color: var(--gold); margin: 0 auto 1rem; }
.empty h3 { font-size: 1.25rem; margin-bottom: .5rem; }
.empty p { color: var(--body-dim); font-size: .9375rem; max-width: 34rem; margin: 0 auto; }

.skeleton-row { display: grid; gap: .625rem; padding: 1.5rem; }
.skeleton-bar {
  height: 14px; border-radius: 4px;
  background: linear-gradient(90deg, #EFEBE2 25%, #F7F5F0 50%, #EFEBE2 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.spinner {
  display: inline-block; width: 15px; height: 15px; vertical-align: -2px;
  border: 2px solid rgba(22,32,58,.25); border-top-color: #16203A;
  border-radius: 50%; animation: spin .7s linear infinite; margin-right: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.portal-foot {
  margin-top: 1.5rem; font-size: .8125rem; color: var(--body-dim); line-height: 1.7;
}
.portal-foot a { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--gold); }

.demo-banner {
  background: rgba(201,162,74,.14); border: 1px solid rgba(201,162,74,.45);
  color: #6E5518; border-radius: var(--r-md);
  padding: .75rem 1rem; font-size: .875rem; margin-bottom: 1.5rem; line-height: 1.55;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .kpi-grid, .kpi-grid.has-debt { grid-template-columns: 1fr; }
}
@media (min-width: 721px) and (max-width: 1000px) {
  .kpi-grid.has-debt { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .portal-who { display: none; }
  .portal-brand-name { font-size: .9375rem; }

  /* stacked cards instead of a side-scrolling table */
  .table-scroll { overflow-x: visible; }
  table.paysheet, table.paysheet tbody, table.paysheet tfoot,
  table.paysheet tr, table.paysheet td { display: block; width: 100%; }
  table.paysheet thead { display: none; }

  table.paysheet tbody tr {
    padding: 1rem clamp(1rem, 4vw, 1.25rem);
    border-bottom: 1px solid var(--line);
  }
  table.paysheet tbody tr:last-child { border-bottom: 0; }
  table.paysheet tbody tr:hover td { background: transparent; }

  table.paysheet td {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem; padding: .3125rem 0; border-bottom: 0;
    white-space: normal; text-align: right;
  }
  table.paysheet td::before {
    content: attr(data-label); flex: none; text-align: left;
    font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase;
    font-weight: 700; color: var(--body-dim);
  }
  table.paysheet td.customer {
    display: block; text-align: left;
    font-family: var(--font-display); font-size: 1.1875rem; font-weight: 600;
    letter-spacing: -0.01em; padding: 0 0 .5rem;
  }
  table.paysheet td.customer::before { display: none; }
  table.paysheet td.payout {
    margin-top: .375rem; padding-top: .5rem; border-top: 1px solid var(--line);
    font-size: 1.0625rem;
  }

  tfoot.paysheet-foot tr {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem; padding: 1rem clamp(1rem, 4vw, 1.25rem);
    background: var(--cream-2); border-top: 1px solid var(--line);
  }
  tfoot.paysheet-foot td { padding: 0; background: transparent; border: 0; }
  tfoot.paysheet-foot td.foot-blank { display: none; }
  tfoot.paysheet-foot td.foot-label,
  tfoot.paysheet-foot td#footTotal { display: block; width: auto; }
  tfoot.paysheet-foot td#footTotal { font-size: 1.125rem; }
}

/* ---------- print ---------- */
@media print {
  .portal-header, .dash-actions, .portal-foot, .demo-banner, .signin-shell { display: none !important; }
  .portal-body { background: #fff; }
  .panel, .kpi { box-shadow: none; border-color: #C9C9C9; break-inside: avoid; }
  .kpi.kpi-primary { background: #fff !important; border-color: #C9C9C9 !important; }
  .kpi.kpi-primary .kpi-label { color: #6E5518 !important; }
  .kpi.kpi-primary .kpi-value { color: #101B36 !important; }
  .kpi.kpi-primary .kpi-note { color: #555 !important; }
  .kpi-grid, .kpi-grid.has-debt { grid-template-columns: repeat(3, 1fr) !important; }
  .kpi-debt .kpi-value { color: var(--ink) !important; }
  .table-scroll { overflow: visible; }
  table.paysheet { font-size: 10.5pt; }
  @page { margin: 14mm; }
}
