/**
 * OrderFlow v3 — Design System
 * Fresh, Professional, Clean — Font Awesome icons only
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-50: #EEF2FF;
    --primary-100: #E0E7FF;
    --primary-200: #C7D2FE;
    --primary-300: #A5B4FC;
    --primary-400: #818CF8;
    --primary-500: #6366F1;
    --primary-600: #4F46E5;
    --primary-700: #4338CA;
    --primary-800: #3730A3;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    --emerald-50: #ECFDF5;
    --emerald-100: #D1FAE5;
    --emerald-500: #10B981;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --amber-50: #FFFBEB;
    --amber-500: #F59E0B;
    --amber-600: #D97706;
    --rose-50: #FFF1F2;
    --rose-500: #F43F5E;
    --rose-600: #E11D48;
    --blue-50: #EFF6FF;
    --blue-500: #3B82F6;
    --blue-600: #2563EB;
    --violet-50: #F5F3FF;
    --violet-500: #8B5CF6;
    --bg: #F1F5F9;
    --surface: #FFFFFF;
    --sidebar-bg: #FAFBFD;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -2px rgba(0, 0, 0, .05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -4px rgba(0, 0, 0, .05);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --sidebar-w: 240px;
}

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

html {
    font-size: 14px;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ===================== SIDEBAR ===================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--gray-200);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform .25s ease;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: -0.5px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--primary-600);
}

.sidebar-nav {
    padding: 12px;
    flex: 1;
}

.nav-section {
    margin-bottom: 6px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--gray-400);
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: all .15s;
    margin-bottom: 1px;
}

.nav-item:hover {
    background: var(--primary-50);
    color: var(--primary-700);
}

.nav-item.active {
    background: var(--primary-100);
    color: var(--primary-700);
    font-weight: 600;
}

.nav-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    color: var(--gray-400);
    flex-shrink: 0;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    color: var(--primary-600);
}

.nav-label {
    flex: 1;
}

.nav-badge {
    background: var(--primary-500);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

/* ===================== MAIN ===================== */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-w));
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.3px;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
    margin-top: -2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.last-sync-info {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 500;
}

