/* Dark surfaces and foregrounds for legacy BIVA operational pages.
   The existing light palette remains untouched. Load this after every page stylesheet. */
.biva-admin-layout.finance-theme-dark {
  --theme-canvas: #0b1c25;
  --theme-surface: #172f3a;
  --theme-raised: #203c47;
  --theme-border: #3b5962;
  --theme-ink: #f1f8f5;
  --theme-text: #dcebe8;
  --theme-muted: #bbd0cf;
  --theme-accent: #91e9bc;
}
/* Shared visual primitives. A surface and its foreground always change together. */
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-card"], [class$="__card"], [class$="-panel"], [class$="__panel"],
  [class$="-surface"], [class$="__surface"]
) { background-color: var(--theme-surface); background-image: none; border-color: var(--theme-border); color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-card"], [class$="__card"], [class$="-panel"], [class$="__panel"],
  [class$="-surface"], [class$="__surface"]
) :is(h1, h2, h3, h4, strong):not([class*="badge"]):not([class*="status"]) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-card"], [class$="__card"], [class$="-panel"], [class$="__panel"],
  [class$="-surface"], [class$="__surface"]
) :is(p, small) { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-hero"], [class$="__hero"]
):not(.pi-hero) { background: var(--theme-surface); border-color: var(--theme-border); color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-hero"], [class$="__hero"]
):not(.pi-hero) :is(h1, h2, h3) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-hero"], [class$="__hero"]
):not(.pi-hero) p { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(table, thead, tbody, tr, td, th) { border-color: var(--theme-border); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(input, textarea, select) { background-color: var(--theme-raised); border-color: #4e6b74; color: var(--theme-ink); }

/* Financial Accounts: compact title, KPI tiles, ledger and account actions. */
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-layout-header { background: transparent !important; color: var(--theme-ink) !important; }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-layout-header h1 { color: var(--theme-ink) !important; }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-layout-header p { color: var(--theme-muted) !important; }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-layout-header span { color: var(--theme-accent) !important; }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-finance-status[data-type="success"] { color: var(--theme-accent); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-account-summary-card,
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-panel,
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-table-scroll { background: var(--theme-surface); border-color: var(--theme-border); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-account-summary-card > :is(strong, span, small),
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-panel__header :is(h2, span, p) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-account-summary-card > :is(span, small),
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-panel__header p { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-account-summary-card:nth-child(3) > strong { color: #ff98a5; }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-table { color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-table :is(th, td) { border-color: var(--theme-border); color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-table th { background: var(--theme-raised); color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-table tbody tr:hover td { background: var(--theme-raised); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-table :is(td strong, .company-account-table-money) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-table td small { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-account-table-money.is-negative { color: #ff98a5; }
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-account-table-money.is-positive { color: var(--theme-accent); }

/* Invoice Generator: the first version never had dark tokens. */
.biva-admin-layout.finance-theme-dark.platform-invoices-page .biva-admin-content { background: var(--theme-canvas); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-metrics article,
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register,
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register > header,
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-skeleton,
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-load-error { background: var(--theme-surface); border-color: var(--theme-border); color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-metrics :is(span, small),
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register :is(td small, .pi-empty span) { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-metrics strong,
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register h2,
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register td strong { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register header small { color: var(--theme-accent); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-tools :is(input, select) { background: var(--theme-raised); border-color: #4e6b74; color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register :is(th, td) { border-color: var(--theme-border); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register th { background: var(--theme-raised); color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register td { background: var(--theme-surface); color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-register tr:hover td { background: var(--theme-raised); }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-more { color: #91e9bc; }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-hero :is(h1, small, .pi-primary) { color: #fff; }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-hero .pi-primary { background: #ffbe22; color: #071d3a; }
/* Badges intentionally keep their tinted backgrounds and matching dark foregrounds. */
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-status.is-draft { color: #334155; }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-status.is-sent { color: #1557b0; }
.biva-admin-layout.finance-theme-dark.platform-invoices-page .pi-status.is-overdue { color: #b4283b; }

/* Internet dashboard: avoid a white body holding dark tiles and invisible figures. */
.biva-admin-layout.finance-theme-dark .biva-admin-surface,
.biva-admin-layout.finance-theme-dark .biva-admin-surface__body { background: var(--theme-surface); border-color: var(--theme-border); color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark .biva-admin-surface__header { background: var(--theme-surface); border-color: var(--theme-border); }
.biva-admin-layout.finance-theme-dark .internet-admin-card { background: var(--theme-raised); border-color: #4e6b74; }
.biva-admin-layout.finance-theme-dark .internet-admin-card :is(h3, strong) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark .internet-admin-card:hover { background: #294a55; }

/* Partner applications: title and register previously inherited light text on white. */
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-hero,
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-card,
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-card__header,
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-table-wrap { background: var(--theme-surface); border-color: var(--theme-border); color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-hero :is(h1, span),
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-card__header :is(h2, span) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell :is(.internet-partner-admin-hero, .internet-partner-admin-card__header) p { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-table th { background: var(--theme-raised); color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-table td { background: var(--theme-surface); color: var(--theme-text); border-color: var(--theme-border); }
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-table tr:hover td { background: var(--theme-raised); }
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-empty { color: var(--theme-muted) !important; }
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-count { background: var(--theme-raised); border-color: var(--theme-border); color: var(--theme-accent); }

/* Account actions and semantic messages retain clear focus and state colours. */
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-layout-header #companyAccountsAddBtn {
  background: #aada63;
  border-color: #aada63;
  color: #102532;
}
.biva-admin-layout.finance-theme-dark.company-finance-accounts-page .company-accounts-layout-header #companyAccountsRefreshBtn {
  background: #174a83;
  border-color: #4773a5;
  color: #fff;
}
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-status:not([data-type]) {
  background: var(--theme-raised);
  border-color: var(--theme-border);
  color: var(--theme-text);
}
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-status[data-type="success"] {
  background: #193e38;
  border-color: #347765;
  color: #a8eec5;
}
.biva-admin-layout.finance-theme-dark.internet-partner-applications-admin-shell .internet-partner-admin-status[data-type="error"] {
  background: #4b3039;
  border-color: #95616a;
  color: #ffbac0;
}

/* Invoice editor renders above the admin layout in document.body. */
body.biva-theme-dark .pi-editor,
body.biva-theme-dark .pi-form-section,
body.biva-theme-dark .pi-editor footer,
body.biva-theme-dark .pi-detail-grid > div { background: #172f3a; border-color: #3b5962; color: #dcebe8; }
body.biva-theme-dark .pi-item-row,
body.biva-theme-dark .pi-payment-rule { background: #203c47; border-color: #3b5962; }
body.biva-theme-dark .pi-editor :is(h3, .pi-calculation strong, .pi-payment-rule strong) { color: #f1f8f5; }
body.biva-theme-dark .pi-editor :is(label > span, .pi-section-title p, .pi-calculation span, .pi-detail-grid span, .pi-detail-grid small, .pi-payment-rule span) { color: #bbd0cf; }
body.biva-theme-dark .pi-editor :is(input, select, textarea) { background: #203c47; border-color: #4e6b74; color: #f1f8f5; }
body.biva-theme-dark .pi-editor :is(.pi-calculation, .pi-detail-items) { border-color: #3b5962; }
body.biva-theme-dark .pi-editor .pi-grand-total { background: #0e2530; }
body.biva-theme-dark .pi-editor .pi-grand-total :is(strong, span) { color: #f1f8f5; }
body.biva-theme-dark .pi-editor :is(button, input, select, textarea):focus-visible { outline: 2px solid #aada63; outline-offset: 2px; }

/* KPI and directory counters shared by Internet, Sales, Hospitality and Talent. */
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-stat"], [class$="__stat"], [class$="-metric"], [class$="__metric"],
  [class$="-tile"], [class$="__tile"],
  [class$="-metrics"] > article, [class$="__metrics"] > article,
  [class$="-summary"] > article, [class$="__summary"] > article,
  .hospitality-admin-profile-grid article
) { background: var(--theme-surface); border-color: var(--theme-border); color: var(--theme-text); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-stat"], [class$="__stat"], [class$="-metric"], [class$="__metric"],
  [class$="-tile"], [class$="__tile"],
  [class$="-metrics"] > article, [class$="__metrics"] > article,
  [class$="-summary"] > article, [class$="__summary"] > article,
  .hospitality-admin-profile-grid article
) :is(strong, b, h2, h3) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark:not(.finance-pro-page) .biva-admin-layout__page-content :is(
  [class$="-stat"], [class$="__stat"], [class$="-metric"], [class$="__metric"],
  [class$="-tile"], [class$="__tile"],
  [class$="-metrics"] > article, [class$="__metrics"] > article,
  [class$="-summary"] > article, [class$="__summary"] > article,
  .hospitality-admin-profile-grid article
) :is(p, small, span:not([class*="badge"]):not([class*="status"])) { color: var(--theme-muted); }

/* Voucher Management: make the search, table canvas and usage display one surface. */
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management {
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
.biva-admin-layout.finance-theme-dark.voucher-management-page :is(.voucher-management__filters, .voucher-management-table-wrap, .voucher-management-search) {
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-search input {
  background: var(--theme-surface);
  color: var(--theme-ink);
}
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-search input::placeholder { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management__filters select {
  background: var(--theme-raised);
  border-color: #4e6b74;
  color: var(--theme-ink);
}
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-page-count {
  background: var(--theme-raised);
  color: var(--theme-ink);
}
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-table tbody tr { background: var(--theme-surface); }
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-table tbody tr:hover { background: var(--theme-raised); }
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-table :is(th, td) { border-color: var(--theme-border); }
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-table :is(th, td strong, .voucher-management-table__value, .voucher-management-usage__top strong) { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-table :is(small, .voucher-management-usage__top span, .voucher-management-usage__bottom span) { color: var(--theme-muted); }
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-pagination span { color: var(--theme-ink); }
.biva-admin-layout.finance-theme-dark.voucher-management-page .voucher-management-usage__track { background: #365464; }

/* Controller details: foregrounds and backgrounds switch together. */
body.biva-theme-dark .internet-controller-details-dialog,
body.biva-theme-dark .internet-controller-details-dialog > header,
body.biva-theme-dark .internet-controller-details-body,
body.biva-theme-dark .internet-controller-details-body .internet-controller-card {
  background: #172f3a;
  border-color: #3b5962;
  color: #dcebe8;
}
body.biva-theme-dark .internet-controller-details-dialog > header h2,
body.biva-theme-dark .internet-controller-details-body .internet-controller-card__details strong { color: #f1f8f5; }
body.biva-theme-dark .internet-controller-details-dialog > header span { color: #91e9bc; }
body.biva-theme-dark .internet-controller-details-body .internet-controller-card__details > div {
  background: #203c47;
  border-color: #4e6b74;
}
body.biva-theme-dark .internet-controller-details-body .internet-controller-card__details span { color: #bbd0cf; }
body.biva-theme-dark .internet-controller-details-body .internet-controller-card__actions .btn-outline,
body.biva-theme-dark .internet-controller-details-dialog > header button {
  background: #203c47;
  border-color: #4e6b74;
  color: #f1f8f5;
}
body.biva-theme-dark .internet-controller-details-body .internet-controller-card__actions .btn-secondary {
  background: #aada63;
  border-color: #aada63;
  color: #102532;
}
