/* App additions on top of style.css (booking-desk's house stylesheet, copied
   whole so it stays diffable). Taken from bdm-portal's bdm.css: KPI tiles,
   filter rows and notes (renamed app-*), the non-production marking, the
   Prod/Dev switcher and the All apps link. */
/* KPI strip: one compact row of chips (LABEL value note). Big tiles took the top third of a
   laptop screen, so lists started below the fold (20 Nov 2026). */
.app-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.app-kpi {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  border: 1px solid var(--bd-border);
  border-radius: 8px;
  background: var(--bd-card);
  padding: 6px 12px;
}

.app-kpi__label {
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bd-muted);
  margin: 0;
}

.app-kpi__value {
  font-family: var(--bd-mono);
  font-size: 17px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--bd-text);
}

.app-kpi__note {
  font-size: 11.5px;
  color: var(--bd-muted);
  margin: 0;
}

/* Progress towards a target. The bar is decoration; the figures beside it are
   the actual statement, so it is aria-hidden. */
.app-meter {
  height: 6px;
  border-radius: 3px;
  background: var(--bd-border);
  overflow: hidden;
  margin-top: 8px;
}

.app-meter__fill {
  height: 100%;
  background: var(--bd-accent);
}

/* Filter bars: a row of labelled controls that wraps on a narrow window. */
.app-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.app-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--bd-muted);
  margin: 0;
}

.app-filters__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Definition rows on the client page. */
.app-pairs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 24px;
  margin: 0;
}

.app-pair dt {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bd-muted);
  font-weight: 500;
}

.app-pair dd {
  margin: 2px 0 0;
  font-family: var(--bd-mono);
  font-size: 14px;
  color: var(--bd-text);
}

/* The window explanation: prose that shows its arithmetic. */
.app-why {
  border-left: 3px solid var(--bd-accent);
  padding: 2px 0 2px 12px;
  margin: 0;
  font-size: 13px;
  color: var(--bd-muted);
}

.app-why strong { color: var(--bd-text); }

/* A row a sync has pinned. Frozen figures are history, and look settled. */
.bd-table tbody tr.is-frozen td:first-child { border-left: 2px solid var(--bd-border); }

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

/* Tab strip. Server-rendered links, not JS tabs: each half of a page is its own
   URL, so it can be linked to and survives a form post. */

/* Non-production marking (PORTAL_ENV != prod). Deliberately loud and the same in
   every theme: a striped bar on top, a DEV tag by the logo, and an edge frame. */
