/*
 * NCSS CRM design tokens, adapted from the approved dashboard-mockup.html.
 * Semantic custom properties only -- nothing in app CSS/markup should
 * hardcode a hex color going forward; reference these instead.
 * Dark values apply via Bootstrap 5.3's native color-mode attribute.
 */

:root {
    --page: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f8f9fa;
    --text: var(--charcoal);
    --text-muted: #6c7075;
    --border: #e5e7ea;

    /* NCSS brand */
    --brand: #C8312A;        /* primary red */
    --brand-strong: #A52220; /* dark red: hover/active */
    --charcoal: #3D3D3D;     /* body text, neutral UI */

    --nav-bg: #2b2d31;
    --nav-text: #c9cbcf;
    --nav-text-dim: #8b8e93;
    --nav-active: #EF4136;

    --warning: #E0912B;
    --warning-bg: #fbf0dc;
    --warning-text: #7a4e08;

    --success: #2e9e5b;
    --success-bg: #e6f4ec;
    --success-text: #1c6b3c;

    --info: #3574c0;
    --info-bg: #e8f0fa;
    --info-text: #1d4e86;

    --danger-bg: #fbe9e8;
    --danger-text: #8f1d18;

    --neutral: #6c7075;
    --neutral-bg: #ececec;
    --neutral-text: var(--charcoal);

    --radius: 8px;
    --radius-lg: 12px;
}

[data-bs-theme="dark"] {
    --page: #131518;
    --surface: #1c1f23;
    --surface-2: #23272c;
    --text: #e7e8ea;
    --text-muted: #9a9da2;
    --border: #2e3339;

    --brand: #EF4136;
    --brand-strong: #F0574C;

    --nav-bg: #141619;
    --nav-text: #c2c4c8;
    --nav-text-dim: #7c8085;
    --nav-active: #EF4136;

    --warning: #E0912B;
    --warning-bg: #3a2c12;
    --warning-text: #f0b559;

    --success: #3bb56d;
    --success-bg: #14301f;
    --success-text: #66c98d;

    --info: #4f8fd6;
    --info-bg: #152738;
    --info-text: #7cb0e6;

    /* Dark mode keeps brighter reds (above) so red text/links stay legible. */
    --charcoal: #d9d9d9;
    --danger-bg: #3a1614;
    --danger-text: #f3877f;

    --neutral: #9a9da2;
    --neutral-bg: #2a2e33;
    --neutral-text: #d4d6d9;
}

/*
 * Phase 2: map Bootstrap's primary/link/focus-ring colors to the NCSS brand,
 * light and dark. --bs-primary/--bs-primary-rgb, --bs-link-*, and
 * --bs-focus-ring-color are plain custom properties Bootstrap declares on
 * :root with literal values (confirmed by inspecting the vendored 5.3.3
 * bootstrap.css) -- re-declaring them here after bootstrap.min.css wins the
 * cascade and correctly retints every utility class that reads them at use
 * time (.bg-primary, .text-primary, .border-primary, links, focus rings).
 *
 * .btn-primary does NOT read var(--bs-primary) -- Bootstrap bakes literal
 * hex directly into its own --bs-btn-* properties, so it needs its own
 * explicit override below (not a Sass rebuild, so this is the correct way
 * to retint it without recompiling Bootstrap).
 */
:root {
    --bs-primary: var(--brand);
    --bs-primary-rgb: 200, 49, 42;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 200, 49, 42;
    --bs-link-hover-color: var(--brand-strong);
    --bs-link-hover-color-rgb: 165, 34, 32;
    --bs-focus-ring-color: rgba(200, 49, 42, .25);
    --bs-dark: #3D3D3D;
    --bs-dark-rgb: 61, 61, 61;
    --bs-body-bg: var(--page);
    --bs-body-color: var(--text);
}

[data-bs-theme="dark"] {
    --bs-primary: var(--brand);
    --bs-primary-rgb: 239, 65, 54;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 239, 65, 54;
    --bs-link-hover-color: var(--brand-strong);
    --bs-link-hover-color-rgb: 240, 87, 76;
    --bs-focus-ring-color: rgba(239, 65, 54, .25);
    --bs-body-bg: var(--page);
    --bs-body-color: var(--text);
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-strong);
    --bs-btn-hover-border-color: var(--brand-strong);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

/*
 * Phase 3: app shell -- left side-nav + thin topbar, adapted from the
 * mockup's .app/.nav/.topbar structure. Classes are prefixed app- to avoid
 * colliding with Bootstrap's own .nav/.navbar-nav (used throughout the app
 * for tabs) and with .main.
 *
 * The side-nav's mobile collapse is a small custom class toggle (below),
 * NOT Bootstrap's offcanvas component: offcanvas's base CSS sets
 * visibility:hidden and transform:translateX(-100%) UNCONDITIONALLY (not
 * gated by any breakpoint media query -- confirmed by reading the vendored
 * 5.3.3 CSS), and its "responsive" (offcanvas-lg etc.) variant only resets
 * display on the *.offcanvas-header/.offcanvas-body children*, not the
 * container's own visibility/transform -- so it never actually becomes a
 * normal static block at wide viewports the way the docs' framing suggests.
 * Rather than fight that, this is a few lines of plain CSS + JS instead.
 */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidenav {
    width: 224px;
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 0;
}