.mobile-menu-btn {
    display: none;
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 12px;
    border: none;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn i {
    font-size: 12px;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.btn-outline:hover {
    border-color: var(--primary-300);
    color: var(--primary-600);
    background: var(--primary-50);
}

.btn-success {
    background: var(--emerald-600);
    color: white;
}

.btn-success:hover {
    background: var(--emerald-700);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.btn.syncing {
    opacity: .6;
    pointer-events: none;
}

.btn.syncing i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================== PAGE CONTENT ===================== */
.page-content {
    padding: 24px 28px;
    flex: 1;
    min-width: 0;
}

/* ===================== CARDS ===================== */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    color: var(--primary-500);
    font-size: 15px;
}

.card-body {
    padding: 20px;
}

/* ===================== STAT CARDS ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: transform .2s, box-shadow .2s;
}

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

.stat-header {
    margin-bottom: 12px;
}

.stat-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.stat-icon-wrap i {
    font-size: 16px;
}

.stat-icon-wrap.blue {
    background: var(--blue-50);
    color: var(--blue-600);
}

.stat-icon-wrap.green {
    background: var(--emerald-50);
    color: var(--emerald-600);
}

.stat-icon-wrap.violet {
    background: var(--violet-50);
    color: var(--violet-500);
}

.stat-icon-wrap.orange {
    background: var(--amber-50);
    color: var(--amber-600);
}

.stat-icon-wrap.rose {
    background: var(--rose-50);
    color: var(--rose-600);
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
    margin-top: 4px;
}

/* ===================== TWO COL ===================== */
.two-col {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ===================== TABLE ===================== */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background .1s;
}

.data-table tbody tr:hover,
.draft-table tbody tr:hover {
    background: var(--gray-50);
}

.draft-table tbody tr.selected-row>td {
    background-color: #eef2ff !important;
}

.draft-table tbody tr.selected-row:hover>td {
    background-color: #e0e7ff !important;
}

.data-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
}

.td-invoice {
    font-weight: 600;
    color: var(--primary-600);
    font-size: 12px;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
}

.td-muted {
    color: var(--gray-400);
    font-size: 12px;
}

.td-value {
    font-weight: 700;
    color: var(--emerald-700);
    white-space: nowrap;
}

/* ===================== DRAFT SPREADSHEET TABLE ===================== */
.draft-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.draft-table thead th {
    padding: 6px 8px;
    text-align: left;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    background: var(--primary-100);
    border: 1px solid var(--primary-200);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.draft-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
}

.draft-table tbody tr:nth-child(even) {
    background: var(--gray-50);
}

.draft-table tbody tr:hover {
    background: #FFFDE7;
}

.draft-table tbody td {
    padding: 5px 8px;
    border: 1px solid var(--gray-100);
    font-size: 12px;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.draft-table .frozen-col {
    position: sticky !important;
    z-index: 1;
}

.draft-table thead .frozen-col {
    z-index: 3 !important;
    background: var(--primary-100) !important;
}

.draft-table tbody tr .frozen-col {
    background: #fff;
}

.draft-table tbody tr:nth-child(even) .frozen-col {
    background: var(--gray-50);
}

.draft-table tbody tr:hover .frozen-col {
    background: #FFFDE7;
}

.draft-table tbody tr.selected-row .frozen-col {
    background: #eef2ff !important;
}

.draft-table tbody tr.selected-row:hover .frozen-col {
    background: #e0e7ff !important;
}

.draft-table .frozen-last {
    border-right: 2px solid var(--primary-300) !important;
    box-shadow: 2px 0 5px -2px rgba(0, 0, 0, 0.2);
}

.draft-table .row-num {
    color: var(--gray-400);
    text-align: center;
    font-size: 11px;
    min-width: 30px;
    background: var(--gray-50);
    font-weight: 600;
}

.draft-table .col-invoice {
    color: var(--primary-600);
    font-weight: 600;
    font-family: monospace;
    font-size: 11px;
}

.draft-table .col-cs {
    font-weight: 600;
    color: var(--gray-700);
}

.draft-table .col-produk {
    font-weight: 700;
    color: var(--gray-800);
}

.draft-table .col-total {
    font-weight: 700;
    color: var(--emerald-700);
}

.draft-table .col-ekspedisi {
    font-weight: 600;
}

.draft-table .col-ekspedisi.spx {
    color: var(--rose-600);
}

.draft-table .col-ekspedisi.evp {
    color: var(--blue-600);
}

.draft-table .col-bayar {
    text-align: center;
}

/* ===================== BADGES ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge i {
    font-size: 8px;
}

.badge.delivered {
    background: var(--emerald-50);
    color: var(--emerald-700);
}

.badge.rts {
    background: var(--rose-50);
    color: var(--rose-600);
}

.badge.pending {
    background: var(--amber-50);
    color: var(--amber-600);
}

.badge.transit {
    background: var(--blue-50);
    color: var(--blue-600);
}

.badge.cod {
    background: var(--amber-50);
    color: var(--amber-600);
    font-weight: 700;
}

.badge.transfer {
    background: var(--emerald-50);
    color: var(--emerald-700);
    font-weight: 700;
}

/* ===================== FILTERS ===================== */
.table-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}

.filter-input,
.filter-select {
    padding: 7px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    background: white;
    color: var(--gray-700);
    transition: border-color .2s, box-shadow .2s;
    font-weight: 500;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
}

.filter-input::placeholder {
    color: var(--gray-300);
}

/* ===================== DATE RANGE PICKER ===================== */
.date-picker-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    background: white;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
    white-space: nowrap;
}

.date-picker-trigger:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}

.date-picker-trigger i {
    color: var(--primary-500);
    font-size: 13px;
}

