:root {
    --bg: #f5f6fb;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --text: #111827;
    --muted: #6b7280;
    --white: #ffffff;
    --border: #e5e7eb;
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

/* Login */

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(124, 58, 237, 0.18), transparent 35%),
        radial-gradient(circle at bottom right, rgba(236, 72, 153, 0.15), transparent 35%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 26px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    color: white;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.login-brand h1 {
    margin: 0;
    font-size: 24px;
}

.login-brand p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-form label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.login-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 15px;
    font: inherit;
    outline: none;
    background: #fff;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

.login-form button {
    border: 0;
    border-radius: 14px;
    padding: 14px 16px;
    font: inherit;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    cursor: pointer;
}

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 600;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
}

.alert.success {
    background: #f0fdf4;
    color: #166534;
}

/* Admin layout */

.admin-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 280px;
    min-height: 100vh;
    background: var(--sidebar);
    color: white;
    padding: 22px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand strong {
    display: block;
    font-size: 16px;
}

.sidebar-brand span {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #9ca3af;
}

.sidebar-close {
    display: none;
    border: 0;
    background: transparent;
    color: white;
    font-size: 30px;
    cursor: pointer;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
    margin-top: 32px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #d1d5db;
    padding: 13px 14px;
    border-radius: 14px;
    font-weight: 650;
    transition: 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--sidebar-soft);
    padding: 14px;
    border-radius: 18px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    font-weight: 800;
}

.user-info strong {
    display: block;
    font-size: 14px;
}

.user-info span {
    display: block;
    color: #9ca3af;
    font-size: 12px;
    margin-top: 2px;
}

.logout-link {
    margin-top: 12px;
    padding: 13px 14px;
    border-radius: 14px;
    text-align: center;
    background: rgba(220, 38, 38, 0.14);
    color: #fecaca;
    font-weight: 800;
}

.main-content {
    width: 100%;
    margin-left: 280px;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0;
    font-size: 30px;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
}

.sidebar-toggle {
    display: none;
    border: 1px solid var(--border);
    background: white;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 20px;
    cursor: pointer;
}

.content-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 26px;
    box-shadow: var(--shadow);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    background: #fafafa;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-card strong {
    display: block;
    font-size: 30px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
}

.panel h2 {
    margin-top: 0;
}

/* Mobile */

.sidebar-overlay {
    display: none;
}

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
        transition: 0.25s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 40;
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .login-card {
        padding: 24px;
        border-radius: 22px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .content-card {
        padding: 20px;
        border-radius: 22px;
    }
}

/* Orders Page */

.orders-page {
    display: grid;
    gap: 22px;
}

.orders-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.orders-header h2 {
    margin: 0;
    font-size: 24px;
}

.orders-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.orders-search {
    display: flex;
    gap: 10px;
    min-width: 360px;
}

.orders-search input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    outline: none;
}

.orders-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

.orders-search button {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 800;
    background: var(--primary);
    color: white;
    cursor: pointer;
}

.order-tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.order-tabs a {
    min-width: max-content;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: var(--text);
    font-weight: 750;
}

.order-tabs a strong {
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #f3f4f6;
    font-size: 12px;
}

.order-tabs a.active {
    color: white;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    border-color: transparent;
}

.order-tabs a.active strong {
    color: var(--primary);
    background: white;
}

.orders-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: white;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1080px;
}

.orders-table th {
    text-align: left;
    padding: 16px;
    font-size: 13px;
    color: var(--muted);
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
}

.orders-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.orders-table tr:last-child td {
    border-bottom: 0;
}

.text-right {
    text-align: right;
}

.order-main,
.customer-cell,
.amount-cell,
.payment-cell,
.status-stack,
.shipping-cell {
    display: grid;
    gap: 4px;
}

.order-main strong,
.customer-cell strong,
.amount-cell strong,
.shipping-cell strong {
    font-size: 14px;
}

.order-main span,
.customer-cell span,
.amount-cell span,
.payment-cell small,
.shipping-cell span {
    color: var(--muted);
    font-size: 13px;
}

.customer-cell small {
    color: var(--muted);
    font-size: 12px;
}