@media (min-width: 992px) {
    .app-sidenav {
        position: sticky;
        top: 0;
        height: 100vh;
        border: none;
    }
}

@media (max-width: 991.98px) {
    .app-sidenav {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 1045;
        box-shadow: var(--bs-box-shadow-lg);
    }

    .app-sidenav.app-sidenav-open {
        display: flex;
    }

    .app-sidenav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1044;
    }

    .app-sidenav-backdrop.app-sidenav-open {
        display: block;
    }
}

@media (min-width: 992px) {
    .app-sidenav-backdrop {
        display: none !important;
    }
}

.app-sidenav-brand {
    padding: 20px 20px 18px;
    display: flex;
    align-items: baseline;
    gap: 2px;
    letter-spacing: .5px;
}

    .app-sidenav-brand .mark {
        font-size: 22px;
        font-weight: 800;
        color: var(--brand);
    }

    .app-sidenav-brand .sub {
        font-size: 12px;
        font-weight: 600;
        color: var(--nav-text-dim);
        margin-left: 6px;
        letter-spacing: 2px;
    }

.app-sidenav-group {
    padding: 8px 12px;
    display: block;
}

.app-sidenav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--nav-text-dim);
    padding: 8px 12px 6px;
}

.app-sidenav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    margin: 1px 0;
    border-radius: var(--radius);
    color: var(--nav-text);
    text-decoration: none;
    font-size: 13.5px;
    position: relative;
}

    .app-sidenav a:hover {
        background: rgba(255,255,255,.06);
        color: #fff;
    }

    .app-sidenav a.active {
        background: rgba(239,65,54,.14);
        color: #fff;
        font-weight: 600;
    }

        .app-sidenav a.active::before {
            content: "";
            position: absolute;
            left: 0;
            top: 6px;
            bottom: 6px;
            width: 3px;
            background: var(--brand);
            border-radius: 0 3px 3px 0;
        }

    .app-sidenav a i.bi {
        font-size: 16px;
        flex-shrink: 0;
        opacity: .9;
    }

.app-sidenav-foot {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.app-sidenav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

    .app-sidenav-user .who {
        font-size: 13px;
        color: #fff;
        line-height: 1.2;
    }

        .app-sidenav-user .who small {
            display: block;
            color: var(--nav-text-dim);
            font-size: 11px;
        }

.app-sidenav-actions {
    display: flex;
    gap: 10px;
    padding: 4px 12px;
    font-size: 12px;
}

    .app-sidenav-actions a,
    .app-sidenav-actions button {
        background: none;
        border: none;
        padding: 0;
        color: var(--nav-text-dim);
        text-decoration: none;
    }

        .app-sidenav-actions a:hover,
        .app-sidenav-actions button:hover {
            color: #fff;
        }

.app-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    min-height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 24px;
    position: sticky;
    top: 0;
    z-index: 5;
}

    .app-topbar h1 {
        font-size: 17px;
        font-weight: 600;
        margin: 0;
        flex: 1;
        min-width: 0;
        /* The top bar is the only page title; long ones (customer names) get an ellipsis. */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Which window a dashboard goal tile covers (Goal.Scope). */
.goal-scope {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: none;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 6px;
    margin-left: 4px;
    white-space: nowrap;
    vertical-align: 1px;
}

/* Global search in the top bar (Pages/Api/Search) */
.app-search {
    position: relative;
    width: 280px;
}

    .app-search .form-control {
        padding-left: 30px;
    }

.app-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #6c757d);
    pointer-events: none;
}

.app-search-results {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: min(440px, calc(100vw - 32px));
    max-height: 70vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    padding: 6px 0;
    z-index: 1050;
}

/* Notifications bell (F35) */
.app-bell-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.app-bell-menu {
    width: min(380px, calc(100vw - 32px));
}

@media (max-width: 575.98px) {
    /* Phones: full width with a 16px gutter instead of Popper placement. */
    .app-bell-menu.show {
        position: fixed !important;
        inset: 60px 16px auto 16px !important;
        transform: none !important;
        width: auto;
    }
}

.app-bell-list {
    max-height: 60vh;
    overflow-y: auto;
}

