/* ============================================================
   CarBazar Management — theme
   ============================================================ */

:root {
    --cb-bg: #f4f6fb;
    --cb-surface: #ffffff;
    --cb-ink: #16204a;
    --cb-muted: #6b7594;
    --cb-line: #e6eaf3;

    --cb-navy: #101a3d;
    --cb-navy-2: #1b2a5c;
    --cb-accent: #4f7cff;
    --cb-accent-2: #7aa2ff;
    --cb-gold: #f5a524;
    --cb-green: #16a34a;
    --cb-green-soft: #e8f7ef;
    --cb-red: #dc2626;
    --cb-red-soft: #fdecec;

    --cb-radius: 16px;
    --cb-shadow: 0 1px 2px rgba(16, 26, 61, .04), 0 12px 28px -18px rgba(16, 26, 61, .35);
    --cb-shadow-lg: 0 24px 60px -30px rgba(16, 26, 61, .45);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    overflow-x: hidden;
    background: var(--cb-bg);
    color: var(--cb-ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---------- Shell ---------- */

.cb-shell {
    display: flex;
    min-height: 100vh;
}

.cb-sidebar {
    width: 258px;
    flex: 0 0 258px;
    background: linear-gradient(175deg, var(--cb-navy) 0%, #16224d 55%, var(--cb-navy-2) 100%);
    color: #cfd8f3;
    padding: 22px 16px 28px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.cb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 22px;
    color: #fff;
}

.cb-brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--cb-accent), #9b6bff);
    display: grid;
    place-items: center;
    box-shadow: 0 10px 24px -10px var(--cb-accent);
    flex: 0 0 42px;
}

.cb-brand-mark svg { width: 22px; height: 22px; }

.cb-brand-text strong {
    display: block;
    font-size: 15.5px;
    letter-spacing: .2px;
    line-height: 1.1;
}

.cb-brand-text span {
    font-size: 11px;
    color: #8e9cc9;
    letter-spacing: 1.4px;
    text-transform: uppercase;
}

.cb-nav-label {
    font-size: 10.5px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: #6d7aa8;
    padding: 16px 12px 8px;
}

.cb-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 11px;
    color: #c3cdea;
    font-weight: 500;
    margin-bottom: 3px;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.cb-nav a svg { width: 18px; height: 18px; opacity: .85; flex: 0 0 18px; }

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

.cb-nav a.active {
    background: linear-gradient(100deg, rgba(79, 124, 255, .95), rgba(122, 91, 255, .8));
    color: #fff;
    box-shadow: 0 12px 26px -14px var(--cb-accent);
}

.cb-nav a.active svg { opacity: 1; }

.cb-side-foot {
    margin-top: 26px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .07);
    font-size: 12px;
    color: #93a0cb;
    line-height: 1.5;
}

.cb-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cb-topbar {
    background: var(--cb-surface);
    border-bottom: 1px solid var(--cb-line);
    padding: 14px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 20;
}

.cb-topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.cb-topbar-heading { min-width: 0; }

.cb-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.cb-topbar h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hamburger — byzhar bas 3ala l shashet l zghire */
.cb-burger {
    display: none;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 11px;
    border: 1px solid var(--cb-line);
    background: #fff;
    color: var(--cb-ink);
    align-items: center;
    justify-content: center;
    padding: 0;
}

.cb-burger svg { width: 20px; height: 20px; }
.cb-burger:active { transform: scale(.96); }

.cb-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 16, 38, .55);
    z-index: 45;
    backdrop-filter: blur(2px);
}

.cb-topbar .cb-sub {
    font-size: 12.5px;
    color: var(--cb-muted);
    margin-top: 2px;
}

.cb-content {
    padding: 26px 30px 48px;
    flex: 1 1 auto;
}

/* ---------- Cards ---------- */

.cb-card {
    background: var(--cb-surface);
    border: 1px solid var(--cb-line);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    overflow: hidden;
}

.cb-card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--cb-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.cb-card-head h2 {
    font-size: 15.5px;
    font-weight: 700;
    margin: 0;
}

.cb-card-head .cb-hint {
    font-size: 12px;
    color: var(--cb-muted);
    margin-top: 2px;
}

.cb-card-body { padding: 20px; }

/* ---------- Stat tiles ---------- */

.cb-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.cb-stat {
    background: var(--cb-surface);
    border: 1px solid var(--cb-line);
    border-radius: var(--cb-radius);
    padding: 18px 20px;
    box-shadow: var(--cb-shadow);
    position: relative;
    overflow: hidden;
}

