:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --muted: #64748b;
    --accent: #7c3aed;
    --success: #16a34a;
    --danger: #ef4444;
    --text: #1e293b;
    --radius: 12px;
}
.king-night {
    --bg: #0b1220;
    --card: #141b2d;
    --muted: #94a3b8;
    --accent: #7c3aed;
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 12px;
    --text: #e6eef8;
}

#merchDashboard.wrap {
    max-width: 1200px;
    margin: 0 auto;
}

#merchDashboard header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

#merchDashboard .brand {
    display: flex;
    gap: 14px;
    align-items: center;
}

#merchDashboard .logo {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
}

#merchDashboard h1 {
    margin: 0;
    font-size: 18px;
}

#merchDashboard .controls {
    display: flex;
    gap: 10px;
}

#merchDashboard .btn , #modalBackdrop .btn{
    background: var(--accent);
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
}

#merchDashboard .btn:hover , #modalBackdrop .btn:hover {
    opacity: .9;
}

#merchDashboard .theme-toggle {
    background: var(--card);
    color: var(--accent);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    padding: 8px 10px;
    font-weight: 600;
}

.king-night .theme-toggle {
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--accent);
    background: var(--card);
}

#merchDashboard .grid {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 18px;
}

#merchDashboard .card {
    background: var(--card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#merchDashboard .metrics {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

#merchDashboard .metric {
    flex: 1;
    background: var(--card);
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}

#merchDashboard .metric h3 {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}


#merchDashboard .metric p {
    margin: 8px 0 0;
    font-size: 20px;
    font-weight: 700;
}

#merchDashboard table {
    width: 100%;
    border-collapse: collapse;
}

#merchDashboard th,
#merchDashboard td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#merchDashboard th {
    color: var(--muted);
    font-size: 12px;
}

.king-night th,
.king-night td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

#merchDashboard .actions {
    display: flex;
    gap: 8px;
}

#merchDashboard .action-btn {
    border: none;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    color: white;
}

#merchDashboard .edit {
    background: var(--accent);
}

#merchDashboard .delete {
    background: var(--danger);
}

#merchDashboard .chart-wrap {
    position: relative;
    width: 100%;
    height: 260px;
    margin-bottom: 12px;
}

#merchDashboard .chart-wrap:last-child {
    height: 200px;
}

/* Pagination */
#merchDashboard .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}

#merchDashboard .page-btn {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

#merchDashboard .page-btn:hover {
    background: var(--accent);
    color: white;
}

#merchDashboard .page-btn.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 99;
}

#modalBackdrop .modal {
    width: 100%;
    max-width: 720px;
    background: var(--card);
    padding: 18px;
    border-radius: var(--radius);
    display: block;
    top: auto !important;
    left: auto;
    height: auto;
}

#modalBackdrop .form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

#modalBackdrop .form-row label {
    flex: 0 0 110px;
    color: var(--muted);
    font-size: 13px;
}

#modalBackdrop .form-row input,
#modalBackdrop .form-row textarea {
    flex: 1;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 8px;
    color: var(--text);
}

.king-night .form-row input,
.king-night .form-row textarea {
    border-color: rgba(0, 0, 0, 0.1);
    background: #f9fafb;
    color: #1e293b;
}

#modalBackdrop textarea {
    min-height: 80px;
}

#modalBackdrop .variation-list {
    margin-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 8px;
}

#modalBackdrop .variation-item {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

#modalBackdrop .small {
    width: 100px;
}

.chart-wrap canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 350px;
}

/* =========================================
   ✅ Responsive Design Enhancements
   ========================================= */
@media (max-width: 1200px) {
    #merchDashboard .grid {
        grid-template-columns: 1fr;
    }

    #merchDashboard aside.card {
        order: -1;
    }
}

/* ----- Medium screens (≤ 1024px) ----- */
@media (max-width: 1024px) {
    #merchDashboard .grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    #merchDashboard aside.card {
        order: -1;
        /* show charts above products */
    }

    .chart-wrap {
        height: auto;
    }

    .chart-wrap canvas {
        max-height: 260px;
    }

    .controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    #merchDashboard .controls .btn,
    .theme-toggle {
        flex: 1 1 45%;
        text-align: center;
    }

    #merchDashboard .metrics {
        flex-wrap: wrap;
    }

    #merchDashboard .metric {
        flex: 1 1 45%;
    }
}

/* ----- Tablets (≤ 768px) ----- */
@media (max-width: 768px) {
    #merchDashboard h1 {
        font-size: 16px;
    }

    #merchDashboard .logo {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    #merchDashboard .metric p {
        font-size: 18px;
    }

    #merchDashboard .metric h3 {
        font-size: 12px;
    }

    /* Table to card view */
    #merchDashboard table {
        border: none;
    }

    table thead {
        display: none;
    }

    #merchDashboard table tr {
        display: block;
        background: var(--card);
        margin-bottom: 10px;
        border-radius: 10px;
        padding: 10px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    #merchDashboard table td {
        display: flex;
        justify-content: space-between;
        border: none;
        padding: 6px 0;
        font-size: 14px;
    }

    #merchDashboard table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
    }

    #merchDashboard .actions {
        justify-content: flex-end;
    }

    #merchDashboard .page-btn {
        padding: 6px 10px;
        font-size: 13px;
    }

    #modalBackdrop .modal {
        max-width: 95%;
        padding: 14px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row label {
        margin-bottom: 4px;
    }

    .variation-item {
        flex-direction: column;
        align-items: stretch;
    }

    .variation-item input {
        width: 100%;
    }

    .variation-item .btn {
        width: 100%;
    }

    .chart-wrap canvas {
        max-height: 220px;
    }
}

/* ----- Phones (≤ 480px) ----- */
@media (max-width: 480px) {
    body {
        padding: 16px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .brand {
        width: 100%;
        justify-content: space-between;
    }

    .controls {
        width: 100%;
        flex-direction: column;
    }

    .controls button {
        width: 100%;
    }

    .metric {
        flex: 1 1 100%;
    }

    .chart-wrap {
        height: auto;
    }

    .chart-wrap canvas {
        max-height: 180px;
    }

    .btn {
        padding: 10px;
        font-size: 14px;
    }

    .page-btn {
        padding: 5px 8px;
    }

    /* Modal scroll fix */
    #modalBackdrop .modal {
        max-height: 90vh;
        overflow-y: auto;
    }
}