.app-bell-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    white-space: normal;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}

    .app-bell-item .bi {
        margin-top: 2px;
        color: var(--text-muted, #6c757d);
    }

    .app-bell-item.unread {
        background: var(--surface-2);
        font-weight: 600;
    }

        .app-bell-item.unread .bi {
            color: var(--brand);
        }

.app-search-heading {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted, #6c757d);
    padding: 6px 14px 2px;
}

.app-search-hit {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 14px;
    color: inherit;
    text-decoration: none;
}

    .app-search-hit:hover, .app-search-hit:focus, .app-search-hit.is-active {
        background: var(--surface-hover, rgba(127, 127, 127, .12));
        outline: none;
    }

    .app-search-hit .bi {
        margin-top: 2px;
    }

.app-search-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-search-title, .app-search-detail {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-search-detail {
    font-size: 12px;
    color: var(--text-muted, #6c757d);
}

.app-search-empty {
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

@media (max-width: 991.98px) {
    .app-search {
        width: 180px;
    }
}

@media (max-width: 575.98px) {
    .app-search {
        width: 38px;
        transition: width .15s ease;
    }

        .app-search .form-control {
            padding-right: 0;
        }

        .app-search .form-control::placeholder {
            color: transparent;
        }

        .app-search:focus-within {
            width: min(70vw, 260px);
        }

            .app-search:focus-within .form-control::placeholder {
                color: var(--text-muted);
            }
}

.app-icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
}

    .app-icon-btn:hover {
        background: var(--surface-2);
    }

.app-content {
    padding: 24px;
    width: 100%;
}

@media (max-width: 991.98px) {
    .app-topbar h1 {
        font-size: 15px;
    }
}

/*
 * Phase 4: quiet headers + components, app-wide.
 *
 * Semantic color remap for danger/warning/success/info, light and dark.
 * Same pattern established in Phase 2 for --bs-primary: plain root variables
 * (--bs-{color}/-rgb) retint utility classes (.bg-*/.text-*/.border-*) for
 * free since those reference the variable at use time. --bs-{color}-text-
 * emphasis/-bg-subtle/-border-subtle are Bootstrap 5.3's own accessible
 * pairing utilities (.text-warning-emphasis + .bg-warning-subtle etc.) --
 * reused here (rather than inventing new badge classes) specifically
 * because plain amber-on-white fails WCAG AA (~2.5:1) while the emphasis/
 * subtle pairing is verified >6:1 in both modes. --bs-danger maps to the
 * brand red itself per the mockup's rule that red is reserved for brand/
 * primary/destructive -- one red in the app, not two similar ones.
 */
:root {
    --bs-danger: var(--brand);
    --bs-danger-rgb: 200, 49, 42;
    --bs-danger-text-emphasis: var(--danger-text);
    --bs-danger-bg-subtle: var(--danger-bg);
    --bs-danger-border-subtle: var(--brand);

    --bs-warning: var(--warning);
    --bs-warning-rgb: 224, 145, 43;
    --bs-warning-text-emphasis: var(--warning-text);
    --bs-warning-bg-subtle: var(--warning-bg);
    --bs-warning-border-subtle: var(--warning);

    --bs-success: var(--success);
    --bs-success-rgb: 46, 158, 91;
    --bs-success-text-emphasis: var(--success-text);
    --bs-success-bg-subtle: var(--success-bg);
    --bs-success-border-subtle: var(--success);

    --bs-info: var(--info);
    --bs-info-rgb: 53, 116, 192;
    --bs-info-text-emphasis: var(--info-text);
    --bs-info-bg-subtle: var(--info-bg);
    --bs-info-border-subtle: var(--info);
}

[data-bs-theme="dark"] {
    --bs-danger: var(--brand);
    --bs-danger-rgb: 239, 65, 54;
    --bs-danger-text-emphasis: var(--danger-text);
    --bs-danger-bg-subtle: var(--danger-bg);
    --bs-danger-border-subtle: var(--brand);

    --bs-warning: var(--warning);
    --bs-warning-rgb: 224, 145, 43;
    --bs-warning-text-emphasis: var(--warning-text);
    --bs-warning-bg-subtle: var(--warning-bg);
    --bs-warning-border-subtle: var(--warning);

    --bs-success: var(--success);
    --bs-success-rgb: 59, 181, 109;
    --bs-success-text-emphasis: var(--success-text);
    --bs-success-bg-subtle: var(--success-bg);
    --bs-success-border-subtle: var(--success);

    --bs-info: var(--info);
    --bs-info-rgb: 79, 143, 214;
    --bs-info-text-emphasis: var(--info-text);
    --bs-info-bg-subtle: var(--info-bg);
    --bs-info-border-subtle: var(--info);
}

/* .btn-* components bake literal hex into their own scoped --bs-btn-*
   properties (confirmed in Phase 2 for .btn-primary) rather than reading
   the root color variables -- each used color variant needs the same
   explicit override. Text color per variant follows whichever of black/
   white actually passes contrast against that specific background. */
.btn-success {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--success);
    --bs-btn-border-color: var(--success);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--success-text);
    --bs-btn-hover-border-color: var(--success-text);
    --bs-btn-focus-shadow-rgb: var(--bs-success-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--success-text);
    --bs-btn-active-border-color: var(--success-text);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--success);
    --bs-btn-disabled-border-color: var(--success);
}

.btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-strong);
    --bs-btn-hover-border-color: var(--brand-strong);
    --bs-btn-focus-shadow-rgb: var(--bs-danger-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-warning {
    --bs-btn-color: #000;
    --bs-btn-bg: var(--warning);
    --bs-btn-border-color: var(--warning);
    --bs-btn-hover-color: #000;
    --bs-btn-hover-bg: var(--warning-text);
    --bs-btn-hover-border-color: var(--warning-text);
    --bs-btn-focus-shadow-rgb: var(--bs-warning-rgb);
    --bs-btn-active-color: #000;
    --bs-btn-active-bg: var(--warning-text);
    --bs-btn-active-border-color: var(--warning-text);
    --bs-btn-disabled-color: #000;
    --bs-btn-disabled-bg: var(--warning);
    --bs-btn-disabled-border-color: var(--warning);
}

.btn-info {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--info);
    --bs-btn-border-color: var(--info);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--info-text);
    --bs-btn-hover-border-color: var(--info-text);
    --bs-btn-focus-shadow-rgb: var(--bs-info-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--info-text);
    --bs-btn-active-border-color: var(--info-text);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--info);
    --bs-btn-disabled-border-color: var(--info);
}