.cb-stat::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--cb-accent);
}

.cb-stat.is-green::after { background: var(--cb-green); }
.cb-stat.is-red::after { background: var(--cb-red); }
.cb-stat.is-gold::after { background: var(--cb-gold); }

.cb-stat .cb-stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--cb-muted);
    font-weight: 600;
}

.cb-stat .cb-stat-value {
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -.5px;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.cb-stat .cb-stat-note {
    font-size: 12px;
    color: var(--cb-muted);
    margin-top: 4px;
}

.cb-stat-hero {
    background: linear-gradient(135deg, var(--cb-navy) 0%, #2a3a75 100%);
    color: #fff;
    border: none;
    box-shadow: var(--cb-shadow-lg);
}

.cb-stat-hero::after { display: none; }
.cb-stat-hero .cb-stat-label { color: #9fb0e0; }
.cb-stat-hero .cb-stat-note { color: #b6c2e8; }

/* ---------- Tables ---------- */

.cb-table-wrap { overflow-x: auto; }

table.cb-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

table.cb-table thead th {
    background: #f7f9fd;
    color: var(--cb-muted);
    font-size: 11.5px;
    letter-spacing: .9px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 12px 16px;
    border-bottom: 1px solid var(--cb-line);
    white-space: nowrap;
    text-align: left;
}

table.cb-table thead th a { color: inherit; }
table.cb-table thead th a:hover { color: var(--cb-accent); }

table.cb-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f0f3fa;
    vertical-align: middle;
}

table.cb-table tbody tr:last-child td { border-bottom: none; }
table.cb-table tbody tr:hover { background: #fafbff; }

table.cb-table tfoot td {
    padding: 13px 16px;
    background: #f7f9fd;
    font-weight: 700;
    border-top: 1px solid var(--cb-line);
}

.cb-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cb-strong { font-weight: 700; }

.cb-empty {
    padding: 46px 20px;
    text-align: center;
    color: var(--cb-muted);
}

.cb-empty svg { width: 42px; height: 42px; opacity: .35; margin-bottom: 10px; }

/* ---------- Badges / money ---------- */

.cb-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
}

.cb-badge-green { background: var(--cb-green-soft); color: #10763a; }
.cb-badge-red { background: var(--cb-red-soft); color: #b91c1c; }
.cb-badge-gold { background: #fff5e2; color: #a06008; }
.cb-badge-blue { background: #eaf0ff; color: #2c50b5; }
.cb-badge-gray { background: #f0f2f8; color: #59617e; }

.cb-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

.cb-money-due { color: var(--cb-red); font-weight: 700; }
.cb-money-credit { color: var(--cb-green); font-weight: 700; }
.cb-money-zero { color: var(--cb-muted); font-weight: 600; }

/* ---------- Forms ---------- */

.cb-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px 18px;
}

.cb-field label,
.cb-field .cb-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--cb-muted);
    margin-bottom: 6px;
}

.cb-field input.form-control,
.cb-field select.form-select,
.cb-field textarea.form-control {
    border-radius: 11px;
    border: 1px solid #dfe4f0;
    padding: 10px 13px;
    font-size: 14px;
    box-shadow: none;
}

.cb-field input.form-control:focus,
.cb-field select.form-select:focus,
.cb-field textarea.form-control:focus {
    border-color: var(--cb-accent);
    box-shadow: 0 0 0 4px rgba(79, 124, 255, .14);
}

.cb-field input[readonly] {
    background: #f3f6fd;
    color: var(--cb-ink);
    font-weight: 700;
    border-style: dashed;
}

.cb-span-2 { grid-column: span 2; }

@media (max-width: 640px) { .cb-span-2 { grid-column: span 1; } }

.cb-form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--cb-line);
}

.cb-calc-box {
    background: linear-gradient(135deg, #f2f6ff, #eef2ff);
    border: 1px dashed #c9d6ff;
    border-radius: 14px;
    padding: 16px 18px;
}

.cb-calc-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    font-size: 13.5px;
    color: var(--cb-muted);
}

.cb-calc-line span:last-child {
    font-variant-numeric: tabular-nums;
    color: var(--cb-ink);
    font-weight: 600;
}

.cb-calc-total {
    border-top: 1px solid #d5deff;
    margin-top: 6px;
    padding-top: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--cb-ink);
}

.text-danger, .field-validation-error {
    font-size: 12.5px;
    color: var(--cb-red) !important;
}

/* ---------- Buttons ---------- */

.btn {
    border-radius: 11px;
    font-weight: 600;
    font-size: 13.5px;
    padding: 9px 16px;
    border: 1px solid transparent;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-cb {
    background: linear-gradient(120deg, var(--cb-accent), #6a5bff);
    color: #fff;
    box-shadow: 0 12px 24px -14px var(--cb-accent);
}

.btn-cb:hover { color: #fff; filter: brightness(1.06); }

.btn-cb-ghost {
    background: #fff;
    border-color: #dde3f2;
    color: var(--cb-ink);
}

.btn-cb-ghost:hover { border-color: var(--cb-accent); color: var(--cb-accent); }

.btn-cb-danger { background: #fff; border-color: #f3c9c9; color: var(--cb-red); }
.btn-cb-danger:hover { background: var(--cb-red); color: #fff; border-color: var(--cb-red); }

.btn-cb-gold { background: var(--cb-gold); color: #3a2500; }
.btn-cb-gold:hover { color: #3a2500; filter: brightness(1.06); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }

.cb-row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

/* ---------- Toolbar / filters ---------- */

.cb-toolbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.cb-toolbar .form-control,
.cb-toolbar .form-select {
    border-radius: 11px;
    border: 1px solid #dfe4f0;
    font-size: 13.5px;
    padding: 9px 12px;
}

.cb-search { min-width: 240px; }

/* ---------- Alerts ---------- */

.cb-alert {
    border-radius: 13px;
    padding: 13px 17px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 18px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cb-alert-success { background: var(--cb-green-soft); border-color: #bfe8d1; color: #10763a; }
.cb-alert-error { background: var(--cb-red-soft); border-color: #f6cccc; color: #b91c1c; }
.cb-alert-warn { background: #fff6e5; border-color: #fadfae; color: #92610a; }
.cb-alert-info { background: #eef3ff; border-color: #cfdcff; color: #2c50b5; }

/* ---------- Misc ---------- */

.cb-avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: linear-gradient(135deg, #e7edff, #dfe7ff);
    color: #3a55b8;
    display: inline-grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex: 0 0 34px;
}

.cb-person { display: flex; align-items: center; gap: 11px; }
.cb-person .cb-person-name { font-weight: 600; color: var(--cb-ink); }
.cb-person .cb-person-sub { font-size: 12px; color: var(--cb-muted); }

.cb-chip-list { display: flex; flex-wrap: wrap; gap: 5px; }

.cb-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--cb-muted);
    margin-bottom: 12px;
}

.cb-back:hover { color: var(--cb-accent); }

.cb-section-title {
    font-size: 12px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--cb-muted);
    font-weight: 700;
    margin: 26px 0 12px;
}

.cb-grid-2 {
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .cb-grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Topbar user ---------- */

.cb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 14px;
    margin-left: 4px;
    border-left: 1px solid var(--cb-line);
}

.cb-user .cb-user-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.15;
}

.cb-user .cb-user-role {
    font-size: 11px;
    color: var(--cb-muted);
}

/* ---------- Login page ---------- */

.cb-auth-body {
    min-height: 100vh;
    background:
        radial-gradient(1000px 600px at 12% -10%, #26386f 0%, transparent 60%),
        radial-gradient(900px 600px at 110% 110%, #3b2a6b 0%, transparent 55%),
        linear-gradient(160deg, #0d1531 0%, #131e46 100%);
    display: grid;
    place-items: center;
    padding: 28px 16px;
}

.cb-auth-wrap { width: 100%; max-width: 940px; }

.cb-auth-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--cb-surface);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 50px 110px -50px rgba(0, 0, 0, .8);
}

.cb-auth-side {
    background: linear-gradient(165deg, #16224d 0%, #1f2f66 60%, #2b2a6d 100%);
    color: #c9d3f2;
    padding: 38px 34px;
}

.cb-auth-side h2 {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 10px;
    letter-spacing: -.3px;
}

.cb-auth-side p {
    font-size: 13.5px;
    line-height: 1.65;
    color: #a9b6de;
    margin-bottom: 22px;
}

.cb-auth-points { list-style: none; padding: 0; margin: 0; }

.cb-auth-points li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    padding: 7px 0;
    color: #cdd7f5;
}

.cb-auth-points li span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-accent-2);
    flex: 0 0 7px;
}

.cb-auth-form { padding: 44px 40px; }

.cb-auth-form h1 {
    font-size: 25px;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -.4px;
}

.cb-auth-sub {
    font-size: 13.5px;
    color: var(--cb-muted);
    margin-bottom: 26px;
}

.cb-remember {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    color: var(--cb-muted);
    cursor: pointer;
    user-select: none;
}

@media (max-width: 780px) {
    .cb-auth-card { grid-template-columns: 1fr; }
    .cb-auth-side { display: none; }
    .cb-auth-form { padding: 34px 26px; }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1200px) {
    .cb-content { padding: 22px 20px 40px; }
    .cb-topbar { padding-left: 20px; padding-right: 20px; }
}

/* --- Tablet: sidebar bytdayya2 --- */
@media (max-width: 1080px) and (min-width: 901px) {
    .cb-sidebar { width: 212px; flex-basis: 212px; padding-left: 12px; padding-right: 12px; }
    .cb-nav a { padding: 10px 11px; font-size: 14px; }
}

/* --- Mobile / small tablet: sidebar off-canvas --- */
@media (max-width: 900px) {
    .cb-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 268px;
        flex-basis: 268px;
        height: 100dvh;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 0 0 60px rgba(0, 0, 0, .45);
    }

    .cb-shell.is-nav-open .cb-sidebar { transform: none; }
    .cb-shell.is-nav-open .cb-scrim { display: block; }

    .cb-burger { display: inline-flex; }

    .cb-topbar { padding: 12px 16px; }
    .cb-content { padding: 18px 16px 40px; }

    .cb-topbar h1 { font-size: 17px; }
    .cb-topbar .cb-sub { font-size: 11.5px; }

    /* L actions bynzalo 3ala satr la7alon w byemshu horizontal iza ktar */
    .cb-topbar-actions {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .cb-topbar-actions::-webkit-scrollbar { display: none; }
    .cb-topbar-actions > * { flex: 0 0 auto; }

    .cb-user { margin-left: auto; border-left: none; padding-left: 0; }
    .cb-user-meta { display: none; }

    .cb-stats { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin-bottom: 16px; }
    .cb-stat { padding: 14px 15px; }
    .cb-stat .cb-stat-value { font-size: 21px; }

    .cb-card-head { padding: 14px 16px; }
    .cb-card-body { padding: 16px; }

    /* Kel l toolbars bysiro full width w bystacko */
    .cb-toolbar { width: 100%; gap: 8px; }
    .cb-toolbar > * { flex: 1 1 160px; min-width: 0; }
    .cb-toolbar .cb-search { min-width: 0; flex: 1 1 100%; }
    .cb-toolbar .form-control,
    .cb-toolbar .form-select { width: 100%; }

    table.cb-table { font-size: 13px; }
    table.cb-table thead th { padding: 10px 12px; }
    table.cb-table tbody td { padding: 10px 12px; }
    table.cb-table tfoot td { padding: 10px 12px; }

    .cb-row-actions { justify-content: flex-start; }

    .cb-grid-2 { gap: 16px; }
}

/* --- Phones --- */
@media (max-width: 600px) {
    .cb-topbar { padding: 10px 13px; }
    .cb-content { padding: 14px 13px 36px; }

    .cb-stats { grid-template-columns: 1fr 1fr; }
    .cb-stat .cb-stat-value { font-size: 19px; }
    .cb-stat .cb-stat-label { font-size: 10.5px; }
    .cb-stat-hero { grid-column: 1 / -1; }

    .cb-card { border-radius: 14px; }
    .cb-card-head { flex-direction: column; align-items: stretch; gap: 12px; }

    .cb-form-grid { grid-template-columns: 1fr; gap: 14px; }

    .cb-form-actions { flex-wrap: wrap; }
    .cb-form-actions .btn { flex: 1 1 140px; }

    .cb-alert { font-size: 13px; padding: 11px 13px; }

    /* Iza fi jadwal 3aridh, mnbayyen eno byenzallat */
    .cb-table-wrap { position: relative; }
    .cb-table-wrap::after {
        content: "";
        position: sticky;
        right: 0;
        top: 0;
        float: right;
        width: 22px;
        height: 100%;
        background: linear-gradient(to right, transparent, rgba(16, 26, 61, .07));
        pointer-events: none;
    }
}

@media (max-width: 359px) {
    .cb-stats { grid-template-columns: 1fr; }
    .cb-topbar h1 { font-size: 16px; }
}

/* Ehtiram la 3adad l users yalli mtaffyin l animations */
@media (prefers-reduced-motion: reduce) {
    .cb-sidebar, .btn, .cb-nav a { transition: none !important; }
}
