/* speed-and-look (2026-10-22): one look for the shared building blocks -- buttons, inputs, dropdowns, tables, tab bars,
   cards, badges / status chips, empty and loading states -- on every page, from core/css/tokens.css. Loaded after
   app.css and frame.css (and before a page's own stylesheet). Selectors are kept low (:where) wherever a page's own
   rule should still win, e.g. the Sales list's stage-coloured rows. Motion is small and short, and off for anyone who
   asks the system for less. */

/* ---------- type ---------- */
body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    background: var(--c-bg);
    color: var(--c-text);
    -webkit-font-smoothing: antialiased;
}
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
    /* Bootstrap reads its own variables: point them at the tokens */
    --bs-body-font-family: var(--font-sans);
    --bs-body-font-size: var(--fs-base);
    --bs-body-line-height: var(--lh-base);
    --bs-body-bg: var(--c-bg);
    --bs-body-color: var(--c-text);
    --bs-emphasis-color: var(--c-text);
    --bs-secondary-color: var(--c-muted);
    --bs-tertiary-color: var(--c-faint);
    --bs-secondary-bg: var(--c-surface-2);
    --bs-tertiary-bg: var(--c-surface-2);
    --bs-border-color: var(--c-border);
    --bs-border-color-translucent: var(--c-border);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: var(--radius);
    --bs-border-radius-lg: var(--radius);
    --bs-border-radius-xl: var(--radius);
    --bs-box-shadow: var(--shadow);
    --bs-box-shadow-sm: var(--shadow);
    --bs-focus-ring-color: rgba(31, 95, 191, 0.28);
    --bs-heading-color: var(--c-text);
    --bs-success-text-emphasis: var(--c-ok);   --bs-success-bg-subtle: var(--c-ok-bg);   --bs-success-border-subtle: var(--c-ok-bg);
    --bs-warning-text-emphasis: var(--c-warn); --bs-warning-bg-subtle: var(--c-warn-bg); --bs-warning-border-subtle: var(--c-warn-bg);
    --bs-danger-text-emphasis: var(--c-bad);   --bs-danger-bg-subtle: var(--c-bad-bg);   --bs-danger-border-subtle: var(--c-bad-bg);
    --bs-info-text-emphasis: var(--c-info);    --bs-info-bg-subtle: var(--c-info-bg);    --bs-info-border-subtle: var(--c-info-bg);
    --bs-secondary-text-emphasis: var(--c-neutral); --bs-secondary-bg-subtle: var(--c-neutral-bg);
}
h1, .h1 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: 1.25; }
h2, .h2 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: 1.3; }
h3, .h3 { font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: 1.35; }
h4, .h4, h5, .h5, h6, .h6 { font-size: var(--fs-base); font-weight: var(--fw-semibold); line-height: 1.4; }
small, .small { font-size: var(--fs-xs); }
.text-muted, .text-body-secondary { color: var(--c-muted) !important; }
a { color: var(--c-link); text-underline-offset: 2px; transition: color var(--ease); }
.topbar-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.topbar { background: var(--c-surface); border-bottom-color: var(--c-border); }
.content { background: var(--c-bg); }