.bd-envbar {
  position: sticky; top: 0; z-index: 1100;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  padding: 7px 16px;
  font: 600 13px/1.3 var(--bd-sans, system-ui);
  color: #1a1200;
  background: repeating-linear-gradient(135deg, #ffb703 0 18px, #ffa000 18px 36px);
  border-bottom: 2px solid #c25100;
}
.bd-envbar strong { padding: 2px 8px; border-radius: 4px; background: #1a1200; color: #ffb703; letter-spacing: .06em; }
.bd-envbar span { font-weight: 500; }
.bd-envbar a { margin-left: auto; color: #1a1200; text-decoration: underline; font-weight: 600; }
.bd-envtag {
  margin-left: 8px; padding: 2px 8px; border-radius: 4px;
  font: 700 11px/1.4 var(--bd-mono, monospace); letter-spacing: .08em;
  color: #1a1200; background: #ffb703; border: 1px solid #c25100;
}
body.is-nonprod { box-shadow: inset 0 0 0 4px #ffb703; min-height: 100vh; }

.bd-envswitch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bd-envswitch__opt {
  display: block; text-align: center; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--bd-border); color: var(--bd-text); text-decoration: none; font-size: 12.5px;
}
.bd-envswitch__opt:hover { background: var(--bd-hover); }
.bd-envswitch__opt.is-active { font-weight: 600; border-color: var(--bd-accent, var(--primary)); }
.bd-envswitch__opt--dev.is-active { background: #ffb703; color: #1a1200; border-color: #c25100; }

/* Back to the Authentik app library */
.bd-appslink {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 10px;
  padding: 5px 10px; border: 1px solid var(--bd-border); border-radius: 8px;
  color: var(--bd-text); text-decoration: none; font-size: 12.5px;
}
.bd-appslink:hover { background: var(--bd-hover); }
@media (max-width: 760px) { .bd-appslink span { display: none; } }
.app-kpi--link { color: inherit; text-decoration: none; }
.app-kpi--link:hover { box-shadow: 0 0 0 2px var(--bd-accent, var(--primary)); }

/* --- phones (≤ 640px) ----------------------------------------------------
   One swipeable menu row under the brand instead of the menu wrapping onto
   three or four rows; KPI tiles two to a row; tables marked .app-cards turn
   into one card per row (label: value), so nothing hides off the right edge.
   The labels come from the table's header: static/app-cards.js copies each
   <th> into its column's cells as data-label. */
@media (max-width: 640px) {
  .bd-topbar { padding: 6px 12px; gap: 4px 10px; }
  .bd-page { padding: 16px 12px 0; }
  .bd-nav {
    order: 3;
    flex: 1 0 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 2px 12px 4px;
  }
  .bd-nav::-webkit-scrollbar { display: none; }
  .bd-user { margin-left: auto; }
  .bd-user__name { display: none; }

  .app-kpis { gap: 6px; margin-bottom: 12px; }
  .app-kpi { padding: 5px 10px; gap: 6px; }
  .app-kpi__value { font-size: 15px; }
  .app-kpi__note { display: none; }

  .bd-tablewrap:has(> table.app-cards) {
    overflow: visible; max-height: none; height: auto; border: 0; background: none; box-shadow: none;
  }
  table.app-cards, table.app-cards tbody, table.app-cards tr, table.app-cards td { display: block; width: 100%; }
  table.app-cards { min-width: 0 !important; }
  table.app-cards thead { display: none; }
  table.app-cards tr {
    border: 1px solid var(--bd-border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--bd-card);
  }
  table.app-cards td {
    height: auto;                 /* style.css fixes desktop rows at 44px */
    border: 0 !important;
    padding: 3px 0 !important;
    text-align: right !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  table.app-cards td::after { content: ""; display: table; clear: both; }
  table.app-cards td::before {
    content: attr(data-label);
    float: left;
    margin-right: 12px;
    color: var(--bd-muted);
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 12px;
    font-weight: 400;
    text-align: left;
  }
  /* Columns that only matter on a wide screen: add .app-hide-sm to the <th> and <td>. */
  table.app-cards .app-hide-sm { display: none; }
  table.app-cards td[data-label=""]::before { content: none; }
  table.app-cards td:empty { display: none; }
  table.app-cards td > form { margin-left: auto; }
  /* Cells holding a form field (an editable list, e.g. People): label on top, field
     full width under it. Beside it, the label was covered by the 100%-wide field. */
  table.app-cards td:has(> input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), > select, > textarea, > .bd-combo) {
    text-align: left !important;
    padding: 5px 0 !important;
  }
  table.app-cards td:has(> input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), > select, > textarea, > .bd-combo)::before {
    float: none; display: block; margin: 0 0 3px;
  }
  /* Long text (notes, audit changes): add .app-stack-sm to the <td> for label on top, text full width. */
  table.app-cards td.app-stack-sm { text-align: left !important; }
  table.app-cards td.app-stack-sm::before { float: none; display: block; margin: 0 0 2px; }
  /* Filter / add rows: fields share the width two to a row instead of keeping their desktop sizes. */
  .app-filters label { flex: 1 1 140px; min-width: 0; }
  .app-filters label > .bd-select { width: 100%; }
  .app-pager { flex-direction: column; align-items: stretch; gap: 10px; }
  .app-pager .bd-pager__group { flex-wrap: wrap; justify-content: center; }
  .app-pager__per { justify-content: center; }
}

/* ------------------------------------------------------------ UI kit additions
   Shared pieces shown on /ui in sample-web. */

/* Pager (house_ui.paginate + ui.pager). Built on style.css's .bd-pager. */
.app-pager { padding-top: 12px; gap: 10px 20px; }
.app-pager .bd-pager__group { gap: 4px; flex-wrap: wrap; }
.app-pager__num {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--bd-border); border-radius: 7px;
  font-family: var(--bd-mono); font-size: 12.5px;
  color: var(--bd-text); text-decoration: none; background: var(--bd-card);
}
.app-pager__num:hover { background: var(--bd-hover); }
.app-pager__num.is-on { background: var(--bd-btn-fill); color: var(--bd-btn-fg); border-color: transparent; font-weight: 600; }
.app-pager__num.is-off { opacity: .4; pointer-events: none; }
.app-pager__gap { color: var(--bd-muted-2); padding: 0 2px; }
.app-pager__per { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; color: var(--bd-muted-2); }
.app-pager__per .bd-select { width: auto; height: 30px; padding: 0 28px 0 8px; font-size: 12.5px; }

/* Segmented choice without JavaScript: the checked radio's label is "on". */
.bd-seg__label:has(input:checked) { background: var(--bd-btn-fill); color: var(--bd-btn-fg); font-weight: 600; }

/* A message box: info / success / warning / danger. */
.app-alert {
  border: 1px solid var(--bd-border); border-left-width: 3px; border-radius: 8px;
  padding: 10px 14px; font-size: 13px; background: var(--bd-card); color: var(--bd-text);
}
.app-alert strong { font-weight: 600; }
.app-alert--info { border-left-color: var(--bd-accent, var(--primary)); }
.app-alert--success { border-left-color: var(--bd-success-text); }
.app-alert--warning { border-left-color: var(--bd-warning-text); }
.app-alert--danger { border-left-color: var(--bd-danger); }

/* Tabs as links (each tab is its own URL, so it can be linked and survives a post). */
.app-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--bd-border); overflow-x: auto; }
.app-tabs a {
  padding: 8px 12px; font-size: 13px; color: var(--bd-muted); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.app-tabs a:hover { color: var(--bd-text); }
.app-tabs a.is-active { color: var(--bd-text); font-weight: 600; border-bottom-color: var(--bd-accent, var(--primary)); }

/* The UI kit page itself. */
.app-kit__demo { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.app-kit__code { margin: 0; }
.app-kit__code summary { font-size: 12px; color: var(--bd-muted-2); cursor: pointer; }
.app-kit__code pre {
  margin: 6px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--bd-inset);
  border: 1px solid var(--bd-border); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Toasts (static/house-ui.js: houseToast, form[data-confirm]). Bottom centre, above everything. */
.app-toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.app-toast {
  pointer-events: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--bd-border); border-left-width: 3px;
  border-left-color: var(--bd-success-text);
  background: var(--bd-card); color: var(--bd-text); font-size: 13.5px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22); animation: app-toast-in .16s ease-out;
}
.app-toast--danger { border-left-color: var(--bd-danger); }
.app-toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all .18s ease-in; }
.app-toast__text { flex: 1 1 180px; }
.app-toast__actions { display: flex; gap: 6px; margin-left: auto; }
@keyframes app-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Confirm dialog (static/house-ui.js: houseConfirm, data-confirm-dialog). Centred, dims the page. */
.app-dialog {
  padding: 0; border: 1px solid var(--bd-border); border-top: 4px solid var(--bd-btn-fill);
  border-radius: 14px; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--bd-card); color: var(--bd-text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28); animation: app-dialog-in .16s ease-out;
}
.app-dialog--danger { border-top-color: var(--bd-danger); }
.app-dialog--wide { width: min(560px, calc(100vw - 32px)); }
.app-dialog::backdrop { background: rgba(15, 18, 30, .45); backdrop-filter: blur(2px); animation: app-fade-in .16s ease-out; }
.app-dialog.is-leaving { opacity: 0; transform: translateY(6px) scale(.98); transition: all .14s ease-in; }
.app-dialog__box { margin: 0; padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 56px); overflow: auto; }
.app-dialog__title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.3; }
.app-dialog__text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--bd-muted); }
.app-dialog__details {
  margin: 4px 0 0; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px;
  border-radius: 10px; background: var(--muted, var(--bd-inset)); font-size: 13.5px;
}
.app-dialog__details dt { color: var(--bd-muted); font-weight: 400; white-space: nowrap; }
.app-dialog__details dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.app-dialog__details .app-dialog__section {
  grid-column: 1 / -1; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--bd-border);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--bd-muted);
}
.app-dialog__details .app-dialog__section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.app-dialog__details .is-strong { font-weight: 700; color: var(--bd-text); }
.app-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@keyframes app-dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes app-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Sortable list table: drag handle, compact rows, remove button. */
.app-sorttable { width: 100%; border-collapse: collapse; }
.app-sorttable td { padding: 6px 8px; border-bottom: 1px solid var(--bd-border-soft, var(--bd-border)); vertical-align: middle; }
.app-sorttable tr:last-child td { border-bottom: 0; }
.app-sorttable .app-sorttable__grip { width: 28px; padding-right: 0; }
.app-sorttable .app-sorttable__act { width: 1%; white-space: nowrap; text-align: right; }
/* Value and its description side by side; the description wraps under on a phone. */
.app-sorttable__main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.app-sorttable__main > strong, .app-sorttable__main > .app-sorttable__value { flex: 0 0 11rem; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.app-sorttable__main > .bd-input { flex: 1 1 12rem; min-width: 0; color: var(--bd-muted); }
.app-sorttable__main > .bd-input:focus { color: var(--bd-text); }
.app-sorttable__main > .bd-input:not(:focus):not(:hover) { border-color: transparent; background: transparent; }
.app-sorttable .bd-input { height: 32px; font-size: 13px; }
.app-sorttable tr.is-ghost td { background: var(--bd-accent-tint, var(--bd-hover)); opacity: .7; }
.app-sorttable tr.is-chosen td { background: var(--bd-hover); }
.app-drag {
  display: inline-grid; place-items: center; width: 24px; height: 28px; border-radius: 6px;
  color: var(--bd-muted-2); cursor: grab; touch-action: none; user-select: none; font-size: 16px; line-height: 1;
}
.app-drag:hover { background: var(--bd-hover); color: var(--bd-text); }
.app-drag:active { cursor: grabbing; }
.app-remove {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--bd-muted-2); font-size: 18px; line-height: 1;
  cursor: pointer;
}
.app-remove:hover { color: var(--bd-danger); border-color: var(--bd-border); background: var(--bd-card); }
.app-sorttable__add td { padding-top: 10px; border-bottom: 0; }
.app-retired { margin-top: 8px; font-size: 12.5px; color: var(--bd-muted); }
.app-retired summary { cursor: pointer; }
.app-retired ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.app-retired li { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 8px;
  border: 1px dashed var(--bd-border); border-radius: 6px; }
