/* Tenant portal and the demo payment gateway. Builds on the tokens and
   components in styles.css; only what those two pages add lives here. */

/*============================================================ tokens =====*/

/* Scoped to the portal, so the owner dashboard and the gateway keep their look. */
body.portal {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --line: #d5dae6;
  --line-soft: #e7eaf2;
  --text: #111827;
  --muted: #4b5563;
  --faint: #6b7280;

  --accent: #4f46e5;
  --accent-bg: #eef0ff;
  --accent-line: #c7d2fe;
  --accent-fill: #4f46e5;
  --accent-fill-hover: #4338ca;

  --radius: 16px;
  --shadow: 0 1px 2px rgb(17 24 39 / .04), 0 6px 20px rgb(17 24 39 / .05);
  --hero-a: #eef0ff;
  --hero-b: #f7f5ff;
  --hero-ring: rgb(79 70 229 / .07);

  /* Chart series, in fixed order. Validated for colour-blind separation
     against this surface; three light steps sit under 3:1, so every chart
     has a legend and a table view. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-other: #9ca3af;

  font-size: 15px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Light by default. Dark only when the tenant picks it, never from the OS. */
:root[data-theme="dark"] body.portal {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #121829;
  --surface-2: #182038;
  --line: #2b3552;
  --line-soft: #212a42;
  --text: #e7eaf3;
  --muted: #b1b9cc;
  --faint: #8b95ab;
  --on: #4ade80;
  --on-bg: rgb(34 197 94 / .14);
  --on-line: rgb(74 222 128 / .32);
  --off: #f87171;
  --off-bg: rgb(239 68 68 / .15);
  --off-line: rgb(248 113 113 / .35);
  --warn: #fbbf24;
  --warn-bg: rgb(245 158 11 / .14);
  --warn-line: rgb(251 191 36 / .32);
  --accent: #a5b4fc;
  --accent-bg: rgb(99 102 241 / .16);
  --accent-line: rgb(129 140 248 / .38);
  --accent-fill: #4f46e5;
  --accent-fill-hover: #5b54f0;
  --shadow: 0 1px 2px rgb(0 0 0 / .35);
  --hero-a: #1b2042;
  --hero-b: #151a33;
  --hero-ring: rgb(165 180 252 / .06);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-other: #6b7280;
}

/* Components from styles.css that carry a fixed colour. Filled buttons keep
   white text readable in both themes. */
body.portal .btn-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
body.portal .btn-primary:hover:not(:disabled),
body.portal a.btn.btn-primary:hover { background: var(--accent-fill-hover); }
body.portal .btn-off { background: #dc2626; border-color: #dc2626; color: #fff; }
body.portal .btn-sm { min-height: 38px; padding: 7px 13px; font-size: .88rem; }
body.portal .banner.info,
body.portal .toast.info { border-color: var(--accent-line); }
body.portal .chip[aria-pressed="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
body.portal input[type=radio] { accent-color: var(--accent-fill); }
body.portal .err:empty { display: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.icon-btn {
  width: 40px; height: 40px; min-height: 40px; padding: 0; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line-soft); background: var(--accent-bg); color: var(--accent);
}
.icon-btn:hover:not(:disabled) { background: var(--accent-bg); border-color: var(--accent-line); }

.fine { margin: 0; font-size: .82rem; color: var(--faint); }
.muted-note { margin: 0; color: var(--muted); font-size: .92rem; }
.btn-block { width: 100%; }

/*------------------------------------------------------------- login ----*/

.portal #login { max-width: 420px; }
.login-brand { display: flex; gap: 14px; align-items: center; }
.login-mark {
  flex-shrink: 0; width: 54px; height: 54px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.7rem;
  background: var(--accent-bg); border: 1px solid var(--accent-line);
}
#login h1.login-building { font-size: 1.35rem; letter-spacing: -.02em; line-height: 1.25; }
.login-tag { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.login-help { margin: 0; font-size: .85rem; color: var(--faint); text-align: center; }

/*------------------------------------------------------------- shell ----*/

.shell {
  display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 18px; align-items: start;
  max-width: 1480px; margin: 0 auto; padding: 18px; min-height: 100vh;
}

.side {
  position: sticky; top: 18px; display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - 36px); overflow-y: auto; padding: 2px;
}

.side-card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}

.side-brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.brand-text { flex: 1; min-width: 0; line-height: 1.25; }
.brand-text strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--faint); font-size: .8rem; }