/* ---------- buttons: one shape, one weight, one set of colours ---------- */
.btn {
    --bs-btn-font-size: var(--fs-sm);
    --bs-btn-font-weight: var(--fw-semibold);
    --bs-btn-border-radius: var(--radius);
    --bs-btn-focus-box-shadow: var(--focus-ring);
    border-radius: var(--radius);
    font-weight: var(--fw-semibold);
    transition: background-color var(--ease), border-color var(--ease), color var(--ease), filter var(--ease),
        box-shadow var(--ease);
}
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn-primary, .btn-accent {
    --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-color: var(--accent-contrast);
    --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-hover-color: var(--accent-contrast);
    --bs-btn-active-bg: var(--accent); --bs-btn-active-border-color: var(--accent); --bs-btn-active-color: var(--accent-contrast);
    --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); --bs-btn-disabled-color: var(--accent-contrast);
    background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
}
.btn-primary:hover, .btn-accent:hover { filter: brightness(0.9); color: var(--accent-contrast); }
.btn-outline-primary {
    --bs-btn-color: var(--c-accent-text); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-hover-color: var(--accent-contrast);
    --bs-btn-active-bg: var(--accent); --bs-btn-active-border-color: var(--accent); --bs-btn-active-color: var(--accent-contrast);
}
.btn-secondary, .btn-light, .btn-outline-secondary, .btn-outline-dark, .btn-outline-light {
    --bs-btn-bg: var(--c-surface); --bs-btn-color: var(--c-text); --bs-btn-border-color: var(--c-border-strong);
    --bs-btn-hover-bg: var(--c-surface-2); --bs-btn-hover-color: var(--c-text); --bs-btn-hover-border-color: var(--c-border-strong);
    --bs-btn-active-bg: var(--c-selected); --bs-btn-active-color: var(--c-text); --bs-btn-active-border-color: var(--c-border-strong);
    --bs-btn-disabled-bg: var(--c-surface); --bs-btn-disabled-color: var(--c-faint); --bs-btn-disabled-border-color: var(--c-border);
}
.btn-success {
    --bs-btn-bg: var(--c-green); --bs-btn-border-color: var(--c-green); --bs-btn-color: var(--c-on-dark);
    --bs-btn-hover-bg: var(--c-green-strong); --bs-btn-hover-border-color: var(--c-green-strong); --bs-btn-hover-color: var(--c-on-dark);
}
.btn-danger {
    --bs-btn-bg: var(--c-red); --bs-btn-border-color: var(--c-red); --bs-btn-color: var(--c-on-dark);
    --bs-btn-hover-bg: var(--c-red-strong); --bs-btn-hover-border-color: var(--c-red-strong); --bs-btn-hover-color: var(--c-on-dark);
}
.btn-warning {
    --bs-btn-bg: var(--c-amber); --bs-btn-border-color: var(--c-amber); --bs-btn-color: var(--c-on-light);
    --bs-btn-hover-bg: var(--c-amber); --bs-btn-hover-border-color: var(--c-amber); --bs-btn-hover-color: var(--c-on-light);
}
.btn-outline-success { --bs-btn-color: var(--c-ok); --bs-btn-border-color: var(--c-ok); --bs-btn-hover-bg: var(--c-ok-bg);
    --bs-btn-hover-color: var(--c-ok); --bs-btn-hover-border-color: var(--c-ok); }
.btn-outline-danger { --bs-btn-color: var(--c-bad); --bs-btn-border-color: var(--c-bad); --bs-btn-hover-bg: var(--c-bad-bg);
    --bs-btn-hover-color: var(--c-bad); --bs-btn-hover-border-color: var(--c-bad); }
.btn-outline-warning { --bs-btn-color: var(--c-warn); --bs-btn-border-color: var(--c-warn); --bs-btn-hover-bg: var(--c-warn-bg);
    --bs-btn-hover-color: var(--c-warn); --bs-btn-hover-border-color: var(--c-warn); }
.btn-link { --bs-btn-color: var(--c-link); --bs-btn-hover-color: var(--c-link); font-weight: 500; }

/* ---------- inputs and dropdowns ---------- */
.form-control, .form-select {
    background-color: var(--c-input);
    color: var(--c-text);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.form-control::placeholder { color: var(--c-faint); }
.form-control:focus, .form-select:focus {
    background-color: var(--c-input);
    color: var(--c-text);
    border-color: var(--c-info-solid);
    box-shadow: var(--focus-ring);
}
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background-color: var(--c-surface-2); color: var(--c-muted); }
.form-label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.form-text { color: var(--c-muted); font-size: var(--fs-xs); }
.form-check-input { border-color: var(--c-border-strong); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: var(--focus-ring); }
.dropdown-menu {
    --bs-dropdown-bg: var(--c-surface); --bs-dropdown-color: var(--c-text); --bs-dropdown-border-color: var(--c-border);
    --bs-dropdown-border-radius: var(--radius); --bs-dropdown-box-shadow: var(--shadow-pop);
    --bs-dropdown-link-color: var(--c-text); --bs-dropdown-link-hover-bg: var(--c-row-hover);
    --bs-dropdown-link-active-bg: var(--c-selected); --bs-dropdown-link-active-color: var(--c-text);
    box-shadow: var(--shadow-pop);
}

/* ---------- tables: sticky headers, zebra rows, hover, aligned numbers ---------- */
.table {
    --bs-table-bg: var(--c-surface);
    --bs-table-color: var(--c-text);
    --bs-table-border-color: var(--c-border);
    --bs-table-striped-bg: var(--c-surface-2);
    --bs-table-striped-color: var(--c-text);
    --bs-table-hover-bg: var(--c-row-hover);
    --bs-table-hover-color: var(--c-text);
    font-size: var(--fs-sm);
}
:where(.table) > thead > tr > th, :where(.table) > thead > tr > td {
    background: var(--c-surface-2);
    color: var(--c-muted);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--c-border-strong);
}
:where(.table) > tbody > tr:nth-child(even) > * { --bs-table-bg-type: var(--c-surface-2); }
:where(.table) > tbody > tr:hover > * { --bs-table-bg-state: var(--c-row-hover); }
:where(.table) > tbody > tr > * { transition: background-color var(--ease); }
table.data-table th { background: var(--c-surface-2); border-bottom-color: var(--c-border-strong); }
:where(table.data-table) tbody tr:nth-child(even) td { background: var(--c-surface-2); }
:where(table.data-table) tbody tr:hover td { background: var(--c-row-hover); }
table.data-table td { transition: background-color var(--ease); }
/* the payment screens' tables: the header stays under the top bar while the page scrolls (their card clips with
   overflow: clip, which -- unlike hidden -- doesn't trap the sticky header), zebra rows, hover */
