/* =========================================================
   Momentum theme for the tenant dashboard.

   Everything is scoped under .mo (the dashboard layout's root element) so the public site and the SysAdmin area
   keep their own look. The existing pages are plain Bootstrap, so this layer works by (1) setting Bootstrap's own
   variables and (2) overriding the components Bootstrap 5.3 hard-codes colours for (buttons, pills, progress,
   focus rings). Dark mode is the same tokens redefined under html[data-mo-theme="dark"] (set by wwwroot/js/momentum.js).
   ========================================================= */

.mo {
    --mo-bg: #f4f5fa;
    --mo-surface: #ffffff;
    --mo-surface-2: #f8f9fc;
    --mo-surface-3: #eef0f7;
    --mo-border: #e3e6f0;
    --mo-border-strong: #cdd2e3;
    --mo-text: #171a2e;
    --mo-text-2: #4a5070;
    --mo-muted: #636a89;
    --mo-accent: #5b5bd6;
    --mo-accent-hover: #4a4ac2;
    --mo-accent-2: #14b8a6;
    --mo-accent-soft: #ececfd;
    --mo-accent-text: #4141b8;
    --mo-danger: #e5484d;
    --mo-danger-soft: #fdeceb;
    --mo-warn: #f59e0b;
    --mo-warn-soft: #fff4dc;
    --mo-ok: #12a17a;
    --mo-ok-soft: #dff6ee;
    /* Text-safe variants of the status colours (the bright ones are for fills, badges and bars, and fail 4.5:1 as text). */
    --mo-ok-text: #0b7a5b;
    --mo-danger-text: #c93339;
    --mo-warn-text: #8a5a00;
    --mo-shadow-sm: 0 1px 2px rgba(23, 26, 46, .06);
    --mo-shadow: 0 4px 16px rgba(23, 26, 46, .08);
    --mo-shadow-lg: 0 16px 48px rgba(23, 26, 46, .18);
    --mo-radius: 10px;
    --mo-radius-sm: 6px;
    --mo-side-bg: #12142a;
    --mo-side-bg-2: #1a1d3a;
    --mo-side-text: #b9bdda;
    --mo-side-muted: #8189ae;
    --mo-side-active: rgba(124, 124, 255, .16);
    --mo-font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --mo-mono: "Cascadia Code", "SF Mono", Consolas, monospace;

    /* Bootstrap variables, so every existing component picks the palette up. */
    --bs-body-bg: var(--mo-bg);
    --bs-body-color: var(--mo-text);
    --bs-body-color-rgb: 23, 26, 46;
    --bs-body-font-family: var(--mo-font);
    --bs-body-font-size: .875rem;
    --bs-secondary-color: var(--mo-muted);
    --bs-secondary-bg: var(--mo-surface-3);
    --bs-tertiary-bg: var(--mo-surface-2);
    --bs-emphasis-color: var(--mo-text);
    --bs-border-color: var(--mo-border);
    --bs-border-radius: 8px;
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: 10px;
    --bs-link-color: var(--mo-accent-text);
    --bs-link-color-rgb: 65, 65, 184;
    --bs-link-hover-color: var(--mo-accent-hover);
    --bs-primary: var(--mo-accent);
    --bs-primary-rgb: 91, 91, 214;
    --bs-primary-text-emphasis: var(--mo-accent-text);
    --bs-primary-bg-subtle: var(--mo-accent-soft);
    --bs-primary-border-subtle: #c9c9f4;
    --bs-success: var(--mo-ok);
    --bs-success-rgb: 18, 161, 122;
    --bs-success-bg-subtle: var(--mo-ok-soft);
    --bs-success-border-subtle: #a8e3cf;
    --bs-success-text-emphasis: #0b6b51;
    --bs-danger: var(--mo-danger);
    --bs-danger-rgb: 229, 72, 77;
    --bs-danger-bg-subtle: var(--mo-danger-soft);
    --bs-danger-border-subtle: #f6c3c5;
    --bs-danger-text-emphasis: #a3262b;
    --bs-warning-bg-subtle: var(--mo-warn-soft);
    --bs-warning-border-subtle: #fadc9e;
    --bs-warning-text-emphasis: #8a5a00;
    --bs-info-bg-subtle: #e2f4f8;
    --bs-info-border-subtle: #b3e1ec;
    --bs-info-text-emphasis: #0b5b6e;
    --bs-secondary-bg-subtle: var(--mo-surface-3);
    --bs-secondary-border-subtle: var(--mo-border);
    --bs-secondary-text-emphasis: var(--mo-text-2);

    color-scheme: light;
    font-family: var(--mo-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--mo-text);
    background: var(--mo-bg);
    -webkit-font-smoothing: antialiased;
}