.date-picker-trigger .date-text {
    flex: 1;
}

.date-picker-trigger .fa-chevron-down {
    font-size: 10px;
    color: var(--gray-400);
    transition: transform .2s;
}

.date-picker-trigger.open .fa-chevron-down {
    transform: rotate(180deg);
}

.date-picker-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .2);
    z-index: 500;
    backdrop-filter: blur(2px);
}

.date-picker-overlay.show {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
}

.date-picker-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    overflow: hidden;
    animation: fadeSlideIn .2s ease;
    max-width: 700px;
    width: 95%;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.date-picker-presets {
    width: 150px;
    background: var(--gray-800);
    padding: 16px 0;
    display: flex;
    flex-direction: column;
}

.date-picker-presets button {
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: var(--gray-300);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}

.date-picker-presets button:hover {
    background: rgba(255, 255, 255, .08);
    color: white;
}

.date-picker-presets button.active {
    background: var(--primary-600);
    color: white;
    font-weight: 600;
}

.date-picker-calendars {
    flex: 1;
    padding: 20px;
}

.date-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 16px;
}

.date-picker-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    flex: 1;
    margin-right: 12px;
}

.date-picker-selected .date-label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--gray-400);
    letter-spacing: 0.5px;
}

.date-picker-selected .date-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-800);
}

.date-picker-selected .date-arrow {
    color: var(--gray-300);
    margin: 0 8px;
}

.date-picker-months {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dp-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.dp-month-nav span {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-800);
}

.dp-month-nav button {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    transition: color .15s;
}

.dp-month-nav button:hover {
    color: var(--primary-600);
}

.dp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 4px;
}

.dp-weekdays span {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-400);
    padding: 4px;
    text-transform: uppercase;
}

.dp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
}

.dp-day {
    padding: 6px 2px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all .1s;
    user-select: none;
}

.dp-day:hover {
    background: var(--primary-50);
    color: var(--primary-700);
}

.dp-day.empty {
    visibility: hidden;
}

.dp-day.today {
    font-weight: 800;
    color: var(--rose-500);
}

.dp-day.selected {
    background: var(--primary-600);
    color: white;
    font-weight: 700;
    border-radius: var(--radius-sm);
}

.dp-day.in-range {
    background: var(--primary-100);
    color: var(--primary-700);
    border-radius: 0;
}

.dp-day.range-start {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.dp-day.range-end {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.dp-day.other-month {
    color: var(--gray-300);
}

.date-picker-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
    margin-top: 16px;
}

.date-picker-footer .clear-btn {
    color: var(--gray-400);
    font-size: 12px;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    font-weight: 600;
}

.date-picker-footer .clear-btn:hover {
    color: var(--rose-500);
}

/* ===================== EXPORT BAR ===================== */
.export-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    position: relative;
    z-index: 10;
}

.export-bar .selection-info {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    flex: 1;
}

.export-bar .selection-info strong {
    color: var(--gray-800);
}

/* ===================== CHART ===================== */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 140px;
    padding: 10px 0;
}

.chart-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 28px;
}

.chart-bar {
    width: 100%;
    min-height: 4px;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--primary-400), var(--primary-600));
    position: relative;
    transition: height .4s ease;
    cursor: default;
}

.chart-bar:hover {
    background: linear-gradient(180deg, var(--primary-300), var(--primary-500));
}

.chart-bar-value {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    color: var(--primary-600);
    white-space: nowrap;
}

.chart-bar-label {
    font-size: 10px;
    color: var(--gray-400);
    margin-top: 6px;
    font-weight: 600;
}

/* ===================== TOP PRODUCTS ===================== */
.product-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.product-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-400);
    background: var(--gray-100);
}

.product-rank.top {
    background: var(--primary-600);
    color: white;
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.product-bar-bg {
    height: 4px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}

.product-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
    border-radius: 4px;
    transition: width .5s ease;
}

.product-count {
    font-weight: 800;
    font-size: 14px;
    color: var(--primary-600);
    min-width: 30px;
    text-align: right;
}

