/* ==========================================================
   CARBUYSEL DESIGN SYSTEM
   Replaces the old site.css + cental-theme.css layers.

   COLOUR — built on the colour wheel
   Base hue: brand red (352deg). Its split-complements are
   teal (172 - 15 = ~165deg) and azure (172 + 45 = ~215deg).
   Navy (222deg) is a deep, desaturated azure, so it sits in
   the same family as the info colour. Amber (38deg) completes
   a loose triad for warnings.

   Proportion follows the 60-30-10 rule:
     60%  cool neutrals (tinted toward navy, hue 220)
     30%  navy  - header, sidebar, table heads
     10%  red   - primary actions, active states, focus
   Teal / azure / amber are reserved for meaning
   (money in, info, attention), never decoration.
   ========================================================== */

:root {
    /* Brand red, hue 352 */
    --brand-50: #fff1f3;
    --brand-100: #ffe0e5;
    --brand-500: #e3173a;
    --brand-600: #c8102e;
    --brand-700: #a50d27;

    /* Navy, hue 222 */
    --navy-900: #0b1324;
    --navy-800: #131e36;
    --navy-700: #1c2a4a;
    --navy-600: #27385f;
    --navy-500: #3a4d78;

    /* Split-complements and triad, used for meaning only */
    --teal-600: #0e8f7a;
    --teal-50: #e7f7f3;
    --azure-600: #2463d6;
    --azure-50: #eaf1fd;
    --amber-500: #e89611;
    --amber-50: #fdf4e3;

    /* Neutrals, tinted to hue 220 */
    --gray-0: #ffffff;
    --gray-25: #f9fafc;
    --gray-50: #f3f5f9;
    --gray-100: #e9edf3;
    --gray-200: #dce2eb;
    --gray-300: #c4ccd8;
    --gray-500: #6b778c;
    --gray-700: #3d4759;
    --gray-900: #141b29;

    /* Semantic roles */
    --c-bg: var(--gray-50);
    --c-surface: var(--gray-0);
    --c-surface-alt: var(--gray-25);
    --c-border: var(--gray-200);
    --c-text: var(--gray-900);
    --c-text-soft: var(--gray-700);
    --c-muted: var(--gray-500);
    --c-primary: var(--brand-500);
    --c-primary-hover: var(--brand-600);
    --c-primary-soft: var(--brand-50);
    --c-chrome: var(--navy-700);
    --c-chrome-dark: var(--navy-800);
    --c-success: var(--teal-600);
    --c-info: var(--azure-600);
    --c-warning: var(--amber-500);
    --c-danger: var(--brand-600);

    /* Shape, depth, motion */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(11, 19, 36, .06);
    --shadow-sm: 0 1px 3px rgba(11, 19, 36, .08), 0 1px 2px rgba(11, 19, 36, .04);
    --shadow-md: 0 6px 18px rgba(11, 19, 36, .08), 0 2px 6px rgba(11, 19, 36, .05);
    --shadow-lg: 0 18px 40px rgba(11, 19, 36, .16);
    --ring: 0 0 0 3px rgba(227, 23, 58, .18);
    --ease: cubic-bezier(.2, .7, .2, 1);

    /* Layout */
    --header-h: 64px;
    --sidebar-w: 264px;
    --control-h: 40px;

    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-head: "Montserrat", "Inter", system-ui, sans-serif;

    /* Old token names still used by some views */
    --cental-primary: var(--c-primary);
    --cental-primary-dark: var(--c-primary-hover);
    --cental-primary-soft: var(--c-primary-soft);
    --cental-secondary: var(--c-chrome);
    --cental-secondary-light: var(--navy-600);
    --cental-dark: var(--navy-900);
    --cental-light: var(--c-bg);
    --cental-white: #fff;

    /* Point Bootstrap at the palette */
    --bs-primary: #e3173a;
    --bs-primary-rgb: 227, 23, 58;
    --bs-secondary: #1c2a4a;
    --bs-secondary-rgb: 28, 42, 74;
    --bs-success: #0e8f7a;
    --bs-success-rgb: 14, 143, 122;
    --bs-info: #2463d6;
    --bs-info-rgb: 36, 99, 214;
    --bs-warning: #e89611;
    --bs-warning-rgb: 232, 150, 17;
    --bs-danger: #c8102e;
    --bs-danger-rgb: 200, 16, 46;
    --bs-dark: #0b1324;
    --bs-dark-rgb: 11, 19, 36;
    --bs-light: #f3f5f9;
    --bs-light-rgb: 243, 245, 249;
    --bs-body-font-family: var(--font-body);
    --bs-body-color: #141b29;
    --bs-body-bg: #f3f5f9;
    --bs-border-color: #dce2eb;
    --bs-link-color: #c8102e;
    --bs-link-color-rgb: 200, 16, 46;
    --bs-link-hover-color: #1c2a4a;
    --bs-link-hover-color-rgb: 28, 42, 74;
}

