:root {
    --m3-red: #c1121f;
    --m3-black: #111111;
    --m3-white: #f8f9fa;
    --m3-accent: #c1121f;
    --m3-divider: #c1121f;
    --m3-menu-bg: linear-gradient(180deg, #111111 0%, #1f1f1f 100%);
    --m3-menu-text: #f8f9fa;
    --m3-page-bg: radial-gradient(circle at 5% 10%, rgba(193, 18, 31, 0.15), transparent 35%), radial-gradient(circle at 95% 90%, rgba(0, 0, 0, 0.15), transparent 30%), #f0f1f3;
    --m3-font-family: 'Montserrat', sans-serif;
}

body {
    font-family: var(--m3-font-family);
    font-size: calc(1rem * var(--m3-font-scale));
    background: var(--m3-page-bg);
    min-height: 100vh;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 270px;
    height: 100vh;
    background: var(--m3-menu-bg);
    border-right: 2px solid var(--m3-divider);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 1000;
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar-brand {
    font-size: 1.1rem;
    letter-spacing: 0.3px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--m3-menu-text);
}

.brand-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: 8px;
    background: #ffffff;
    padding: 2px;
}

.brand-text {
    font-weight: 700;
    letter-spacing: 0.2px;
}

.brand-logo-login {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 10px;
    background: #ffffff;
    padding: 3px;
    border: 1px solid #e5e7eb;
}

.side-link {
    color: var(--m3-menu-text) !important;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 10px;
    text-decoration: none;
    display: block;
}

.side-link:hover {
    color: var(--m3-menu-text);
    background: color-mix(in srgb, var(--m3-accent) 24%, transparent);
    border-color: color-mix(in srgb, var(--m3-accent) 46%, transparent);
}

.side-link.active {
    color: var(--m3-menu-text);
    background: color-mix(in srgb, var(--m3-accent) 42%, transparent);
    border-color: color-mix(in srgb, var(--m3-menu-text) 30%, transparent);
    font-weight: 700;
}

.sidebar-meta {
    color: color-mix(in srgb, var(--m3-menu-text) 65%, transparent);
}

.admin-content {
    margin-left: 270px;
    width: calc(100% - 270px);
    padding: 24px;
    box-sizing: border-box;
    min-height: 100vh;
}

.sidebar-mobile-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1101;
    border: 1px solid var(--m3-divider);
    background: color-mix(in srgb, var(--m3-divider) 18%, #111111);
    color: #fff;
    border-radius: 8px;
    padding: 8px 12px;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1099;
    display: none;
}

.bg-m3-black {
    background-color: var(--m3-black);
}

.card {
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 18px rgba(17, 17, 17, 0.06);
}

body[data-density='compact'] .admin-content {
    padding: 16px;
}

body[data-density='compact'] .card {
    box-shadow: 0 4px 10px rgba(17, 17, 17, 0.05);
}

body[data-density='compact'] .table > :not(caption) > * > * {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

body[data-density='compact'] .side-link {
    padding: 6px 9px;
}

body[data-density='comfortable'] .table > :not(caption) > * > * {
    padding-top: 0.72rem;
    padding-bottom: 0.72rem;
}

body.high-contrast {
    --m3-accent: #000000;
    --m3-divider: #000000;
    --m3-menu-bg: linear-gradient(180deg, #000000 0%, #000000 100%);
    --m3-menu-text: #ffffff;
    --m3-page-bg: #ffffff;
}

body.high-contrast .side-link,
body.high-contrast .brand-link,
body.high-contrast .admin-sidebar .small {
    color: #ffffff !important;
}

body.high-contrast .side-link.active {
    background: #ffffff;
    color: #000000 !important;
    border-color: #000000;
}

body.high-contrast .side-link:hover {
    background: #f3f4f6;
    color: #000000 !important;
    border-color: #000000;
}

body.high-contrast .card,
body.high-contrast .list-card-item,
body.high-contrast .table {
    border-color: #111111 !important;
    box-shadow: none !important;
}

.metric-card {
    border-left: 5px solid var(--m3-accent);
}

.theme-card {
    border: 1px solid #d4d4d8;
    border-radius: 14px;
    padding: 14px;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

.theme-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.theme-card.selected {
    border-color: var(--m3-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--m3-accent) 25%, transparent);
}

.theme-preview {
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    height: 84px;
    position: relative;
    overflow: hidden;
    margin-bottom: 10px;
}

.theme-preview-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    height: 100%;
}

.theme-preview-divider {
    position: absolute;
    top: 0;
    left: 30%;
    width: 4px;
    height: 100%;
}

.theme-preview-page {
    position: absolute;
    top: 0;
    left: calc(30% + 4px);
    width: calc(70% - 4px);
    height: 100%;
}

.theme-dots {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.18);
}

.theme-font-sample {
    font-size: 0.92rem;
    color: #334155;
}

.view-toggle {
    display: flex;
    gap: 8px;
}

.list-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.list-card-item {
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    padding: 12px;
}

.media-thumb {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
}

.print-only {
    display: none;
}

@media (min-width: 992px) {
    .sidebar-mobile-toggle,
    .sidebar-backdrop {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .admin-shell {
        display: block;
    }

    .admin-sidebar {
        width: 260px;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
    }

    .admin-content {
        margin-left: 0;
        width: 100%;
        padding: 56px 16px 16px;
    }

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

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

@media print {
    body {
        background: #ffffff !important;
    }

    .admin-sidebar,
    .sidebar-mobile-toggle,
    .sidebar-backdrop,
    .no-print {
        display: none !important;
    }

    .admin-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .print-only {
        display: block !important;
    }

    .card {
        border: 1px solid #d1d5db !important;
        box-shadow: none !important;
    }
}
