:root {
    --cp-bg: #080b10;
    --cp-bg-soft: #0d121a;
    --cp-sidebar: rgba(8, 11, 16, .92);
    --cp-card: rgba(17, 23, 34, .86);
    --cp-card-2: rgba(21, 29, 42, .92);
    --cp-border: rgba(255, 255, 255, .08);
    --cp-border-strong: rgba(79, 140, 255, .22);
    --cp-text: #eef4ff;
    --cp-muted: #8290a6;
    --cp-blue: #4f8cff;
    --cp-cyan: #31d0ff;
    --cp-green: #33d69f;
    --cp-red: #ff5f6d;
    --cp-yellow: #ffd166;
    --cp-shadow: 0 18px 55px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body.cp-body,
body#page-top {
    min-height: 100vh;
    margin: 0;
    font-family: Nunito, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--cp-text);
    background:
        radial-gradient(circle at top left, rgba(79, 140, 255, .18), transparent 32%),
        radial-gradient(circle at bottom right, rgba(49, 208, 255, .08), transparent 35%),
        var(--cp-bg) !important;
}

body.cp-body a { color: #77a9ff; text-decoration: none; }
body.cp-body a:hover { color: #a9c8ff; }

.cp-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.cp-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    border-right: 1px solid var(--cp-border);
    background: var(--cp-sidebar);
    backdrop-filter: blur(18px);
    overflow-y: auto;
}

.cp-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 26px;
    border-bottom: 1px solid var(--cp-border);
    margin-bottom: 22px;
}

.cp-brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 17px;
    display: grid;
    place-items: center;
    flex: 0 0 54px;
    background: linear-gradient(135deg, rgba(255, 209, 102, .98), rgba(79, 140, 255, .92));
    color: #05070b;
    font-weight: 950;
    letter-spacing: -.04em;
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 0 34px rgba(79, 140, 255, .25), 0 0 22px rgba(255, 209, 102, .12);
    overflow: hidden;
}

.cp-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cp-brand strong {
    display: block;
    color: #fff;
    font-size: 15px;
    line-height: 1.15;
}

.cp-brand small {
    display: block;
    margin-top: 4px;
    color: var(--cp-muted);
}

.cp-nav {
    display: grid;
    gap: 8px;
}

.cp-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 14px;
    border-radius: 14px;
    color: #b8c3d6 !important;
    text-decoration: none;
    transition: .18s ease;
}

.cp-nav-logo {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
}

.cp-nav-link:hover,
.cp-nav-link.active {
    color: #fff !important;
    background: linear-gradient(90deg, rgba(79, 140, 255, .22), rgba(49, 208, 255, .08));
    box-shadow: inset 0 0 0 1px rgba(79, 140, 255, .18);
}

.cp-sidebar-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--cp-border);
    color: var(--cp-muted);
    font-size: 13px;
}

.cp-main {
    min-width: 0;
    padding: 28px 34px 80px;
}

.cp-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.cp-title h1,
.cp-page-title {
    margin: 0;
    color: #fff;
    font-size: 28px;
    font-weight: 850;
    letter-spacing: -.035em;
}

.cp-title p,
.cp-subtitle {
    margin: 8px 0 0;
    color: var(--cp-muted);
}

.cp-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--cp-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, .04);
    color: #cdd7e8;
    white-space: nowrap;
}

.cp-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--cp-green);
    box-shadow: 0 0 14px var(--cp-green);
}

.cp-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px 18px;
    border: 1px solid var(--cp-border);
    border-radius: 24px;
    background:
        linear-gradient(90deg, rgba(255, 209, 102, .12), rgba(79, 140, 255, .08), rgba(49, 208, 255, .035)),
        rgba(255, 255, 255, .035);
    box-shadow: var(--cp-shadow);
}

.cp-hero-emblem {
    width: 76px;
    height: 76px;
    flex: 0 0 76px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    align-content: center;
    background:
        radial-gradient(circle at 25% 20%, rgba(255, 255, 255, .18), transparent 28%),
        linear-gradient(145deg, rgba(255, 209, 102, .92), rgba(79, 140, 255, .88));
    color: #05070b;
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .35), 0 0 34px rgba(79, 140, 255, .25);
    line-height: 1;
    text-align: center;
}

.cp-hero-emblem img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.cp-hero-emblem span { font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.cp-hero-emblem b { font-size: 13px; letter-spacing: .03em; }
.cp-hero strong { display: block; color: #fff; font-size: 24px; letter-spacing: .04em; }
.cp-hero small { display: block; margin-top: 5px; color: var(--cp-muted); }

.cp-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.cp-stat-card,
.cp-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025));
    border: 1px solid var(--cp-border);
    box-shadow: var(--cp-shadow);
}