/* ---------- BASE ---------- */

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--c-text);
    background: var(--c-bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-head);
    color: var(--c-text);
    letter-spacing: -.01em;
}

a {
    color: var(--c-primary-hover);
    text-decoration: none;
}

    a:hover {
        color: var(--c-chrome);
    }

:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

::selection {
    background: var(--brand-100);
}

.text-primary { color: var(--c-primary) !important; }
.text-secondary { color: var(--c-chrome) !important; }
.text-success { color: var(--c-success) !important; }
.text-danger { color: var(--c-danger) !important; }
.bg-primary { background-color: var(--c-primary) !important; }
.bg-secondary { background-color: var(--c-chrome) !important; }

/* Hide number spinners app-wide (several views did this inline) */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

/* ---------- HEADER ---------- */

.top-navbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--header-h);
    padding: 0 20px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--c-border);
    z-index: 1040;
}

    .top-navbar .container-fluid {
        display: flex;
        align-items: center;
        gap: 14px;
        flex-wrap: nowrap;
        padding: 0;
    }

.menu-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-surface);
    color: var(--c-chrome);
    font-size: 16px;
    cursor: pointer;
    transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}

    .menu-btn:hover {
        background: var(--c-chrome);
        border-color: var(--c-chrome);
        color: #fff;
    }

.cental-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -.02em;
    color: var(--c-chrome) !important;
    white-space: nowrap;
}

    .cental-brand .brand-icon {
        width: 34px;
        height: 34px;
        border-radius: var(--radius-sm);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--c-primary);
        color: #fff;
        font-size: 16px;
    }

    .cental-brand .brand-accent {
        color: var(--c-primary);
    }

    .cental-brand img {
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
        border-radius: var(--radius-sm);
        object-fit: contain;
        background: #fff;
        border: 1px solid var(--c-border);
        padding: 2px;
    }

    .cental-brand .org-name {
        font-size: 17px;
        font-weight: 700;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    background: var(--c-surface);
    color: var(--c-text-soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

    .header-user .user-badge {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--c-chrome);
        color: #fff;
        font-size: 12px;
    }

.header-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid rgba(200, 16, 46, .28);
    border-radius: 999px;
    background: var(--brand-50);
    color: var(--brand-600);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}

    .header-logout:hover,
    .header-logout:focus-visible {
        background: var(--c-primary);
        border-color: var(--c-primary);
        color: #fff;
    }

/* ---------- SIDEBAR ---------- */

.sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    padding: 16px 0 12px;
    background: var(--c-chrome);
    background-image: linear-gradient(180deg, var(--navy-700) 0%, var(--navy-800) 100%);
    overflow-y: auto;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
    scrollbar-width: thin;
    scrollbar-color: var(--navy-500) transparent;
}

    .sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sidebar .nav {
        min-height: 100%;
        flex-wrap: nowrap;
    }

    .sidebar .nav-section {
        padding: 14px 24px 6px;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: .12em;
        text-transform: uppercase;
        color: rgba(255, 255, 255, .42);
    }

    .sidebar .nav-link {
        position: relative;
        display: flex;
        align-items: center;
        gap: 12px;
        margin: 2px 12px;
        padding: 10px 12px;
        border-radius: var(--radius-sm);
        color: rgba(255, 255, 255, .78);
        font-size: 14px;
        font-weight: 500;
        background: transparent;
        transition: background .18s var(--ease), color .18s var(--ease);
        cursor: pointer;
    }

        .sidebar .nav-link > span:first-child {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .sidebar .nav-link:hover {
            background: rgba(255, 255, 255, .07);
            color: #fff;
        }

    .sidebar .menu-icon {
        width: 18px;
        text-align: center;
        font-size: 14px;
        color: rgba(255, 255, 255, .55);
        transition: color .18s var(--ease);
    }

    .sidebar .nav-link:hover .menu-icon {
        color: #fff;
    }

    .sidebar .active-main {
        background: rgba(255, 255, 255, .1);
        color: #fff;
        font-weight: 600;
    }

        .sidebar .active-main::before {
            content: "";
            position: absolute;
            left: -12px;
            top: 8px;
            bottom: 8px;
            width: 3px;
            border-radius: 0 3px 3px 0;
            background: var(--c-primary);
        }

        .sidebar .active-main .menu-icon {
            color: var(--c-primary);
        }

    .sidebar .collapse,
    .sidebar .collapsing {
        margin: 2px 0 6px;
    }

    .sidebar .sub-link {
        margin: 1px 12px 1px 42px;
        padding: 7px 12px;
        font-size: 13.5px;
        color: rgba(255, 255, 255, .62);
        border-radius: var(--radius-sm);
    }

        .sidebar .sub-link::before {
            content: "";
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background: rgba(255, 255, 255, .28);
            flex: 0 0 5px;
            transition: background .18s var(--ease);
        }

    .sidebar .active-sub {
        color: #fff;
        background: rgba(227, 23, 58, .16);
        font-weight: 600;
    }

        .sidebar .active-sub::before {
            background: var(--c-primary);
        }

    .sidebar .menu-arrow {
        margin-left: auto;
        font-size: 10px;
        opacity: .6;
        transition: transform .25s var(--ease);
    }

    .sidebar .nav-link[aria-expanded="true"] .menu-arrow {
        transform: rotate(180deg);
    }

.sidebar-overlay {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(11, 19, 36, .5);
    backdrop-filter: blur(2px);
    z-index: 1044;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s var(--ease), visibility .25s;
}

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

/* ---------- MAIN + FOOTER ---------- */

.main-content {
    margin-top: var(--header-h);
    min-height: calc(100vh - var(--header-h) - 52px);
    padding: 24px;
    transition: margin-left .28s var(--ease);
}

.cental-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px;
    padding: 16px 24px;
    font-size: 12.5px;
    color: var(--c-muted);
    border-top: 1px solid var(--c-border);
    background: var(--c-surface);
    transition: margin-left .28s var(--ease);
}

    .cental-footer a {
        color: var(--c-text-soft);
        font-weight: 600;
    }

        .cental-footer a:hover {
            color: var(--c-primary);
        }

/* Desktop: sidebar is docked open; the menu button collapses it */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0);
        box-shadow: none;
    }

    .main-content,
    .cental-footer {
        margin-left: var(--sidebar-w);
    }

    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-collapsed .main-content,
    body.sidebar-collapsed .cental-footer {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: none;
    }
}

/* ---------- PAGE CARD ---------- */

.main-content .page-container {
    max-width: 1440px;
    margin: 0 auto 24px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    padding-bottom: 8px;
}

.main-content .page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 18px 28px;
    background: var(--c-surface);
    color: var(--c-text);
    font-family: var(--font-head);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
}

    .main-content .page-header::before {
        content: "";
        width: 4px;
        height: 22px;
        border-radius: 4px;
        background: var(--c-primary);
        flex: 0 0 4px;
    }

