:root {
    --sidebar-width: 280px;
    --primary: #0f766e;
    --primary-dark: #0d5f59;
    --primary-soft: #ecfdf8;
    --sidebar-bg: #0b1220;
    --sidebar-bg-2: #111827;
    --body-bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 8px 24px rgba(15, 23, 42, .06);
    --radius: 14px;
    --font: "DM Sans", system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }

body {
    background: var(--body-bg);
    font-family: var(--font);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

body.sidebar-open { overflow: hidden; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, .35), transparent 40%),
        linear-gradient(160deg, #0b1220 0%, #0f2744 55%, #0f766e 120%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    padding: 2rem;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

/* Layout */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, .5);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 1.15rem 1.15rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.brand-logo img {
    display: block;
    width: min(180px, 100%);
    height: auto;
}

.brand-logo small {
    color: rgba(255,255,255,.55);
    font-size: .78rem;
}

.login-logo {
    display: block;
    width: min(220px, 80%);
    height: auto;
    margin: 0 auto;
}

.sidebar-close {
    background: rgba(255,255,255,.08);
    border: 0;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .85rem .7rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .22) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .22);
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 118, 110, .7);
}

.sidebar-nav::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

.nav-group {
    margin-bottom: .45rem;
}

.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    background: transparent;
    border: 0;
    color: rgba(255,255,255,.55);
    padding: .55rem .7rem;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    cursor: pointer;
}

.nav-group-toggle:hover {
    color: rgba(255,255,255,.9);
    background: rgba(255,255,255,.04);
}

.nav-group-label {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
}

.nav-chevron {
    font-size: .65rem;
    transition: transform .2s ease;
}

.nav-group.is-open .nav-chevron {
    transform: rotate(180deg);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .15rem 0 .35rem;
}

.nav-group-items[hidden] {
    display: none;
}

.sidebar .nav-link {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    padding: .65rem .75rem;
    border-radius: 10px;
    font-size: .92rem;
    transition: background .15s ease, color .15s ease;
}

.sidebar .nav-link i {
    width: 1.1rem;
    text-align: center;
    margin-top: .15rem;
    opacity: .85;
}

.sidebar .nav-link:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.sidebar .nav-link.active {
    background: rgba(15, 118, 110, .28);
    color: #fff;
    box-shadow: inset 3px 0 0 #2dd4bf;
}

.nav-link-text {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
}

.nav-link-title {
    font-weight: 550;
    line-height: 1.25;
}

.nav-link-hint {
    font-size: .72rem;
    color: rgba(255,255,255,.45);
    font-weight: 400;
    line-height: 1.3;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: .9rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    background: rgba(0,0,0,.18);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user strong {
    display: block;
    font-size: .88rem;
    line-height: 1.2;
}

.sidebar-user small {
    color: rgba(255,255,255,.5);
    font-size: .72rem;
}

.sidebar-logout {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fda4af;
    background: rgba(244, 63, 94, .12);
    text-decoration: none;
}

.sidebar-logout:hover {
    color: #fff;
    background: rgba(244, 63, 94, .28);
}

/* Main */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 1.25rem 1.5rem 2.5rem;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.topbar-title-wrap {
    flex: 1;
    min-width: 0;
}

.topbar h1 {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.02em;
}

.topbar-subtitle {
    margin: .2rem 0 0;
    color: var(--muted);
    font-size: .9rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.topbar-user {
    font-size: .88rem;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--border);
    padding: .45rem .8rem;
    border-radius: 999px;
}

.menu-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cms-alert {
    border: 0;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.card-panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, .8);
    margin-bottom: 1rem;
    overflow: hidden;
}

.help-banner {
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    background: var(--primary-soft);
    border: 1px solid #99f6e4;
    color: #115e59;
    border-radius: 12px;
    padding: .9rem 1rem;
    margin-bottom: 1rem;
}

.help-banner i {
    margin-top: .15rem;
    flex-shrink: 0;
}