.profile-head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; }
.profile-who { min-width: 0; }
.avatar-lg {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 800; font-size: 1.1rem;
  background: linear-gradient(135deg, #fde68a, #fca5a5); color: #7c2d12;
}
.profile-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.profile-sub { font-size: .84rem; color: var(--faint); }

.kv { margin: 0; }
.kv > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: .9rem;
}
.kv dt { color: var(--muted); font-weight: 600; white-space: nowrap; }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv-lg > div { padding: 12px 0; font-size: .95rem; }

.power-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.power-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.power-chip.on { color: var(--on); }
.power-chip.off { color: var(--off); }

.side-nav { display: flex; flex-direction: column; gap: 8px; }
.side-nav a, .side-signout {
  display: flex; align-items: center; gap: 12px; padding: 7px 12px 7px 7px; min-height: 56px; width: 100%;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px; box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.side-nav a:hover { border-color: var(--accent-line); }
.side-nav a:focus-visible, .side-signout:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.side-nav a[aria-current="page"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent); }

.nav-ic {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--muted);
}
.side-nav a[aria-current="page"] .nav-ic { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }

.nav-badge {
  margin-left: auto; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center; font-size: .75rem; font-weight: 800; color: #fff; background: #dc2626;
}

.side-signout { color: var(--muted); margin-top: 4px; }
.side-signout:hover:not(:disabled) { background: var(--surface); border-color: var(--off-line); color: var(--off); }

.main {
  min-width: 0; min-height: calc(100vh - 36px); padding: 20px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 20px; box-shadow: var(--shadow);
}

.mobile-bar, .scrim { display: none; }

/*------------------------------------------------------- page furniture --*/

.page-title {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.page-title h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.page-title p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.page-title select { width: auto; min-width: 150px; min-height: 42px; padding: 8px 12px; font-weight: 600; }

.panel {
  min-width: 0; padding: 18px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.panel-head h2, .panel-title { margin: 0; font-size: 1.08rem; letter-spacing: -.01em; }
.panel-title { margin-bottom: 12px; }
.panel .filters { margin-bottom: 14px; }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .88rem; font-weight: 600; color: var(--accent); text-decoration: none;
}
.link-btn .ic { width: 16px; height: 16px; }
.link-btn:hover { text-decoration: underline; }

.is-disabled { opacity: .5; pointer-events: none; }

/*--------------------------------------------------------------- hero ----*/

.hero {
  display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 26px 28px; margin-bottom: 18px; border-radius: var(--radius); border: 1px solid var(--line-soft);
  background:
    radial-gradient(circle at 80% -30%, var(--hero-ring) 0 110px, transparent 111px),
    radial-gradient(circle at 96% 130%, var(--hero-ring) 0 130px, transparent 131px),
    linear-gradient(120deg, var(--hero-a), var(--hero-b));
}
.hero-text { min-width: 0; }
.hero-eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.hero-title { margin: 2px 0 10px; font-size: 1.75rem; letter-spacing: -.02em; line-height: 1.2; }
.hero-pill {
  display: inline-flex; padding: 7px 16px; border-radius: 999px;
  background: var(--accent-fill); color: #fff; font-weight: 700;
}

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.quick {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 86px; padding: 10px 6px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px; box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font-size: .78rem; font-weight: 600; text-align: center;
}
.quick:hover { border-color: var(--accent-line); color: var(--accent); }
.quick:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.quick-ic {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-bg); color: var(--accent);
}

/*-------------------------------------------------------------- alert ----*/