/* ===================== STATUS ===================== */
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-50);
}

.status-row:last-child {
    border: none;
}

/* ===================== CS CARDS ===================== */
.cs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.cs-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    padding: 20px;
    transition: transform .2s;
}

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

.cs-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cs-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--gray-800);
}

.cs-orders-badge {
    background: var(--primary-100);
    color: var(--primary-700);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.cs-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.cs-metric {
    text-align: center;
    padding: 10px 0;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.cs-metric-value {
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
}

.cs-metric-value.green {
    color: var(--emerald-600);
}

.cs-metric-value.red {
    color: var(--rose-500);
}

.cs-metric-value.blue {
    color: var(--blue-500);
}

.cs-metric-label {
    font-size: 10px;
    color: var(--gray-400);
    font-weight: 600;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cs-progress {
    height: 6px;
    border-radius: 6px;
    background: var(--gray-100);
    display: flex;
    overflow: hidden;
    margin-bottom: 12px;
}

.cs-progress-bar {
    height: 100%;
    transition: width .4s;
}

.cs-progress-bar.delivered {
    background: var(--emerald-500);
}

.cs-progress-bar.transit {
    background: var(--blue-500);
}

.cs-progress-bar.rts {
    background: var(--rose-500);
}

.cs-progress-bar.unmatched {
    background: var(--gray-300);
}

.cs-rates {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cs-rate-label {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 500;
}

.cs-rate-value {
    font-weight: 700;
    font-size: 13px;
}

.cs-rate-value.good {
    color: var(--emerald-600);
}

.cs-rate-value.warn {
    color: var(--amber-600);
}

.cs-rate-value.bad {
    color: var(--rose-600);
}

.cs-revenue {
    display: flex;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.cs-revenue-label {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 500;
}

.cs-revenue-value {
    font-weight: 700;
    font-size: 14px;
    color: var(--emerald-600);
}

/* ===================== SYNC CARDS ===================== */
.sync-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    padding: 24px;
    text-align: center;
}

.sync-card .sync-card-icon {
    font-size: 32px;
    color: var(--primary-500);
    margin-bottom: 12px;
}

.sync-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.sync-card p {
    font-size: 12px;
    color: var(--gray-400);
    margin-bottom: 16px;
    line-height: 1.5;
}

.sync-result {
    margin-top: 12px;
    font-size: 12px;
}

/* ===================== TABLE FOOTER ===================== */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid var(--gray-100);
}

.table-info {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
}

.pagination {
    display: flex;
    gap: 4px;
}

.pagination button {
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--gray-600);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all .15s;
    font-family: inherit;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary-400);
    color: var(--primary-600);
    background: var(--primary-50);
}

.pagination button.active {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.pagination button:disabled {
    opacity: .3;
    cursor: default;
}

/* ===================== MODAL ===================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .4);
    backdrop-filter: blur(4px);
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 550px;
    max-width: 95vw;
    max-height: 80vh;
    overflow-y: auto;
    animation: fadeSlideIn .25s ease;
}

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

.modal-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-title i {
    color: var(--primary-500);
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: 20px 24px;
}

.modal-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--gray-50);
}

.modal-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-400);
}

.modal-value {
    font-size: 13px;
    color: var(--gray-800);
    word-break: break-word;
}

.modal-divider {
    padding: 14px 0 8px;
    border-top: 2px solid var(--primary-100);
    margin-top: 6px;
}

.modal-divider-text {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-600);
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-divider-text i {
    font-size: 13px;
}

/* ===================== EMPTY / LOADING ===================== */
.loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.empty {
    text-align: center;
    padding: 40px 20px;
}

.empty-icon {
    font-size: 40px;
    color: var(--gray-300);
    margin-bottom: 12px;
}

.empty-icon i {
    font-size: 40px;
}

.empty-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
}

/* ===================== TOAST ===================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    border-left: 4px solid var(--gray-300);
    animation: toastIn .3s ease, toastOut .3s ease 4s forwards;
    min-width: 280px;
}

.toast i {
    font-size: 16px;
}

.toast.success {
    border-color: var(--emerald-500);
}

.toast.success i {
    color: var(--emerald-500);
}

.toast.error {
    border-color: var(--rose-500);
}

.toast.error i {
    color: var(--rose-500);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ===================== CHECKBOX ===================== */
.draft-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-600);
    cursor: pointer;
}