.help-banner p {
    margin: 0;
    font-size: .9rem;
    line-height: 1.45;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.15rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, .8);
    height: 100%;
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.stat-icon.bg-primary { background: var(--primary) !important; }
.stat-icon.bg-success { background: #059669 !important; }
.stat-icon.bg-warning { background: #d97706 !important; }
.stat-icon.bg-info { background: #0284c7 !important; }

.stat-card h3 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
}

.stat-card p {
    margin: 0;
    color: var(--muted);
    font-size: .88rem;
}

.dash-section-title {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 .85rem;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .75rem;
}

.quick-card {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.quick-card:hover {
    border-color: #99f6e4;
    background: var(--primary-soft);
    color: var(--text);
    transform: translateY(-1px);
}

.quick-card i {
    color: var(--primary);
    font-size: 1.15rem;
}

.quick-card strong {
    font-size: .95rem;
}

.quick-card span {
    font-size: .78rem;
    color: var(--muted);
    line-height: 1.35;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: #99f6e4;
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.list-header-title {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.list-entity-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.list-item-cell {
    display: flex;
    align-items: center;
    gap: .85rem;
    min-width: 220px;
}

.list-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
    flex-shrink: 0;
}

.list-thumb-sm {
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

.thumb-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: linear-gradient(145deg, #ecfdf8, #e2e8f0);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
    border: 1px dashed #99f6e4;
}

.thumb-placeholder-sm {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    font-size: .95rem;
}

.list-item-body {
    min-width: 0;
}

.list-item-title {
    font-weight: 650;
    font-size: .95rem;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
}

.list-item-meta {
    margin-top: .2rem;
    font-size: .78rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .35rem;
}

.list-item-meta i {
    font-size: .72rem;
}

.list-item-meta code {
    font-size: .72rem;
    background: #f1f5f9;
    padding: .1rem .35rem;
    border-radius: 4px;
    color: #475569;
}

.meta-sep {
    opacity: .45;
}

.list-id {
    font-size: .8rem;
    color: var(--muted);
    font-weight: 600;
}

.list-price {
    font-weight: 700;
    color: var(--primary-dark);
    white-space: nowrap;
}

.list-rating {
    color: #d97706;
    font-weight: 600;
    white-space: nowrap;
}

.list-rating i {
    font-size: .75rem;
}

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 650;
    margin-right: .25rem;
}

.badge-soft-success { background: #d1fae5; color: #065f46; }
.badge-soft-muted { background: #f1f5f9; color: #64748b; }
.badge-soft-info { background: #e0f2fe; color: #075985; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }

.empty-state {
    padding: 1rem;
}

.empty-state i {
    font-size: 1.75rem;
    color: #94a3b8;
    margin-bottom: .5rem;
    display: block;
}

.cms-rich-table tbody tr:hover {
    background: #f8fafc;
}

.image-upload-box .image-preview img,
.list-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
}

.image-upload-box .image-preview img {
    width: 160px;
    height: 110px;
    max-width: 100%;
}

.image-size-label {
    display: inline-block;
    margin-left: .25rem;
    color: var(--primary);
    font-weight: 650;
    font-size: .82rem;
}

.image-size-tip {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    margin-top: .55rem;
    padding: .65rem .8rem;
    border-radius: 10px;
    background: #ecfdf8;
    border: 1px solid #99f6e4;
    color: #115e59;
    font-size: .84rem;
    line-height: 1.4;
}

.image-size-tip i {
    margin-top: .15rem;
    color: var(--primary);
    flex-shrink: 0;
}

.image-size-tip strong {
    font-weight: 700;
}

.tox-tinymce {
    border-radius: 10px !important;
    border: 1px solid var(--border) !important;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.media-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.media-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.media-meta { padding: .75rem; }

.datatable-toolbar,
.datatable-footer,
.table-panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .75rem;
    align-items: center;
}

.table-panel-header { margin-bottom: 1rem; }
.datatable-toolbar { margin-bottom: 1rem; }
.datatable-footer { margin-top: 1rem; }

table.dataTable {
    width: 100% !important;
    margin: 0 !important;
    border-collapse: collapse !important;
}

table.dataTable thead th {
    white-space: nowrap;
    background: #f8fafc;
    border-bottom: 1px solid var(--border) !important;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 700;
}

table.dataTable tbody td {
    vertical-align: middle;
    border-color: #eef2f7 !important;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .45rem .75rem;
}

.dataTables_wrapper .dataTables_filter input { min-width: 200px; }

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    border: 0 !important;
    margin: 0 2px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary) !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_info {
    color: var(--muted);
    font-size: .9rem;
}

div.dataTables_wrapper div.dataTables_filter label,
div.dataTables_wrapper div.dataTables_length label {
    margin: 0;
    font-weight: 500;
    color: var(--muted);
}

.action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.form-label {
    font-weight: 600;
    font-size: .88rem;
    color: #334155;
}

.form-control,
.form-select {
    border-radius: 10px;
    border-color: var(--border);
    padding: .6rem .85rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .12);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-pill.published { background: #d1fae5; color: #065f46; }
.status-pill.draft { background: #fef3c7; color: #92400e; }
.status-pill.archived { background: #e2e8f0; color: #475569; }

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(300px, 88vw);
    }

    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        min-width: 140px;
        width: 100%;
    }

    .datatable-toolbar,
    .datatable-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .datatable-left,
    .datatable-right,
    .datatable-info,
    .datatable-paginate { width: 100%; }

    .datatable-right .dataTables_filter,
    .datatable-left .dataTables_length {
        float: none !important;
        text-align: left !important;
        width: 100%;
    }

    .datatable-paginate .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        padding-top: .5rem;
    }
}

@media (max-width: 575.98px) {
    .topbar h1 { font-size: 1.2rem; }
    .card-panel { padding: 1rem; }
    .login-card { padding: 1.5rem; }
    .action-btns .btn { flex: 1; }
    .image-upload-box .image-preview img {
        width: 100%;
        height: auto;
        max-height: 180px;
    }
    .quick-grid { grid-template-columns: 1fr 1fr; }
}
