:root {
    --cd-bg: #f4f7fb;
    --cd-surface: #ffffff;
    --cd-text: #263244;
    --cd-heading: #0f172a;
    --cd-muted: #64748b;
    --cd-soft: #eef4ff;
    --cd-border: #dde6f1;
    --cd-border-strong: #cfdae8;
    --cd-radius: 16px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body.cd-admin-body,
body {
    margin: 0;
    background: var(--cd-bg);
    color: var(--cd-text);
    font-family: "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    font-weight: 400;
    line-height: 21px;
    overflow-x: hidden;
}

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

a:hover {
    color: var(--cd-secondary);
}

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

.app-sidebar {
    width: 250px;
    background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,0)), var(--cd-sidebar);
    color: #e5e7eb;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    overflow-y: auto;
    scrollbar-width: none;
    box-shadow: 14px 0 28px rgba(15, 23, 42, .08);
}

.app-sidebar::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.brand-block {
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--cd-primary);
    font-weight: 700;
    flex: 0 0 auto;
    box-shadow: 0 8px 22px rgba(37, 99, 235, .24);
}

.brand-copy {
    min-width: 0;
}

.brand-title {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 18px;
    margin: 0;
    max-width: 164px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-subtitle {
    color: rgba(255,255,255,.58);
    font-size: 11px;
    line-height: 14px;
}

.nav-section {
    padding: 14px 14px 12px;
}

.nav-label {
    color: rgba(255,255,255,.43);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .085em;
    text-transform: uppercase;
    padding: 10px 9px 6px;
}

.sidebar-link {
    color: rgba(255,255,255,.75);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 12px;
    margin-bottom: 3px;
    font-size: 13px;
    font-weight: 500;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}

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

.sidebar-link:hover {
    transform: translateX(1px);
}

.sidebar-link.active {
    box-shadow: inset 3px 0 0 var(--cd-primary);
}

.sidebar-link-muted {
    opacity: .82;
}

.sidebar-icon {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.76);
    font-size: 10px;
    font-weight: 700;
    flex: 0 0 auto;
}

.sidebar-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-link.active .sidebar-icon,
.sidebar-link:hover .sidebar-icon {
    color: #fff;
    background: var(--cd-primary);
}

.app-main {
    flex: 1;
    margin-left: 250px;
    min-width: 0;
}

.app-topbar {
    min-height: 68px;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--cd-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(12px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-copy {
    min-width: 0;
}

.topbar-title {
    display: block;
    color: var(--cd-heading);
    font-size: 14px;
    line-height: 18px;
    font-weight: 700;
    max-width: 460px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-date {
    color: var(--cd-muted);
    font-size: 11px;
    line-height: 16px;
    margin-top: 1px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    flex: 0 0 auto;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    max-width: 250px;
    min-width: 0;
    background: #f8fafc;
    border: 1px solid var(--cd-border);
    border-radius: 999px;
    padding: 4px 10px 4px 4px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--cd-secondary);
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
}

.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-toggle {
    width: 38px;
    height: 38px;
    border: 1px solid var(--cd-border);
    border-radius: 12px;
    background: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
}

.sidebar-toggle span {
    width: 16px;
    height: 2px;
    background: #334155;
    border-radius: 999px;
}

.sidebar-backdrop {
    display: none;
}

.page-wrap {
    padding: 24px;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-title {
    font-size: 24px;
    line-height: 30px;
    font-weight: 700;
    margin: 0;
    color: var(--cd-heading);
}

.page-subtitle {
    color: var(--cd-muted);
    margin: 4px 0 0;
}

.card {
    border: 1px solid var(--cd-border);
    border-radius: var(--cd-radius);
    box-shadow: 0 12px 34px rgba(15, 23, 42, .055);
    background: #fff;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--cd-border);
    border-radius: var(--cd-radius) var(--cd-radius) 0 0 !important;
    color: var(--cd-heading);
    font-size: 13px;
    font-weight: 600;
    padding: 13px 16px;
}

.card-body {
    padding: 16px;
}

.cd-dashboard-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--cd-hero-from) 0%, var(--cd-hero-to) 100%);
    color: #fff;
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .16);
}