/* Outline variants bake the same literal hex into their own scoped
   properties too -- only the three actually used in this app get the
   explicit override (warning/info outline buttons aren't used anywhere). */
.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
    --bs-btn-disabled-color: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-danger {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: var(--bs-danger-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
    --bs-btn-disabled-color: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-success {
    --bs-btn-color: var(--success);
    --bs-btn-border-color: var(--success);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--success);
    --bs-btn-hover-border-color: var(--success);
    --bs-btn-focus-shadow-rgb: var(--bs-success-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--success);
    --bs-btn-active-border-color: var(--success);
    --bs-btn-disabled-color: var(--success);
    --bs-btn-disabled-border-color: var(--success);
}

/* Cards + quiet headers: .card and .card-header are fully variable-driven
   in Bootstrap 5.3 (confirmed by reading the vendored CSS), so this alone
   restyles every card app-wide -- EXCEPT instances with bg-primary/bg-light
   text-white utility classes still applied directly in markup (those use
   !important and win regardless); those need the utility classes removed
   at the markup level, done page-by-page separately from this file. */
.card {
    --bs-card-border-radius: var(--radius-lg);
    --bs-card-border-color: var(--border);
    --bs-card-cap-bg: transparent;
    --bs-card-cap-color: var(--text);
    --bs-card-bg: var(--surface);
    --bs-card-color: var(--text);
}

/* Tables: token colors + uppercase muted column headers, matching the
   mockup's th{} rule. --bs-table-bg defaults to --bs-body-bg (mapped to
   --page in Phase 2) which would mismatch a table sitting inside a
   --surface card, so it's pinned to --surface directly here instead. */
.table {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-hover-color: var(--text);
}

    .table > thead > tr > th {
        text-transform: uppercase;
        font-size: .75rem;
        letter-spacing: .04em;
        font-weight: 600;
        color: var(--text-muted);
    }

/* Small general-purpose utility, same spirit as Bootstrap's own .bg-light/
   .bg-white but theme-aware (bg-light stays literally light in dark mode). */
.bg-surface-2 {
    background-color: var(--surface-2) !important;
}

/* Charcoal for dark buttons (light mode; dark mode keeps Bootstrap's). */
:root:not([data-bs-theme="dark"]) .btn-dark {
    --bs-btn-bg: #3D3D3D;
    --bs-btn-border-color: #3D3D3D;
    --bs-btn-hover-bg: #2a2a2a;
    --bs-btn-hover-border-color: #2a2a2a;
    --bs-btn-active-bg: #2a2a2a;
    --bs-btn-active-border-color: #2a2a2a;
}

/*
 * Semantic status badges. Pick the class by MEANING, not by colour, so the
 * palette can change in one place:
 *
 *   .status-success  done / good     Won, Completed, Succeeded, Resolved
 *   .status-info     new / open      New, Open, Qualified
 *   .status-warning  in progress     Contacted, Assigned, In progress, Running
 *   .status-danger   bad / overdue   Lost, Failed, Overdue
 *   .status-neutral  inactive        Draft, Expired, Withdrawn, Archived, Closed
 *   .status-brand    highlight       Use sparingly (e.g. a "Hot" lead)
 *
 * Usage: <span class="badge badge-status status-success">Won</span>
 * Soft background + dark text keeps each pair at WCAG AA or better in
 * light and dark mode.
 */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: .35em;
    padding: .35em .65em;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .02em;
    white-space: nowrap;
}

    /* Optional leading dot: class="badge badge-status status-info dot" */
    .badge-status.dot::before {
        content: "";
        width: .5em;
        height: .5em;
        border-radius: 50%;
        background: currentColor;
    }

.status-success { background: var(--success-bg); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.status-info    { background: var(--info-bg);    color: var(--info-text);    border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.status-warning { background: var(--warning-bg); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.status-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.status-neutral { background: var(--neutral-bg); color: var(--neutral-text); border-color: color-mix(in srgb, var(--neutral) 35%, transparent); }
.status-brand   { background: var(--brand);      color: #fff;                border-color: var(--brand); }

/*
 * Shared list tables (Pages/Shared/_SortableTable.cshtml).
 * Card-style frame, sticky header, sort indicators, clickable rows, empty state.
 */
.list-table-wrap {
    /* Start below any floated page controls (search box, buttons) instead of
       squeezing in beside them -- overflow:auto makes the box avoid floats. */
    clear: both;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: auto;
}

    .list-table-wrap.list-table-scroll {
        max-height: 70vh;
    }

@media (max-width: 576px) {
    .list-table-wrap.list-table-scroll {
        max-height: 60vh;
    }
}

.list-table {
    margin-bottom: 0;
}

    .list-table > thead > tr > th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
        vertical-align: middle;
    }

    .list-table > tbody > tr:last-child > td {
        border-bottom: 0;
    }

    .list-table > tbody > tr[data-href] {
        cursor: pointer;
    }

    .list-table > tbody > tr.list-table-empty > td {
        text-align: center;
        color: var(--text-muted);
        padding: 2rem 1rem;
    }

/* Sortable headers (also used by any table.table-sortable). */
.table-sortable th.sortable {
    cursor: pointer;
    user-select: none;
}

    .table-sortable th.sortable::after {
        content: "\2195"; /* up-down arrow: sortable, not sorted */
        margin-left: .35rem;
        font-size: .8em;
        opacity: .35;
    }

    .table-sortable th.sortable:hover::after {
        opacity: .7;
    }

    .table-sortable th.sortable[aria-sort="ascending"]::after {
        content: "\25B2";
        opacity: .9;
    }

    .table-sortable th.sortable[aria-sort="descending"]::after {
        content: "\25BC";
        opacity: .9;
    }

    .table-sortable th.sortable[aria-sort] {
        color: var(--text);
    }

    .table-sortable th.sortable:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: -2px;
    }

/*
 * KPI tiles (Pages/Shared/_KpiTile.cshtml). Wrap tiles in .kpi-grid.
 * Tone adds a coloured top edge; the number itself stays in body text colour
 * so it reads at a glance in light and dark mode.
 */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.kpi-tile {
    display: block;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px 14px;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
}

    .kpi-tile::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        height: 3px;
        background: transparent;
    }

a.kpi-tile:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
}

