:root {
    --mx-primary: #6366f1;
    --mx-primary-hover: #4f46e5;
    --mx-bg: #f1f5f9;
    --mx-surface: rgba(255, 255, 255, 0.72);
    --mx-border: rgba(148, 163, 184, 0.35);
    --mx-text: #0f172a;
    --mx-muted: #64748b;
    --mx-sidebar-w: 260px;
    --mx-sidebar-collapsed: 78px;
    --mx-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
    --mx-bg: #0b1220;
    --mx-surface: rgba(30, 41, 59, 0.65);
    --mx-border: rgba(71, 85, 105, 0.45);
    --mx-text: #e2e8f0;
    --mx-muted: #94a3b8;
    --mx-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    background: var(--mx-bg);
    color: var(--mx-text);
}

.glass-panel {
    background: var(--mx-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--mx-border);
    border-radius: 1rem;
    box-shadow: var(--mx-shadow);
}

/* Auth */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-page { position: relative; width: 100%; max-width: 440px; }
.auth-bg {
    position: fixed; inset: 0; z-index: -1;
    background:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.25), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.15), transparent 35%),
        var(--mx-bg);
}

.auth-card { padding: 2rem; }
.auth-brand { display: flex; align-items: center; gap: 1rem; }
.auth-logo {
    width: 48px; height: 48px; border-radius: 12px;
    background: linear-gradient(135deg, var(--mx-primary), #8b5cf6);
    color: #fff; display: grid; place-items: center; font-weight: 700;
}

/* Admin layout */
.admin-body { overflow-x: hidden; }
.admin-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(15, 23, 42, 0.45);
    display: none; align-items: center; justify-content: center;
}
.admin-overlay.show { display: flex; }

.admin-wrapper { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--mx-sidebar-w);
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1040;
    border-radius: 0; border-top: 0; border-bottom: 0; border-left: 0;
    transition: width 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

.admin-sidebar.collapsed { width: var(--mx-sidebar-collapsed); }
.admin-sidebar.collapsed .brand-text,
.admin-sidebar.collapsed .nav-link span { opacity: 0; width: 0; overflow: hidden; }

.sidebar-brand {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 1.25rem 1rem; border-bottom: 1px solid var(--mx-border);
}
.brand-icon {
    width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--mx-primary), #8b5cf6);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}
.brand-text { font-weight: 700; white-space: nowrap; transition: opacity 0.2s; }

.sidebar-nav { padding: 0.75rem; height: calc(100vh - 72px); overflow-y: auto; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.85rem; border-radius: 0.65rem;
    color: var(--mx-muted); text-decoration: none;
    transition: all 0.2s ease; margin-bottom: 0.15rem;
}
.sidebar-nav .nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .nav-link span { white-space: nowrap; transition: opacity 0.2s; }
.sidebar-nav .nav-link:hover { background: rgba(99, 102, 241, 0.1); color: var(--mx-text); }
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.15));
    color: var(--mx-primary); font-weight: 600;
}
.sidebar-nav .nav-link.disabled { opacity: 0.45; pointer-events: none; }

.admin-main {
    flex: 1; margin-left: var(--mx-sidebar-w);
    transition: margin-left 0.25s ease;
    min-width: 0;
}
.admin-sidebar.collapsed ~ .admin-main,
#adminWrapper:has(.admin-sidebar.collapsed) .admin-main {
    margin-left: var(--mx-sidebar-collapsed);
}

.admin-topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1.25rem; border-radius: 0;
    border-top: 0; border-left: 0; border-right: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.5rem; }
.topbar-title { font-size: 1.1rem; font-weight: 600; margin: 0; }

.btn-icon {
    width: 40px; height: 40px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--mx-border); background: transparent;
    border-radius: 0.65rem; color: var(--mx-text);
}
.btn-icon:hover { background: rgba(99, 102, 241, 0.1); }

.btn-user {
    display: inline-flex; align-items: center; gap: 0.5rem;
    border: 1px solid var(--mx-border); background: transparent;
    border-radius: 999px; padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    color: var(--mx-text);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--mx-primary); color: #fff;
    display: grid; place-items: center; font-size: 0.8rem; font-weight: 700;
}

.admin-content { padding: 1.25rem; }

/* Widgets */
.widget-card {
    padding: 1.25rem; display: flex; gap: 1rem; align-items: flex-start;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.widget-card:hover { transform: translateY(-2px); }
.widget-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center; flex-shrink: 0;
}
.widget-icon svg { width: 22px; height: 22px; }
.widget-label { margin: 0; font-size: 0.85rem; color: var(--mx-muted); }
.widget-value { margin: 0.25rem 0 0; font-size: 1.5rem; font-weight: 700; }