/* Dark mode is screen-only: printing always uses the light palette, so a dark-mode user never prints light text on white paper. */
@media screen {
html[data-mo-theme="dark"] .mo {
    --mo-bg: #0d0f1e;
    --mo-surface: #161933;
    --mo-surface-2: #1a1e3b;
    --mo-surface-3: #21254a;
    --mo-border: #2a2f57;
    --mo-border-strong: #3a4070;
    --mo-text: #eceefb;
    --mo-text-2: #b6bbdc;
    --mo-muted: #8e95bb;
    --mo-accent: #8b8bff;
    --mo-accent-hover: #a2a2ff;
    --mo-accent-soft: #26295a;
    --mo-accent-text: #b4b4ff;
    --mo-danger-soft: #3a1c26;
    --mo-warn-soft: #3a2f14;
    --mo-ok-soft: #12332c;
    --mo-ok-text: #6fe3bf;
    --mo-danger-text: #ff9ea2;
    --mo-warn-text: #f7c765;
    --mo-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --mo-shadow: 0 4px 16px rgba(0, 0, 0, .4);
    --mo-shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    --mo-side-bg: #090a17;
    --mo-side-bg-2: #12142a;

    --bs-body-color-rgb: 236, 238, 251;
    --bs-primary-rgb: 139, 139, 255;
    --bs-link-color-rgb: 180, 180, 255;
    --bs-primary-border-subtle: #3a3f86;
    --bs-success-border-subtle: #1d5a49;
    --bs-success-text-emphasis: #6fe3bf;
    --bs-danger-border-subtle: #6b2a35;
    --bs-danger-text-emphasis: #ff9ea2;
    --bs-warning-border-subtle: #66511f;
    --bs-warning-text-emphasis: #f7c765;
    --bs-info-bg-subtle: #14323a;
    --bs-info-border-subtle: #1f5663;
    --bs-info-text-emphasis: #7fd3e6;
    /* Bootstrap swaps the select arrow to a light one in dark mode; we scope dark mode ourselves, so do it here. */
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    color-scheme: dark;
}
}