a.kpi-tile:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.kpi-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.kpi-info::before { background: var(--info); }
.kpi-success::before { background: var(--success); }
.kpi-warning::before { background: var(--warning); }
.kpi-danger::before { background: var(--brand); }
.kpi-danger .kpi-value { color: var(--brand); }

/* Rows hidden by the proposal-type filter (_AlcFilter). !important so it wins
   over pages that set row.style.display for their own filters. */
tr.alc-filtered {
    display: none !important;
}

/* Compact KPI row for list pages: <div class="kpi-grid kpi-grid-mini">.
   clear:both keeps it below floated page controls (grid boxes avoid floats). */
.kpi-grid-mini {
    clear: both;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin: 12px 0 16px;
}

    .kpi-grid-mini .kpi-tile {
        padding: 10px 14px 9px;
        border-radius: var(--radius);
    }

    .kpi-grid-mini .kpi-label {
        font-size: .6875rem;
    }

    .kpi-grid-mini .kpi-value {
        font-size: 1.375rem;
        margin-top: 2px;
    }

    .kpi-grid-mini .kpi-sub {
        font-size: .75rem;
    }

/*
 * Grouped, collapsible main menu (Pages/Shared/_SideNav.cshtml, Navigation/NavMenu.cs).
 * Items inherit the base .app-sidenav a styles above (hover, active bar).
 */
.app-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
}

.app-nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 12px;
    margin: 1px 0;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--nav-text);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}

    .app-nav-group-toggle:hover {
        background: rgba(255,255,255,.06);
        color: #fff;
    }

    .app-nav-group-toggle:focus-visible,
    .app-sidenav a:focus-visible {
        outline: 2px solid var(--nav-active);
        outline-offset: -2px;
    }

    .app-nav-group-toggle i.bi {
        font-size: 16px;
        flex-shrink: 0;
        opacity: .9;
    }

.app-nav-group.is-active > .app-nav-group-toggle {
    color: #fff;
    font-weight: 600;
}

.app-nav-group-label {
    flex: 1;
}

.app-nav-group-toggle .app-nav-chevron {
    font-size: 11px;
    opacity: .6;
    transition: transform .15s ease;
}

.app-nav-group-toggle[aria-expanded="true"] .app-nav-chevron {
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
    .app-nav-group-toggle .app-nav-chevron {
        transition: none;
    }
}

.app-nav-group-items {
    padding: 0 0 4px 14px;
}

    .app-nav-group-items .app-nav-item {
        font-size: 13px;
        padding: 7px 10px;
        gap: 9px;
    }

        .app-nav-group-items .app-nav-item i.bi {
            font-size: 14px;
        }

.app-nav-item.indent-1 { padding-left: 22px !important; }
.app-nav-item.indent-2 { padding-left: 34px !important; }
.app-nav-item.indent-3 { padding-left: 46px !important; }

.app-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav-item.is-soon {
    color: #9a9da2;
}

    .app-nav-item.is-soon i.bi {
        opacity: .55;
    }

.app-nav-tag {
    flex-shrink: 0;
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 0 6px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.2);
    color: #b4b7bb;
}

.app-nav-tag-preview {
    border-color: color-mix(in srgb, var(--warning) 60%, transparent);
    color: var(--warning);
}

/* Placeholder page for not-yet-built features (Pages/Soon.cshtml). */
.soon-page {
    display: flex;
    justify-content: center;
    padding: 48px 0;
}

.soon-card {
    max-width: 520px;
    width: 100%;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
}

.soon-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand);
}

.soon-eyebrow {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.soon-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 4px 0 8px;
}

.soon-desc {
    margin-bottom: 16px;
}

.soon-note {
    color: var(--text-muted);
    font-size: .875rem;
    margin: 16px 0 20px;
}

/* Account menu on the topbar avatar (_Layout). */
.app-avatar-btn {
    border: 0;
    padding: 0;
    cursor: pointer;
}

    .app-avatar-btn:hover {
        filter: brightness(1.08);
    }

    .app-avatar-btn:focus-visible {
        outline: 2px solid var(--brand);
        outline-offset: 2px;
    }

.app-user-menu {
    min-width: 240px;
    padding-top: 0;
}