.pv-card { overflow: clip; }
:where(.pv-card) > :where(.pv-table) > thead th, :where(.pv-card) > :where(.pv-table) > thead td {
    position: sticky; top: var(--sticky-head-top, var(--topbar-height)); z-index: 2; background: var(--c-surface-2);
}
/* sticky-header-fix (2026-10-27): inside its own scrolling box (a wide card that scrolls sideways, a fixed-height
   list) "top" counts from that box, not the page -- the top bar's 56 px there pushed the labels over the first row.
   There the labels sit at the box's own top. core/js/sticky_heads.js marks every such table; the wide payments card
   is set here too, so it is right before any script runs. */
.sticky-in-box, .pv-wide-card { --sticky-head-top: 0px; }
.sticky-in-box > thead > tr > th, .sticky-in-box > thead > tr > td { top: var(--sticky-head-top); }
:where(.pv-table, .em-table, .mk-table) > tbody > tr:nth-child(even) > td { background: var(--c-surface-2); }
:where(.pv-table, .em-table, .mk-table) > tbody > tr:hover > td { background: var(--c-row-hover); }
:where(.pv-table, .em-table, .mk-table) > tbody > tr > td { transition: background-color var(--ease); }
.pagination {
    --bs-pagination-color: var(--c-text); --bs-pagination-bg: var(--c-surface); --bs-pagination-border-color: var(--c-border);
    --bs-pagination-hover-color: var(--c-text); --bs-pagination-hover-bg: var(--c-surface-2);
    --bs-pagination-hover-border-color: var(--c-border);
    --bs-pagination-focus-color: var(--c-text); --bs-pagination-focus-bg: var(--c-surface-2); --bs-pagination-focus-box-shadow: var(--focus-ring);
    --bs-pagination-active-color: var(--accent-contrast); --bs-pagination-active-bg: var(--accent);
    --bs-pagination-active-border-color: var(--accent);
    --bs-pagination-disabled-color: var(--c-faint); --bs-pagination-disabled-bg: var(--c-surface);
    --bs-pagination-disabled-border-color: var(--c-border);
    --bs-pagination-border-radius: var(--radius);
    --bs-pagination-font-size: var(--fs-sm);
}
/* numbers line up: equal-width digits, right-aligned where the column says so */
.money, .num, .numeric, td.text-end, th.text-end, .amount, .tabular, [data-num] {
    font-variant-numeric: tabular-nums;
}
td.money, th.money, td.num, th.num { text-align: right; font-family: var(--font-sans); white-space: nowrap; }
.data-table-wrap, .table-responsive {
    border-radius: var(--radius);
    border-color: var(--c-border);
    background: var(--c-surface);
}

/* ---------- tab bars: one style everywhere ---------- */
.nav-tabs {
    --bs-nav-tabs-border-color: var(--c-border);
    --bs-nav-tabs-link-active-color: var(--c-text);
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-link-active-border-color: transparent;
    --bs-nav-link-color: var(--c-muted);
    --bs-nav-link-hover-color: var(--c-text);
    gap: 2px;
}
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
    transition: color var(--ease), border-color var(--ease); }
.nav-tabs .nav-link.active { border-bottom-color: var(--c-highlight); font-weight: var(--fw-semibold); }
.ps-tabs, .pv-sections {
    border-bottom: 1px solid var(--c-border);
    gap: 2px;
}
.ps-tabs a, .ps-tabs span, .pv-sections a {
    color: var(--c-muted);
    font-size: var(--fs-base);
    font-weight: 500;
    padding: 8px 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--ease), border-color var(--ease);
}
.ps-tabs a:hover, .pv-sections a:hover { color: var(--c-text); }
.ps-tabs .is-on, .pv-sections a.is-on {
    color: var(--c-text);
    font-weight: var(--fw-semibold);
    border-bottom-color: var(--c-highlight);
}
.list-tab { transition: background-color var(--ease), color var(--ease), border-color var(--ease); }