.panel { overflow: hidden; }
.panel-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--mx-border);
}
.panel-body { padding: 1.25rem; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.quick-actions .btn svg { width: 16px; height: 16px; margin-right: 0.35rem; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
    display: flex; gap: 0.75rem; padding: 0.65rem 0;
    border-bottom: 1px solid var(--mx-border);
}
.activity-list li:last-child { border-bottom: 0; }
.activity-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--mx-primary); margin-top: 0.45rem; flex-shrink: 0;
}
.activity-dot.success { background: #10b981; }
.activity-dot.danger { background: #ef4444; }

.status-badge { background: rgba(99, 102, 241, 0.15); color: var(--mx-primary); }

[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }

[data-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--mx-text); }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: rgba(15, 23, 42, 0.6); border-color: var(--mx-border); color: var(--mx-text);
}

.btn-primary {
    --bs-btn-bg: var(--mx-primary);
    --bs-btn-border-color: var(--mx-primary);
    --bs-btn-hover-bg: var(--mx-primary-hover);
    --bs-btn-hover-border-color: var(--mx-primary-hover);
}

@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
        width: var(--mx-sidebar-w);
    }
    .admin-sidebar.mobile-open { transform: translateX(0); }
    .admin-main { margin-left: 0 !important; }
}

.media-grid .media-card {
    border: 1px solid var(--mx-border);
    border-radius: 0.85rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.media-card__top {
    position: relative;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.04);
}

.media-card__top .form-check-input {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 2;
}

.media-card__preview {
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 0.65rem;
    background: #0f172a;
}

.media-card__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-card__body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.media-card__path {
    font-size: 0.72rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    word-break: break-all;
    color: var(--mx-muted);
    line-height: 1.35;
    max-height: 2.7em;
    overflow: hidden;
}

.media-card__meta {
    font-size: 0.72rem;
    color: var(--mx-muted);
    margin-bottom: 0.35rem;
}

.media-card__form .form-label {
    color: var(--mx-muted);
}

.media-stats code {
    font-size: 0.85em;
}

/* Product editor */
.product-editor__tabs { border-bottom: 1px solid var(--mx-border); }
.product-editor__tabs .nav-link { font-size: .85rem; color: var(--mx-muted); border: none; }
.product-editor__tabs .nav-link.active { color: var(--mx-primary); font-weight: 600; background: transparent; border-bottom: 2px solid var(--mx-primary); }
.product-editor__body { padding-top: 1.25rem; }
.product-editor__footer { margin-top: .5rem; }

.product-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: .75rem;
}

.product-gallery__item {
    position: relative;
    border: 1px solid var(--mx-border);
    border-radius: .75rem;
    overflow: hidden;
    aspect-ratio: 1;
    background: #fff;
}

.product-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-gallery__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, .75);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.product-table__thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: .4rem;
    border: 1px solid var(--mx-border);
}

.product-table__no-thumb {
    display: inline-block;
    width: 36px;
    text-align: center;
    color: var(--mx-muted);
}

.bulk-toolbar { background: rgba(99, 102, 241, .04); }

.seo-preview {
    border: 1px dashed var(--mx-border);
    border-radius: .75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, .5);
}

.seo-preview__title { color: #1a0dab; font-size: 1.05rem; }
.seo-preview__url { color: #006621 !important; }

/* Quotes premium */
.quote-stat-card {
    background: var(--mx-surface);
    border: 1px solid var(--mx-border);
    border-radius: 1rem;
    padding: 1rem 1.15rem;
    box-shadow: var(--mx-shadow);
}

.quote-stat-card__label {
    display: block;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--mx-muted);
}

.quote-stat-card__value {
    font-size: 1.5rem;
    line-height: 1.2;
}

.quote-badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: .25rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--mx-border);
    background: #fff;
}