.app-retired form { margin: 0; }
.app-sorttable__main > .app-sorttable__rename { flex: 1 1 14rem; font-weight: 600; color: var(--bd-text); }

/* Scroll tables (static/house-table.js): pinned key column(s), Cards ⇄ Table on phones,
   Columns picker. Applies to every table.app-cards inside a .bd-tablewrap. */
.app-viewbar { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.app-viewbar__mode { display: none; border: 1px solid var(--bd-border); border-radius: 8px; overflow: hidden; background: var(--bd-inset); }
.app-viewbar__mode button { border: 0; background: transparent; padding: 5px 12px; font-size: 12.5px; color: var(--bd-muted); }
.app-viewbar__mode button.is-on { background: var(--bd-btn-fill); color: var(--bd-btn-fg); font-weight: 600; }
.app-viewbar__cols { margin-left: auto; }
.app-viewbar__excel { margin-left: auto; }
.app-viewbar__excel + .app-viewbar__cols { margin-left: 0; }
.app-viewbar:not(:has(.app-viewbar__cols, .app-viewbar__excel, .app-viewbar__full)) { display: none; }
.app-colmenu { border: 1px solid var(--bd-border); border-radius: 10px; padding: 10px 12px; margin: 0 0 8px; background: var(--bd-card); font-size: 13px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; }
.app-colmenu[hidden] { display: none; }
.app-colmenu__title { grid-column: 1 / -1; font-size: 11.5px; color: var(--bd-muted-2); margin-bottom: 2px; }
.app-colmenu label { display: flex; align-items: center; gap: 8px; padding: 3px 0; margin: 0; }
.app-scrolltable .app-col-off { display: none !important; }
.app-scrolltable td.app-pin, .app-scrolltable th.app-pin { position: sticky; z-index: 1; background: var(--bd-card); }
.app-scrolltable thead th.app-pin { z-index: 3; }
.app-scrolltable .app-pin--last { box-shadow: 6px 0 8px -6px rgba(0, 0, 0, .22); }
.app-scrolltable tbody tr:hover td.app-pin { background: var(--bd-hover); }
@media (max-width: 640px) {
  .app-viewbar, .app-viewbar:not(:has(.app-viewbar__cols, .app-viewbar__excel, .app-viewbar__full)) { display: flex; }
  .app-viewbar__mode { display: inline-flex; }
  /* Table mode on a phone: one line per cell, sideways scroll, pinned key kept narrow. */
  .bd-tablewrap.app-scrollwrap.is-table { max-height: 70vh; }
  .app-scrollwrap.is-table .app-scrolltable { min-width: 100%; width: max-content; }
  .app-scrollwrap.is-table .app-scrolltable td, .app-scrollwrap.is-table .app-scrolltable th { white-space: nowrap; }
  .app-scrollwrap.is-table .app-scrolltable td.app-pin--last { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .app-scrollwrap.is-table .app-scrolltable td.app-stack-sm { white-space: normal; min-width: 16rem; }
  .app-scrollwrap.is-table .app-scrolltable td.app-pin--last:has(input, select) { max-width: none; }
}

/* Data grid (static/house-grid.js, Tabulator 6.3.0): house tokens instead of Tabulator's own
   white theme, as on sgb-account-creator. tabulator.min.css loads after this file (ui.grid_assets),
   so the rules are scoped under .app-grid to win. */
.app-grid.tabulator {
  --tabulator-row-background-color: var(--bd-card);
  --tabulator-row-alt-background-color: var(--row-stripe, var(--bd-inset));
  font-family: var(--bd-sans); font-size: 13.5px;
  background: var(--bd-card); background-color: var(--bd-card); color: var(--bd-text);
  border: 1px solid var(--bd-border); border-radius: 12px; overflow: hidden;
}
.app-grid.tabulator .tabulator-header,
.app-grid.tabulator .tabulator-header .tabulator-col,
.app-grid.tabulator .tabulator-header .tabulator-frozen {
  background: var(--bd-card); background-color: var(--bd-card); color: var(--bd-muted-2);
  border-color: var(--bd-border); font-family: var(--bd-mono); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.app-grid.tabulator .tabulator-header .tabulator-col:hover { background-color: var(--bd-hover) !important; color: var(--bd-text) !important; }
.app-grid.tabulator .tabulator-col.tabulator-moving { background-color: var(--bd-accent-tint, var(--bd-hover)); }
.app-grid.tabulator .tabulator-row,
.app-grid.tabulator .tabulator-row.tabulator-row-odd { background-color: var(--bd-card); color: var(--bd-text); min-height: 44px; }
.app-grid.tabulator .tabulator-row.tabulator-row-even { background-color: var(--row-stripe, var(--bd-inset)); }
.app-grid.tabulator .tabulator-row:hover, .app-grid.tabulator .tabulator-row:hover .tabulator-cell { background-color: var(--bd-hover); cursor: pointer; }
.app-grid.tabulator .tabulator-row .tabulator-cell {
  background-color: inherit; color: var(--bd-text); border-right: 1px solid var(--bd-border-soft, var(--bd-border));
  line-height: 1.3; padding: 10px 12px; height: auto;
}
.app-grid.tabulator .tabulator-row .tabulator-cell.tabulator-frozen { background-color: var(--bd-card); }
.app-grid.tabulator .tabulator-row.tabulator-row-even .tabulator-cell.tabulator-frozen { background-color: var(--row-stripe, var(--bd-inset)); }
.app-grid.tabulator .tabulator-frozen.tabulator-frozen-left { border-right: 1px solid var(--bd-border); box-shadow: 6px 0 8px -6px rgba(0, 0, 0, .22); }
.app-grid.tabulator .tabulator-row a { color: var(--bd-text); font-weight: 600; text-decoration: none; }
.app-grid.tabulator .tabulator-row a:hover { color: var(--bd-accent-text); text-decoration: underline; }
.app-grid .app-grid__muted { color: var(--bd-muted); font-size: 12px; font-family: var(--bd-sans); font-weight: 400; }
.app-grid.tabulator .tabulator-footer { background: var(--bd-card); color: var(--bd-muted); border-color: var(--bd-border); font-size: 12.5px; }
.app-grid.tabulator .tabulator-footer .tabulator-page {
  background: var(--bd-card); color: var(--bd-text); border: 1px solid var(--bd-border); border-radius: 7px;
  min-width: 30px; height: 30px; margin: 0 2px; font-family: var(--bd-mono);
}
.app-grid.tabulator .tabulator-footer .tabulator-page.active { background: var(--bd-btn-fill); color: var(--bd-btn-fg); border-color: transparent; }
.app-grid.tabulator .tabulator-footer .tabulator-page:disabled { opacity: .4; }
.app-grid.tabulator .tabulator-footer select { background: var(--bd-inset); color: var(--bd-text); border: 1px solid var(--bd-border); border-radius: 6px; }
.app-grid.tabulator .tabulator-placeholder span { color: var(--bd-muted); font-size: 14px; font-weight: 400; }
.app-grid.tabulator .tabulator-range-overlay .tabulator-range.tabulator-range-active { border-color: var(--bd-accent, var(--primary)); }
.app-grid.tabulator .tabulator-cell.tabulator-range-selected { background-color: var(--bd-accent-tint, var(--bd-hover)) !important; }
.app-grid.tabulator .tabulator-header .tabulator-col.tabulator-range-highlight,
.app-grid.tabulator .tabulator-header .tabulator-col.tabulator-range-selected,
.app-grid.tabulator .tabulator-row .tabulator-cell.tabulator-range-row-header.tabulator-range-highlight {
  background-color: var(--bd-accent-tint, var(--bd-hover)) !important; color: var(--bd-text) !important; }
.app-viewbar--grid { display: flex; flex-wrap: wrap; }
.app-viewbar--grid .app-grid__hint { font-size: 12px; color: var(--bd-muted-2); flex: 1 1 260px; }
.app-viewbar--grid .app-viewbar__cols { margin-left: 0; }
@media (max-width: 640px) {
  .app-grid.tabulator .tabulator-footer .tabulator-paginator { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .app-grid.tabulator .tabulator-footer .tabulator-page-counter { display: block; text-align: center; margin: 0 0 4px; }
  .app-grid.tabulator .tabulator-footer .tabulator-page[data-page="first"],
  .app-grid.tabulator .tabulator-footer .tabulator-page[data-page="last"] { display: none; }
  .app-grid.tabulator .tabulator-footer .tabulator-footer-contents { flex-direction: column; gap: 6px; }
}

/* A filter form that folds away on phones (results first): <details class="app-filterbox" open>
   <summary>Filters</summary> <form class="app-filters">…</form></details>. house-table.js closes it
   on phones unless a filter is set (data-active="N" on the details). */
.app-filterbox > summary { list-style: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--bd-text); margin: 0 0 10px; }
.app-filterbox > summary::-webkit-details-marker { display: none; }
.app-filterbox > summary::before { content: "▸ "; color: var(--bd-muted-2); }
.app-filterbox[open] > summary::before { content: "▾ "; }
@media (min-width: 641px) { .app-filterbox > summary { display: none; } }

/* List pages (Bookings, Clients…): a slim filter bar and the list right under it, so the list gets
   the screen. {% call ui.filterbar(n_set) %}<form class="app-filters">…</form>{% endcall %}, then the
   grid / table without a card around it. */
.app-filterbar {
  background: var(--bd-card);
  border: 1px solid var(--bd-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--bd-card-shadow);
}
.app-filterbar .app-filters { margin-bottom: 0; gap: 8px 10px; }
.app-filterbar .app-filters label { font-size: 11.5px; gap: 2px; }
.app-results { min-width: 0; }
.app-results > .app-viewbar { margin-bottom: 6px; }
/* Long scroll tables use the whole window once scrolled to (their header stays put inside). */
@media (min-width: 641px) {
  .bd-tablewrap.app-scrollwrap { max-height: calc(100vh - 80px); }
}

/* Forms on wide screens: as many fields per row as fit (2 below 1100px, ~4 on a laptop, 5-6 on a
   big monitor) instead of always two. Only grids inside a <form>. A long field (notes, address):
   add .app-span-2, or .app-span-all for the whole row. */
@media (min-width: 1100px) {
  form .bd-grid:not(.bd-grid--1):not(.bd-grid--3) { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  form .bd-grid > .app-span-2 { grid-column: span 2; }
}
form .bd-grid > .app-span-all { grid-column: 1 / -1; }

/* A table's own links ("Show cancelled too") sit on the table's toolbar line, left of Excel /
   Columns: <div class="app-tablebar">…</div> right before the .bd-tablewrap (house-table.js moves it). */
.app-viewbar > .app-tablebar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0; font-size: 13px; }

/* One panel per list: filters, toolbar, table/grid and pager together (ui.listpanel). */
.app-listpanel {
  background: var(--bd-card);
  border: 1px solid var(--bd-border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--bd-card-shadow);
  min-width: 0;
}
.app-listpanel > .app-filterbar {
  background: none; border: 0; box-shadow: none; border-radius: 0;
  padding: 0 0 12px; margin: 0 0 10px; border-bottom: 1px solid var(--bd-border);
}
.app-listpanel .bd-tablewrap { box-shadow: none; }
.app-viewbar__full { white-space: nowrap; }
/* Icon toolbar buttons (houseIconButton): square, the name in the tooltip. */
.app-iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 32px; padding: 0; flex: 0 0 auto; }
.app-iconbtn svg { display: block; }
.app-iconbtn__badge { position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--bd-btn-fill); color: var(--bd-btn-fg); font-size: 10.5px; font-weight: 700;
  line-height: 16px; text-align: center; }
.app-viewbar__mode { flex: 0 0 auto; }
.app-viewbar__mode button { white-space: nowrap; }

/* Full screen (house-table.js houseFullscreen): the panel, or the card holding a table, covers the
   window; the table / grid takes the height left; Esc or the button goes back. */
html.app-fullscreen-on, html.app-fullscreen-on body { overflow: hidden; }
.is-fullscreen {
  position: fixed !important; inset: 0; z-index: 9000;     /* above the dev banner and the header */
  margin: 0 !important; border: 0 !important; border-radius: 0 !important;
  background: var(--bd-page, var(--background));
  padding: 14px 18px !important;
  display: flex; flex-direction: column; overflow: hidden;
}
.is-fullscreen > .bd-card__body, .is-fullscreen .app-results { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.is-fullscreen .bd-tablewrap { flex: 1 1 auto; min-height: 0; max-height: none !important; }
.is-fullscreen > .bd-card__body > *, .is-fullscreen > * { flex-shrink: 0; }
.is-fullscreen .bd-tablewrap, .is-fullscreen > .bd-card__body, .is-fullscreen .app-results { flex-shrink: 1; }

/* Multi-select filter (ui.multiselect): a dropdown of ticks inside an .app-filters form. */
.app-filters__group { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--bd-muted); }
.app-multi { position: relative; }
.app-multi__summary { list-style: none; cursor: pointer; min-width: 180px; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.app-multi__summary::-webkit-details-marker { display: none; }
.app-multi__menu {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 340px; overflow: auto;
  background: var(--bd-card); border: 1px solid var(--bd-border); border-radius: 10px; padding: 8px 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); display: flex; flex-direction: column; gap: 2px;
  min-width: 280px; max-width: min(420px, 92vw);
}
.app-multi__quick { display: flex; gap: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--bd-border); }
.app-multi__opt { white-space: nowrap; display: flex !important; flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 13px !important; color: var(--bd-text) !important; padding: 3px 2px; cursor: pointer; }
@media (max-width: 640px) { .app-filters__group { flex: 1 1 140px; min-width: 0; } .app-multi__summary { min-width: 0; max-width: none; } }
/* Key–value facts (a record's summary): label above value, auto-fit columns. */
.app-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 18px; margin: 0 0 10px; }
.app-kv > div { display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.app-kv > div > span:first-child { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--bd-muted); }
.app-up { color: var(--bd-success-text, #2e7d32); font-weight: 600; }
.app-down { color: var(--bd-danger-text, #c62828); font-weight: 600; }
/* A small bar trend (e.g. AUM by month): bars scaled to the largest, labels under. */
.app-spark { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding: 6px 0 0; margin: 4px 0 6px; overflow-x: auto; }
.app-spark__bar { flex: 1 0 28px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.app-spark__bar i { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--bd-accent); opacity: .85; }
.app-spark__bar span { font-size: 10.5px; color: var(--bd-muted); white-space: nowrap; }
.app-list { margin: 0; padding-left: 18px; }
.app-list li { margin: 2px 0; }
.app-spark__bar i.is-cash { opacity: .35; border-radius: 0; }
.app-spark__bar i + i { margin-top: 1px; }
.app-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--bd-accent); vertical-align: -1px; margin-left: 6px; }
.app-key--cash { opacity: .35; }

/* --- phones: the mobile audit rules (README "Mobile audit", tools/mobile_audit.js) ------------
   M3 every tap target at least 40px; M4 form fields at 16px so iPhones don't zoom in on tap. */
@media (max-width: 640px) {
  .bd-input, .bd-select, .bd-textarea, .ts-control, .ts-control input, .ts-dropdown,
  .bd-combo input, .app-sorttable .bd-input, .app-pager__per .bd-select { font-size: 16px; }
  .bd-input, .bd-select, .app-sorttable .bd-input, .app-pager__per .bd-select { min-height: 40px; }
  .bd-nav__item, .bd-appslink, .bd-brand { min-height: 40px; display: inline-flex; align-items: center; }
  .bd-appslink { display: none; }   /* M1 header on one row: "All apps" is also in the avatar menu */
  .bd-user { gap: 6px; }
  .bd-brand { min-width: 0; }
  .app-viewbar__mode button, .app-viewbar button { min-height: 40px; min-width: 40px; }
  .bd-help .bd-mono, .bd-help code { font-size: inherit; }
  .bd-avatar { width: 40px; height: 40px; font-size: 13px; }
  .bd-btn, .bd-btn--sm, .bd-btn--tiny, .bd-pager a, .bd-pager button { min-height: 40px; min-width: 40px; }
  .bd-btn--tiny { font-size: 13px; }
  /* M3: the other house pieces people tap */
  .app-kpi--link { min-height: 40px; align-items: center; }
  summary, .app-filterbox > summary { padding-block: 11px; margin-bottom: 4px; min-height: 40px; box-sizing: border-box; }
  /* M1: a table's own links take their own line, so Excel / Columns / Full screen stay on screen */
  .app-viewbar { flex-wrap: wrap; }
  .app-viewbar > .app-tablebar { flex: 1 0 100%; }
  .app-tablebar a { min-height: 40px; display: inline-flex; align-items: center; }
  .app-tabs a { min-height: 40px; display: inline-flex; align-items: center; }
  .app-remove { width: 40px; height: 40px; }
  .bd-combo__toggle { width: 40px; }
  label:has(> input[type=checkbox]), label:has(> input[type=radio]) { min-height: 40px; display: flex; align-items: center; gap: 8px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; flex: 0 0 auto; margin: 0; }
  /* M5: nothing under 12px (11px for labels in capitals) */
  .app-kpi__label { font-size: 11px; }
  .app-filters label, .bd-field__label, .small, small, code { font-size: max(12px, .875em); }
  .bd-chip { font-size: 12px; }
  .app-spark__bar span { font-size: 12px; }
  /* the house grid's pager (Tabulator) */
  .tabulator .tabulator-footer .tabulator-paginator .tabulator-page { min-width: 40px; min-height: 40px; padding: 0 10px; }
  .tabulator .tabulator-footer .tabulator-page-size { min-height: 40px; font-size: 16px; }
  .bd-muted, .app-filterbar .app-filters label, .app-filters__group, .app-filters__label, .app-colmenu__title { font-size: 12px; }
}

/* driver-ot: narrow column for sign-in / password; row of buttons */
.app-narrow { max-width: 30rem; margin-inline: auto; }
.bd-row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dot-times { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dot-times + .dot-times { margin-top: 6px; }
@media (max-width: 640px) { .app-wide-sm { width: 100%; } }