/* ---------- cards ---------- */
.card {
    --bs-card-bg: var(--c-surface);
    --bs-card-border-color: var(--c-border);
    --bs-card-border-radius: var(--radius);
    --bs-card-inner-border-radius: calc(var(--radius) - 1px);
    --bs-card-cap-bg: var(--c-surface-2);
    --bs-card-color: var(--c-text);
    box-shadow: var(--shadow);
}
.db-card, .detail-card, .pv-filterbar, .stat-chip {
    border-radius: var(--radius);
}
.db-card { box-shadow: var(--shadow); }
.detail-card { background: var(--c-surface); border-color: var(--c-border); box-shadow: var(--shadow); }
.modal-content { --bs-modal-bg: var(--c-surface); --bs-modal-border-radius: var(--radius); --bs-modal-box-shadow: var(--shadow-pop);
    --bs-modal-border-color: var(--c-border); }
.alert { --bs-alert-border-radius: var(--radius); }
.alert-success { --bs-alert-bg: var(--c-ok-bg); --bs-alert-color: var(--c-ok); --bs-alert-border-color: var(--c-ok-bg); }
.alert-warning { --bs-alert-bg: var(--c-warn-bg); --bs-alert-color: var(--c-warn); --bs-alert-border-color: var(--c-warn-bg); }
.alert-danger { --bs-alert-bg: var(--c-bad-bg); --bs-alert-color: var(--c-bad); --bs-alert-border-color: var(--c-bad-bg); }
.alert-info { --bs-alert-bg: var(--c-info-bg); --bs-alert-color: var(--c-info); --bs-alert-border-color: var(--c-info-bg); }

/* ---------- badges and status chips: one pill ---------- */
.badge-pill, .db-pill, .badge {
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    line-height: 1.5;
    padding: 1px 8px;
}
.badge { --bs-badge-font-size: var(--fs-xs); --bs-badge-font-weight: var(--fw-semibold); --bs-badge-border-radius: var(--radius-pill); }
.badge.bg-success, .badge.text-bg-success { background: var(--c-ok-bg) !important; color: var(--c-ok) !important; }
.badge.bg-warning, .badge.text-bg-warning { background: var(--c-warn-bg) !important; color: var(--c-warn) !important; }
.badge.bg-danger, .badge.text-bg-danger { background: var(--c-bad-bg) !important; color: var(--c-bad) !important; }
.badge.bg-info, .badge.text-bg-info, .badge.bg-primary, .badge.text-bg-primary { background: var(--c-info-bg) !important; color: var(--c-info) !important; }
.badge.bg-secondary, .badge.text-bg-secondary, .badge.bg-light, .badge.text-bg-light { background: var(--c-neutral-bg) !important; color: var(--c-neutral) !important; }

/* ---------- empty states ---------- */
.empty-state, .db-empty, .lp-empty, .wm-empty, .mp-empty {
    color: var(--c-muted);
    font-size: var(--fs-sm);
    text-align: center;
    padding: var(--sp-5) var(--sp-4);
    border: 1px dashed var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface-2);
}
.empty-state::before, .db-empty::before, .lp-empty::before, .wm-empty::before, .mp-empty::before {
    content: "";
    display: block;
    width: 28px; height: 28px;
    margin: 0 auto var(--sp-2);
    border-radius: 50%;
    background: var(--c-neutral-bg) center / 16px no-repeat
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A919E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 13V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v6'/%3E%3Cpath d='M2 13h6l2 3h4l2-3h6v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2z'/%3E%3C/svg%3E");
}
/* icon above the words, whatever display the page gave the box */
:is(.empty-state, .db-empty, .lp-empty, .wm-empty, .mp-empty)[class] { display: block; }
td .empty-state, td.empty-state { border: 0; background: transparent; }
.empty-state.mb-0 { margin-bottom: 0; }

/* ---------- loading: a thin bar at the top while a page or an inline update loads ---------- */
#crmLoadBar {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 5000; pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    background-size: 40% 100%; background-repeat: no-repeat;
    opacity: 0; transition: opacity 150ms ease;
}
body.is-loading #crmLoadBar { opacity: 1; animation: crm-load 1s linear infinite; }
@keyframes crm-load { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.htmx-request:not(body) { opacity: 0.6; transition: opacity var(--ease); }
button.is-busy, .btn.is-busy { cursor: progress; opacity: 0.75; }

/* ---------- focus, selection, small motion ---------- */
:focus-visible { outline-color: var(--c-info-solid); }
::selection { background: var(--c-selected); color: var(--c-text); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
