:root {
    --font-sans: 'Inter', 'Poppins', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --border-subtle: #e5e7eb;
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04);
    --transition: 0.2s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg, #f8f9fb);
    color: var(--text, #1f2937);
    line-height: 1.6;
    font-size: 14px;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary, #0d9488);
}

/* ========================================
   APP SHELL & LAYOUT
   ======================================== */

.app-shell {
    min-height: 100vh;
    background: var(--bg, #f8f9fb);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    padding: 14px 24px;
    background: var(--topbar-bg, #ffffff);
    border-bottom: 1px solid var(--topbar-border, #e5e7eb);
    box-shadow: var(--shadow-soft);
}

.app-layout {
    min-height: calc(100vh - 72px);
    background: var(--bg, #f8f9fb);
}

/* ========================================
   SIDEBAR - Clean Modern Style
   ======================================== */

.app-sidebar {
    width: 240px;
    background: var(--sidebar-bg, #fafbfc);
    border-right: 1px solid var(--sidebar-border, #eef0f2);
    padding: 20px 16px;
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    transition: transform var(--transition);
}

.sidebar-inner {
    gap: 20px;
}

.sidebar-section {
    padding: 0 16px;
    margin-bottom: 8px;
}

.sidebar-section:first-child {
    margin-top: 8px;
}

.sidebar-section+.sidebar-section {
    margin-top: 16px;
}

.sidebar-heading {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--muted, #9ca3af);
    text-transform: uppercase;
    padding: 8px 12px 6px;
    margin-bottom: 4px;
}

.sidebar-section .text-muted.text-uppercase {
    font-size: 11px;
    letter-spacing: 0.8px;
    color: var(--muted, #9ca3af);
    font-weight: 600;
    padding-left: 12px;
    margin-bottom: 8px;
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */

.app-content {
    flex: 1;
    padding: 24px 28px;
    background: var(--bg, #f8f9fb);
}

/* ========================================
   BRAND & LOGO
   ======================================== */

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-gradient, linear-gradient(135deg, #0d9488, #14b8a6));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.brand-title {
    color: var(--text, #1f2937);
    font-size: 16px;
    font-weight: 600;
}

.brand-subtitle {
    color: var(--muted, #9ca3af);
    font-size: 12px;
}

/* ========================================
   NAVIGATION - Clean Sidebar Links
   ======================================== */

.nav-link {
    color: var(--sidebar-text, #4b5563);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition);
    position: relative;
    border-left: 3px solid transparent;
    margin-bottom: 4px;
}

.nav-link i {
    font-size: 16px;
    color: var(--sidebar-icon, #9ca3af);
    width: 20px;
    text-align: center;
    transition: color var(--transition);
}

.nav-link:hover {
    background: var(--sidebar-active-bg, rgba(13, 148, 136, 0.08));
    color: var(--primary, #0d9488);
}

.nav-link:hover i {
    color: var(--primary, #0d9488);
}

.nav-link.active {
    background: var(--sidebar-active-bg, rgba(13, 148, 136, 0.08));
    color: var(--primary, #0d9488);
    border-left-color: var(--primary, #0d9488);
    font-weight: 600;
}

.nav-link.active i {
    color: var(--primary, #0d9488);
}

/* ========================================
   UPGRADE CARD
   ======================================== */

.upgrade-card {
    border-radius: var(--radius);
    background: var(--primary-soft, rgba(13, 148, 136, 0.1));
    border: 1px dashed var(--primary, #0d9488);
    padding: 16px;
}

/* ========================================
   AVATAR & USER ELEMENTS
   ======================================== */

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--primary, #0d9488);
    color: #fff;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    padding: 0;
}

.btn-primary {
    background: var(--primary, #45a7a6);
    border-color: var(--primary, #45a7a6);
    color: #fff;
}

.btn-primary:hover {
    background: #3d9695;
    border-color: #3d9695;
    color: #fff;
}

.btn-primary:focus,
.btn-primary:focus-visible,
.btn-primary:active,
.btn-primary.active,
.btn-primary:active:focus,
.btn-primary:first-child:active {
    background: var(--primary, #45a7a6) !important;
    border-color: var(--primary, #45a7a6) !important;
    color: #fff !important;
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(69, 167, 166, 0.3)) !important;
}

.btn-outline-primary {
    border-color: var(--primary, #45a7a6);
    color: var(--primary, #45a7a6);
}

.btn-outline-primary:hover {
    background: var(--primary, #45a7a6);
    border-color: var(--primary, #45a7a6);
    color: #fff;
}

.btn-outline-primary:focus,
.btn-outline-primary:focus-visible,
.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-outline-primary:active:focus,
.btn-outline-primary:first-child:active {
    background: var(--primary, #45a7a6) !important;
    border-color: var(--primary, #45a7a6) !important;
    color: #fff !important;
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(69, 167, 166, 0.3)) !important;
}

.btn-sm {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap !important;
    padding: 8px 16px;
    line-height: 1.4;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn-sm .bi,
.btn-sm .fa-solid,
.btn-sm .fa {
    margin-right: 0;
    font-size: 14px;
}

/* ========================================
   CARDS - Clean Modern Style
   ======================================== */

.card {
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: var(--radius);
    background: var(--surface, #ffffff);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition);
}

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

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light, #f3f4f6);
    padding: 16px 20px;
}

.card-body {
    padding: 20px;
}

.card-title {
    color: var(--text, #1f2937);
    font-weight: 600;
    font-size: 15px;
}

.card-footer {
    background: var(--surface-alt, #f5f6f8);
    border-top: 1px solid var(--border-light, #f3f4f6);
    padding: 14px 20px;
}

/* ========================================
   STATS BOX - Dashboard Cards
   ======================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stats-box {
    border-radius: var(--radius);
    background: var(--surface, #ffffff);
    border: 1px solid var(--border-subtle, #e5e7eb);
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}

.stats-box:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.stats-box .card-body {
    padding: 20px;
}

.stats-box .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft, rgba(13, 148, 136, 0.1));
    color: var(--primary, #0d9488);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stats-box .text-muted.small.text-uppercase {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted, #9ca3af);
    letter-spacing: 0.3px;
    text-transform: none !important;
}

.stats-box .fs-4.fw-bold {
    font-size: 24px !important;
    font-weight: 700;
    color: var(--text, #1f2937);
    line-height: 1.2;
    margin: 4px 0;
}

/* ========================================
   CHART CARDS
   ======================================== */

.chart-card {
    border-radius: var(--radius);
    background: var(--surface, #ffffff);
    border: 1px solid var(--border-subtle, #e5e7eb);
    box-shadow: var(--shadow-card);
}

.chart-card .card-header {
    padding: 16px 20px;
}

.chart-card .card-title {
    font-size: 15px;
    font-weight: 600;
}

/* ========================================
   TABLES - Clean Modern Style
   ======================================== */

.table-card {
    border-radius: var(--radius);
    background: var(--surface, #ffffff);
    border: 1px solid var(--border-subtle, #e5e7eb);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.table-card table {
    color: var(--text, #1f2937);
    margin: 0;
}

.table-card .table-light,
.table-card thead {
    background: var(--surface-alt, #f5f6f8);
}

.table-card thead th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary, #4b5563);
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}

.table-card tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light, #f3f4f6);
    vertical-align: middle;
}

.table-card tbody tr:last-child td {
    border-bottom: none;
}

.table-card tbody tr:hover {
    background: var(--surface-alt, #f8f9fb);
}

/* ========================================
   COMPONENT CARD
   ======================================== */

.component-card {
    border-radius: var(--radius);
}

/* ========================================
   SEARCH BAR
   ======================================== */

.search-bar .form-control {
    background: var(--surface-alt, #f8fafc);
    border-color: var(--border-subtle, #e5e7eb);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
}

.search-bar .form-control:focus {
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(13, 148, 136, 0.15));
    border-color: var(--primary, #0d9488);
    background: var(--surface, #fff);
}

.search-bar .input-group-text {
    background: var(--surface-alt, #f8fafc);
    border-color: var(--border-subtle, #e5e7eb);
    color: var(--muted, #9ca3af);
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    border-radius: 6px;
    padding: 5px 10px;
    font-weight: 500;
    font-size: 12px;
}

.bg-success-subtle {
    background: var(--success-soft, rgba(16, 185, 129, 0.1)) !important;
}

.text-success {
    color: var(--success, #10b981) !important;
}

.bg-warning-subtle {
    background: var(--warning-soft, rgba(245, 158, 11, 0.1)) !important;
}

.text-warning {
    color: var(--warning, #f59e0b) !important;
}

.bg-danger-subtle {
    background: var(--danger-soft, rgba(239, 68, 68, 0.1)) !important;
}

.text-danger {
    color: var(--danger, #ef4444) !important;
}

.bg-primary-soft {
    background: var(--primary-soft, rgba(13, 148, 136, 0.1));
}

/* ========================================
   SHADOWS
   ======================================== */

.shadow-sm {
    box-shadow: var(--shadow-card) !important;
}

.shadow-soft {
    box-shadow: var(--shadow-soft);
}

/* ========================================
   SECTION TITLES
   ======================================== */

.app-section-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text, #1f2937);
    letter-spacing: -0.3px;
}

/* ========================================
   TIMELINE
   ======================================== */

.timeline {
    position: relative;
    padding-left: 28px;
    list-style: none;
    margin: 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border-subtle, #e5e7eb);
}

.timeline-item {
    position: relative;
    margin-bottom: 12px;
    padding-left: 8px;
    line-height: 1.5;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary, #45a7a6);
    border: 2px solid var(--surface, #ffffff);
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(69, 167, 166, 0.2));
}

/* ========================================
   UTILITIES
   ======================================== */

.text-title {
    color: var(--text, #1f2937);
}

.text-muted {
    color: var(--muted, #9ca3af) !important;
}

.label-muted {
    font-size: 12px;
    color: var(--muted, #9ca3af);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface-alt, #f8fafc);
    border-radius: 999px;
    color: var(--text, #1f2937);
    font-weight: 500;
    font-size: 13px;
}

/* ========================================
   DROPDOWN MENUS
   ======================================== */

.dropdown-menu {
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    padding: 8px;
}

.dropdown-item {
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    transition: all var(--transition);
}

.dropdown-item:hover {
    background: var(--primary-soft, rgba(13, 148, 136, 0.08));
    color: var(--primary, #0d9488);
}

/* ========================================
   ALERTS
   ======================================== */

.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
}

.alert-warning {
    background: var(--warning-soft, rgba(245, 158, 11, 0.1));
    color: #92400e;
}

.alert-danger {
    background: var(--danger-soft, rgba(239, 68, 68, 0.1));
    color: #991b1b;
}

.alert-info {
    background: var(--info-soft, rgba(14, 165, 233, 0.1));
    color: #0369a1;
}

.alert-success {
    background: var(--success-soft, rgba(16, 185, 129, 0.1));
    color: #047857;
}

/* ========================================
   BUYER LIST (Top Buyers component)
   ======================================== */

.top-buyers-list .buyer-row {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light, #f3f4f6);
}

.top-buyers-list .buyer-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.top-buyers-list .buyer-row:first-child {
    padding-top: 0;
}

.buyer-metrics {
    display: flex;
    gap: 16px;
    margin-top: 4px;
}

.buyer-metrics .metric {
    font-size: 13px;
    color: var(--text-secondary, #4b5563);
}

.buyer-metrics .metric strong {
    color: var(--text, #1f2937);
}

/* ========================================
   AUTH PAGES (Login/Register)
   ======================================== */

body[data-page="register"] .topbar,
body[data-page="register"] .app-sidebar,
body[data-page="login"] .topbar,
body[data-page="login"] .app-sidebar {
    display: none !important;
}

body[data-page="register"] .app-layout,
body[data-page="login"] .app-layout {
    min-height: 100vh;
    background: var(--bg, #f8f9fb);
    display: block !important;
}

body[data-page="register"] .app-content,
body[data-page="login"] .app-content {
    padding: 0;
    min-height: 100vh;
}

/* ========================================
   FORM CONTROLS
   ======================================== */

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-subtle, #e5e7eb);
    font-size: 14px;
    padding: 10px 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary, #45a7a6);
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(69, 167, 166, 0.15));
}

.form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary, #4b5563);
    margin-bottom: 6px;
}

/* Form Switches & Checkboxes */
.form-check-input {
    border-color: #d1d5db;
}

.form-check-input:checked {
    background-color: var(--primary, #45a7a6);
    border-color: var(--primary, #45a7a6);
}

.form-check-input:focus {
    border-color: var(--primary, #45a7a6);
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(69, 167, 166, 0.25));
}

.form-switch {
    padding-left: 3.5em;
}

.form-switch .form-check-input {
    width: 2.5em;
    height: 1.25em;
    margin-left: -3.5em;
    margin-right: 0.75em;
    background-color: #d1d5db;
    border: none;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary, #45a7a6);
}

.form-switch .form-check-input:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    box-shadow: 0 0 0 3px var(--primary-soft, rgba(69, 167, 166, 0.25));
}

.form-check-label {
    padding-left: 4px;
}

/* ========================================
   BUTTON GROUP FILTERS
   ======================================== */

.btn-group-sm .btn {
    font-size: 12px;
    padding: 6px 12px;
}

.btn-group .btn-outline-secondary.active,
.btn-group .btn-outline-secondary:focus {
    background: var(--primary, #0d9488);
    border-color: var(--primary, #0d9488);
    color: #fff;
}

/* ========================================
   PROGRESS INDICATORS (for percentage displays)
   ======================================== */

.progress {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary, #f3f4f6);
}

.progress-bar {
    background: var(--primary, #0d9488);
    border-radius: 3px;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

#toastContainer {
    z-index: 1085;
}

.toast.lx-toast {
    border: none;
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.lx-toast__icon {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.lx-toast__message {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.1px;
}

.lx-toast--success {
    background: #34c96b;
}

.lx-toast--success .lx-toast__icon {
    color: #34c96b;
}

.lx-toast--danger {
    background: #f04438;
}

.lx-toast--danger .lx-toast__icon {
    color: #f04438;
}

.lx-toast--info {
    background: #2563eb;
}

.lx-toast--info .lx-toast__icon {
    color: #2563eb;
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        z-index: 1040;
        top: 64px;
        bottom: 0;
        height: auto;
        transform: translateX(-100%);
        box-shadow: var(--shadow-hover);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-content {
        padding: 20px;
    }
}

@media (max-width: 575px) {
    .topbar {
        padding: 12px 16px;
    }

    .app-content {
        padding: 16px;
    }

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

    .app-section-title {
        font-size: 18px;
    }
}