.main-content .section-title,
.main-content .section-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin: 8px 0 0;
    padding: 14px 28px;
    background: var(--c-surface-alt);
    color: var(--c-chrome);
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: left;
    border: 0;
    border-top: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
    border-radius: 0;
}

.main-content .card,
.main-content .main-card {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.main-content .card-header {
    background: var(--c-surface-alt);
    color: var(--c-text);
    font-weight: 700;
    border-bottom: 1px solid var(--c-border);
}

.summary-box {
    height: 100%;
    padding: 14px 16px;
    background: var(--c-surface-alt);
    border: 1px solid var(--c-border);
    border-left: 3px solid var(--c-chrome);
    border-radius: var(--radius);
    color: var(--c-text);
    font-size: 14px;
    font-weight: 600;
}

.report-box {
    width: 100%;
    background: var(--c-surface);
}

/* Compact, consistent rhythm inside pages
   (the old site.css forced this with !important, views rely on it) */
.main-content .page-container .row {
    margin-bottom: 14px !important;
}

.main-content .container-fluid .row,
.main-content .container .row {
    margin-left: 0;
    margin-right: 0;
}

/* ---------- FORMS ---------- */

label,
.form-label {
    font-size: 13px;
    font-weight: 600 !important;
    color: var(--c-text-soft);
    margin-bottom: 4px;
}

    label .req {
        color: var(--c-primary);
        margin-left: 2px;
        font-weight: 700;
    }

.form-control,
.form-select,
.main-content select,
.main-content input[type=text],
.main-content input[type=number],
.main-content input[type=date],
.main-content input[type=email],
.main-content input[type=tel],
.main-content input[type=password],
.main-content input[type=file],
.main-content textarea {
    width: 100%;
    min-height: var(--control-h);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--c-text);
    background-color: var(--c-surface);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}

.main-content input[type=file] {
    padding: 6px 8px;
}

.main-content textarea,
textarea.form-control {
    min-height: 84px;
    resize: vertical;
}

    .form-control:hover,
    .form-select:hover,
    .main-content select:hover,
    .main-content input:hover,
    .main-content textarea:hover {
        border-color: var(--gray-500);
    }

    .form-control:focus,
    .form-select:focus,
    .main-content select:focus,
    .main-content input:focus,
    .main-content textarea:focus {
        outline: none;
        border-color: var(--c-primary);
        box-shadow: var(--ring);
    }

    .form-control[readonly],
    .main-content input[readonly],
    .form-control:disabled,
    .main-content input:disabled,
    .main-content select:disabled {
        background-color: var(--gray-50);
        color: var(--c-text-soft);
    }

    .form-control::placeholder,
    .main-content input::placeholder,
    .main-content textarea::placeholder {
        color: var(--gray-500);
        opacity: 1;
    }

/* Custom chevron for every select */
select.form-control,
.form-select,
.main-content select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%233d4759' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    cursor: pointer;
}

.main-content input[type=checkbox],
.main-content input[type=radio],
.form-check-input {
    width: 18px;
    min-height: 0;
    height: 18px;
    padding: 0;
    accent-color: var(--c-primary);
    box-shadow: none;
    vertical-align: middle;
}

.form-check-input:checked {
    background-color: var(--c-primary);
    border-color: var(--c-primary);
}

/* Only flag fields after the user has interacted with them */
.form-control:user-invalid,
.main-content select:user-invalid,
.main-content input:user-invalid {
    border-color: var(--c-danger);
}

.error-msg,
.field-validation-error,
.text-danger.small {
    margin-top: 4px;
    font-size: 12px !important;
    font-weight: 600;
    color: var(--c-danger) !important;
}

/* ---------- BUTTONS ---------- */

.btn,
.save-btn,
.btn-custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--control-h);
    padding: 8px 20px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .01em;
    border-radius: var(--radius-sm);
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}

    .btn:active,
    .save-btn:active,
    .btn-custom:active {
        transform: translateY(1px);
    }

    .btn:focus-visible,
    .save-btn:focus-visible,
    .btn-custom:focus-visible {
        outline: none;
        box-shadow: var(--ring);
    }