.app-user-menu-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 6px;
}

    .app-user-menu-head .min-w-0 {
        min-width: 0;
    }

/* Morphius, fixed at the bottom of the sidebar (_MorphiusDock). */
.morphius-dock {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px !important;
    border-radius: var(--radius-lg) !important;
    background: linear-gradient(135deg, rgba(239,65,54,.18), rgba(239,65,54,.06));
    border: 1px solid rgba(239,65,54,.28);
    color: #fff !important;
}

    .morphius-dock:hover {
        background: linear-gradient(135deg, rgba(239,65,54,.26), rgba(239,65,54,.10)) !important;
    }

    .morphius-dock.active::before {
        display: none;
    }

    .morphius-dock.active {
        border-color: var(--nav-active);
    }

.morphius-dock-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: #fff;
    font-size: 16px;
}

.morphius-dock-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.morphius-dock-name {
    font-weight: 700;
    font-size: 13.5px;
}

.morphius-dock-sub {
    font-size: 11px;
    color: #b4b7bb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* List-page toolbar + filters (site.js "List-page filters"). */
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin-bottom: 12px;
}

    .list-toolbar .list-search {
        width: 260px;
        max-width: 100%;
    }

.list-count {
    margin-left: auto;
    font-size: .8125rem;
    color: var(--text-muted);
}

tr.list-filtered {
    display: none !important;
}

/* Morphius chat panel (_MorphiusPanel, morphius.js). */
.morphius-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, .18);
}

    .morphius-panel[hidden] {
        display: none;
    }

/* On wide screens, make room instead of covering the page. */
@media (min-width: 1400px) {
    body.morphius-open .app-main {
        margin-right: 420px;
    }
}

.morphius-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

    .morphius-head .min-w-0 {
        min-width: 0;
    }

.morphius-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.morphius-empty {
    color: var(--text);
    font-size: .9rem;
}

.morphius-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.morphius-chip {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: .8125rem;
    cursor: pointer;
}

    .morphius-chip:hover {
        border-color: var(--brand);
    }