.alert {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 18px;
  border: 1px solid; border-radius: 14px;
}
.alert.tone-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.alert.tone-off { background: var(--off-bg); border-color: var(--off-line); }
.alert-ic { display: grid; place-items: center; }
.alert-ic .ic { width: 26px; height: 26px; }
.alert.tone-warn :is(.alert-ic, .alert-title) { color: var(--warn); }
.alert.tone-off :is(.alert-ic, .alert-title) { color: var(--off); }
.alert-text { flex: 1; min-width: 0; }
.alert-title { font-weight: 800; }
.alert-detail { font-size: .92rem; }
.alert button { flex-shrink: 0; }

/*-------------------------------------------------------------- stats ----*/

.stats {
  display: grid; gap: 14px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr));
}
.stat {
  display: flex; align-items: center; gap: 14px; min-width: 0; padding: 16px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px;
}
.stat-ic {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
}
.stat-ic .ic { width: 22px; height: 22px; }
.stat.tone-good .stat-ic { background: var(--on-bg); color: var(--on); }
.stat.tone-bad  .stat-ic { background: var(--off-bg); color: var(--off); }
.stat.tone-warn .stat-ic { background: var(--warn-bg); color: var(--warn); }
.stat.tone-info .stat-ic { background: var(--accent-bg); color: var(--accent); }

.stat-body { min-width: 0; }
.stat-label { font-size: .84rem; font-weight: 600; color: var(--faint); }
.stat-value {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.22rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.3;
}
.stat.tone-good .stat-value { color: var(--on); }
.stat.tone-bad  .stat-value { color: var(--off); }
.stat.tone-warn .stat-value { color: var(--warn); }
.stat-sub { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex-shrink: 0;
  animation: live 2s ease-out infinite;
}
.live-dot.stale { animation: none; background: var(--faint); }
@keyframes live {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/*---------------------------------------------------------- dashboard ----*/

.dash-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.dash-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.month-items { list-style: none; margin: 0; padding: 0; }
.month-items li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: .92rem;
}
.month-items .sw { margin-top: 6px; }
.mi-label { flex: 1; min-width: 0; }
.mi-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/*------------------------------------------------------------- ledger ----*/

.ledger { min-width: 540px; }
.ledger th, .plain th {
  font-size: .72rem; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line-soft);
}
.ledger td { padding: 11px 12px; font-size: .9rem; vertical-align: top; }
.ledger :is(th, td).num, .plain :is(th, td).num { text-align: right; }
.ledger td.date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.l-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.l-title .tag { font-size: .64rem; padding: 2px 7px; }
.l-sub { font-size: .8rem; color: var(--faint); margin-top: 1px; }
td.none { color: var(--faint); }

/*-------------------------------------------------------------- chart ----*/

.chart-tools { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 14px; }
.chart-tools select { min-height: 40px; padding: 7px 10px; font-size: .92rem; }
.chart-tools .btn { min-height: 40px; }
.chart-tools .ic { width: 16px; height: 16px; }

.chart-title { margin: 0 0 4px; font-size: 1.05rem; text-align: center; letter-spacing: -.01em; }

.legend {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px;
  margin-bottom: 8px; font-size: .8rem; color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; flex-shrink: 0; width: 10px; height: 10px; border-radius: 3px; }

.chart { position: relative; min-height: 250px; }
.chart.chart-lg { min-height: 300px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .tick.on { fill: var(--text); font-weight: 700; }
.chart .col-band { fill: var(--accent-bg); }
.chart .empty-msg { fill: var(--faint); font-size: 13px; }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 2; }

.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 180px; max-width: 250px;
  padding: 10px 12px; font-size: .8rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgb(15 23 42 / .18);
}
.tip-title { font-weight: 700; margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tip-label { flex: 1; color: var(--muted); }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-total { margin-top: 4px; padding-top: 5px; border-top: 1px solid var(--line-soft); }
.tip-status { margin-top: 6px; color: var(--faint); }

.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; padding: 4px 0; font-size: .88rem; font-weight: 600; color: var(--accent); }

/*------------------------------------------------------------ reports ----*/