.select-all-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--primary-50);
    border-bottom: 1px solid var(--primary-100);
    font-size: 12px;
    color: var(--gray-600);
    font-weight: 500;
}

.select-all-bar label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* ===================== DRAFT TABS ===================== */
.draft-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-100);
    padding: 0 20px;
    background: var(--gray-50);
    position: relative;
    z-index: 10;
}

.draft-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
    font-family: inherit;
}

.draft-tab:hover {
    color: var(--primary-600);
    background: var(--primary-50);
}

.draft-tab.active {
    color: var(--primary-700);
    border-bottom-color: var(--primary-600);
}

.draft-tab i {
    font-size: 12px;
}

.draft-tab-count {
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.draft-tab.active .draft-tab-count {
    background: var(--primary-500);
    color: white;
}

/* ===================== NEW ORDERS BAR ===================== */
.new-orders-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
    border-bottom: 1px solid var(--primary-200);
    color: var(--primary-700);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s;
    animation: slideDownFade .3s ease;
}

.new-orders-bar:hover {
    background: linear-gradient(135deg, #E0E7FF, #C7D2FE);
}

.new-orders-bar i {
    color: var(--primary-500);
    animation: bellRing 1s ease infinite;
}

@keyframes bellRing {

    0%,
    100% {
        transform: rotate(0);
    }

    15% {
        transform: rotate(12deg);
    }

    30% {
        transform: rotate(-12deg);
    }

    45% {
        transform: rotate(6deg);
    }

    60% {
        transform: rotate(0);
    }
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        max-height: 0;
        padding: 0 20px;
    }

    to {
        opacity: 1;
        max-height: 60px;
        padding: 10px 20px;
    }
}

/* ===================== RESIZABLE COLUMNS ===================== */
.draft-table thead th {
    position: relative;
    user-select: none;
}

.draft-table thead th:not(.th-no-resize)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--primary-300);
    cursor: col-resize;
    opacity: 0;
    transition: opacity .2s;
    border-radius: 2px;
}

.draft-table thead th:not(.th-no-resize):hover::after {
    opacity: 1;
}

/* ===================== ROW SELECTION ===================== */
.draft-table tbody tr.row-selected {
    background: var(--primary-50) !important;
    outline: 1px solid var(--primary-200);
}

.draft-table tbody tr.row-selected td {
    color: var(--primary-800);
}

/* ===================== MODAL ===================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp .25s ease;
}

.modal-content.modal-lg {
    max-width: 1100px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-title i {
    color: var(--primary-500);
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all .15s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

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

.export-preview-info {
    padding: 10px 14px;
    background: var(--emerald-50);
    border-radius: var(--radius-sm);
    color: var(--emerald-700);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .date-picker-months {
        grid-template-columns: 1fr;
    }

    .date-picker-panel {
        flex-direction: column;
    }

    .date-picker-presets {
        width: auto;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px;
    }

    .date-picker-presets button {
        padding: 6px 12px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar {
        padding: 12px 16px;
    }

    .page-content {
        padding: 16px;
    }
}

/* =========================================
   SPX ADVANCED DASHBOARD STYLES
========================================= */