.morphius-msg {
    position: relative;
    max-width: 92%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: .9rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

    .morphius-msg p {
        margin: 0 0 .5em;
    }

        .morphius-msg p:last-of-type {
            margin-bottom: 0;
        }

    .morphius-msg ul, .morphius-msg ol {
        margin: 0 0 .5em;
        padding-left: 1.2em;
    }

    .morphius-msg pre {
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 8px;
        margin: .4em 0;
        white-space: pre-wrap;
        font-size: .8125rem;
    }

.morphius-user {
    align-self: flex-end;
    background: var(--brand);
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

.morphius-assistant {
    align-self: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    padding-right: 34px;
}

.morphius-thinking {
    align-self: flex-start;
    color: var(--text-muted);
    font-style: italic;
    background: transparent;
}

.morphius-error {
    align-self: stretch;
    max-width: 100%;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: .8125rem;
}

.morphius-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    border: 0;
    background: none;
    color: var(--text-muted);
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
}

    .morphius-copy:hover {
        color: var(--text);
        background: var(--surface);
    }

.morphius-compose {
    border-top: 1px solid var(--border);
    padding: 10px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

    .morphius-compose textarea {
        resize: none;
        font-size: .9rem;
    }

.morphius-compose-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

button.morphius-dock, a.morphius-dock[data-morphius-toggle] {
    cursor: pointer;
}

/* Sales > Touches (Pages/Sales/Touches.cshtml). */
tr.touch-row {
    cursor: pointer;
}

.touch-preview {
    max-width: 480px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.touch-body {
    overflow-wrap: anywhere;
}

    .touch-body img {
        max-width: 100%;
        height: auto;
    }

/* Settings > Roles (Pages/Ncss/Roles.cshtml) and Users. */
.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.role-card-title {
    font-size: 1.05rem;
    margin: 0 0 2px;
}

.role-perms {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.role-perm {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75rem;
    border: 1px solid var(--bs-border-color);
    white-space: nowrap;
}

    .role-perm small {
        font-size: .6875rem;
        opacity: .8;
    }

    .role-perm.is-edit {
        background: rgba(200, 49, 42, .1);
        border-color: rgba(200, 49, 42, .35);
    }

    .role-perm.is-view {
        background: var(--bs-tertiary-bg);
    }

    .role-perm.is-none {
        color: var(--bs-secondary-color);
        opacity: .6;
    }

.role-members {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    border-top: 1px solid var(--bs-border-color);
    padding-top: 10px;
}

.role-member {
    font-size: .8125rem;
    background: var(--bs-tertiary-bg);
    border-radius: 4px;
    padding: 1px 6px;
}

.role-perm-table td:first-child {
    width: 70%;
}

.role-member-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
}

.role-member-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 0;
    cursor: pointer;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

    .role-member-option:last-child {
        border-bottom: 0;
    }

    .role-member-option .form-check-input {
        margin: 0;
        flex-shrink: 0;
    }

    .role-member-option .text-muted {
        margin-left: auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.user-role-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

/* Access denied page (Areas/Identity/Pages/Account/AccessDenied.cshtml). */
.access-denied {
    max-width: 520px;
    margin: 48px auto;
    text-align: center;
}

.access-denied-icon {
    font-size: 2.5rem;
    color: var(--bs-secondary-color);
    display: block;
    margin-bottom: 8px;
}

/* Small notice for blocked HTMX actions (site.js). */
.crm-toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1090;
    max-width: 360px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-left: 4px solid #C8312A;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
    font-size: .875rem;
}

/* Sales leaderboard (Pages/Sales/Leaderboard.cshtml). */
.leaderboard-won {
    min-width: 180px;
    width: 32%;
}

.leaderboard-bar-wrap {
    position: relative;
    height: 22px;
    display: flex;
    align-items: center;
}

.leaderboard-bar {
    position: absolute;
    inset: 2px auto 2px 0;
    border-radius: 3px;
    background: rgba(200, 49, 42, .22);
    min-width: 0;
}

.leaderboard-bar-value {
    position: relative;
    padding-left: 6px;
    font-variant-numeric: tabular-nums;
}

.leaderboard-medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: .75rem;
    font-weight: 700;
    color: #1d1d1d;
}

    .leaderboard-medal.medal-1 { background: #E8C547; }
    .leaderboard-medal.medal-2 { background: #C9CED6; }
    .leaderboard-medal.medal-3 { background: #D29A62; }

tr.leaderboard-me > td {
    background: rgba(200, 49, 42, .06);
}

/* Floated page controls (Customers, Leads): keep a gap above the content that clears them,
   now that the in-page heading is gone (the top bar is the only title). */
.app-main .btn.float-end,
.app-main input.float-end,
.app-main select.float-end {
    margin-bottom: 10px;
}

/* Top bar quick add ("New" menu, _Layout.cshtml). */
.app-quick-add {
    height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
}

/* Morphius: data used for an answer (morphius.js). */
.morphius-sql {
    margin-top: 8px;
    font-size: .75rem;
}

    .morphius-sql summary {
        cursor: pointer;
        color: var(--text-muted);
    }

    .morphius-sql pre {
        margin: 6px 0 2px;
        padding: 6px 8px;
        border-radius: 6px;
        background: var(--surface-2, rgba(127, 127, 127, .12));
        white-space: pre-wrap;
        word-break: break-word;
        font-size: .75rem;
    }

.morphius-sql-meta {
    color: var(--text-muted);
    margin-bottom: 4px;
}

/*
 * Dashboard scoreboard and gamified goal tiles (Pages/Dashboard, Pages/Shared/_GoalTile.cshtml,
 * Services/Kpis). Tiers: gold = goal reached, silver = on pace, bronze = behind. Meters use one
 * hue; the pace marker shows where the period is today.
 */
.scoreboard {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
    gap: 16px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

    .scoreboard::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: var(--neutral);
    }

    .scoreboard.scoreboard-legend::before,
    .scoreboard.scoreboard-all-star::before { background: var(--success); }
    .scoreboard.scoreboard-pro::before { background: var(--info); }
    .scoreboard.scoreboard-contender::before { background: var(--warning); }
    .scoreboard.scoreboard-rookie::before { background: var(--brand); }

@media (max-width: 767.98px) {
    .scoreboard {
        grid-template-columns: 1fr;
    }
}

.scoreboard-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 575.98px) {
    .scoreboard-main {
        grid-template-columns: 1fr;
    }
}

.scoreboard-number {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 6px;
}

.scoreboard-of {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 2px;
}

.scoreboard-level {
    margin-top: 6px;
    font-weight: 600;
}

.scoreboard-hero-number {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin: 6px 0 10px;
}

.scoreboard-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

@media (max-width: 767.98px) {
    .scoreboard-side {
        border-left: 0;
        padding-left: 0;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }
}

.scoreboard-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
}

.scoreboard-medals {
    display: inline-flex;
    gap: 6px;
}

.goal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}

.goal-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px 12px;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
}

    .goal-tile::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        height: 3px;
        background: transparent;
    }

    .goal-tile.goal-gold::before { background: #E8C547; }
    .goal-tile.goal-silver::before { background: var(--info); }
    .goal-tile.goal-bronze::before { background: var(--warning); }

a.goal-tile:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
}

a.goal-tile:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.goal-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.goal-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    margin-top: 4px;
}

.goal-meta {
    font-size: .8125rem;
    display: flex;
    gap: 6px;
    align-items: baseline;
    min-height: 1.2em;
}

.goal-delta {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.goal-delta-good { color: var(--success-text); }
.goal-delta-bad { color: var(--danger-text); }

.goal-medal {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .02em;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    background: var(--neutral-bg);
    color: var(--neutral-text);
}

.goal-medal-gold { background: #f6e9b5; color: #6b5300; }
.goal-medal-silver { background: var(--info-bg); color: var(--info-text); }
.goal-medal-bronze { background: var(--warning-bg); color: var(--warning-text); }

[data-bs-theme="dark"] .goal-medal-gold { background: #3d3410; color: #f0d76a; }

.goal-meter {
    position: relative;
    height: 6px;
    margin-top: 8px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--info) 18%, var(--surface-2));
}

.goal-meter-lg {
    height: 10px;
    border-radius: 5px;
}

.goal-meter-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--info);
    transition: width .4s ease;
}