/* Primary action: the 10% red */
.btn-primary,
.save-btn,
.main-content .btn-custom {
    background: var(--c-primary) !important;
    border: 1px solid var(--c-primary) !important;
    color: #fff !important;
    box-shadow: 0 1px 2px rgba(200, 16, 46, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
    text-transform: none !important;
    cursor: pointer;
}

    .btn-primary:hover,
    .save-btn:hover,
    .main-content .btn-custom:hover {
        background: var(--c-primary-hover) !important;
        border-color: var(--c-primary-hover) !important;
        color: #fff !important;
    }

.save-btn {
    min-width: 128px;
}

/* Secondary: navy */
.btn-secondary,
.btn-info,
.btn-view {
    background: var(--c-chrome) !important;
    border: 1px solid var(--c-chrome) !important;
    color: #fff !important;
}

    .btn-secondary:hover,
    .btn-info:hover,
    .btn-view:hover {
        background: var(--navy-600) !important;
        border-color: var(--navy-600) !important;
        color: #fff !important;
    }

.btn-success {
    background: var(--c-success);
    border-color: var(--c-success);
    color: #fff;
}

    .btn-success:hover {
        background: #0b7a68;
        border-color: #0b7a68;
        color: #fff;
    }

.btn-warning {
    background: var(--c-warning);
    border-color: var(--c-warning);
    color: #fff !important;
}

    .btn-warning:hover {
        background: #cf830b;
        border-color: #cf830b;
    }

.btn-danger {
    background: var(--c-danger);
    border-color: var(--c-danger);
}

.btn-outline-primary {
    color: var(--c-primary);
    border-color: var(--c-primary);
    background: transparent;
}

    .btn-outline-primary:hover {
        background: var(--c-primary);
        border-color: var(--c-primary);
        color: #fff;
    }

.btn-light,
.btn-outline-secondary {
    background: var(--c-surface);
    border: 1px solid var(--gray-300);
    color: var(--c-text);
}

    .btn-light:hover,
    .btn-outline-secondary:hover {
        background: var(--gray-50);
        border-color: var(--gray-500);
        color: var(--c-text);
    }

/* ---------- ROW ACTION ICONS ----------
   Font Awesome icons in tinted chips, one hue per action from the
   palette: edit = azure, save = teal, cancel = gray, delete = brand red.
   The icon is either inside a button/link or is the control itself
   (.act-chip). */

.main-content :is(a, button):has(> .act-icon),
.act-chip,
.btn-edit,
.btn-update,
.btn-cancel,
.btn-delete,
.editBtn,
.saveBtn,
.cancelBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-height: 0;
    margin: 0 2px;
    padding: 0 !important;
    vertical-align: middle;
    border: 1px solid var(--act-line, var(--c-border)) !important;
    border-radius: var(--radius-sm);
    background: var(--act-soft, var(--gray-50)) !important;
    color: var(--act, var(--navy-600));
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
}

/* Page scripts re-show icons with style.display = "inline"; keep them chips */
.act-chip:not([style*="none"]),
.main-content :is(a, button):has(> .act-icon):not([style*="none"]) {
    display: inline-flex !important;
}

.act-icon {
    font-size: 14px;
    line-height: 1;
}

:is(.act-chip.act-edit, :has(> .act-edit), .btn-edit) {
    --act: var(--azure-600);
    --act-soft: var(--azure-50);
    --act-line: rgba(36, 99, 214, .28);
}

:is(.act-chip.act-save, :has(> .act-save), .btn-update) {
    --act: var(--teal-600);
    --act-soft: var(--teal-50);
    --act-line: rgba(14, 143, 122, .3);
}

:is(.act-chip.act-cancel, :has(> .act-cancel), .btn-cancel) {
    --act: var(--gray-700);
    --act-soft: var(--gray-50);
    --act-line: var(--gray-200);
}

