:root {
    --crp-sidebar-w: 260px;
    --crp-bg: #f4f6fb;
    --crp-surface: #ffffff;
    --crp-ink: #1c2333;
    --crp-muted: #6b7385;
    --crp-border: #e7e9f0;
    --crp-primary: #4f6ef7;
    --crp-primary-ink: #ffffff;
    --crp-sidebar-bg: linear-gradient(180deg, #0f1c3f 0%, #0a1329 50%, #060a1a 100%);
    --crp-sidebar-ink: #c9d6f9;
    --crp-sidebar-ink-active: #ffffff;
    --crp-sidebar-hover: rgba(255,255,255,.10);
    --crp-sidebar-active: rgba(255,255,255,.18);
    --crp-sidebar-accent: #7dd3fc;
    --crp-success: #21c584;
    --crp-warning: #f5a524;
    --crp-danger: #f24957;
    --crp-info: #3fb6e8;
    --crp-shadow: 0 2px 10px rgba(23, 29, 46, 0.06);
    --crp-shadow-md: 0 6px 20px rgba(23, 29, 46, 0.08);
    --crp-radius: 14px;
}

html, body {
    height: 100%;
}

body {
    background: var(--crp-bg);
    color: var(--crp-ink);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: 14.5px;
}

a {
    text-decoration: none;
}

/* ===== Sidebar ===== */
#sidebar {
    width: var(--crp-sidebar-w);
    background: var(--crp-sidebar-bg);
    color: var(--crp-sidebar-ink);
}

#sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.25rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: .2px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

#sidebar .sidebar-brand .bi {
    color: var(--crp-sidebar-accent);
    font-size: 1.5rem;
    filter: drop-shadow(0 0 10px rgba(125,211,252,.6));
}

#sidebar .nav-section-label {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .08em;
    color: #a9c1ee;
    padding: 1.1rem 1.25rem .35rem;
    font-weight: 700;
}

#sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--crp-sidebar-ink);
    padding: .62rem 1.25rem;
    border-radius: 0;
    font-weight: 500;
    font-size: .92rem;
    position: relative;
    transition: background .15s ease, color .15s ease;
}

#sidebar .nav-link .bi {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
}

#sidebar .nav-link:hover {
    background: var(--crp-sidebar-hover);
    color: #fff;
}

#sidebar .nav-link.active {
    background: var(--crp-sidebar-active);
    color: var(--crp-sidebar-ink-active);
    font-weight: 600;
}

#sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--crp-sidebar-accent);
    box-shadow: 0 0 10px rgba(125,211,252,.8);
}

#sidebar .nav-link.disabled {
    color: #8298d6;
    pointer-events: none;
    cursor: default;
}

#sidebar .nav-link .soon-badge {
    margin-left: auto;
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .04em;
    background: rgba(255,255,255,.12);
    color: #d3deff;
    padding: .12rem .45rem;
    border-radius: 20px;
}

@media (min-width: 992px) {
    #sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        z-index: 1030;
        visibility: visible !important;
        transform: none !important;
    }
    .crp-content {
        margin-left: var(--crp-sidebar-w);
    }
}

/* ===== Topbar ===== */
.crp-topbar {
    background: var(--crp-surface);
    border-bottom: 1px solid var(--crp-border);
    padding: .75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.crp-topbar .btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--crp-border);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--crp-ink);
}

.crp-topbar .btn-icon:hover {
    background: var(--crp-bg);
}

.crp-page-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0;
}

.crp-user-chip {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .35rem .7rem .35rem .35rem;
    background: var(--crp-bg);
    border-radius: 30px;
    border: 1px solid var(--crp-border);
}

.crp-user-chip:hover, .crp-user-chip:focus {
    background: var(--crp-bg);
    box-shadow: none;
}

.crp-user-chip .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--crp-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.crp-user-chip .user-name {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 420px) {
    .crp-user-chip .user-name {
        display: none;
    }
}