.cp-stat-card { min-height: 136px; }
.cp-stat-card::after {
    content: "";
    position: absolute;
    width: 110px;
    height: 110px;
    right: -35px;
    top: -35px;
    border-radius: 50%;
    background: rgba(79, 140, 255, .14);
    filter: blur(3px);
}

.cp-stat-label { color: var(--cp-muted); font-size: 14px; margin-bottom: 18px; }
.cp-stat-value { color: #fff; font-size: 31px; font-weight: 850; letter-spacing: -.04em; }
.cp-stat-value span { color: var(--cp-muted); font-weight: 650; }
.cp-stat-note { color: var(--cp-muted); font-size: 13px; margin-top: 10px; }

.cp-grid {
    display: grid;
    grid-template-columns: 1.4fr .6fr;
    gap: 18px;
}

.cp-panel {
    border: 1px solid var(--cp-border);
    border-radius: 22px;
    background: var(--cp-card);
    box-shadow: var(--cp-shadow);
    overflow: hidden;
}

.cp-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--cp-border);
}

.cp-panel-header h2 { margin: 0; color: #fff; font-size: 17px; font-weight: 850; }
.cp-panel-header span { color: var(--cp-muted); font-size: 13px; }

.cp-actions { padding: 20px; display: grid; gap: 12px; }
.cp-action {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--cp-border);
    background: rgba(255, 255, 255, .035);
}
.cp-action strong { display: block; margin-bottom: 5px; color: #fff; }
.cp-action small { color: var(--cp-muted); }

.table,
body.cp-body table.table {
    --bs-table-color: #dbe5f5;
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(255, 255, 255, .07);
    --bs-table-striped-bg: rgba(255, 255, 255, .025);
    --bs-table-striped-color: #dbe5f5;
    --bs-table-hover-bg: rgba(79, 140, 255, .055);
    --bs-table-hover-color: #fff;
    color: #dbe5f5;
    margin-bottom: 0;
}

.table th,
body.cp-body table.table th {
    color: #8d9bb1;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 850;
}

.table td,
.table th { padding: 15px 18px; vertical-align: middle; }

.cp-table-wrap { overflow-x: auto; }
.cp-table-wrap table { min-width: 760px; }

.cp-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
    background: rgba(79, 140, 255, .14);
    color: #9fc0ff;
    border: 1px solid rgba(79, 140, 255, .2);
}

.cp-badge-owner {
    color: #ffd9a3;
    background: rgba(255, 209, 102, .12);
    border-color: rgba(255, 209, 102, .22);
}

.btn-primary,
.cp-btn-primary {
    border: 0 !important;
    color: #fff !important;
    background: linear-gradient(135deg, var(--cp-blue), var(--cp-cyan)) !important;
    box-shadow: 0 12px 28px rgba(79, 140, 255, .24);
}

.btn-outline-primary,
.btn-outline-success,
.btn-outline-danger {
    border-color: var(--cp-border-strong) !important;
    color: #dbe8ff !important;
    background: rgba(79, 140, 255, .04) !important;
}

.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover {
    background: linear-gradient(135deg, rgba(79, 140, 255, .8), rgba(49, 208, 255, .75)) !important;
    color: #fff !important;
}

.form-control,
.form-select,
.combobox-container {
    color: #e8efff !important;
    background-color: rgba(255, 255, 255, .045) !important;
    border: 1px solid rgba(255, 255, 255, .11) !important;
    border-radius: 14px !important;
}

.form-control:focus,
.form-select:focus,
.combobox-container:focus {
    border-color: rgba(79, 140, 255, .72) !important;
    box-shadow: 0 0 0 .25rem rgba(79, 140, 255, .18) !important;
}

.form-control::placeholder { color: #748197 !important; }

.bg-body-tertiary,
.card {
    background-color: var(--cp-card) !important;
    border-color: var(--cp-border) !important;
    color: var(--cp-text) !important;
}

.text-body-secondary,
.text-dark { color: var(--cp-muted) !important; }

.status-online,
.status-offline {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    margin-bottom: 2px;
}
.status-online { background-color: var(--cp-green); box-shadow: 0 0 12px var(--cp-green); }
.status-offline { background-color: var(--cp-red); box-shadow: 0 0 12px var(--cp-red); }

.cp-footer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 260px;
    padding: 12px 20px;
    color: var(--cp-muted);
    text-align: center;
    background: rgba(8, 11, 16, .76);
    border-top: 1px solid var(--cp-border);
    backdrop-filter: blur(14px);
    z-index: 10;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(430px, 100%);
    padding: 30px;
    border-radius: 26px;
    background: rgba(17, 23, 34, .86);
    border: 1px solid var(--cp-border);
    box-shadow: var(--cp-shadow);
}