.report-grid {
  display: grid; gap: 18px; margin-top: 18px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
}
.plain td { padding: 9px 12px; font-size: .9rem; }
.charge-cell { display: flex; align-items: center; gap: 8px; }
.share { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.share-track { flex: 1; height: 8px; overflow: hidden; border-radius: 999px; background: var(--line-soft); }
.share-fill { height: 100%; border-radius: 999px; }
.share span { width: 38px; text-align: right; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/*----------------------------------------------------------- pay bill ----*/

.pay-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.5fr) minmax(290px, 1fr); align-items: start; }
.pay-form { display: flex; flex-direction: column; gap: 10px; }
.pay-form .panel-title { margin: 0; }
.pay-form .panel-title:not(:first-child) { margin-top: 14px; }

.bill-choices { display: flex; flex-direction: column; gap: 8px; }
.bill-choice {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px;
}
.bill-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.bill-choice input { width: 18px; height: 18px; flex-shrink: 0; }
.bc-main { flex: 1; min-width: 0; }
.bc-main strong { display: block; }
.bc-main small { font-size: .84rem; color: var(--muted); }
.bc-amt {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bc-amt .tag { font-size: .64rem; padding: 2px 7px; }

.amount-input.wide { max-width: none; margin-left: 0; }
.amount-input.wide input { text-align: left; }

.method-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.method-strip span {
  color: #fff; font-size: .72rem; font-weight: 800; padding: 4px 9px; border-radius: 6px; letter-spacing: .01em;
}

.pay-summary { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 12px; }
.pay-summary .panel-title { margin: 0; }
.pay-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 14px; border-radius: 12px; background: var(--accent-bg);
}
.pay-total span { font-weight: 700; }
.pay-total strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 44px 20px; text-align: center; }
.empty-ic {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--on-bg); color: var(--on);
}
.empty-ic .ic { width: 32px; height: 32px; }
.empty-title { font-size: 1.25rem; font-weight: 800; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-state .row { justify-content: center; margin-top: 8px; }

/*-------------------------------------------------------------- bills ----*/

.bill-list { display: flex; flex-direction: column; gap: 12px; }

details.bill {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 14px; overflow: hidden;
}
details.bill.owed { border-left: 4px solid var(--off); }

details.bill > summary {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto 20px; gap: 12px; align-items: center;
  padding: 14px 18px; min-height: 68px;
}
details.bill > summary::-webkit-details-marker { display: none; }
details.bill > summary:hover { background: var(--surface-2); }
details.bill > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

.bill-sum-main { min-width: 0; }
.bill-sum-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bill-month { font-weight: 700; font-size: 1.05rem; }
.bill-sum-top .tag { font-size: .68rem; padding: 3px 9px; }
.bill-sub { font-size: .84rem; color: var(--muted); margin-top: 1px; }
.bill-sum-amount { font-weight: 700; font-size: 1.08rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.chev { display: grid; color: var(--faint); transform: rotate(90deg); transition: transform .15s; }
.chev .ic { width: 18px; height: 18px; }
details[open] .chev { transform: rotate(-90deg); }

.bill-body { padding: 4px 18px 18px; border-top: 1px solid var(--line-soft); }

.items td { padding: 11px 0; }
.items td.num { padding-left: 12px; }
.item-note { display: block; font-size: .8rem; color: var(--faint); }
.mini-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }

.bill-sums { margin: 6px 0 0 auto; max-width: 320px; }
.bill-sums > div { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.bill-sums > div span { color: var(--muted); }
.bill-sums strong { font-variant-numeric: tabular-nums; }
.bill-sums .due { border-top: 2px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 1.08rem; }
.bill-sums .due span { color: var(--text); font-weight: 700; }
.bill-sums .due strong { font-weight: 800; color: var(--on); }
.bill-sums .due.owed strong { color: var(--off); }

.bill-payments { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.pay-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: .92rem; }
.pay-none { padding: 6px 0; font-size: .9rem; color: var(--faint); }
.pay-row strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

.bill-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.bill-actions > * { flex: 1 1 160px; }
.bill-actions .ic { width: 16px; height: 16px; }

/*------------------------------------------------------------ profile ----*/

.profile-grid {
  display: grid; gap: 18px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
}
.stack { display: flex; flex-direction: column; gap: 18px; }
.profile-banner { display: flex; align-items: center; gap: 16px; padding-bottom: 16px; }
.avatar-xl { width: 72px; height: 72px; border-radius: 20px; font-size: 1.5rem; }
.pf-name { font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; }
.pf-sub { color: var(--muted); }
.profile-grid .fine { margin-top: 12px; }
.pw-form { display: flex; flex-direction: column; gap: 12px; }
.pw-form .panel-title { margin: 0; }
.pw-form button { align-self: flex-start; }

.seg {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; margin: 0; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px;
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 9px;
  font-size: .9rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(15 23 42 / .15); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -1px; }

/*--------------------------------------------------------- responsive ----*/

@media (max-width: 1200px) {
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .pay-layout { grid-template-columns: 1fr; }
  .pay-summary { position: static; }
}

/* The sidebar becomes a drawer. */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; gap: 0; padding: 0; }
  .main {
    min-height: 100vh; padding: 0 16px 32px;
    background: var(--bg); border: 0; border-radius: 0; box-shadow: none;
  }
  .mobile-bar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
    margin: 0 -16px 16px; padding: 10px 16px;
    background: var(--surface); border-bottom: 1px solid var(--line-soft);
  }
  .mobile-title { flex: 1; min-width: 0; font-size: 1.05rem; }

  .side {
    position: fixed; z-index: 50; inset: 0 auto 0 0; top: 0;
    width: min(300px, 86vw); height: 100vh; max-height: none; padding: 16px;
    background: var(--bg); transform: translateX(-105%); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }
  .menu-open .side { transform: none; visibility: visible; transition: transform .2s ease; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(15 23 42 / .5); }
}