.goal-gold .goal-meter-fill { background: #d9b53a; }
.goal-bronze .goal-meter-fill,
.goal-none .goal-meter-fill { background: var(--warning); }

.goal-pace {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    margin-left: -1px;
    background: var(--text-muted);
    opacity: .7;
}

.goal-target {
    font-size: .75rem;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Charts (Pages/Shared/Charts). One hue, thin marks, hairline grid; emphasis = current period. */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px 10px;
    min-width: 0;
}

.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.chart-title {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.chart-subtitle {
    font-size: .8125rem;
    color: var(--text-muted);
}

.chart-empty {
    color: var(--text-muted);
    font-size: .875rem;
    padding: 24px 0;
    text-align: center;
}

.chart-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.chart-svg .chart-grid {
    display: initial;
    stroke: var(--border);
    stroke-width: 1;
}

.chart-axis {
    stroke: var(--border);
    stroke-width: 1;
}

.chart-tick {
    font-size: 12px;
    fill: var(--text-muted);
}

@media (min-width: 768px) {
    .chart-card-wide {
        grid-column: span 2;
    }
}

.chart-bar {
    fill: color-mix(in srgb, var(--info) 55%, var(--surface));
}

.chart-col-emphasis .chart-bar {
    fill: var(--info);
}

.chart-hit {
    fill: transparent;
}

.chart-col:hover .chart-bar {
    fill: var(--info);
}

.chart-col:hover .chart-hit {
    fill: color-mix(in srgb, var(--text) 5%, transparent);
}

.chart-table {
    margin-top: 6px;
    font-size: .8125rem;
}

    .chart-table summary {
        color: var(--text-muted);
        cursor: pointer;
    }

    .chart-table .table {
        margin-top: 6px;
    }

.bar-list {
    display: grid;
    grid-template-columns: minmax(80px, auto) minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    font-size: .875rem;
}

.bar-row {
    display: contents;
}

.bar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    height: 14px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--info) 10%, var(--surface-2));
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    background: color-mix(in srgb, var(--info) 55%, var(--surface));
    min-width: 2px;
}

.bar-row-emphasis .bar-fill {
    background: var(--info);
}

.bar-row:hover .bar-fill {
    background: var(--info);
}

.bar-value {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.bar-share {
    color: var(--text-muted);
    font-size: .75rem;
    margin-left: 6px;
    display: inline-block;
    min-width: 2.5em;
}

/* By-product tables (Pages/Sales/Products, dashboard product card). */
.bar-cell {
    min-width: 150px;
}

.leaderboard-bar.bar-revenue {
    background: color-mix(in srgb, var(--info) 30%, transparent);
}

.product-table td,
.product-table th {
    font-variant-numeric: tabular-nums;
}

.proposal-breakdown summary {
    cursor: pointer;
}

/* Pipeline kanban (Pages/Sales/Pipeline). Proof of concept with sample data; columns scroll
   sideways on narrow screens, cards are HTML5-draggable (wwwroot/js/pipeline.js). */
.kanban {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    scroll-snap-type: x proximity;
}

.kanban-col {
    flex: 0 0 250px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 230px);
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    scroll-snap-align: start;
    transition: border-color .12s, box-shadow .12s;
}

    .kanban-col.kanban-col-closed {
        flex-basis: 210px;
    }

    .kanban-col.is-over {
        border-color: var(--info);
        box-shadow: inset 0 0 0 1px var(--info);
    }

.kanban-col-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
}

.kanban-col-title {
    font-size: .8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Click-to-rename stage names (pipeline.js startRename). */
.kanban-col-title[data-stage-title] {
    cursor: text;
    border-radius: 4px;
    padding: 1px 4px;
    margin-left: -4px;
}

    .kanban-col-title[data-stage-title]:hover,
    .kanban-col-title[data-stage-title]:focus-visible {
        background: var(--surface);
        outline: 1px dashed var(--border);
    }

    .kanban-col-title.is-editing {
        flex: 1 1 auto;
        padding: 0;
        margin-left: 0;
        overflow: visible;
        background: none;
        outline: none;
    }

.kanban-col-rename {
    height: 26px;
    padding: 2px 6px;
    font-size: .8125rem;
    font-weight: 600;
    min-width: 0;
}

.kanban-col-count {
    font-variant-numeric: tabular-nums;
}

.kanban-col-total {
    margin-left: auto;
    font-size: .8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kanban-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    min-height: 80px;
    overflow-y: auto;
}

    .kanban-cards.is-empty::after {
        content: "Drop here";
        display: block;
        padding: 18px 0;
        text-align: center;
        font-size: .8125rem;
        color: var(--text-muted);
        border: 1px dashed var(--border);
        border-radius: var(--radius);
    }

.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transition: box-shadow .12s, opacity .12s;
}

    .kanban-card:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
    }

    .kanban-card:active {
        cursor: grabbing;
    }

    .kanban-card.is-dragging {
        opacity: .45;
    }

    .kanban-card.is-moved {
        border-left: 3px solid var(--info);
    }

.kanban-card-company {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    font-size: .75rem;
    color: var(--text-muted);
}

.kanban-card-title {
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.3;
    margin: 2px 0 6px;
}

.kanban-card-meta,
.kanban-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: .8125rem;
}

.kanban-card-foot {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: .75rem;
}

.kanban-card-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.kanban-card-rep {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.kanban-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--info-bg);
    color: var(--info-text);
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.kanban-col-closed .kanban-card {
    opacity: .85;
}