.login-logo {
    width: 74px;
    height: 74px;
    border-radius: 24px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(255, 209, 102, .98), rgba(79, 140, 255, .92));
    color: #05070b;
    font-weight: 950;
    overflow: hidden;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

/* Select/status fallback */
.combobox-container {
    width: 100%;
    padding: 8px;
}
.combobox-container option {
    background-color: #1f1f1f;
    color: #ffffff;
}
a { text-decoration: none; }

/* =========================================================
   MOBILE OPTIMIZATION
   ========================================================= */

@media (max-width: 1100px) {
    .cp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cp-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    html, body { width: 100%; max-width: 100%; overflow-x: hidden; }

    body.cp-body, body#page-top { background-attachment: fixed !important; }

    .cp-shell { display: block; min-height: 100vh; }

    .cp-sidebar {
        position: relative;
        height: auto;
        width: 100%;
        padding: 14px 14px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--cp-border);
        overflow: visible;
    }

    .cp-brand {
        padding: 8px 4px 14px;
        margin-bottom: 12px;
    }

    .cp-brand-mark {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
        border-radius: 14px;
        font-size: 14px;
    }

    .cp-brand strong { font-size: 14px; }
    .cp-brand small { font-size: 12px; }

    .cp-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .cp-nav::-webkit-scrollbar { display: none; }

    .cp-nav-link {
        flex: 0 0 auto;
        padding: 10px 12px;
        min-height: 42px;
        border-radius: 999px;
        font-size: 14px;
        white-space: nowrap;
    }

    .cp-sidebar-footer { display: none; }

    .cp-main {
        width: 100%;
        min-width: 0;
        padding: 20px 14px 96px;
    }

    .cp-topbar {
        gap: 12px;
        margin-bottom: 20px;
        align-items: flex-start;
        flex-direction: column;
    }

    .cp-title h1,
    .cp-page-title {
        font-size: 25px;
        line-height: 1.15;
        letter-spacing: -.045em;
    }

    .cp-title p,
    .cp-subtitle {
        font-size: 15px;
        line-height: 1.45;
    }

    .cp-user-pill {
        align-self: flex-start;
        padding: 9px 12px;
        font-size: 14px;
    }

    .cp-hero {
        gap: 12px;
        padding: 14px;
        border-radius: 20px;
    }

    .cp-hero-emblem {
        width: 56px;
        height: 56px;
        flex-basis: 56px;
        border-radius: 18px;
    }

    .cp-hero strong {
        font-size: 18px;
        line-height: 1.15;
    }

    .cp-hero small { font-size: 13px; }

    .cp-stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .cp-stat-card {
        min-height: 118px;
        padding: 16px;
        border-radius: 18px;
    }

    .cp-stat-label {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .cp-stat-value { font-size: 25px; }

    .cp-stat-note {
        font-size: 12px;
        margin-top: 7px;
    }

    .cp-card,
    .cp-panel { border-radius: 18px; }

    .cp-panel-header { padding: 15px 16px; }
    .cp-panel-header h2 { font-size: 16px; }

    .cp-table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 18px;
    }

    .cp-table-wrap table,
    table.table {
        min-width: 720px;
    }

    .table td,
    .table th {
        padding: 13px 14px;
    }

    .form-control,
    .form-select,
    .combobox-container {
        min-height: 46px;
        font-size: 16px !important;
    }

    .btn,
    button,
    .cp-btn-primary {
        min-height: 44px;
    }

    .cp-footer {
        left: 0;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
        font-size: 13px;
    }
}

@media (max-width: 560px) {
    .cp-main {
        padding-left: 12px;
        padding-right: 12px;
    }

    .cp-title h1,
    .cp-page-title {
        font-size: 24px;
    }

    .cp-stats { grid-template-columns: 1fr; }
    .cp-stat-card { min-height: 112px; }
    .cp-grid { gap: 14px; }

    .cp-panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .cp-actions { padding: 14px; }
    .cp-action { padding: 14px; }

    .input-group,
    .row,
    form .row {
        min-width: 0;
    }

    .input-group {
        display: flex;
        flex-wrap: nowrap;
    }

    .input-group .form-control { min-width: 0; }

    .input-group .btn {
        flex: 0 0 auto;
        padding-left: 14px;
        padding-right: 14px;
    }

    .login-page { padding: 18px 12px; }

    .login-card {
        padding: 22px;
        border-radius: 22px;
    }
}

@media (max-width: 390px) {
    .cp-title h1,
    .cp-page-title {
        font-size: 22px;
    }

    .cp-nav-link {
        font-size: 13px;
        padding: 9px 11px;
    }

    .cp-stat-value { font-size: 23px; }

    .table td,
    .table th {
        padding: 12px;
    }
}
