:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #20242d;
  --muted: #687386;
  --blue: #2f6fed;
  --green: #15805a;
  --amber: #a96500;
  --red: #bb3030;
  --ink: #161a22;
}

* {
  box-sizing: border-box;
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #174ea6;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  background: var(--ink);
  color: #f8fafc;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #2f6fed;
  font-weight: 800;
}

.brand-logo {
  background: #ffffff;
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #b5bdc9;
  font-size: 13px;
  margin-top: 3px;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar nav a {
  color: #d8dee8;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: #283142;
  color: #ffffff;
}

.shell {
  min-width: 0;
}

.topbar {
  min-height: 88px;
  padding: 18px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

h3 {
  font-size: 15px;
}

.topbar p,
.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.content {
  padding: 28px 32px 40px;
  display: grid;
  gap: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.stat,
.panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 16px;
  min-height: 106px;
  min-width: 0;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 28px;
  margin-top: 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.stat > small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.stat.warning {
  border-color: #e8c27d;
  background: #fffbf3;
}

.stat.danger {
  border-color: #efb4b4;
  background: #fff8f8;
}

.stat.success {
  border-color: #b6ddcf;
}

button.dashboard-attention-stat {
  width: 100%;
  height: auto;
  display: block;
  text-align: left;
  cursor: pointer;
}

button.dashboard-attention-stat:hover,
button.dashboard-attention-stat:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(35, 88, 201, 0.12);
}

.dashboard-attention-stat .stat-action-label {
  display: block;
  margin-top: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-attention-panel {
  scroll-margin-top: 18px;
}

.currency-stat strong {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  font-size: 21px;
}

.currency-stat strong > span {
  display: grid;
  gap: 2px;
}

.currency-stat strong small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.usd-total-stat strong {
  font-size: 30px;
  white-space: nowrap;
}

.currency-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.button-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #2358c9;
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--blue);
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.button-link.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

.dashboard-primary-stats {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.current-month-money-section {
  display: grid;
  gap: 12px;
}

.current-month-money-stats .stat {
  min-height: 154px;
}

.current-month-money-stats .usd-total-stat strong {
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: clamp(22px, 2.25vw, 30px);
  line-height: 1.15;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.report-overview {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.two-column-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.metric-list {
  display: grid;
  margin-top: 8px;
}

.metric-list > div {
  min-height: 47px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.metric-list > div:last-child {
  border-bottom: 0;
}

.metric-list > div > span:first-child {
  flex: 1;
  color: var(--muted);
  font-size: 14px;
}

.metric-list strong,
.metric-list b {
  font-size: 16px;
}

.metric-list strong:has(.badge) + b {
  min-width: 24px;
  text-align: right;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 18px;
}

.invoice-run-layout {
  grid-template-columns: minmax(0, 1fr);
}

.invoice-run-layout > * {
  min-width: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 210px) auto auto auto;
  gap: 10px;
  align-items: end;
  margin: 18px 0 8px;
}

.usage-ledger-toolbar {
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px) minmax(160px, 210px) 90px auto auto;
}

.usage-account-cell {
  display: grid;
  gap: 3px;
  min-width: 180px;
}

.usage-account-cell small {
  color: var(--muted);
  font-size: 11px;
}

.usage-data-note {
  margin: 14px 0 0;
}

.usage-movement-stats {
  grid-template-columns: repeat(5, minmax(125px, 1fr));
  margin: 16px 0;
}

.usage-movement-date {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.table-count-note {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.compact-table {
  margin-top: 4px;
}

.account-list-table td:first-child,
.detail-panel td:first-child {
  min-width: 210px;
}

.account-list-table td strong,
.account-list-table td small,
.detail-panel td strong,
.detail-panel td small {
  display: block;
}

.account-list-table td small,
.detail-panel td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.selected-row {
  background: #f3f7ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 7px;
  align-items: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.pagination > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-panel {
  border-top: 3px solid var(--blue);
}

.detail-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.detail-summary span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.customer-portfolio-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  gap: 14px;
}

.customer-portfolio-stats > div, .customer-attention-filter {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.customer-portfolio-stats strong { font-size: 22px; }
.customer-portfolio-stats span { color: var(--muted); font-size: 12px; }
.customer-attention-filter { border: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; padding: 8px 10px; margin: -8px 0; border-radius: 6px; }
.customer-attention-filter:hover, .customer-attention-filter.selected { background: var(--accent-soft, #edf4ff); border-color: var(--accent, #2563eb); }
.customer-attention-filter small { display: block; font-size: 10px; margin-top: 3px; }
.customer-attention-panel { border-left: 3px solid #c58b24; }
.customer-attention-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.customer-attention-panel summary span { color: var(--muted); font-size: 12px; }
.customer-attention-panel ul { padding-left: 20px; margin: 12px 0; display: grid; gap: 8px; font-size: 13px; }
.signup-offer-fields { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 14px; }
.signup-offer-fields legend { padding: 0 6px; font-weight: 650; }
.signup-offer-fields input, .signup-offer-fields textarea { max-width: 100%; }
.signup-offer-fields textarea { min-height: 90px; }
.signup-offer-fields .offer-link { overflow-wrap: anywhere; font-size: 12px; }

.customer-back-button { display: none; }

.customer-directory-scope {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  padding: 12px 0 8px;
}

.customer-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 310px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.customer-directory {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 224px);
  min-height: 420px;
  max-height: 950px;
  padding: 16px;
  overflow: hidden;
}

.customer-directory-heading {
  margin-bottom: 14px;
  flex: 0 0 auto;
  gap: 8px;
}

.customer-directory-heading h2 { font-size: 16px; }

.customer-directory-heading h2,
.customer-data-panel .section-heading h2 {
  margin-bottom: 3px;
}

.customer-result-count {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.customer-search-form {
  display: grid;
  flex: 0 0 auto;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.customer-search-field input {
  width: 100%;
}

.customer-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.customer-search-row button { padding-left: 10px; padding-right: 10px; }
.customer-search-field { min-width: 0; }
.customer-quick-filters { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.customer-quick-filters .inline-check { font-size: 12px; text-transform: none; }
.customer-directory-filters summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 650; padding: 3px 0; }
.customer-directory-filters[open] summary { margin-bottom: 10px; }

.customer-search-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.customer-search-options > button {
  width: 100%;
}

.customer-search-options .inline-check {
  min-height: 38px;
  align-content: center;
  text-transform: none;
}

.customer-result-list {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  gap: 5px;
  margin-top: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 2px;
}

.customer-directory .pagination {
  flex: 0 0 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
}

.customer-directory .pagination > div {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.customer-directory .pagination button { padding: 7px 9px; }
.customer-directory .pagination span { font-size: 11px; }

button.customer-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 8px;
  width: 100%;
  min-height: 0;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f7f9fc;
  color: var(--text);
  text-align: left;
}

button.customer-result:hover {
  border-color: #b9c8e5;
  background: #f1f5fc;
}

button.customer-result.selected {
  border-color: #8eace9;
  background: #eef4ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.customer-result-main,
.customer-result-main strong,
.customer-result-main small {
  display: block;
  min-width: 0;
}

.customer-result-main strong {
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.4;
}

.customer-result-main small.customer-attention-reason {
  color: #8a5b08;
  line-height: 1.35;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.customer-result-main strong,
.customer-result-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-result-main small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.customer-result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  grid-column: 1;
}

.customer-result-balance {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  text-align: right;
}

.customer-result-balance small,
.customer-result-balance strong {
  display: block;
}

.customer-result-balance small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.customer-result-balance strong {
  margin-top: 4px;
  font-size: 13px;
}

.customer-record {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.customer-record:focus {
  outline: none;
}

.customer-record:focus-visible {
  outline: 2px solid #8eace9;
  outline-offset: 4px;
  border-radius: 10px;
}

.customer-empty-state {
  min-height: 360px;
  padding: 48px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.customer-empty-state p {
  max-width: 520px;
}

.customer-empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 22px;
  font-weight: 800;
}

.customer-record-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border-top: 3px solid var(--blue);
}

.customer-record-identity {
  min-width: 0;
}

.customer-record-identity h2 {
  margin: 4px 0 10px;
  font-size: 24px;
}

.customer-record-identity > p {
  margin-top: 12px;
  color: var(--muted);
}

.customer-eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.customer-currency-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.customer-identity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.customer-identity-meta strong {
  color: var(--text);
  margin-right: 4px;
}

.customer-record-actions {
  display: flex;
  flex: 0 0 168px;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding-left: 18px;
  border-left: 1px solid var(--line);
  max-width: 220px;
}

.customer-default-card { display: grid; gap: 5px; }
.customer-default-card span, .customer-default-card small { color: var(--muted); font-size: 11px; }
.customer-default-card strong { font-size: 13px; overflow-wrap: anywhere; }
.payment-provider-link { min-width: 170px; max-width: 250px; }
.payment-provider-link code { display: block; white-space: normal; overflow-wrap: anywhere; font-size: 11px; margin: 5px 0; }

.customer-managed-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: right;
}

.customer-account-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.customer-metric {
  min-width: 0;
  min-height: 100px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.customer-metric.warning {
  border-color: #e8c27d;
  background: #fffbf3;
}

.customer-metric.success {
  border-color: #b6ddcf;
}

.customer-metric span,
.customer-metric small {
  display: block;
  color: var(--muted);
}

.customer-metric span {
  font-size: 12px;
  font-weight: 700;
}

.customer-metric strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 19px;
  line-height: 1.25;
}

.customer-metric small {
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.4;
}

.customer-section-nav {
  display: flex;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.customer-section-nav button {
  flex: 1 0 auto;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.customer-section-nav button:hover {
  background: #f3f6fa;
  color: var(--text);
}

.customer-section-nav button.active {
  background: var(--blue);
  color: #ffffff;
}

.customer-section-nav button span {
  display: inline-grid;
  min-width: 21px;
  min-height: 21px;
  margin-left: 5px;
  padding: 2px 6px;
  place-items: center;
  border-radius: 999px;
  background: #e8edf5;
  color: var(--muted);
  font-size: 11px;
}

.customer-section-nav button.active span {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.customer-section-content,
.customer-panel-stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.customer-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.customer-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.customer-data-panel {
  min-width: 0;
  padding: 20px;
}

.customer-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.customer-detail-list > div {
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.customer-detail-list > div:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.customer-detail-list > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.customer-detail-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.customer-detail-list dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 650;
}

.customer-cutover {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.customer-cutover.success {
  border-color: #b6ddcf;
  background: #f5fbf8;
}

.customer-cutover.warning {
  border-color: #e8c27d;
  background: #fffbf3;
}

.customer-cutover-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.customer-cutover p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.customer-cutover p + p {
  margin-top: 7px;
}

.customer-cutover-actions {
  justify-content: flex-start;
  margin-top: 10px;
}

.customer-import-note,
.customer-edit-account {
  margin-top: 14px;
}

.customer-contact-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.customer-contact-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafbfc;
}

.customer-contact-card > div {
  min-width: 0;
}

.customer-contact-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e7efff;
  color: var(--blue);
  font-weight: 800;
}

.customer-contact-card strong,
.customer-contact-card a,
.customer-contact-card small {
  display: block;
  overflow-wrap: anywhere;
}

.customer-inline-editor {
  margin-top: 10px;
}

.compact-form-grid {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.customer-contact-card .compact-form-grid {
  grid-template-columns: 1fr;
}

.customer-service-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.customer-contact-card a {
  margin-top: 3px;
  color: var(--blue);
  font-size: 13px;
}

.customer-contact-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.customer-data-panel table td > strong,
.customer-data-panel table td > small {
  display: block;
}

.customer-data-panel table td > small {
  margin-top: 4px;
  color: var(--muted);
}

.report-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.report-chart-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.report-chart-panel h2 {
  margin: 0 0 4px;
}

.report-chart-wrap {
  min-width: 0;
}

.report-chart {
  display: block;
  width: 100%;
  height: auto;
  color: var(--text);
}

.chart-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-label,
.chart-value-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-value-label {
  fill: var(--text);
  font-weight: 700;
}

.chart-bar-invoiced,
.chart-bar-active,
.legend-invoiced,
.legend-active {
  fill: var(--blue);
  background: var(--blue);
}

.chart-bar-paid,
.legend-paid {
  fill: var(--green);
  background: var(--green);
}

.chart-bar-trial,
.legend-trial {
  fill: var(--amber);
  background: var(--amber);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.chart-empty {
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.subpanel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  overflow: hidden;
}

.subpanel h2,
.subpanel h3 {
  margin-bottom: 12px;
}

.inline-details {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.inline-details > summary {
  padding: 14px 0 4px;
  cursor: pointer;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.admin-section {
  padding: 0;
  overflow: hidden;
}

.admin-section > summary,
.report-section > summary {
  min-height: 70px;
  padding: 16px 18px;
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-section > summary::-webkit-details-marker,
.report-section > summary::-webkit-details-marker {
  display: none;
}

.admin-section > summary span:first-child,
.report-section > summary span:first-child {
  display: grid;
  gap: 4px;
}

.admin-section > summary small,
.report-section > summary small {
  color: var(--muted);
  font-weight: 400;
}

.admin-section[open] > summary,
.report-section[open] > summary {
  border-bottom: 1px solid var(--line);
}

.disclosure-label {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.admin-section-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.report-section {
  padding: 0;
  overflow: hidden;
}

.amount-buckets {
  display: grid;
  gap: 3px;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field-help {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  text-transform: none;
}

.setting-field {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.segmented label {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 112px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  cursor: pointer;
}

.segmented label + label {
  border-left: 1px solid var(--line);
}

.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  width: 100%;
  height: 100%;
  padding: 9px 14px;
  text-align: center;
}

.segmented input:checked + span {
  background: var(--blue);
  color: #ffffff;
}

.segmented:has(input:focus-visible) {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #174ea6;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  flex: 0 0 16px;
  accent-color: var(--blue);
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

.page-heading,
.section-heading,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-heading {
  min-height: 54px;
}

.page-heading h2,
.section-heading h2,
.section-heading h3,
.dialog-heading h2 {
  margin-bottom: 5px;
}

.page-actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.form-actions {
  flex-basis: 100%;
  grid-column: 1 / -1;
  margin-top: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide-field {
  grid-column: 1 / -1;
}

.settings-list {
  display: grid;
  gap: 10px;
  max-width: 1080px;
}

.settings-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.settings-section > summary,
.template-editor > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.settings-section > summary {
  min-height: 76px;
  padding: 16px 18px;
}

.settings-section > summary::-webkit-details-marker,
.template-editor > summary::-webkit-details-marker {
  display: none;
}

.settings-section > summary span:first-child,
.template-editor > summary span:first-child {
  display: grid;
  gap: 4px;
}

.settings-section > summary small,
.template-editor > summary small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
}

.settings-section[open] > summary {
  border-bottom: 1px solid var(--line);
}

.settings-section > form,
.settings-section > .connection-result {
  margin: 18px;
}

.settings-form {
  max-width: 820px;
}

.settings-source-note {
  flex-basis: 100%;
  grid-column: 1 / -1;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.advanced-fields {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.advanced-fields > summary {
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.advanced-fields > .form-grid {
  margin-top: 14px;
}

.brand-preview {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.brand-preview img {
  max-width: 180px;
  max-height: 54px;
  object-fit: contain;
}

.connection-result {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
}

.connection-result.success {
  border-color: #a9ddc9;
  color: var(--green);
  background: #eef9f5;
}

.connection-result.error {
  border-color: #f0b6b6;
  color: var(--red);
  background: #fff3f3;
}

.template-list {
  display: grid;
  gap: 8px;
}

.template-editor {
  border: 1px solid var(--line);
  border-radius: 6px;
}

.template-editor > summary {
  min-height: 58px;
  padding: 11px 13px;
}

.template-editor[open] > summary {
  border-bottom: 1px solid var(--line);
}

.template-editor > .form-grid {
  padding: 14px;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.catalog-nav {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.catalog-nav-heading {
  min-height: 48px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.catalog-nav-heading span {
  color: var(--muted);
  font-size: 13px;
}

button.catalog-product {
  width: 100%;
  min-height: 66px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 14px;
  background: #ffffff;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

button.catalog-product:last-child {
  border-bottom: 0;
}

button.catalog-product.active {
  background: #eef5ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.catalog-product > span:first-child {
  display: grid;
  gap: 4px;
}

.catalog-product small {
  color: var(--muted);
}

.catalog-content {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.product-overview {
  padding-top: 20px;
  padding-bottom: 20px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.plan-workspace {
  display: grid;
  gap: 16px;
}

.price-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.price-book {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.price-book-heading {
  min-height: 46px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.price-book-heading span {
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.compact-button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
}

.empty-state {
  padding: 28px;
  text-align: center;
}

.empty-state.compact {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.admin-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--text);
  background: var(--panel);
}

.admin-dialog::backdrop {
  background: rgba(22, 26, 34, 0.55);
}

.admin-dialog > form {
  margin-top: 20px;
}

.customer-service-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
}

.customer-service-dialog[open] {
  display: flex;
  flex-direction: column;
}

.customer-service-dialog > .dialog-heading {
  flex: 0 0 auto;
  align-items: flex-start;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.customer-service-dialog .dialog-heading > div,
.customer-service-form > label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.customer-service-dialog .dialog-heading > button {
  flex: 0 0 auto;
}

.customer-service-dialog-body {
  min-height: 0;
  padding: 20px 22px;
  overflow: auto;
  overscroll-behavior: contain;
}

.customer-service-form input,
.customer-service-form select {
  min-width: 0;
  max-width: 100%;
}

.customer-service-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 20px;
}

.customer-service-facts dt,
.customer-service-lifecycle > span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.customer-service-facts dd {
  margin: 0;
}

.customer-service-save-actions {
  justify-content: flex-end;
  padding-top: 8px;
}

.customer-service-lifecycle {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.customer-service-dialog [data-customer-service-error][hidden] {
  display: none;
}

@media (max-width: 620px) {
  .customer-service-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .customer-service-dialog > .dialog-heading {
    flex-direction: row;
    padding: 16px;
    gap: 12px;
  }

  .customer-service-dialog-body {
    padding: 16px;
  }

  .customer-service-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

.small-dialog {
  width: min(460px, calc(100vw - 32px));
}

.admin-confirm-dialog > form {
  margin-top: 0;
}

.admin-confirm-message {
  margin: 20px 0 0;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}

.admin-confirm-actions {
  margin-top: 22px;
}

button.danger-button {
  border-color: #9f2525;
  background: #b52d2d;
}

.admin-notice-region {
  position: fixed;
  z-index: 1000;
  top: 18px;
  right: 18px;
  width: min(430px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.admin-notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 12px 32px rgba(22, 26, 34, 0.2);
  pointer-events: auto;
}

.admin-notice p {
  margin: 4px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.admin-notice-dismiss {
  min-height: 30px;
  flex: 0 0 auto;
  padding: 4px 8px;
  color: inherit;
}

.payment-method-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 26, 34, 0.55);
}

.payment-method-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  margin: 0;
  width: min(780px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
  transform: translate(-50%, -50%);
}

.payment-method-dialog > .dialog-heading {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.payment-method-modal-body {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 20px 22px 24px;
}

.payment-method-modal-body > .notice {
  margin-bottom: 16px;
}

.payment-method-current {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(180px, 1fr) auto;
  align-items: center;
  gap: 8px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fbfcfe;
}

.payment-method-current span,
.payment-method-current small {
  color: var(--muted);
}

.payment-method-current strong {
  text-transform: capitalize;
}

.payment-method-security-note {
  margin-bottom: 18px;
  border-left: 3px solid #4f7bd9;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  background: #f4f7fd;
}

.payment-method-security-note p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.payment-method-modal-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.payment-method-modal-form .form-actions,
.payment-method-modal-actions {
  grid-column: auto;
  margin-top: 0;
}

.payment-method-dropin {
  margin-top: 18px;
  min-height: 320px;
}

.payment-method-modal-actions {
  margin-top: 16px;
}

.invoice-collection-dialog {
  width: min(620px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
}

.invoice-collection-dialog > .dialog-heading {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.invoice-collection-form {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 20px 22px 24px;
}

.invoice-collection-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}

.invoice-collection-summary > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcfe;
}

.invoice-collection-summary dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.invoice-collection-summary dd {
  overflow-wrap: anywhere;
  margin: 0;
}

.invoice-card-options {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 0;
  padding: 0;
}

.invoice-card-options legend {
  margin-bottom: 10px;
  font-weight: 700;
}

.invoice-card-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #ffffff;
  cursor: pointer;
}

.invoice-card-option:has(input:checked) {
  border-color: #4f7bd9;
  box-shadow: 0 0 0 2px rgba(79, 123, 217, 0.13);
  background: #f6f9ff;
}

.invoice-card-option input {
  margin: 0;
}

.invoice-card-option span {
  display: grid;
  gap: 3px;
}

.invoice-card-option small,
.invoice-card-guidance {
  color: var(--muted);
}

.invoice-card-guidance {
  margin: 10px 0 0;
}

.invoice-collection-confirmation {
  margin-top: 16px;
}

.invoice-collection-result {
  margin-top: 16px;
}

.inline-payment-result-heading,
.payment-attempt-action {
  display: grid;
  gap: 6px;
}

.inline-payment-result-heading {
  grid-template-columns: auto 1fr;
  align-items: baseline;
}

.invoice-collection-summary.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0 0;
}

.invoice-collection-summary.compact > div:last-child {
  grid-column: 1 / -1;
}

.inline-payment-actions {
  margin-top: 14px;
}

.payment-attempt-action {
  min-width: 190px;
}

.invoice-collection-form > .form-actions {
  margin-top: 18px;
}

button {
  min-height: 38px;
  border: 1px solid #2358c9;
  background: var(--blue);
  color: #ffffff;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

.icon-button {
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.panel > table,
.subpanel > table {
  display: block;
  overflow-x: auto;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f7;
  color: #3a4352;
}

.badge.green {
  background: #e8f7f1;
  color: var(--green);
}

.badge.amber {
  background: #fff3df;
  color: var(--amber);
}

.badge.red {
  background: #ffebeb;
  color: var(--red);
}

.quote-result {
  min-height: 72px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef5ff;
  color: #214f96;
  border: 1px solid #cfe1ff;
}

.usage-action-status {
  margin: 14px 0 0;
}

.notice.usage-action-status {
  display: grid;
  gap: 4px;
}

.notice.usage-action-status span {
  color: inherit;
}

.portal-body {
  display: block;
  min-height: 100vh;
  background: var(--bg);
}

.signup-body {
  display: block;
  min-height: 100vh;
  background: #f6f7f9;
}

.portal-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: grid;
  gap: 22px;
}

.portal-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.portal-login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
}

.admin-login-panel {
  width: min(100%, 440px);
}

.admin-session-note {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.admin-login-cancel {
  justify-content: center;
}

.portal-login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-login-brand > div,
.portal-login-form {
  display: grid;
  gap: 12px;
}

.portal-login-brand span {
  display: block;
  color: var(--muted);
}

.error-notice {
  color: #8f1d1d;
  background: #fff2f2;
  border-color: #efc1c1;
}

.success-notice {
  color: #126043;
  background: #eefaf5;
  border-color: #b9e5d2;
}

.audit-json {
  max-width: 560px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.signup-shell {
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 22px 44px;
  display: grid;
  gap: 18px;
}

.signup-shell [hidden] {
  display: none !important;
}

.portal-header {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.signup-header {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.signup-brand-intro {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.signup-heading-copy {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.signup-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.signup-header .brand-mark {
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
  border-radius: 12px;
  font-size: 22px;
}

.signup-header .brand-logo {
  width: 96px;
  height: 60px;
}

.signup-header p {
  color: var(--muted);
  max-width: 720px;
  line-height: 1.45;
}

.signup-trial-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  margin: 1px 0 0;
  padding: 0;
  list-style: none;
  color: #35506f;
  font-size: 13px;
  font-weight: 700;
}

.signup-trial-highlights li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.signup-trial-highlights li::before {
  content: "✓";
  color: var(--green);
  font-weight: 900;
}

.secondary-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

.signup-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.signup-steps span {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}

.signup-steps span.active {
  border-color: #b8d1ff;
  background: #eef5ff;
  color: var(--blue);
}

.signup-steps span.complete {
  border-color: #b6ddcf;
  background: #eef9f5;
  color: var(--green);
}

.signup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 18px;
}

.signup-grid.signup-grid-payment {
  grid-template-columns: minmax(0, 720px);
  justify-content: center;
}

.signup-card {
  display: grid;
  gap: 14px;
  align-content: start;
}

.signup-plan-pricing {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.signup-pricing-heading,
.signup-tier-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.signup-pricing-heading > div,
.signup-tier-row strong {
  display: grid;
  gap: 2px;
}

.signup-pricing-heading span,
.signup-tier-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.signup-tier-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.signup-tier-row {
  min-height: 46px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.signup-tier-row strong {
  justify-items: end;
  text-align: right;
}

.signup-pricing-note {
  font-size: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.signup-state {
  min-height: 88px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.signup-state strong,
.signup-state span {
  display: block;
}

.airwallex-dropin {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.airwallex-loading {
  min-height: 254px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.signup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  text-transform: none;
  font-size: 13px;
  font-weight: 600;
}

.inline-check input {
  min-height: 0;
}

.signup-alternate-admin-field {
  text-transform: none;
}

.operation-checks {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(230px, 1fr));
  gap: 10px 18px;
  padding: 12px 0 4px;
}

.automation-policy {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.compact-heading {
  align-items: flex-start;
}

.compact-heading h3 {
  margin-bottom: 4px;
}

.automation-policy-grid,
.operation-run-metadata {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.automation-policy-grid > div,
.operation-run-metadata > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.automation-policy-grid dt,
.operation-run-metadata dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.automation-policy-grid dd,
.operation-run-metadata dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.automation-policy-grid dd small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.automation-step-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.automation-step-list > span {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #eef2f7;
  font-size: 12px;
}

.automation-policy-warning {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #efc1c1;
  border-radius: 6px;
  color: #8f1d1d;
  background: #fff2f2;
  font-size: 13px;
}

.automation-policy-warning ul {
  margin: 5px 0 0;
  padding-left: 20px;
}

.expandable-operation-row {
  cursor: pointer;
}

.expandable-operation-row:hover td,
.expandable-operation-row.expanded td {
  background: #eef5ff;
}

.table-row-toggle {
  min-height: 28px;
  max-width: 260px;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: var(--blue);
  display: inline-flex;
  align-items: flex-start;
  gap: 7px;
  text-align: left;
}

.table-row-toggle span {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
  transition: transform 120ms ease;
}

.table-row-toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
}

.table-row-toggle code {
  overflow-wrap: anywhere;
}

.operation-run-detail-row > td {
  padding: 0;
  background: #f8fafc;
}

.operation-run-inspector {
  min-width: 720px;
  padding: 14px;
  display: grid;
  gap: 14px;
}

.operation-run-inspector h3 {
  margin-bottom: 8px;
}

.operation-run-metadata {
  margin-top: 0;
}

.record-time-range,
.provider-reference-list,
.payment-failure-detail,
.provisioning-result {
  display: grid;
  gap: 3px;
}

.provisioning-result {
  min-width: 140px;
  justify-items: start;
}

.record-time-range,
.provider-raw-status {
  white-space: nowrap;
}

.record-time-range small,
.provider-raw-status,
.record-secondary {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.record-secondary {
  max-width: 260px;
  overflow-wrap: anywhere;
}

.provider-reference-list {
  min-width: 150px;
  max-width: 280px;
}

.provider-reference-list > span {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: baseline;
}

.provider-reference-list b {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.provider-reference-list code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.payment-failure-detail,
.record-failure {
  max-width: 280px;
  color: var(--red);
  overflow-wrap: anywhere;
}

.payment-fee {
  min-width: 145px;
  display: grid;
  justify-items: start;
  gap: 4px;
}

.payment-fee strong {
  white-space: nowrap;
}

.payment-fee small {
  max-width: 220px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.record-failure {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.4;
}

.record-details > summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.record-json {
  width: min(520px, 70vw);
  max-height: 240px;
  margin: 8px 0 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  line-height: 1.45;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.signup-result {
  display: grid;
  gap: 14px;
}

.signup-success-view {
  width: min(100%, 780px);
  justify-self: center;
  justify-items: center;
  padding: 38px;
  text-align: center;
}

.signup-success-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e7f8f0;
  color: var(--green);
  font-size: 32px;
  font-weight: 800;
}

.signup-success-view h2 {
  font-size: clamp(28px, 4vw, 38px);
}

.signup-success-lead {
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.signup-success-summary {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 8px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.signup-success-summary > div {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
}

.signup-success-summary > div + div {
  border-left: 1px solid var(--line);
}

.signup-success-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.signup-success-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.signup-success-actions {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 12px;
}

.signup-primary-cta {
  min-height: 54px;
  justify-content: center;
  padding: 12px 24px;
  font-size: 17px;
}

.signup-success-actions .button-link.secondary {
  justify-content: center;
}

.signup-one-time-note {
  max-width: 620px;
  font-size: 12px;
}

.signup-busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 247, 249, 0.86);
  backdrop-filter: blur(3px);
}

.signup-busy-overlay[hidden] {
  display: none;
}

.signup-busy-card {
  width: min(100%, 410px);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(20, 35, 65, 0.16);
  text-align: center;
}

.signup-busy-card strong {
  font-size: 20px;
}

.signup-busy-card > span:last-child {
  color: var(--muted);
  line-height: 1.5;
}

.signup-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #dce7fb;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: signup-spin 0.8s linear infinite;
}

.signup-is-busy {
  overflow: hidden;
}

@keyframes signup-spin {
  to { transform: rotate(360deg); }
}

.signup-error {
  border-color: #ffd2d2;
  background: #ffefef;
  color: var(--red);
}

.stats-grid.compact .stat {
  min-height: 82px;
}

.stats-grid.compact .stat strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.portal-header p {
  color: var(--muted);
  margin-top: 6px;
}

.affiliate-filter-toolbar {
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 210px) auto auto;
}

.affiliate-overview-table table {
  min-width: 1120px;
}

.affiliate-overview-table th,
.affiliate-overview-table td {
  vertical-align: top;
}

.affiliate-identity-cell {
  min-width: 160px;
}

.affiliate-identity-cell strong,
.affiliate-identity-cell small {
  display: block;
}

.affiliate-identity-cell small {
  margin-top: 4px;
  color: var(--muted);
}

.affiliate-account-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.affiliate-linked-accounts {
  min-width: 190px;
}

.affiliate-linked-accounts > summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
}

.affiliate-linked-accounts > div {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.affiliate-linked-account {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 3px 8px;
  align-items: start;
}

.affiliate-linked-account small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.affiliate-currency-values {
  display: grid;
  gap: 5px;
  min-width: 110px;
  font-weight: 700;
}

.affiliate-currency-values > span {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 6px;
}

.affiliate-currency-values small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

@media (max-width: 1180px) {
  .customer-record-header { flex-wrap: wrap; }
  .customer-record-actions { flex: 1 0 160px; max-width: none; border-left: 0; padding-left: 0; }
  .dashboard-primary-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .usage-movement-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .usage-ledger-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .customer-account-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .customer-overview-grid,
  .customer-panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .usage-movement-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px 12px;
    gap: 14px;
    min-width: 0;
    width: 100%;
    overflow: hidden;
  }

  .sidebar nav {
    display: flex;
    gap: 6px;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .sidebar nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 8px 10px;
  }

  .sidebar nav::-webkit-scrollbar {
    height: 4px;
  }

  .topbar,
  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .split,
  .stats-grid,
  .dashboard-primary-stats,
  .dashboard-grid,
  .report-overview,
  .detail-grid,
  .report-chart-grid,
  .report-grid,
  .signup-grid,
  .field-row,
  .form-grid,
  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .customer-workspace {
    grid-template-columns: 1fr;
  }

  .customer-directory {
    position: static;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .customer-back-button { display: inline-flex; justify-self: start; }
  .customer-directory .customer-directory-heading { flex-direction: row; align-items: center; }

  .customer-result-list {
    max-height: min(340px, 40vh);
    padding-right: 4px;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  .list-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .wide-field,
  .form-actions {
    grid-column: 1;
  }

  .page-heading,
  .section-heading,
  .dialog-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .signup-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-grid.usage-movement-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .invoice-collection-summary {
    grid-template-columns: 1fr;
  }

  .payment-method-current,
  .payment-method-modal-form {
    grid-template-columns: 1fr;
  }

  .payment-method-modal-form .form-actions {
    justify-content: stretch;
  }

  .payment-method-modal-form .form-actions button {
    width: 100%;
  }

  .customer-detail-list {
    grid-template-columns: 1fr;
  }

  .customer-account-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .customer-metric { min-height: 92px; padding: 12px; }
  .customer-metric strong { font-size: 17px; }
  .customer-portfolio-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 14px; }
  .customer-portfolio-stats strong { font-size: 20px; }
  .customer-portfolio-stats > div { gap: 7px; }
  .customer-attention-filter { grid-column: 1 / -1; margin: 0; justify-content: center; }

  .customer-detail-list > div,
  .customer-detail-list > div:nth-child(odd),
  .customer-detail-list > div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .customer-detail-list > div:last-child {
    border-bottom: 0;
  }

  .customer-record-header {
    align-items: stretch;
    flex-direction: column;
  }

  .customer-record-actions,
  .customer-record-actions button {
    width: 100%;
    max-width: none;
  }

  .customer-record-actions { flex: 0 0 auto; border-left: 0; border-top: 1px solid var(--line); padding: 12px 0 0; }
  .customer-record-header { gap: 12px; padding: 16px; }
  .customer-record-identity h2 { font-size: 21px; }

  .customer-managed-note {
    text-align: left;
  }

  .customer-search-options {
    grid-template-columns: 1fr;
  }

  .customer-search-options button {
    grid-column: 1 / -1;
  }

  .signup-pricing-heading,
  .signup-tier-row {
    align-items: flex-start;
  }

  .signup-success-view {
    padding: 26px 18px;
  }

  .signup-success-summary,
  .signup-success-actions {
    grid-template-columns: 1fr;
  }

  .signup-success-summary > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .customer-section-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
  }

  .customer-section-nav button {
    min-width: 0;
    padding: 10px 4px;
    font-size: 12px;
  }

  .customer-section-nav button span { display: none; }

  .topbar,
  .signup-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .signup-header-actions {
    width: 100%;
  }

  .signup-brand-intro {
    align-items: flex-start;
  }

  .signup-header .brand-logo {
    width: 88px;
    height: 56px;
  }

  .content,
  .portal-shell,
  .signup-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .list-toolbar,
  .two-column-stats {
    grid-template-columns: 1fr;
  }

  .price-book-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .operation-checks {
    grid-template-columns: 1fr;
  }

  .pagination,
  .section-heading,
  .detail-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination > div {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  .signup-spinner {
    animation: none;
  }
}

@media (min-width: 981px) and (max-height: 740px) {
  .customer-directory { position: static; height: auto; min-height: 0; max-height: none; }
  .customer-result-list { max-height: 400px; }
}

.customer-data-panel .table-wrap { max-height: 28rem; overflow: auto; }
.customer-data-panel .table-wrap thead { position: sticky; top: 0; z-index: 1; background: var(--panel, white); }
.rich-text-input { min-height: 12rem; padding: 1rem; border: 1px solid #cbd5e1; border-radius: .4rem; background: white; color: #172033; line-height: 1.6; }
.rich-text-input:focus { outline: 2px solid #3b6eef; }
.email-rich-editor .form-actions { margin: .5rem 0; }
