:root {
    --primary: #4F6BED;
    --primary-hover: #3b52d9;
    --bg-page: #fbfbfc;
    --bg-surface: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font: 'Outfit', sans-serif;

    --status-green-bg: #dcfce7;
    --status-green-fg: #166534;
    --status-blue-bg: #dbeafe;
    --status-blue-fg: #1e40af;
    --status-orange-bg: #ffedd5;
    --status-orange-fg: #9a3412;
    --status-red-bg: #fee2e2;
    --status-red-fg: #991b1b;
    --status-gray-bg: #f3f4f6;
    --status-gray-fg: #374151;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layouts */
.admin-layout,
.client-layout {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

.admin-layout {
    flex-direction: row;
}

/* Sidebar (Admin) */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-page);
    color: var(--text-main);
}

.sidebar-nav a i {
    width: 18px;
    height: 18px;
}

.sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 16px 12px 6px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-info {
    margin-bottom: 12px;
    padding: 0 8px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.logout-btn:hover {
    color: var(--status-red-fg);
}

/* Client Top Header */
.top-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.top-nav {
    display: flex;
    gap: 24px;
}

.top-nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s;
}

.top-nav a:hover,
.top-nav a.active {
    color: var(--text-main);
}

.user-menu {
    display: flex;
    gap: 16px;
    align-items: center;
}

.profile-link,
.logout-link {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.profile-link:hover,
.logout-link:hover {
    color: var(--text-main);
}

.profile-link i,
.logout-link i {
    width: 16px;
    height: 16px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    background: var(--bg-page);
    overflow-y: auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content-client {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

h1.page-title {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Cards & Containers */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.summary-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-card .val {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Typography */
a {
    color: var(--primary);
}

a:hover {
    color: var(--primary-hover);
}

p {
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
    font-family: var(--font);
}

.btn i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
    background: var(--bg-page);
}

.btn-danger {
    background: var(--status-red-fg);
    color: #fff;
}

.btn-danger:hover {
    background: #7f1d1d;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: #fafafa;
    padding: 12px 16px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-page);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text-main);
    background: var(--bg-surface);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 107, 237, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green {
    background: var(--status-green-bg);
    color: var(--status-green-fg);
}

.badge-blue {
    background: var(--status-blue-bg);
    color: var(--status-blue-fg);
}

.badge-orange {
    background: var(--status-orange-bg);
    color: var(--status-orange-fg);
}

.badge-red {
    background: var(--status-red-bg);
    color: var(--status-red-fg);
}

.badge-gray {
    background: var(--status-gray-bg);
    color: var(--status-gray-fg);
}

.badge-purple {
    background: #f3e8ff;
    color: #7c3aed;
}

/* Login/Register specifically */
.auth-layout {
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    padding: 24px;
    min-height: 100vh;
    display: flex;
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-md);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.product-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
}

.product-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
}

.product-img.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--border);
    font-size: 3rem;
}

.product-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 8px;
}

.product-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.product-sku {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
    margin-bottom: 12px;
}

.product-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.product-price {
    font-weight: 600;
    font-size: 1.2rem;
}

.product-actions {
    display: flex;
    gap: 8px;
}

.qty-input {
    width: 60px;
    text-align: center;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    transition: transform 0.2s;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 16px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--status-green-fg);
}

.toast.error .toast-icon {
    color: var(--status-red-fg);
}

.toast-content {
    font-weight: 500;
    font-size: 0.95rem;
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

/* Utilities */
.text-right {
    text-align: right;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.gap-2 {
    gap: 0.5rem;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

/* Mobile menus */
.mobile-menu-btn,
.mobile-menu-btn-client {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
}

.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {

    /* Auth Layout overrides */
    .auth-layout {
        padding: 16px;
    }

    .auth-card {
        padding: 24px;
    }

    /* Layouts */
    .admin-layout {
        flex-direction: column;
    }

    .main-content {
        padding: 16px;
        margin-top: 56px;
    }

    .main-content-client {
        padding: 16px;
    }

    /* Admin Sidebar Layout */
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        width: 260px;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-md);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 90;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Headings */
    h1.page-title {
        font-size: 1.3rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header>div:last-child {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .page-header>div:last-child form {
        flex-direction: column;
        width: 100%;
    }

    .page-header>div:last-child form select,
    .page-header>div:last-child form input {
        width: 100% !important;
    }

    .page-header>div:last-child .btn {
        width: 100%;
        justify-content: center;
    }

    /* Admin Hamburger */
    .mobile-menu-btn {
        display: flex;
        position: fixed;
        top: 12px;
        left: 16px;
        z-index: 50;
        padding: 6px;
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: 6px;
        box-shadow: var(--shadow-sm);
    }

    /* Forms & Grids */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .summary-card .val {
        font-size: 1.3rem;
    }

    /* Show mobile-only nav links */
    .mobile-only-link {
        display: block !important;
    }

    /* ===================== */
    /* CLIENT TOP NAV MOBILE */
    /* ===================== */
    .top-header {
        padding: 0 16px;
        position: relative;
    }

    .header-container {
        padding: 0;
        height: 56px;
        position: relative;
    }

    .logo {
        font-size: 1.1rem;
    }

    /* Hide desktop user menu items */
    .user-menu {
        display: none;
    }

    /* Hamburger button */
    .mobile-menu-btn-client {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 6px;
        order: 3;
    }

    /* Mobile dropdown nav */
    .top-nav {
        display: none;
        position: absolute;
        top: 56px;
        left: -16px;
        right: -16px;
        flex-direction: column;
        gap: 0;
        background: var(--bg-surface);
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        z-index: 50;
    }

    .top-nav.open {
        display: flex;
    }

    .top-nav a {
        padding: 14px 20px;
        border-bottom: 1px solid var(--border);
        font-size: 0.95rem;
    }

    .top-nav a:last-child {
        border-bottom: none;
    }

    .top-nav a.active {
        background: var(--bg-page);
        font-weight: 600;
    }

    /* ============================== */
    /* CLIENT TABLES → CARDS (MOBILE) */
    /* ============================== */
    .client-layout .table-wrapper {
        overflow-x: visible;
        border: none;
        background: transparent;
        margin: 0;
        border-radius: 0;
    }

    .client-layout table,
    .client-layout thead,
    .client-layout tbody,
    .client-layout th,
    .client-layout tr,
    .client-layout td {
        display: block;
    }

    .client-layout thead {
        display: none;
    }

    .client-layout tr {
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 16px;
        box-shadow: var(--shadow-sm);
    }

    .client-layout tr:hover td {
        background: transparent;
    }

    .client-layout td {
        padding: 6px 0;
        border-bottom: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.9rem;
    }

    .client-layout td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.8rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        margin-right: 12px;
        flex-shrink: 0;
    }

    .client-layout td:last-child {
        justify-content: flex-end;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px solid var(--border);
    }

    /* Modals */
    .modal-content {
        max-height: 95vh;
        margin: 0 12px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
}