.mo *, .mo *::before, .mo *::after { box-sizing: border-box; }
.mo ::selection { background: var(--mo-accent-soft); }
.mo :focus-visible { outline: 2px solid var(--mo-accent); outline-offset: 1px; }
.mo ::-webkit-scrollbar { width: 10px; height: 10px; }
.mo ::-webkit-scrollbar-thumb { background: var(--mo-border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.mo ::-webkit-scrollbar-thumb:hover { background-color: var(--mo-muted); }

/* ---------- Typography ---------- */
.mo h1, .mo h2, .mo h3, .mo h4, .mo h5, .mo h6 { font-family: var(--mo-font); font-weight: 650; letter-spacing: -.01em; color: var(--mo-text); }
.mo h1 { font-size: 22px; }
.mo h2 { font-size: 17px; }
.mo h3 { font-size: 15px; }
.mo h4 { font-size: 15px; }
.mo h5 { font-size: 14px; }
.mo h6 { font-size: 13px; }
.mo .text-muted { color: var(--mo-muted) !important; }
.mo .text-success { color: var(--mo-ok-text) !important; }
.mo .text-danger { color: var(--mo-danger-text) !important; }
.mo .text-warning { color: var(--mo-warn-text) !important; }
.mo .fs-3 { font-size: 26px !important; font-weight: 700 !important; letter-spacing: -.02em; }
.mo .fs-4 { font-size: 22px !important; font-weight: 700 !important; letter-spacing: -.02em; }
.mo small, .mo .small { font-size: 12px; }
.mo a:not(.btn) { color: var(--mo-accent-text); text-decoration: none; }
.mo a:not(.btn):hover { color: var(--mo-accent-hover); text-decoration: underline; }
.mo a.btn { text-decoration: none; }
.mo hr { border-color: var(--mo-border); opacity: 1; }

/* ---------- Shell ---------- */
.mo-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.mo-side { background: var(--mo-side-bg); color: var(--mo-side-text); display: flex; flex-direction: column; min-height: 0; height: 100vh; position: sticky; top: 0; overflow: hidden; }
.mo-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.02em; min-height: 62px; }
.mo-brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #7c7cff, #14b8a6); display: grid; place-items: center; flex: none; font-size: 14px; font-weight: 800; box-shadow: 0 4px 14px rgba(124, 124, 255, .35); }
.mo-brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mo-side-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.mo-side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mo-side-muted); padding: 14px 10px 6px; white-space: nowrap; }
.mo-nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--mo-side-text) !important; text-decoration: none !important; position: relative; font-weight: 500; white-space: nowrap; margin-bottom: 2px; }
.mo-nav-item i { width: 18px; text-align: center; font-size: 14px; flex: none; }
.mo-nav-item:hover { background: var(--mo-side-bg-2); color: #fff !important; }
.mo-nav-item.active { background: var(--mo-side-active); color: #fff !important; }
.mo-nav-item.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: #8b8bff; }
.mo-side-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .07); }
.mo-side-user .who { min-width: 0; line-height: 1.25; }
.mo-side-user .who strong { display: block; color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mo-side-user .who span { font-size: 11px; color: var(--mo-side-muted); }

.mo-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #5b5bd6, #8b5cf6); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; text-transform: uppercase; box-shadow: 0 0 0 2px rgba(255, 255, 255, .12); }
.mo-avatar.sm { width: 28px; height: 28px; font-size: 11px; }

.mo-main { min-width: 0; display: flex; flex-direction: column; }
.mo-top { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--mo-surface); border-bottom: 1px solid var(--mo-border); position: sticky; top: 0; z-index: 20; min-height: 56px; }
.mo-top .spacer { flex: 1; }
.mo-icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--mo-text-2); display: inline-grid; place-items: center; cursor: pointer; }
.mo-icon-btn:hover { background: var(--mo-surface-3); color: var(--mo-text); }
.mo-theme-btn .sun { display: none; }
html[data-mo-theme="dark"] .mo-theme-btn .sun { display: inline; }
html[data-mo-theme="dark"] .mo-theme-btn .moon { display: none; }
.mo-crumb { color: var(--mo-muted); font-size: 13px; }
.mo-content { padding: 24px 28px 40px; flex: 1; min-width: 0; }

/* Account menu */
.mo-user-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 3px 8px 3px 4px; border-radius: 999px; color: var(--mo-text); cursor: pointer; }
.mo-user-btn:hover { background: var(--mo-surface-3); }
.mo-user-btn .name { font-weight: 550; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mo-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--mo-surface); border: 1px solid var(--mo-border); border-radius: 10px; box-shadow: var(--mo-shadow-lg); padding: 6px; z-index: 41; }
.mo-pop a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--mo-text) !important; text-decoration: none !important; font-weight: 500; }
.mo-pop a:hover { background: var(--mo-surface-3); }
.mo-pop a i { width: 16px; text-align: center; color: var(--mo-muted); }
.mo-pop-backdrop { position: fixed; inset: 0; z-index: 40; background: transparent; border: 0; cursor: default; }

/* Collapsed rail (desktop only) */
@media (min-width: 768px) {
    html[data-mo-collapsed="true"] .mo-shell { grid-template-columns: 68px 1fr; }
    html[data-mo-collapsed="true"] .mo-shell .mo-brand-name, html[data-mo-collapsed="true"] .mo-shell .mo-nav-item span, html[data-mo-collapsed="true"] .mo-shell .mo-side-label, html[data-mo-collapsed="true"] .mo-shell .mo-side-user .who { display: none; }
    html[data-mo-collapsed="true"] .mo-shell .mo-nav-item { justify-content: center; padding: 9px 0; }
    html[data-mo-collapsed="true"] .mo-shell .mo-nav-item.active::before { left: -10px; }
    html[data-mo-collapsed="true"] .mo-shell .mo-side-user { justify-content: center; }
    html[data-mo-collapsed="true"] .mo-shell .mo-brand { justify-content: center; padding-left: 0; padding-right: 0; }
}

