/* ClienOS platform layer. Load after the existing feature styles.
   Merchant colors, customer-brand variables and card art remain owned by their modules. */
@font-face {
  font-family: "DM Sans";
  src: url("/assets/clienos/fonts/DMSans-variable.ttf") format("truetype");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DM Serif Display";
  src: url("/assets/clienos/fonts/DMSerifDisplay-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --clienos-purple: #302044;
  --clienos-orange: #ff702e;
  --clienos-orange-hover: #ef5f1b;
  --clienos-paper: #faf9f6;
  --clienos-ink: #21172f;
  --clienos-secondary: #61596b;
  --clienos-border: #8f879a;
  --clienos-divider: #d8d3dc;
  --clienos-soft: #f0edf1;
  --clienos-error: #b42318;
  --clienos-error-bg: #fff0ed;
  --clienos-font-ui: "DM Sans", system-ui, sans-serif;
  --clienos-font-display: "DM Serif Display", Georgia, serif;
}
body, button, input, select, textarea {
  font-family: var(--clienos-font-ui);
}
body:has(.shell), body:has(.login),
body:has(#step-body), body:has(#contract-body), body:has(#subscription-page) {
  background: var(--clienos-paper);
  color: var(--clienos-ink);
}
.shell, .login, .public-page:not(.customer-brand-scope),
.client-shell:not(.customer-brand-scope),
body:has(#step-body), body:has(#contract-body), body:has(#subscription-page) {
  --green: var(--clienos-purple);
  --muted: var(--clienos-secondary);
  --line: var(--clienos-divider);
  --light: var(--clienos-soft);
  color: var(--clienos-ink);
}
.shell {
  --workspace-nav: var(--clienos-paper);
  --workspace-nav-text: var(--clienos-ink);
  --workspace-nav-active: var(--clienos-soft);
  --workspace-focus: var(--clienos-purple);
}
.shell .workspace, .shell .content, .login-form {
  background: var(--clienos-paper);
}
.shell .sidebar {
  background: var(--clienos-paper);
  border-color: var(--clienos-divider);
}
.brand img.clienos-logo {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
}
.shell .sidebar .brand {
  color: var(--clienos-purple);
  gap: 0;
  min-height: 48px;
}
.shell .sidebar .nav {
  scrollbar-color: var(--clienos-border) var(--clienos-paper);
}
.shell .sidebar .nav a, .shell .sidebar .nav button {
  min-height: 48px;
  color: var(--clienos-ink);
  font-size: 15px;
  border-radius: 8px;
}
.shell .sidebar .nav a:hover, .shell .sidebar .nav button:hover {
  background: var(--clienos-soft);
  color: var(--clienos-ink);
}
.shell .sidebar .nav a.active, .shell .sidebar .nav button.active {
  color: var(--clienos-purple);
  background: var(--clienos-soft);
  font-weight: 700;
  box-shadow: inset 3px 0 var(--clienos-purple);
  border-right: 3px solid var(--clienos-orange);
}
.shell .sidebar .nav .ui-icon { width: 24px; height: 24px; }
.shell .sidebar .profile { border-color: var(--clienos-divider); }
.shell .sidebar .profile strong { color: var(--clienos-ink); }
.shell .sidebar .profile small,
.shell .sidebar .edition, .shell .sidebar .nav-label { color: var(--clienos-secondary); }
.shell .sidebar .avatar, .shell .avatar {
  color: var(--clienos-purple);
  background: var(--clienos-soft);
}
.shell .sidebar .sidebar-bottom .profile .logout {
  color: var(--clienos-purple);
  min-height: 48px;
}
.shell .topbar {
  color: var(--clienos-paper);
  background: var(--clienos-purple);
  border-color: var(--clienos-purple);
}
.shell .topbar .breadcrumb,
.shell .topbar .breadcrumb strong,
.shell .topbar .breadcrumb a,
.shell .topbar .top-actions > strong { color: var(--clienos-paper); }
.shell .topbar .tag {
  color: var(--clienos-paper);
  background: transparent;
  border: 1px solid var(--clienos-paper);
}
.shell .topbar .tenant-select {
  background: var(--clienos-paper);
  color: var(--clienos-ink);
  border-color: var(--clienos-paper);
}
.shell .page-head h1, .login-story h1,
.public-page > h1:not(.customer-brand-scope *),
.client-shell:not(.customer-brand-scope) :is(.intro, .auth) h1,
body:has(#step-body) main > h1,
body:has(#contract-body) main > h1,
#subscription-page > h1 {
  font-family: var(--clienos-font-display);
  font-weight: 400;
  font-synthesis: none;
  font-size: clamp(32px, 3.5vw, 40px);
  line-height: 1.12;
  letter-spacing: -.025em;
  color: var(--clienos-purple);
}
.shell :is(h2, h3, .metric-value):not(.customer-brand-scope *),
.login-form :is(h2, h3) {
  font-family: var(--clienos-font-ui);
  letter-spacing: -.02em;
}
.shell .subtitle, .shell .muted, .shell .notice,
.shell .cell-person small, .shell .activity-main small,
.shell .metric-label, .shell .metric-detail,
.login .subtitle, .login .notice { color: var(--clienos-secondary); }
.shell .metric-value, .shell .activity-amount,
.shell .receipt .amount, .shell table { font-variant-numeric: tabular-nums; }
.shell :is(.panel, .metric, .program):not(.customer-brand-scope *) {
  background: var(--clienos-paper);
  border-color: var(--clienos-divider);
  border-radius: 12px;
  box-shadow: none;
}
.shell table { font-size: 15px; color: var(--clienos-ink); }
.shell th {
  font-size: 12px;
  color: var(--clienos-secondary);
  letter-spacing: .045em;
  font-weight: 600;
}
.shell :is(th, td) { border-color: var(--clienos-divider); }
.shell td { padding-top: 18px; padding-bottom: 18px; }
/* Customer data and recovery labels must fit without widening desktop tables.
   Other ledgers keep their existing number/amount wrapping behavior. */
.shell .table-wrap:has(#customer-rows) table {
  width: 100%;
  table-layout: fixed;
  white-space: normal;
}
.shell .table-wrap:has(#customer-rows) th:nth-child(1) { width: 32%; }
.shell .table-wrap:has(#customer-rows) th:nth-child(2) { width: 34%; }
.shell .table-wrap:has(#customer-rows) th:nth-child(3) { width: 14%; }
.shell .table-wrap:has(#customer-rows) th:nth-child(4) { width: 20%; }
.shell #customer-rows td { vertical-align: top; white-space: normal; }
.shell #customer-rows .cell-person { align-items: flex-start; min-width: 0; }
.shell #customer-rows .cell-person > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.shell #customer-rows .tag {
  display: inline-block;
  max-width: 100%;
  margin-inline: 0 !important;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.shell #customer-rows :is(.btn, .text-link) {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.shell #customer-rows td:last-child > :is(button, a) {
  display: flex;
  align-items: center;
  min-height: 48px;
  width: 100%;
  text-align: left;
}
.shell #customer-rows td:last-child > :is(button, a) + :is(button, a) {
  margin-top: 8px;
}
.shell :is(.activity, .program footer) { border-color: var(--clienos-divider); }
:is(.shell, .login, .public-page, .client-shell:not(.customer-brand-scope))
  .btn:not(.customer-brand-scope *),
body:has(#step-body) button, body:has(#contract-body) button,
#subscription-page button {
  min-height: 48px;
  font-size: 16px;
  line-height: 1.4;
  border-radius: 8px;
  color: var(--clienos-purple);
  background: var(--clienos-paper);
  border-color: var(--clienos-border);
  box-shadow: none;
}
:is(.shell, .login, .public-page, .client-shell:not(.customer-brand-scope))
  .btn.primary:not(.customer-brand-scope *),
body:has(#step-body) button.primary,
body:has(#contract-body) button.primary,
#subscription-page button.primary {
  color: var(--clienos-ink);
  background: var(--clienos-orange);
  border-color: var(--clienos-orange);
  font-weight: 700;
  filter: none;
}
:is(.shell, .login, .public-page, .client-shell:not(.customer-brand-scope))
  .btn.primary:not(.customer-brand-scope *):hover {
  color: var(--clienos-ink);
  background: var(--clienos-orange-hover);
  border-color: var(--clienos-orange-hover);
}
.shell .btn.danger:not(.customer-brand-scope *) {
  color: var(--clienos-error);
  border-color: var(--clienos-error);
}
.shell .btn:disabled, .login .btn:disabled {
  color: var(--clienos-secondary);
  background: var(--clienos-soft);
  border-color: var(--clienos-border);
  opacity: 1;
}
:is(.shell, .login) :is(.field input, .field select, .field textarea, input.search):not(.customer-brand-scope *) {
  min-height: 48px;
  color: var(--clienos-ink);
  background: var(--clienos-paper);
  border: 1px solid var(--clienos-border);
  border-radius: 8px;
  font-size: 16px;
}
:is(.shell, .login) :is(.field label, label):not(.customer-brand-scope *) {
  color: var(--clienos-ink);
  font-size: 14px;
}
:is(.shell, .login) input::placeholder { color: var(--clienos-secondary); opacity: 1; }
.shell :is(.text-link, .panel-back):not(.customer-brand-scope *) { color: var(--clienos-purple); }
.shell .info:not(.customer-brand-scope *) {
  color: var(--clienos-purple);
  background: var(--clienos-soft);
  border-color: var(--clienos-divider);
}
.shell .error:not(.customer-brand-scope *), .login .error {
  color: var(--clienos-error);
  background: var(--clienos-error-bg);
}
.shell .tag:not(.amber, .gray, .customer-brand-scope *, .topbar *) {
  background: var(--clienos-soft);
  color: var(--clienos-purple);
}
.shell .modal, .panel-session-dialog {
  color: var(--clienos-ink);
  background: var(--clienos-paper);
  border-color: var(--clienos-border);
  box-shadow: none;
  border-radius: 12px;
}
.login-story {
  background: var(--clienos-soft);
  color: var(--clienos-ink);
}
.login-story .brand { color: var(--clienos-purple); }
.login-story h1 { font-size: clamp(40px, 4.5vw, 64px); }
.login-story p, .login-story .eyebrow { color: var(--clienos-secondary); }
.login-form h2 { color: var(--clienos-purple); }
/* Help retains all position, dismissal, progress and recovery behavior. */
.bj-launcher, .bj-panel, .bj-guide {
  font-family: var(--clienos-font-ui);
  color: var(--clienos-ink);
  background: var(--clienos-paper);
  border-color: var(--clienos-border);
  box-shadow: none;
}
.bj-launcher:hover { box-shadow: none; }
.bj-launcher > svg { color: var(--clienos-paper); background: var(--clienos-purple); }
.bj-launcher.is-ready > svg { background: #176b4b; }
.bj-launcher-count, .bj-tip-count { color: var(--clienos-purple); border-color: var(--clienos-border); }
.bj-panel :is(h2, h3), .bj-guide :is(h2, h3) {
  color: var(--clienos-ink);
  font-family: var(--clienos-font-ui);
}
.bj-panel p, .bj-guide p, .bj-panel .bj-progress,
.bj-guide .bj-muted, .bj-confirm small, .bj-guide .bj-close,
.bj-panel .bj-footnote, .bj-guide .bj-guide-order { color: var(--clienos-secondary); }
.bj-panel .bj-eyebrow, .bj-guide .bj-eyebrow,
.bj-panel .bj-link, .bj-guide .bj-link { color: var(--clienos-purple); }
.bj-panel :is(.bj-task, .bj-actions, .bj-next, .bj-tips, .bj-confirm, .bj-preference-actions) {
  border-color: var(--clienos-divider);
}
.bj-panel .bj-progress progress { accent-color: var(--clienos-purple); background: var(--clienos-soft); }
.bj-panel .bj-progress progress::-webkit-progress-value { background: var(--clienos-purple); }
.bj-panel .bj-progress progress::-moz-progress-bar { background: var(--clienos-purple); }
.bj-panel .bj-progress progress::-webkit-progress-bar { background: var(--clienos-soft); }
.bj-guide [data-bj-focus], .bj-panel .bj-next .btn.primary {
  color: var(--clienos-ink);
  background: var(--clienos-orange);
  border-color: var(--clienos-orange);
}
.bj-panel.bj-detail-panel [data-bj-focus],
.bj-panel.bj-detail-panel [data-bj-focus]:hover {
  color: var(--clienos-ink);
  background: var(--clienos-orange);
  border-color: var(--clienos-orange);
}
.bj-guide-target {
  outline-color: var(--clienos-purple) !important;
  box-shadow: none;
}
.bj-panel .al-library :is(.al-eyebrow, .al-link, .al-back),
.bj-guide .al-library :is(.al-eyebrow, .al-link, .al-back) { color: var(--clienos-purple); }
.bj-panel .al-library :is(p, .al-meta, .al-filters label),
.bj-guide .al-library :is(p, .al-meta) { color: var(--clienos-secondary); }
.bj-panel .al-library .al-primary, .bj-guide .al-library .al-primary {
  color: var(--clienos-ink);
  background: var(--clienos-orange);
  border-color: var(--clienos-orange);
}
.bj-panel .al-library .al-filters select {
  color: var(--clienos-ink);
  background: var(--clienos-paper);
  border-color: var(--clienos-border);
}
/* Focus is explicit in both polarities, without overriding merchant-brand focus. */
:is(.shell, .login, .public-page, .client-shell:not(.customer-brand-scope), .bj-panel, .bj-guide)
  :is(button, a, input, select, textarea, summary):not(.customer-brand-scope *):focus-visible {
  outline: 3px solid var(--clienos-purple);
  outline-offset: 3px;
}
.shell .sidebar .nav :is(a, button):focus-visible,
.shell .sidebar .logout:focus-visible { outline-offset: -3px; }
.shell .topbar :is(button, a, input, select, summary):focus-visible {
  outline-color: var(--clienos-paper);
}
.bj-launcher:focus-visible {
  outline: 3px solid var(--clienos-purple);
  outline-offset: 3px;
}
/* Standalone platform flows also use the shared identity. A merchant-branded
   benefits page is excluded by its existing scope class, including after bootstrap. */
body:has(#benefit-hub-nav):not(.customer-brand-scope),
body:has(#step-body), body:has(#contract-body), body:has(#subscription-page) {
  --blue: var(--clienos-purple);
  --border: var(--clienos-divider);
  --ink: var(--clienos-ink);
  --muted: var(--clienos-secondary);
  --surface: var(--clienos-paper);
  --bg: var(--clienos-paper);
  background: var(--clienos-paper);
  color: var(--clienos-ink);
}
body:has(#benefit-hub-nav):not(.customer-brand-scope) #page-title {
  font: 400 clamp(32px, 3.5vw, 40px)/1.12 var(--clienos-font-display);
  letter-spacing: -.025em;
  color: var(--clienos-purple);
}
:is(body:has(#step-body), body:has(#contract-body), body:has(#subscription-page),
  body:has(#benefit-hub-nav):not(.customer-brand-scope)) :is(h2, h3) {
  font-family: var(--clienos-font-ui);
}
:is(body:has(#step-body), body:has(#contract-body), body:has(#subscription-page),
  body:has(#benefit-hub-nav):not(.customer-brand-scope)) :is(a, .eyebrow) {
  color: var(--clienos-purple);
}
:is(body:has(#step-body), body:has(#contract-body), body:has(#subscription-page),
  body:has(#benefit-hub-nav):not(.customer-brand-scope))
  :is(button, .button):not(.secondary, .danger):not(.customer-brand-scope *) {
  min-height: 48px;
  color: var(--clienos-ink);
  background: var(--clienos-orange);
  border-color: var(--clienos-orange);
  border-radius: 8px;
  box-shadow: none;
}
:is(body:has(#step-body), body:has(#contract-body), body:has(#subscription-page),
  body:has(#benefit-hub-nav):not(.customer-brand-scope))
  :is(button, .button).secondary:not(.customer-brand-scope *) {
  min-height: 48px;
  color: var(--clienos-purple);
  background: var(--clienos-paper);
  border-color: var(--clienos-border);
}
:is(body:has(#step-body), body:has(#contract-body), body:has(#subscription-page),
  body:has(#benefit-hub-nav):not(.customer-brand-scope))
  :is(button, .button).danger:not(.customer-brand-scope *) {
  color: var(--clienos-error);
  background: var(--clienos-paper);
  border-color: var(--clienos-error);
}
body:has(#benefit-hub-nav):not(.customer-brand-scope) #benefit-hub-nav button {
  color: var(--clienos-purple);
  background: var(--clienos-paper);
  border-color: var(--clienos-border);
  font-weight: 500;
}
body:has(#benefit-hub-nav):not(.customer-brand-scope)
  #benefit-hub-nav button[aria-current=page] {
  color: var(--clienos-paper);
  background: var(--clienos-purple);
  border-color: var(--clienos-purple);
  font-weight: 700;
}
:is(body:has(#step-body), body:has(#contract-body), body:has(#subscription-page),
  body:has(#benefit-hub-nav):not(.customer-brand-scope))
  :is(input, select, textarea):not([type=checkbox], [type=radio]):not(.customer-brand-scope *) {
  min-height: 48px;
  font-size: 16px;
  color: var(--clienos-ink);
  background: var(--clienos-paper);
  border-color: var(--clienos-border);
  border-radius: 8px;
}
:is(body:has(#step-body), body:has(#contract-body), body:has(#subscription-page),
  body:has(#benefit-hub-nav):not(.customer-brand-scope))
  :is(button, a, input, select, textarea, summary):not(.customer-brand-scope *):focus-visible {
  outline: 3px solid var(--clienos-purple);
  outline-offset: 3px;
}
@media (min-width: 761px) and (hover: hover) and (pointer: fine) {
  html:has(.shell)::-webkit-scrollbar-track { background: var(--clienos-paper); }
  html:has(.shell)::-webkit-scrollbar-thumb { background: var(--clienos-border); border-color: var(--clienos-paper); }
}
@media (max-width: 760px) {
  .shell .sidebar { background: var(--clienos-paper); border-color: var(--clienos-divider); }
  .shell .sidebar .brand { min-height: 48px; padding-right: 94px; }
  .brand img.clienos-logo { width: 170px; }
  .shell .sidebar .workspace-menu-toggle {
    min-height: 48px;
    background: var(--clienos-paper);
    color: var(--clienos-purple);
    border-color: var(--clienos-border);
  }
  .shell .sidebar .workspace-menu-toggle:focus-visible { outline-color: var(--clienos-purple); }
  .shell .sidebar .nav a, .shell .sidebar .nav button { min-height: 48px; font-size: 15px; }
  .shell .content { padding: 24px 20px 56px; }
  .shell.bj-has-launcher .content, .bj-has-launcher .shell .content { padding-bottom: 112px; }
  .shell .page-head h1 { font-size: 32px; }
  .shell .page-head .btn { font-size: 16px; }
  .shell .topbar { padding: 14px 20px; min-height: 72px; }
  .shell .breadcrumb { font-size: 13px; }
  .shell .top-actions { flex-wrap: wrap; }
  .shell .panel { padding: 20px; }
  .shell .table-wrap:has(#customer-rows) table { min-width: 600px; }
  /* The customer table supplies explicit table/row/cell roles in its markup.
     Only its visual layout changes; every program, balance and action remains. */
  .shell .customers-panel .table-wrap:has(#customer-rows) { overflow: visible; }
  .shell .customers-panel .table-wrap:has(#customer-rows) table {
    display: block;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .shell .customers-panel thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .shell .customers-panel #customer-rows { display: block; width: 100%; }
  .shell .customers-panel #customer-rows tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--clienos-divider);
  }
  .shell .customers-panel #customer-rows tr:last-child { border-bottom: 0; }
  .shell .customers-panel #customer-rows td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  .shell .customers-panel #customer-rows td:nth-child(1),
  .shell .customers-panel #customer-rows td:nth-child(2) { grid-column: 1 / -1; }
  .shell .customers-panel #customer-rows .tag { font-size: 13px; }
  .shell .customers-panel #customer-rows td:nth-child(3) .text-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 8px 0;
    text-align: left;
  }
  .shell .customers-panel #customer-rows td:last-child {
    display: flex;
    flex-direction: column;
    grid-column: 1 / -1;
    padding-inline-end: 112px;
    align-items: flex-start;
    gap: 8px;
  }
  /* Keep customer actions to the left of the floating help launcher's lane. */
  .shell .customers-panel #customer-rows td:last-child > :is(button, a) {
    width: 100%;
    min-height: 48px;
    scroll-margin-bottom: 112px;
  }
  .shell .customers-panel #customer-rows td:last-child > :is(button, a) + :is(button, a) {
    margin-top: 0;
  }
  .login-story { padding: 28px 24px; }
  .login-story h1 { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .bj-launcher { transition: none; transform: none; }
}
@media (forced-colors: active) {
  .shell .sidebar .nav a.active, .shell .sidebar .nav button.active {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}

/* Feature styles with ID selectors must share the same type and field contrast. */
.shell #main h1:not(.customer-brand-scope *) {
  font-family: var(--clienos-font-display);
  font-weight: 400;
  color: var(--clienos-purple);
}
.shell #main :is(h2, h3, .metric-value):not(.customer-brand-scope *) {
  font-family: var(--clienos-font-ui);
}
.shell #main :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea):not(.customer-brand-scope *) {
  color: var(--clienos-ink);
  background-color: var(--clienos-paper);
  border-color: var(--clienos-border);
  font-family: var(--clienos-font-ui);
  font-size: 16px;
  min-height: 48px;
}
.shell #main :is(input, select, textarea)[aria-invalid="true"]:not(.customer-brand-scope *) {
  border-color: var(--clienos-error);
}
.shell #main :is(button, a, input, select, textarea, summary):not(.customer-brand-scope *):focus-visible {
  outline: 3px solid var(--clienos-purple);
  outline-offset: 3px;
}
.shell #main .text-link:not(.danger, .error, .customer-brand-scope *) {
  color: var(--clienos-purple);
}
.login-form > .tag {
  background: var(--clienos-soft);
  color: var(--clienos-purple);
}
.bj-preparation-summary .bj-link {
  color: var(--clienos-purple);
}