.cd-dashboard-hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -70px;
    top: -90px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
}

.cd-dashboard-hero > * {
    position: relative;
    z-index: 1;
}

.cd-dashboard-hero h1 {
    margin: 0;
    font-size: 24px;
    line-height: 30px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.cd-dashboard-hero p {
    margin: 6px 0 0;
    color: rgba(255,255,255,.72);
    max-width: 700px;
}

.cd-dashboard-hero .btn {
    border-color: rgba(255,255,255,.22);
    color: #fff;
    background: rgba(255,255,255,.1);
}

.cd-dashboard-hero .btn:hover {
    background: rgba(255,255,255,.18);
}

.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.hero-stat {
    min-width: 132px;
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.08);
    border-radius: 14px;
    padding: 10px 12px;
}

.hero-stat strong {
    display: block;
    color: #fff;
    font-size: 18px;
    line-height: 22px;
    font-weight: 700;
}

.hero-stat span {
    display: block;
    color: rgba(255,255,255,.68);
    font-size: 11px;
    line-height: 16px;
    margin-top: 1px;
}

.kpi-card {
    overflow: hidden;
    position: relative;
    min-height: 116px;
}

.kpi-card::after {
    content: "";
    position: absolute;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    right: -34px;
    top: -34px;
    background: color-mix(in srgb, var(--cd-primary) 14%, transparent);
}

.kpi-card .card-body {
    position: relative;
    z-index: 1;
}

.kpi-label {
    color: var(--cd-muted);
    font-weight: 500;
}

.kpi-value {
    color: var(--cd-heading);
    font-size: 26px;
    line-height: 32px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-top: 4px;
}

.kpi-hint {
    color: var(--cd-muted);
    font-size: 11px;
    line-height: 16px;
    margin-top: 5px;
}

.metric-list {
    display: grid;
    gap: 10px;
}

.metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--cd-border);
    border-radius: 14px;
    padding: 11px 12px;
    background: #fbfdff;
}

.metric-row span {
    color: var(--cd-muted);
}

.metric-row strong {
    color: var(--cd-heading);
    font-size: 14px;
    font-weight: 700;
}

.table {
    color: #334155;
    font-size: 13px;
    margin-bottom: 0;
}

.table thead th {
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid var(--cd-border);
    white-space: nowrap;
    background: #f6f9fd;
    padding-top: 11px;
    padding-bottom: 11px;
}

.table tbody td {
    color: #263244;
    font-size: 13px;
    font-weight: 400;
    vertical-align: middle;
    white-space: nowrap;
    padding-top: 10px;
    padding-bottom: 10px;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: #fbfdff;
}

.table-striped > tbody > tr:nth-of-type(even) > * {
    --bs-table-bg-type: #ffffff;
}

.table-hover tbody tr:hover > * {
    --bs-table-bg-type: #eef4ff;
}

.btn {
    font-size: 13px;
    font-weight: 600;
    border-radius: 11px;
}

.btn-primary {
    background: var(--cd-primary);
    border-color: var(--cd-primary);
}

.btn-dark {
    background: var(--cd-dark);
    border-color: var(--cd-dark);
    box-shadow: 0 10px 20px rgba(15, 23, 42, .14);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.form-control,
.form-select {
    font-size: 13px;
    border-radius: 11px;
    border-color: var(--cd-border);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cd-primary);
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12);
}

.badge {
    font-weight: 600;
    border-radius: 999px;
}

.badge-soft {
    background: #eef4ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.alert {
    border-radius: 14px;
    font-size: 13px;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--cd-border);
    border-radius: 22px;
    box-shadow: 0 22px 70px rgba(15, 23, 42, .12);
    overflow: hidden;
}

.auth-card-header {
    padding: 28px 28px 14px;
}

.auth-card-body {
    padding: 14px 28px 28px;
}