/* Mobile: sidebar becomes an overlay opened from the top bar */
@media (max-width: 767.98px) {
    .mo-shell, html[data-mo-collapsed="true"] .mo-shell { grid-template-columns: 1fr; }
    .mo-side { position: fixed; z-index: 60; width: 264px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--mo-shadow-lg); }
    html[data-mo-nav="open"] .mo-side { transform: none; }
    html[data-mo-nav="open"] .mo-scrim { display: block; position: fixed; inset: 0; background: rgba(9, 10, 23, .5); z-index: 55; border: 0; }
    .mo-content { padding: 16px 14px 32px; }
    .mo-top { padding: 8px 12px; }
    .mo-user-btn .name { display: none; }
}
.mo-scrim { display: none; }

/* ---------- Cards, tables, lists ---------- */
.mo .card { background: var(--mo-surface); border: 1px solid var(--mo-border); border-radius: var(--mo-radius); box-shadow: var(--mo-shadow-sm); color: var(--mo-text); --bs-card-cap-bg: var(--mo-surface-2); --bs-card-border-color: var(--mo-border); }
.mo .card-header, .mo .card-footer { background: var(--mo-surface-2); border-color: var(--mo-border); }
.mo .bg-white, .mo .bg-light { background-color: var(--mo-surface) !important; }
.mo .text-dark { color: var(--mo-text) !important; }
.mo .border, .mo .border-top, .mo .border-bottom { border-color: var(--mo-border) !important; }
.mo .rounded { border-radius: var(--mo-radius-sm) !important; }
.mo .shadow-sm { box-shadow: var(--mo-shadow-sm) !important; }

.mo .table { --bs-table-bg: transparent; --bs-table-color: var(--mo-text); --bs-table-border-color: var(--mo-border); --bs-table-striped-bg: var(--mo-surface-2); --bs-table-striped-color: var(--mo-text); --bs-table-hover-bg: var(--mo-surface-3); color: var(--mo-text); }
.mo .table > thead > tr > th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--mo-muted); font-weight: 600; background: var(--mo-surface-2); border-bottom: 1px solid var(--mo-border); }
.mo .table-light { --bs-table-bg: var(--mo-surface-2); --bs-table-color: var(--mo-text); --bs-table-border-color: var(--mo-border); }
.mo .table-responsive { border: 1px solid var(--mo-border); border-radius: var(--mo-radius); background: var(--mo-surface); }
.mo .table-responsive > .table { margin-bottom: 0; }
.mo .list-group { --bs-list-group-bg: var(--mo-surface); --bs-list-group-border-color: var(--mo-border); --bs-list-group-color: var(--mo-text); --bs-list-group-action-hover-bg: var(--mo-surface-3); --bs-list-group-action-hover-color: var(--mo-text); --bs-list-group-action-active-bg: var(--mo-accent); --bs-list-group-active-bg: var(--mo-accent-soft); --bs-list-group-active-color: var(--mo-accent-text); --bs-list-group-active-border-color: var(--mo-border-strong); --bs-list-group-border-radius: var(--mo-radius); }
.mo .list-group-item.active { font-weight: 600; }
.mo .list-group-item.active .text-white-50 { color: var(--mo-muted) !important; font-weight: 400; }
.mo .accordion { --bs-accordion-bg: var(--mo-surface); --bs-accordion-border-color: var(--mo-border); --bs-accordion-btn-bg: var(--mo-surface); --bs-accordion-active-bg: var(--mo-accent-soft); --bs-accordion-active-color: var(--mo-accent-text); --bs-accordion-color: var(--mo-text); }