:is(.act-chip.act-delete, :has(> .act-delete), .btn-delete) {
    --act: var(--brand-600);
    --act-soft: var(--brand-50);
    --act-line: rgba(200, 16, 46, .25);
}

    .main-content :is(a, button):has(> .act-icon):hover,
    .act-chip:hover {
        background: var(--act, var(--navy-600)) !important;
        border-color: var(--act, var(--navy-600)) !important;
        color: #fff;
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(11, 19, 36, .14);
    }

    .main-content :is(a, button):has(> .act-icon):focus-visible,
    .act-chip:focus-visible {
        outline: 2px solid var(--act, var(--navy-600));
        outline-offset: 2px;
    }

    .main-content :is(a, button):has(> .act-icon):active,
    .act-chip:active {
        transform: none;
        box-shadow: none;
    }

/* ---------- ORGANIZATION LOGO (grid) ---------- */

.org-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    overflow: hidden;
    vertical-align: middle;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: #fff;
}

    .org-logo img {
        width: 100%;
        height: 100%;
        padding: 3px;
        object-fit: contain;
    }

    .org-logo.is-missing {
        border-color: transparent;
        background: linear-gradient(135deg, var(--navy-600), var(--navy-700));
        color: #fff;
        font-family: var(--font-head);
        font-size: 14px;
        font-weight: 700;
        letter-spacing: .04em;
    }

        .org-logo.is-missing::before {
            content: attr(data-initials);
        }

.action-icon {
    cursor: pointer;
    transition: transform .15s var(--ease), opacity .15s var(--ease);
}

    .action-icon:hover {
        transform: scale(1.1);
    }

/* ---------- TABLES ---------- */

.table-wrapper,
.table-responsive,
.table-scroll,
.table-responsive-mobile,
.table-container,
.main-content .page-container div[style*="overflow-x"] {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

.main-content .page-container div[style*="overflow-x"],
.main-content .page-container .table-responsive,
.main-content .page-container .table-wrapper,
.main-content .page-container .table-responsive-mobile {
    padding: 0 20px 12px;
}

.table-container {
    max-height: 420px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}

.main-content .table {
    width: 100%;
    margin: 0 !important;
    font-size: 13.5px;
    color: var(--c-text);
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: transparent;
}

    .main-content .table > :not(caption) > * > * {
        border-width: 0 0 1px 0;
        border-color: var(--gray-100);
        box-shadow: none;
    }

    .main-content .table th,
    .main-content .table td {
        padding: 10px 14px !important;
        text-align: center;
        vertical-align: middle;
        white-space: nowrap;
    }

    .main-content .table thead th,
    .main-content table thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--c-chrome) !important;
        color: #fff !important;
        font-family: var(--font-body);
        font-size: 12px;
        font-weight: 700 !important;
        letter-spacing: .06em;
        text-transform: uppercase;
        border-color: var(--navy-600) !important;
    }

    .main-content .table tbody tr td {
        background: var(--c-surface) !important;
        transition: background-color .12s var(--ease);
    }

    .main-content .table tbody tr:nth-child(even) td {
        background: var(--c-surface-alt) !important;
    }

    .main-content .table tbody tr:hover td {
        background: var(--brand-50) !important;
    }

    .main-content .table tbody tr:last-child td {
        border-bottom: 0;
    }

    .main-content .table tfoot td,
    .main-content .table tfoot th {
        background: var(--gray-50) !important;
        font-weight: 700;
    }

    /* inline-edit controls inside rows */
    .main-content .table td input,
    .main-content .table td select {
        min-height: 34px;
        padding: 5px 8px;
        font-size: 13px;
        min-width: 110px;
    }

    .main-content .table td select {
        padding-right: 30px;
    }

.no-data {
    display: none;
    margin: 18px 20px;
    padding: 28px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--c-muted);
    background: var(--c-surface-alt);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius);
}

/* ---------- TOASTS ----------
   Views render #toastMsg / #errorToast with inline styles;
   these rules restyle them into consistent toasts. */