/* ===== Content area ===== */
.crp-content {
    min-width: 0;
}

.crp-content-inner {
    padding: 1.5rem;
    max-width: 100vw;
    overflow-x: hidden;
}

.crp-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.crp-page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

.crp-page-header p {
    color: var(--crp-muted);
    margin: .15rem 0 0;
    font-size: .88rem;
}

/* ===== Cards ===== */
.crp-card {
    background: var(--crp-surface);
    border: 1px solid var(--crp-border);
    border-radius: var(--crp-radius);
    box-shadow: var(--crp-shadow);
}

.crp-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--crp-border);
}

.crp-card-header h2 {
    font-size: .98rem;
    font-weight: 700;
    margin: 0;
}

.crp-card-body {
    padding: 1.25rem;
}

/* ===== Stat cards ===== */
.stat-card {
    background: var(--crp-surface);
    border: 1px solid var(--crp-border);
    border-radius: var(--crp-radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--crp-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
}

.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card .stat-label {
    color: var(--crp-muted);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.stat-icon.bg-primary-soft { background: rgba(79,110,247,.12); color: var(--crp-primary); }
.stat-icon.bg-success-soft { background: rgba(33,197,132,.12); color: var(--crp-success); }
.stat-icon.bg-warning-soft { background: rgba(245,165,36,.12); color: var(--crp-warning); }
.stat-icon.bg-info-soft { background: rgba(63,182,232,.12); color: var(--crp-info); }
.stat-icon.bg-danger-soft { background: rgba(242,73,87,.12); color: var(--crp-danger); }

/* ===== Buttons ===== */
.btn-primary {
    background: var(--crp-primary);
    border-color: var(--crp-primary);
}

.btn-primary:hover {
    background: #3d5ce0;
    border-color: #3d5ce0;
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .82rem;
    font-weight: 600;
}

/* ===== Status badges ===== */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .28rem .65rem;
    border-radius: 30px;
    font-size: .74rem;
    font-weight: 600;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-available, .status-completed, .status-paid, .status-sold, .status-posted, .status-present, .status-approved, .status-investment { background: rgba(33,197,132,.12); color: #17995f; }
.status-rented, .status-active, .status-inprogress, .status-listedforsale, .status-distribution { background: rgba(79,110,247,.12); color: #3d5ce0; }
.status-maintenance, .status-pending, .status-reserved, .status-partiallypaid, .status-ingarage, .status-inreconditioning, .status-draft, .status-late, .status-halfday, .status-notmarked, .status-withdrawal { background: rgba(245,165,36,.12); color: #c07f0e; }
.status-outofservice, .status-cancelled, .status-overdue, .status-unpaid, .status-defaulted, .status-repossessed, .status-rejected, .status-absent, .status-exited { background: rgba(242,73,87,.12); color: #d5303c; }

/* ===== DataTables tweaks ===== */
table.dataTable {
    font-size: .88rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--crp-border);
    border-radius: 8px;
    padding: .3rem .6rem;
}

/* ===== Select2 tweaks ===== */
.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #ced4da;
    border-radius: .375rem;
    display: flex;
    align-items: center;
}

.select2-lookup-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.select2-lookup-row .select2-container {
    flex: 1 1 auto;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--crp-muted);
}

/* ===== Tabs ===== */
.crp-tabs {
    border-bottom: 1px solid var(--crp-border);
    gap: .25rem;
}

.crp-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--crp-muted);
    font-weight: 600;
    font-size: .88rem;
    padding: .65rem .25rem;
    margin-right: 1.25rem;
    border-radius: 0;
}

.crp-tabs .nav-link:hover {
    color: var(--crp-ink);
    border-color: transparent;
}

.crp-tabs .nav-link.active {
    color: var(--crp-primary);
    background: transparent;
    border-bottom-color: var(--crp-primary);
}

.empty-state .bi {
    font-size: 2rem;
    color: #c7cbdb;
    margin-bottom: .5rem;
    display: block;
}