/* ---------- Buttons (Bootstrap 5.3 hard-codes these colours) ---------- */
.mo .btn { --bs-btn-border-radius: 8px; --bs-btn-font-weight: 550; font-size: 13px; }
.mo .btn-primary { --bs-btn-color: #fff; --bs-btn-bg: var(--mo-accent); --bs-btn-border-color: var(--mo-accent); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--mo-accent-hover); --bs-btn-hover-border-color: var(--mo-accent-hover); --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--mo-accent-hover); --bs-btn-active-border-color: var(--mo-accent-hover); --bs-btn-disabled-color: #fff; --bs-btn-disabled-bg: var(--mo-accent); --bs-btn-disabled-border-color: var(--mo-accent); --bs-btn-focus-shadow-rgb: 91, 91, 214; }
@media screen { html[data-mo-theme="dark"] .mo .btn-primary { --bs-btn-color: #12142a; --bs-btn-hover-color: #12142a; --bs-btn-active-color: #12142a; --bs-btn-disabled-color: #12142a; } }
.mo .btn-outline-primary { --bs-btn-color: var(--mo-accent-text); --bs-btn-border-color: var(--mo-accent); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--mo-accent); --bs-btn-hover-border-color: var(--mo-accent); --bs-btn-active-bg: var(--mo-accent); --bs-btn-active-border-color: var(--mo-accent); --bs-btn-disabled-color: var(--mo-accent-text); --bs-btn-disabled-border-color: var(--mo-accent); }
.mo .btn-outline-secondary, .mo .btn-outline-dark { --bs-btn-color: var(--mo-text-2); --bs-btn-border-color: var(--mo-border-strong); --bs-btn-hover-color: var(--mo-text); --bs-btn-hover-bg: var(--mo-surface-3); --bs-btn-hover-border-color: var(--mo-border-strong); --bs-btn-active-color: var(--mo-text); --bs-btn-active-bg: var(--mo-surface-3); --bs-btn-active-border-color: var(--mo-border-strong); --bs-btn-disabled-color: var(--mo-muted); --bs-btn-disabled-border-color: var(--mo-border); }
.mo .btn-secondary { --bs-btn-color: var(--mo-text); --bs-btn-bg: var(--mo-surface-3); --bs-btn-border-color: var(--mo-border); --bs-btn-hover-color: var(--mo-text); --bs-btn-hover-bg: var(--mo-border); --bs-btn-hover-border-color: var(--mo-border-strong); --bs-btn-active-color: var(--mo-text); --bs-btn-active-bg: var(--mo-border); --bs-btn-disabled-color: var(--mo-muted); --bs-btn-disabled-bg: var(--mo-surface-3); }
.mo .btn-danger { --bs-btn-bg: var(--mo-danger); --bs-btn-border-color: var(--mo-danger); --bs-btn-hover-bg: #cf3a3f; --bs-btn-hover-border-color: #cf3a3f; --bs-btn-active-bg: #cf3a3f; --bs-btn-disabled-bg: var(--mo-danger); --bs-btn-disabled-border-color: var(--mo-danger); }
.mo .btn-outline-danger { --bs-btn-color: var(--mo-danger); --bs-btn-border-color: var(--mo-danger); --bs-btn-hover-bg: var(--mo-danger); --bs-btn-hover-border-color: var(--mo-danger); --bs-btn-active-bg: var(--mo-danger); --bs-btn-disabled-color: var(--mo-danger); --bs-btn-disabled-border-color: var(--mo-danger); }
.mo .btn-success { --bs-btn-bg: var(--mo-ok); --bs-btn-border-color: var(--mo-ok); --bs-btn-hover-bg: #0f8a67; --bs-btn-hover-border-color: #0f8a67; --bs-btn-active-bg: #0f8a67; --bs-btn-disabled-bg: var(--mo-ok); --bs-btn-disabled-border-color: var(--mo-ok); }
.mo .btn-outline-success { --bs-btn-color: var(--mo-ok); --bs-btn-border-color: var(--mo-ok); --bs-btn-hover-bg: var(--mo-ok); --bs-btn-hover-border-color: var(--mo-ok); --bs-btn-active-bg: var(--mo-ok); --bs-btn-disabled-color: var(--mo-ok); --bs-btn-disabled-border-color: var(--mo-ok); }
.mo .btn-warning { --bs-btn-color: #3a2600; --bs-btn-bg: var(--mo-warn); --bs-btn-border-color: var(--mo-warn); --bs-btn-hover-color: #3a2600; --bs-btn-hover-bg: #e08e00; --bs-btn-hover-border-color: #e08e00; --bs-btn-active-bg: #e08e00; --bs-btn-disabled-color: #3a2600; --bs-btn-disabled-bg: var(--mo-warn); }
.mo .btn-link { --bs-btn-color: var(--mo-accent-text); --bs-btn-hover-color: var(--mo-accent-hover); }
.mo .btn-close { opacity: .6; }

/* ---------- Forms ---------- */
.mo .form-control, .mo .form-select { background-color: var(--mo-surface); color: var(--mo-text); border: 1px solid var(--mo-border-strong); border-radius: 8px; font-size: 13.5px; }
.mo .form-control::placeholder { color: var(--mo-muted); opacity: .8; }
.mo .form-control:focus, .mo .form-select:focus { background-color: var(--mo-surface); color: var(--mo-text); border-color: var(--mo-accent); box-shadow: 0 0 0 3px var(--mo-accent-soft); }
.mo .form-control:disabled, .mo .form-select:disabled, .mo .form-control[readonly] { background-color: var(--mo-surface-3); color: var(--mo-muted); }
.mo .form-label { font-weight: 550; color: var(--mo-text-2); margin-bottom: 4px; }
.mo .form-text { color: var(--mo-muted); }
.mo .form-check-input { border-color: var(--mo-border-strong); background-color: var(--mo-surface); }
.mo .form-check-input:checked { background-color: var(--mo-accent); border-color: var(--mo-accent); }
.mo .form-check-input:focus { border-color: var(--mo-accent); box-shadow: 0 0 0 3px var(--mo-accent-soft); }
.mo .input-group-text { background: var(--mo-surface-3); border-color: var(--mo-border-strong); color: var(--mo-text-2); }
.mo .form-control-color { padding: 3px; }
.mo .valid.modified:not([type=checkbox]) { outline: 1px solid var(--mo-ok); }
.mo .invalid { outline: 1px solid var(--mo-danger); }
.mo .validation-message { color: var(--mo-danger-text); }

/* ---------- Tabs / pills ---------- */
.mo .nav-pills { --bs-nav-pills-link-active-bg: var(--mo-accent-soft); --bs-nav-pills-link-active-color: var(--mo-accent-text); --bs-nav-link-color: var(--mo-text-2); --bs-nav-link-hover-color: var(--mo-text); gap: 4px; }
.mo-content .nav-pills .nav-link { border-radius: 8px; font-weight: 550; padding: 6px 12px; background: transparent; border: 0; }
.mo-content .nav-pills .nav-link:hover { background: var(--mo-surface-3); }
.mo-content .nav-pills .nav-link.active { background: var(--mo-accent-soft); color: var(--mo-accent-text); }
.mo .nav-tabs { --bs-nav-tabs-border-color: var(--mo-border); --bs-nav-tabs-link-active-bg: transparent; --bs-nav-tabs-link-active-color: var(--mo-accent-text); --bs-nav-tabs-link-active-border-color: transparent transparent var(--mo-accent); --bs-nav-link-color: var(--mo-text-2); }
.mo .nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -1px; color: var(--mo-text-2); font-weight: 550; padding: 8px 14px; background: transparent; }
.mo .nav-tabs .nav-link:hover, .mo .nav-tabs .nav-link:focus-visible { border-bottom-color: var(--mo-border-strong); color: var(--mo-text); background: transparent; }
.mo .nav-tabs .nav-link.active { border-bottom-color: var(--mo-accent); color: var(--mo-accent-text); font-weight: 600; background: transparent; }

/* ---------- Badges, alerts, progress ---------- */
.mo .badge { font-weight: 600; border-radius: 999px; padding: .32em .65em; }
.mo .badge.bg-secondary { background-color: var(--mo-surface-3) !important; color: var(--mo-text-2) !important; }
.mo .badge.bg-primary { background-color: var(--mo-accent-soft) !important; color: var(--mo-accent-text) !important; }
.mo .badge.bg-success { background-color: var(--mo-ok-soft) !important; color: var(--bs-success-text-emphasis) !important; }
.mo .badge.bg-danger { background-color: var(--mo-danger-soft) !important; color: var(--bs-danger-text-emphasis) !important; }
.mo .badge.bg-warning { background-color: var(--mo-warn-soft) !important; color: var(--bs-warning-text-emphasis) !important; }
.mo .badge.bg-info { background-color: var(--bs-info-bg-subtle) !important; color: var(--bs-info-text-emphasis) !important; }
.mo .alert { border-radius: var(--mo-radius); border-width: 1px; }
.mo .progress { --bs-progress-bg: var(--mo-surface-3); --bs-progress-bar-bg: var(--mo-accent); --bs-progress-border-radius: 999px; }
.mo .progress-bar.bg-success { background-color: var(--mo-ok) !important; }
.mo .progress-bar.bg-warning { background-color: var(--mo-warn) !important; }
.mo .progress-bar.bg-danger { background-color: var(--mo-danger) !important; }
.mo .spinner-border.text-primary { color: var(--mo-accent) !important; }

/* ---------- Modals (the manual .modal.d-block pattern used by purchase orders) ---------- */
.mo .modal-content { background: var(--mo-surface); color: var(--mo-text); border: 1px solid var(--mo-border); border-radius: 16px; box-shadow: var(--mo-shadow-lg); }
.mo .modal-header, .mo .modal-footer { border-color: var(--mo-border); }
@media screen { html[data-mo-theme="dark"] .mo .btn-close { filter: invert(1) grayscale(100%) brightness(200%); } }

/* ---------- Page-level pieces ---------- */
.mo-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }

.mo-hero { background: linear-gradient(120deg, #4a46c4 0%, #5b5bd6 45%, #3f8fc4 100%); color: #fff; border-radius: 16px; padding: 28px 28px 24px; margin-bottom: 18px; position: relative; overflow: hidden; box-shadow: var(--mo-shadow); }
.mo-hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 70%); pointer-events: none; }
.mo-hero h1 { color: #fff; font-size: 26px; font-weight: 700; margin: 0 0 4px; }
.mo-hero p { color: rgba(255, 255, 255, .85); margin: 0 0 16px; font-weight: 500; }
.mo-hero .actions { display: flex; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; }
.mo-hero .hero-btn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .16); color: #fff !important; text-decoration: none !important; }
.mo-hero .hero-btn:hover { background: rgba(255, 255, 255, .26); }
.mo-hero .hero-btn.solid { background: #fff; color: #3d3dad !important; border-color: #fff; }
.mo-hero .hero-btn.solid:hover { background: #f1f1ff; }

.mo-stat { padding: 16px 18px; height: 100%; }
.mo-stat .label { font-size: 12px; color: var(--mo-muted); margin-bottom: 2px; }
.mo-stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; color: var(--mo-text); }
.mo-stat .value.sm { font-size: 22px; }
.mo-stat .sub { font-size: 12px; color: var(--mo-muted); margin-top: 2px; }
.mo-stat .sub.ok { color: var(--mo-ok-text); }
.mo-stat .sub.bad { color: var(--mo-danger-text); }

/* ---------- Project workspace primitives: pills, avatar stacks, progress, cards, view switcher, drawer ---------- */
.mo-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; background: var(--mo-surface-3); color: var(--mo-text-2); white-space: nowrap; }
.mo-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.mo-pill.ok { background: var(--mo-ok-soft); color: var(--mo-ok-text); }
.mo-pill.warn { background: var(--mo-warn-soft); color: var(--mo-warn-text); }
.mo-pill.danger { background: var(--mo-danger-soft); color: var(--mo-danger-text); }
.mo-pill.accent { background: var(--mo-accent-soft); color: var(--mo-accent-text); }

.mo-progress { height: 6px; border-radius: 999px; background: var(--mo-surface-3); overflow: hidden; }
.mo-progress > span { display: block; width: calc(var(--p, 0) * 1%); height: 100%; border-radius: inherit; background: var(--mo-accent); }
.mo-progress.ok > span { background: var(--mo-ok); }

.mo-avatar-stack { display: inline-flex; align-items: center; }
.mo-avatar-stack .mo-avatar { width: 28px; height: 28px; margin-left: -5px; font-size: 11px; background: var(--av, var(--mo-accent)); box-shadow: 0 0 0 2px var(--mo-surface); }
.mo-avatar-stack .mo-avatar:first-child { margin-left: 0; }
.mo-avatar-stack .mo-avatar.more { background: var(--mo-surface-3); color: var(--mo-text-2); }

.mo-card-link { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--mo-surface); border: 1px solid var(--mo-border); border-radius: var(--mo-radius); box-shadow: var(--mo-shadow-sm); color: var(--mo-text) !important; text-decoration: none !important; }
.mo-card-link:hover { border-color: var(--mo-border-strong); box-shadow: var(--mo-shadow); }
@media (prefers-reduced-motion: no-preference) {
    .mo-card-link { transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
    .mo-card-link:hover { transform: translateY(-1px); }
}

/* The view switcher: a segmented control for the views of the work, and a quieter row for the money side. */
.mo-views { display: flex; gap: 4px; width: fit-content; max-width: 100%; padding: 4px; overflow-x: auto; background: var(--mo-surface-2); border: 1px solid var(--mo-border); border-radius: 12px; }
.mo-view { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--mo-text-2) !important; text-decoration: none !important; white-space: nowrap; }
.mo-view i { color: var(--mo-muted); }
.mo-view:hover { background: var(--mo-surface-3); }
.mo-view.active { background: var(--mo-surface); color: var(--mo-accent-text) !important; box-shadow: var(--mo-shadow-sm); }
.mo-view.active i { color: var(--mo-accent); }
.mo-subviews { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 18px; margin-top: 10px; font-size: 13px; }
.mo-subviews .label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mo-muted); }
.mo-subview { padding: 4px 1px; border-bottom: 2px solid transparent; font-weight: 550; color: var(--mo-text-2) !important; text-decoration: none !important; }
.mo-subview:hover { color: var(--mo-text) !important; }
.mo-subview.active { color: var(--mo-accent-text) !important; border-bottom-color: var(--mo-accent); }