/* CarSale sets this one's colour from script, so only shape it */
#customMsg {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
}

#toastMsg,
#errorToast {
    position: fixed !important;
    top: calc(var(--header-h) + 16px) !important;
    right: 16px !important;
    left: auto !important;
    z-index: 2000 !important;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 16px 12px 14px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--c-text) !important;
    background: var(--c-surface) !important;
    border: 1px solid var(--c-border) !important;
    border-left: 4px solid var(--c-success) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg) !important;
    animation: toast-in .35s var(--ease);
}

    #toastMsg::before,
    #errorToast::before {
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        width: 24px;
        height: 24px;
        flex: 0 0 24px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #fff;
    }

    #toastMsg::before {
        content: "\f00c";
        background: var(--c-success);
    }

#errorToast {
    top: calc(var(--header-h) + 76px) !important;
    border-left-color: var(--c-danger) !important;
}

    #errorToast::before {
        content: "\f12a";
        background: var(--c-danger);
    }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

/* ---------- MODAL ---------- */

.modal-content {
    background: var(--c-surface);
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header,
.modal-footer {
    border-color: var(--c-border);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
}

.confirm-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-50);
    color: var(--c-primary);
    font-size: 18px;
    margin-bottom: 12px;
}

/* ---------- DASHBOARD BUILDING BLOCKS ---------- */

.page-hero {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding: 28px 28px;
    border-radius: var(--radius-lg);
    color: #fff;
    overflow: hidden;
    background:
        radial-gradient(600px 240px at 100% 0%, rgba(227, 23, 58, .35), transparent 60%),
        linear-gradient(135deg, var(--navy-800) 0%, var(--navy-600) 100%);
    box-shadow: var(--shadow-md);
}

    .page-hero .eyebrow {
        display: inline-block;
        margin-bottom: 6px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: .12em;
        text-transform: uppercase;
        color: rgba(255, 255, 255, .65);
    }

    .page-hero h1 {
        margin: 0;
        color: #fff;
        font-size: 28px;
        font-weight: 800;
    }

    .page-hero p {
        margin: 6px 0 0;
        color: rgba(255, 255, 255, .75);
    }

    .page-hero .hero-date {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 8px 14px;
        border-radius: 999px;
        background: rgba(255, 255, 255, .1);
        border: 1px solid rgba(255, 255, 255, .18);
        font-size: 13px;
        font-weight: 600;
    }

.section-label {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 28px 0 12px;
}

    .section-label h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 700;
    }

    .section-label span {
        font-size: 12px;
        font-weight: 600;
        letter-spacing: .08em;
        text-transform: uppercase;
        color: var(--c-muted);
    }