.auth-title {
    color: var(--cd-heading);
    font-size: 22px;
    line-height: 28px;
    font-weight: 700;
    margin: 0;
}

.auth-subtitle {
    color: var(--cd-muted);
    margin: 5px 0 0;
}

@media (max-width: 1199.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1025;
        background: rgba(15, 23, 42, .42);
    }
}

@media (max-width: 767.98px) {
    .app-topbar {
        padding: 0 14px;
    }

    .page-wrap {
        padding: 16px;
    }

    .topbar-actions {
        gap: 8px;
    }

    .user-name {
        display: none;
    }

    .cd-dashboard-hero {
        padding: 18px;
    }

    .page-title,
    .cd-dashboard-hero h1 {
        font-size: 21px;
        line-height: 27px;
    }
}


/* Fix 005: brand foundation and reusable theme utilities */
.brand-block {
    text-decoration: none;
    min-height: 68px;
}

.brand-logo-full {
    width: 172px;
    max-width: calc(100% - 14px);
    height: auto;
    display: block;
}

.brand-logo-mark {
    display: none;
    width: 38px;
    height: 38px;
}

.hero-eyebrow {
    color: rgba(255,255,255,.7);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.kpi-topline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--cd-primary);
    box-shadow: 0 10px 20px rgba(15, 23, 42, .1);
    font-size: 11px;
    font-weight: 800;
}

.kpi-primary .kpi-icon,
.kpi-primary::after { background: color-mix(in srgb, var(--cd-primary) 18%, transparent); }
.kpi-primary .kpi-icon { background: var(--cd-primary); }

.kpi-success .kpi-icon,
.kpi-success::after { background: color-mix(in srgb, var(--cd-success) 18%, transparent); }
.kpi-success .kpi-icon { background: var(--cd-success); }

.kpi-violet .kpi-icon,
.kpi-violet::after { background: color-mix(in srgb, #7C3AED 18%, transparent); }
.kpi-violet .kpi-icon { background: #7C3AED; }

.kpi-info .kpi-icon,
.kpi-info::after { background: color-mix(in srgb, var(--cd-info) 18%, transparent); }
.kpi-info .kpi-icon { background: var(--cd-info); }

.kpi-warning .kpi-icon,
.kpi-warning::after { background: color-mix(in srgb, var(--cd-warning) 18%, transparent); }
.kpi-warning .kpi-icon { background: var(--cd-warning); }

.kpi-danger .kpi-icon,
.kpi-danger::after { background: color-mix(in srgb, var(--cd-danger) 18%, transparent); }
.kpi-danger .kpi-icon { background: var(--cd-danger); }

.metric-primary { border-left: 4px solid var(--cd-primary); }
.metric-success { border-left: 4px solid var(--cd-success); }
.metric-warning { border-left: 4px solid var(--cd-warning); }
.metric-info { border-left: 4px solid var(--cd-info); }

.theme-preview-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.theme-preview-card {
    text-align: left;
    border: 1px solid var(--cd-border);
    border-radius: 16px;
    background: #fff;
    padding: 12px;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.theme-preview-card:hover,
.theme-preview-card.active {
    border-color: var(--cd-primary);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .08);
    transform: translateY(-1px);
}

.theme-preview-name {
    color: var(--cd-heading);
    display: block;
    font-weight: 700;
    margin-bottom: 10px;
}

.theme-swatch-row {
    display: flex;
    gap: 5px;
}

.theme-swatch-row span {
    width: 100%;
    height: 28px;
    border-radius: 9px;
    border: 1px solid rgba(15, 23, 42, .08);
}

.auth-brand {
    padding: 28px 28px 0;
}

.auth-brand img {
    width: 230px;
    max-width: 100%;
    height: auto;
    display: block;
}

@media (max-width: 1199.98px) {
    .theme-preview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .theme-preview-grid {
        grid-template-columns: 1fr;
    }
    .brand-logo-full {
        width: 158px;
    }
}