/* Hero Section */
.spx-hero {
    background: linear-gradient(135deg, #1e1e2d 0%, #2b2b40 100%);
    border-radius: var(--radius-lg);
    padding: 24px 30px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    flex-wrap: wrap;
    gap: 16px;
}

.spx-hero-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.spx-hero-icon {
    width: 50px;
    height: 50px;
    background: rgba(255, 107, 107, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ff6b6b;
}

.spx-hero h2 {
    margin: 0 0 4px 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.spx-hero p {
    margin: 0;
    font-size: 13px;
    color: var(--gray-400);
}

.spx-hero-actions {
    display: flex;
    gap: 10px;
}

.spx-btn-outline {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all .2s;
}

.spx-btn-outline:hover {
    background: rgba(255, 255, 255, 0.2);
}

.spx-btn-primary {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all .2s;
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.4);
}

.spx-btn-primary:hover {
    background: #ff5252;
    transform: translateY(-1px);
}

/* Metric Cards */
.spx-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.spx-metric-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    transition: all .2s;
}

.spx-metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.spx-mc-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.spx-mc-body {
    flex: 1;
}

.spx-mc-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.spx-mc-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

/* Charts Layout */
.spx-charts-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.spx-chart-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .spx-chart-row-2 {
        grid-template-columns: 1fr;
    }
}

.spx-chart-card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

.borderless {
    border-bottom: none;
    padding-bottom: 0;
}

/* Table Card & Toolbar */
.spx-table-card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-100);
    overflow: hidden;
}

.spx-table-toolbar {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
    gap: 16px;
    background: #fafafa;
}

.spx-toolbar-search {
    position: relative;
    width: 350px;
    max-width: 100%;
}

.spx-toolbar-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.spx-toolbar-search input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: white;
    transition: all .2s;
}

.spx-toolbar-search input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.spx-toolbar-filters {
    display: flex;
    gap: 12px;
}

.spx-filter-btn {
    background: white;
    border: 1px solid var(--gray-200);
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.spx-filter-btn:hover {
    background: var(--gray-50);
}

.spx-select-limit {
    background: white;
    border: 1px solid var(--gray-200);
    padding: 9px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

/* Status Tabs */
.spx-status-tabs {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 20px;
    background: white;
    scrollbar-width: none;
}

.spx-status-tabs::-webkit-scrollbar {
    display: none;
}

.spx-tab {
    padding: 14px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid transparent;
    transition: all .2s;
    white-space: nowrap;
}

.spx-tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}

.spx-tab:hover:not(.active) {
    color: var(--gray-800);
    background: var(--gray-50);
}

.spx-tab-badge {
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

.spx-tab.active .spx-tab-badge {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-600);
}

/* Specific Tab Colored Badges */
.spx-tab-badge.bg-red {
    background: #fee2e2;
    color: #ef4444;
}

.spx-tab-badge.bg-red.active {
    background: #ef4444;
    color: white;
}

.spx-tab-badge.bg-blue {
    background: #e0f2fe;
    color: #0ea5e9;
}

.spx-tab-badge.bg-blue.active {
    background: #0ea5e9;
    color: white;
}

.spx-tab-badge.bg-green {
    background: #dcfce7;
    color: #22c55e;
}

.spx-tab-badge.bg-green.active {
    background: #22c55e;
    color: white;
}

/* Modern Table Adjustments */
.spx-modern-table th {
    background: #fdfdfd;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: none;
}

.spx-modern-table td {
    padding: 14px 16px;
    font-size: 13px;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
}

.spx-modern-table tbody tr:hover {
    background: #f8fafc;
}

/* Pill Badges inside Data Table */
.spx-pill {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pill-blue {
    background: #e0f2fe;
    color: #0ea5e9;
}

.pill-green {
    background: #dcfce7;
    color: #22c55e;
}

.pill-yellow {
    background: #fef9c3;
    color: #eab308;
}

.pill-red {
    background: #fee2e2;
    color: #ef4444;
}

.pill-gray {
    background: #f1f5f9;
    color: #64748b;
}

.text-primary-red {
    color: #ef4444;
    font-weight: 700;
}

.text-mute-sm {
    font-size: 11px;
    color: var(--gray-400);
    display: block;
    margin-top: 2px;
}