.stat-card {
    position: relative;
    height: 100%;
    padding: 18px 20px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease);
}

    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
        border-color: var(--gray-300);
    }

    .stat-card .stat-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 14px;
    }

    .stat-card .stat-label {
        font-size: 13px;
        font-weight: 600;
        color: var(--c-muted);
    }

    .stat-card .stat-icon {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
        border-radius: var(--radius);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
        background: var(--gray-50);
        color: var(--c-chrome);
    }

    .stat-card .stat-value {
        margin: 0;
        font-family: var(--font-head);
        font-size: 26px;
        font-weight: 800;
        letter-spacing: -.02em;
        color: var(--c-text);
        font-variant-numeric: tabular-nums;
        overflow-wrap: anywhere;
    }

    .stat-card .stat-currency {
        font-size: .65em;
        font-weight: 700;
        color: var(--c-muted);
        margin-right: 2px;
    }

    /* tone = meaning, from the split-complement / triad */
    .stat-card.tone-brand .stat-icon { background: var(--brand-50); color: var(--c-primary); }
    .stat-card.tone-navy .stat-icon { background: #e8ecf5; color: var(--c-chrome); }
    .stat-card.tone-teal .stat-icon { background: var(--teal-50); color: var(--c-success); }
    .stat-card.tone-azure .stat-icon { background: var(--azure-50); color: var(--c-info); }
    .stat-card.tone-amber .stat-icon { background: var(--amber-50); color: var(--c-warning); }

    .stat-card.is-feature {
        color: #fff;
        border: 0;
        background:
            radial-gradient(420px 200px at 100% 0%, rgba(227, 23, 58, .35), transparent 60%),
            linear-gradient(135deg, var(--navy-800), var(--navy-600));
    }

        .stat-card.is-feature .stat-label { color: rgba(255, 255, 255, .72); }
        .stat-card.is-feature .stat-value { color: #fff; font-size: 32px; }
        .stat-card.is-feature .stat-currency { color: rgba(255, 255, 255, .6); }
        .stat-card.is-feature .stat-icon { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- PRINT ---------- */

#printArea,
#printArea * {
    font-family: Arial, sans-serif;
}

@media print {
    .top-navbar,
    .sidebar,
    .sidebar-overlay,
    .cental-footer,
    #toastMsg,
    #errorToast {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        background: #fff;
    }
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 991.98px) {
    .main-content {
        padding: 16px;
    }
}

@media (max-width: 767.98px) {
    :root {
        --header-h: 58px;
        --control-h: 44px; /* comfortable touch target */
    }

    html {
        font-size: 15px;
    }

    .top-navbar {
        padding: 0 12px;
    }

    .cental-brand { font-size: 18px; }
    .cental-brand .org-name { font-size: 15px; }
    .cental-brand img { width: 34px; height: 34px; flex-basis: 34px; }

    .header-user {
        padding: 3px;
    }

        .header-user .user-name {
            display: none;
        }

    .header-logout {
        width: 38px;
        padding: 0;
    }

        .header-logout .logout-text {
            display: none;
        }

    .main-content {
        padding: 12px;
    }

        .main-content .page-header {
            padding: 14px 16px;
            font-size: 17px;
        }

        .main-content .section-title,
        .main-content .section-header {
            padding: 12px 16px;
        }

        .main-content .page-container > form > div[style*="padding"],
        .main-content .page-container div[style*="padding:25px"] {
            padding: 16px 12px 8px !important;
        }

        .main-content .page-container div[style*="overflow-x"],
        .main-content .page-container .table-responsive,
        .main-content .page-container .table-wrapper,
        .main-content .page-container .table-responsive-mobile {
            padding: 0 12px 12px;
        }

    /* 16px inputs stop iOS from zooming on focus */
    .form-control,
    .form-select,
    .main-content select,
    .main-content input,
    .main-content textarea {
        font-size: 16px !important;
    }

    .main-content .table td input,
    .main-content .table td select {
        font-size: 14px !important;
    }

    .save-btn,
    .main-content .btn-custom {
        width: 100%;
    }

    .cental-footer {
        justify-content: center;
        text-align: center;
    }

    .page-hero {
        padding: 22px 18px;
    }

        .page-hero h1 {
            font-size: 22px;
        }

    .stat-card .stat-value { font-size: 22px; }
    .stat-card.is-feature .stat-value { font-size: 26px; }
}

/* Phones: stack "label | input" rows so inputs get the full width */
@media (max-width: 575.98px) {
    .main-content .row.align-items-center > label[class*="col-"],
    .main-content .row.align-items-center > [class*="col-"]:not(label) {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .main-content .row.align-items-center > label[class*="col-"] {
        margin-bottom: 6px !important;
    }

    .main-content .page-container .row {
        margin-bottom: 12px !important;
    }

    .main-content .page-container .row.mt-3 {
        margin-top: 0 !important;
    }

    /* "label + input" flex rows with a fixed label width (Organization) */
    .main-content .d-flex.align-items-center:has(> label[style*="width"]) {
        flex-wrap: wrap;
    }

        .main-content .d-flex.align-items-center > label[style*="width"] {
            width: 100% !important;
            margin-bottom: 6px !important;
        }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}