.quote-badge--draft { border-color: #cbd5e1; }
.quote-badge--sent { border-color: #93c5fd; color: #1d4ed8; }
.quote-badge--accepted { border-color: #86efac; color: #15803d; }
.quote-badge--rejected { border-color: #fca5a5; color: #b91c1c; }
.quote-badge--expired { border-color: #fde68a; color: #a16207; }

.quote-table__id { font-family: ui-monospace, monospace; font-size: .85rem; color: var(--mx-muted); }
.quote-table__actions { white-space: nowrap; }

.quote-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.quote-lines__table th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--mx-muted);
}

.quote-summary__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    font-size: .9rem;
}

.quote-summary__row input { max-width: 120px; }

.quote-summary__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
}

.quote-summary__total strong {
    color: var(--mx-primary);
    font-size: 1.35rem;
}

.quote-ref-badge {
    font-family: ui-monospace, monospace;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: #5b4cdb;
    background: linear-gradient(135deg, #ede9fe, #faf5ff);
    border: 1px solid #c4b5fd;
    border-radius: .5rem;
    padding: .4rem .65rem;
}

.quote-svc-chip {
    font-size: .72rem;
    font-weight: 600;
    color: #c2410c;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    padding: .25rem .65rem;
}

.quote-summary__meta strong {
    color: var(--mx-ink);
    font-weight: 600;
}

.blog-table__actions {
    white-space: nowrap;
}

/* Store premium hub */
.store-hub__hero {
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 55%, #6366f1 100%);
    color: #fff;
    border: none;
    overflow: hidden;
    position: relative;
}

.store-hub__hero::after {
    content: '';
    position: absolute;
    right: -40px;
    top: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    pointer-events: none;
}

.store-hub__hero-body {
    position: relative;
    z-index: 1;
    padding: 1.5rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.store-hub__eyebrow {
    display: inline-block;
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    opacity: .75;
    margin-bottom: .35rem;
}

.store-hub__title {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 0 0 .35rem;
    line-height: 1.15;
}

.store-hub__lead {
    margin: 0;
    opacity: .88;
    max-width: 36rem;
    font-size: .92rem;
}

.store-hub__hero-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.store-hub__cta {
    font-weight: 600;
}

.store-stat-card {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    padding: 1rem 1.1rem;
    border-radius: 1rem;
    border: 1px solid var(--mx-border);
    background: var(--mx-surface);
    box-shadow: var(--mx-shadow);
    transition: transform .2s ease, box-shadow .2s ease;
    height: 100%;
}

a:hover .store-stat-card {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

.store-stat-card__icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.store-stat-card__icon svg { width: 20px; height: 20px; }

.store-stat-card--products .store-stat-card__icon { background: #ede9fe; color: #5b4cdb; }
.store-stat-card--categories .store-stat-card__icon { background: #ffedd5; color: #c2410c; }
.store-stat-card--orders .store-stat-card__icon { background: #dcfce7; color: #15803d; }
.store-stat-card--banners .store-stat-card__icon { background: #e0f2fe; color: #0369a1; }

.store-stat-card__label {
    display: block;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--mx-muted);
}

.store-stat-card__value {
    display: block;
    font-size: 1.45rem;
    line-height: 1.1;
    margin-top: .15rem;
}

.store-stat-card__desc {
    display: block;
    font-size: .72rem;
    color: var(--mx-muted);
    margin-top: .25rem;
}

.store-action-tile {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--mx-border);
    border-radius: .85rem;
    text-decoration: none;
    color: inherit;
    background: #fff;
    transition: border-color .2s, box-shadow .2s, transform .2s;
    height: 100%;
}

.store-action-tile:hover {
    border-color: #c4b5fd;
    box-shadow: 0 6px 18px rgba(91, 76, 219, .1);
    transform: translateY(-1px);
    color: inherit;
}

.store-action-tile--primary {
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
    border-color: #86efac;
}

.store-action-tile--primary:hover { border-color: #4ade80; }

.store-action-tile__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--mx-primary-soft, #ede9fe);
    color: var(--mx-primary);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.store-action-tile--primary .store-action-tile__icon {
    background: #bbf7d0;
    color: #166534;
}

.store-action-tile__icon svg { width: 18px; height: 18px; }

.store-action-tile__text strong {
    display: block;
    font-size: .92rem;
}

.store-action-tile__text small {
    display: block;
    color: var(--mx-muted);
    margin-top: .15rem;
}

.store-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.store-summary-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .55rem 0;
    border-bottom: 1px solid var(--mx-border);
    font-size: .88rem;
}

.store-summary-list li:last-child { border-bottom: 0; }

.store-summary-list strong {
    font-size: 1rem;
    color: var(--mx-primary);
}

.cat-table th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--mx-muted);
    background: var(--mx-surface);
}

.cat-row__name { display: flex; align-items: center; gap: .35rem; }

.cat-row__branch {
    color: var(--mx-muted);
    font-family: ui-monospace, monospace;
    font-size: .8rem;
}

.cat-pill {
    display: inline-block;
    min-width: 1.6rem;
    padding: .15rem .45rem;
    border-radius: 999px;
    background: #ede9fe;
    color: #5b4cdb;
    font-size: .75rem;
    font-weight: 700;
}

.cat-row__actions { white-space: nowrap; }

.store-cat-form .panel-header { background: linear-gradient(180deg, #faf5ff, #fff); }