/* A right-hand drawer: only its body scrolls, so the title and footer stay in view. */
.mo-drawer-backdrop { position: fixed; inset: 0; z-index: 1050; background: rgba(9, 10, 23, .45); }
.mo-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1055; display: flex; flex-direction: column; width: min(var(--mo-drawer-w, 760px), 100vw); background: var(--mo-surface); color: var(--mo-text); border-left: 1px solid var(--mo-border); box-shadow: var(--mo-shadow-lg); outline: none; }
.mo-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--mo-border); }
.mo-drawer-titles { min-width: 0; }
.mo-drawer-eyebrow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--mo-muted); }
.mo-drawer-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem; }
.mo-drawer-body { flex: 1 1 auto; min-height: 0; padding: 1rem 1.25rem; overflow-y: auto; overscroll-behavior: contain; }
.mo-drawer-foot { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-top: 1px solid var(--mo-border); background: var(--mo-surface-2); }
@media (prefers-reduced-motion: no-preference) {
    .mo-drawer { animation: mo-drawer-in .22s ease-out; }
    .mo-drawer-backdrop { animation: mo-drawer-fade .22s ease-out; }
    @keyframes mo-drawer-in { from { transform: translateX(100%); } to { transform: none; } }
    @keyframes mo-drawer-fade { from { opacity: 0; } to { opacity: 1; } }
}
@media print { .mo-drawer, .mo-drawer-backdrop { display: none !important; } }

/* Small buttons (toolbar actions, Add task) stay on one line rather than wrapping their label on a phone. */
.mo .btn.btn-sm { white-space: nowrap; }

/* ---------- Print: hide the chrome, keep the page content ---------- */
@media print {
    .mo-side, .mo-top, .mo-scrim { display: none !important; }
    .mo-shell { display: block; }
    .mo-content { padding: 0; }
}

/* ---------- Accessibility ---------- */
/* The default focus ring is the accent, which is too faint against the dark sidebar. */
.mo-side :focus-visible { outline-color: #a2a2ff; }

@media (prefers-reduced-motion: reduce) {
    .mo-side, .mo-nav-item, .mo-icon-btn { transition: none !important; }
}