.pill {
    width: max-content;
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.pill.cod {
    background: #fff7ed;
    color: #c2410c;
}

.pill.prepaid {
    background: #ecfdf5;
    color: #047857;
}

.status-badge {
    width: max-content;
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-confirmed {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-to_dispatch {
    background: #ede9fe;
    color: #6d28d9;
}

.status-in_transit {
    background: #e0f2fe;
    color: #0369a1;
}

.status-delivered {
    background: #dcfce7;
    color: #166534;
}

.status-ndr {
    background: #ffedd5;
    color: #9a3412;
}

.status-rto {
    background: #fee2e2;
    color: #991b1b;
}

.status-cancelled {
    background: #f3f4f6;
    color: #374151;
}

.verified {
    color: #16a34a;
    font-weight: 800;
}

.not-verified {
    color: #dc2626;
    font-weight: 800;
}

.shipping-cell a {
    color: var(--primary);
    font-weight: 800;
    font-size: 13px;
}

.order-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.order-actions form {
    margin: 0;
}

.btn-mini {
    border: 0;
    border-radius: 11px;
    padding: 8px 11px;
    font: inherit;
    font-size: 12px;
    font-weight: 900;
    color: #111827;
    background: #f3f4f6;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-mini.primary {
    color: white;
    background: var(--primary);
}

.btn-mini.light {
    background: #eef2ff;
    color: #4338ca;
}

.btn-mini.danger {
    color: #991b1b;
    background: #fee2e2;
}

.admin-alert {
    border-radius: 16px;
    padding: 14px 16px;
    font-weight: 750;
}

.admin-alert.success {
    background: #ecfdf5;
    color: #047857;
}

.admin-alert.error {
    background: #fef2f2;
    color: #991b1b;
}

.empty-state {
    text-align: center;
    padding: 44px 20px;
}

.empty-state h3 {
    margin: 0;
    font-size: 20px;
}

.empty-state p {
    margin: 8px 0 0;
    color: var(--muted);
}

@media (max-width: 900px) {
    .orders-header {
        display: grid;
    }

    .orders-search {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .orders-search {
        display: grid;
    }
}

/* Admin 404 Page */

.error-page {
    min-height: 480px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 40px 20px;
}

.admin-error-page {
    max-width: 720px;
    margin: 0 auto;
}

.error-visual {
    width: 160px;
    height: 160px;
    display: grid;
    place-items: center;
    margin: 0 auto 26px;
    border-radius: 44px;
    background:
        radial-gradient(circle at top left, rgba(124, 58, 237, 0.22), transparent 45%),
        radial-gradient(circle at bottom right, rgba(236, 72, 153, 0.22), transparent 45%),
        #f8fafc;
    border: 1px solid var(--border);
}

.error-visual span {
    font-size: 52px;
    font-weight: 1000;
    letter-spacing: -0.07em;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.error-page h2 {
    margin: 0;
    font-size: 34px;
    font-weight: 950;
    letter-spacing: -0.04em;
}

.error-page p {
    max-width: 520px;
    margin: 12px auto 0;
    color: var(--muted);
    line-height: 1.7;
}

.error-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.error-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 14px;
    font-weight: 900;
}

.error-btn.primary {
    color: white;
    background: linear-gradient(135deg, var(--primary), #ec4899);
}

.error-btn.light {
    color: var(--primary);
    background: #f3e8ff;
}

@media (max-width: 640px) {
    .error-visual {
        width: 130px;
        height: 130px;
        border-radius: 34px;
    }

    .error-visual span {
        font-size: 42px;
    }

    .error-page h2 {
        font-size: 28px;
    }

    .error-actions {
        display: grid;
    }
}

/* Shopify Page */

.shopify-page {
    display: grid;
    gap: 22px;
}

.shopify-config-box {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.shopify-config-box > div {
    display: grid;
    gap: 5px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f9fafb;
}

.shopify-config-box span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.shopify-config-box strong {
    word-break: break-all;
}

.shopify-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 24px;
}

.shopify-actions form {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.shopify-actions label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.shopify-actions select {
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 11px 13px;
    font: inherit;
    background: white;
}

.btn-modern {
    border: 0;
    border-radius: 14px;
    min-height: 44px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.btn-modern.primary {
    color: white;
    background: linear-gradient(135deg, var(--primary), #ec4899);
}

.btn-modern.light {
    color: var(--primary);
    background: #f3e8ff;
}

.webhook-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.webhook-list > div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f9fafb;
}

.webhook-list span {
    color: var(--muted);
    font-weight: 800;
}
.sidebar-wa-badge {
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.sidebar-wa-badge[hidden] {
    display: none;
}