@media (max-width: 700px) {
  .hero { padding: 20px; }
  .hero-title { font-size: 1.45rem; }
  .hero-actions { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
  .quick { width: auto; }
  .alert { flex-wrap: wrap; }
  .alert button { width: 100%; }
  .page-title h1 { font-size: 1.3rem; }
  .page-title > label, .page-title > .row { width: 100%; }
  .page-title select { flex: 1; width: 100%; }
}

@media (max-width: 420px) {
  .chart-tools { grid-template-columns: 1fr 1fr; }
  .chart-tools .btn { grid-column: 1 / -1; }
}

/*=========================================================== gateway =====*/

body.gateway { background: linear-gradient(165deg, #dbe4ff 0%, #eef2f7 45%, #f1f5f9 100%); min-height: 100vh; }

.gw-ribbon {
  background: var(--warn-bg); color: #92400e; border-bottom: 1px solid var(--warn-line);
  text-align: center; font-size: .86rem; padding: 10px 16px;
}

.gw-shell { max-width: 460px; margin: 0 auto; padding: 24px 16px 48px; }

.gw-card {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 18px;
  box-shadow: 0 24px 60px rgb(15 23 42 / .16); overflow: hidden;
}

.gw-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; background: #0f2a5f; color: #fff;
}
.gw-merchant { display: flex; gap: 12px; align-items: center; min-width: 0; }
.gw-logo {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; background: #fff; color: #0f2a5f; font-weight: 800; font-size: 1.25rem;
}
.gw-merchant-text { min-width: 0; }
.gw-merchant-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gw-ref { font-size: .76rem; opacity: .75; font-variant-numeric: tabular-nums; word-break: break-all; }
.gw-close {
  flex-shrink: 0; width: 42px; min-height: 42px; padding: 0;
  background: rgb(255 255 255 / .12); border-color: transparent; color: #fff; font-size: 1rem;
}
.gw-close:hover:not(:disabled) { background: rgb(255 255 255 / .24); }
.gw-close:focus-visible { outline-color: #fff; }

.gw-amount-bar {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 14px 18px; background: #eef2ff; border-bottom: 1px solid var(--line-soft);
}
.gw-amount-bar span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.gw-amount-bar strong { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }

.gw-body { padding: 18px; }
.gw-prompt { font-weight: 700; margin-bottom: 12px; }

.gw-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 14px;
  padding: 4px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px;
}
.gw-tab {
  min-height: 44px; padding: 6px 4px; border: none; border-radius: 9px;
  background: transparent; color: var(--muted); font-size: .86rem;
}
.gw-tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(15 23 42 / .14); }

.gw-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gw-tile {
  min-height: 84px; padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.gw-tile:hover:not(:disabled) { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.gw-tile small { font-size: .74rem; font-weight: 500; color: var(--faint); }

.gw-mark {
  display: inline-flex; align-items: center; justify-content: center; min-width: 96px;
  padding: 6px 12px; border-radius: 8px; color: #fff; font-weight: 800; font-size: .95rem; white-space: nowrap;
}

.gw-center-row { display: flex; justify-content: center; margin-top: 12px; }
.gw-link {
  min-height: 0; padding: 8px; border: none; background: none;
  color: var(--muted); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px;
}
.gw-link:hover:not(:disabled) { background: none; color: var(--text); }

.gw-step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gw-back { min-height: 40px; padding: 6px 12px; font-size: .86rem; flex-shrink: 0; }
.gw-step-text { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.gw-step-sub { font-size: .85rem; color: var(--muted); font-weight: 600; }

.gw-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 14px; counter-reset: step; }
.gw-steps li {
  flex: 1; font-size: .74rem; font-weight: 700; color: var(--faint); text-align: center;
  padding-top: 8px; border-top: 4px solid var(--line-soft);
}
.gw-steps li.done { color: var(--text); border-top-color: var(--accent); }

.gw-form { display: flex; flex-direction: column; gap: 12px; }
.gw-form .err:empty { display: none; }
.gw-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gw-copy { margin: 0; color: var(--muted); font-size: .92rem; }
.gw-hint {
  font-size: .82rem; color: var(--muted);
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 9px 12px;
}
.gw-pay { width: 100%; min-height: 54px; font-size: 1.05rem; }
.gw-form .gw-link { align-self: center; }

.gw-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 18px; font-size: .76rem; color: var(--faint);
  background: var(--surface-2); border-top: 1px solid var(--line-soft);
}
.gw-lock { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.gw-lock svg { width: 13px; height: 13px; fill: currentColor; }
.gw-timer { margin-top: 14px; text-align: center; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/*------------------------------------------------------- gateway result --*/

.gw-center { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 10px 0 4px; }
.gw-processing { padding: 36px 0 28px; }

.spinner {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0;
  border: 5px solid var(--accent-bg); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 22px; height: 22px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.gw-result-icon {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  font-size: 2.1rem; font-weight: 800; border: 2px solid;
}
.gw-result-icon.ok      { background: var(--on-bg);     color: var(--on);    border-color: var(--on-line); animation: pop .35s ease-out; }
.gw-result-icon.bad     { background: var(--off-bg);    color: var(--off);   border-color: var(--off-line); }
.gw-result-icon.neutral { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

.gw-result-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.gw-result-amount { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }

.gw-receipt { width: 100%; margin-top: 6px; text-align: left; border: 1px solid var(--line-soft); border-radius: 12px; }
.gw-receipt > div {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 9px 14px; font-size: .88rem; border-bottom: 1px solid var(--line-soft);
}
.gw-receipt > div:last-child { border-bottom: none; }
.gw-receipt span { color: var(--muted); white-space: nowrap; }
.gw-receipt strong { text-align: right; word-break: break-all; font-variant-numeric: tabular-nums; }

.gw-power {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  padding: 14px; border: 1px solid; border-radius: 12px; margin-top: 4px;
}
.gw-power.on   { background: var(--on-bg);     border-color: var(--on-line);  color: var(--on); }
.gw-power.off  { background: var(--off-bg);    border-color: var(--off-line); color: var(--off); }
.gw-power.wait { background: var(--accent-bg); border-color: #bfdbfe;         color: var(--accent); }
.gw-power-dot { width: 14px; height: 14px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.gw-power-text { min-width: 0; }
.gw-power-title { font-weight: 800; }
.gw-power-detail { font-size: .88rem; color: var(--text); }

.gw-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 10px; }

@media (max-width: 600px) {
  .gw-shell { padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .gw-result-icon.ok { animation: none; }
  .spinner { animation-duration: 2.4s; }
  .side, .chev { transition: none; }
}
