/* ═══════════════════════════════════════════════════════════════
   LBC Tracker - Complete Stylesheet
   Light & Dark Theme via CSS Custom Properties
   ═══════════════════════════════════════════════════════════════ */

/* ─── Light Theme Variables (Default) ────────────────────────── */
:root,
[data-theme="light"] {
    --bg-primary: #F1F5F9;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F8FAFC;
    --bg-hover: #F1F5F9;
    --bg-active: #E2E8F0;

    --border-color: #E2E8F0;
    --border-light: #F1F5F9;

    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-muted: #64748B;
    --text-light: #94A3B8;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);

    --sidebar-bg: #0F172A;
    --sidebar-text: #94A3B8;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active: rgba(37,99,235,0.2);
    --sidebar-active-text: #60A5FA;
    --sidebar-border: #1E293B;

    --accent: #2563EB;
    --accent-hover: #1D4ED8;
    --accent-light: #DBEAFE;

    --success: #10B981;
    --success-bg: #F0FDF4;
    --success-border: #86EFAC;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --danger-border: #FCA5A5;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --warning-border: #FCD34D;
    --info: #3B82F6;
    --info-bg: #EFF6FF;
    --info-border: #93C5FD;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --modal-overlay: rgba(0,0,0,0.45);

    --input-bg: #FFFFFF;
    --input-border: #D1D5DB;
    --input-focus: #2563EB;

    --table-stripe: #F8FAFC;
    --scrollbar-thumb: #CBD5E1;
    --scrollbar-track: transparent;
}

/* ─── Dark Theme Variables ───────────────────────────────────── */
[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-tertiary: #1A2332;
    --bg-hover: #253348;
    --bg-active: #334155;

    --border-color: #334155;
    --border-light: #1E293B;

    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;
    --text-light: #64748B;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);

    --sidebar-bg: #0B1120;
    --sidebar-text: #94A3B8;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(37,99,235,0.25);
    --sidebar-active-text: #60A5FA;
    --sidebar-border: #1E293B;

    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-light: rgba(59,130,246,0.15);

    --success-bg: rgba(16,185,129,0.1);
    --success-border: rgba(16,185,129,0.3);
    --danger-bg: rgba(239,68,68,0.1);
    --danger-border: rgba(239,68,68,0.3);
    --warning-bg: rgba(245,158,11,0.1);
    --warning-border: rgba(245,158,11,0.3);
    --info-bg: rgba(59,130,246,0.1);
    --info-border: rgba(59,130,246,0.3);

    --modal-overlay: rgba(0,0,0,0.65);

    --input-bg: #1A2332;
    --input-border: #475569;
    --input-focus: #3B82F6;

    --table-stripe: #1A2332;
    --scrollbar-thumb: #475569;
    --scrollbar-track: transparent;
}


/* ─── Reset & Base ───────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }


/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */

.app-wrapper {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden; /* Prevent page-level horizontal scroll */
}


/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease, width 0.3s ease;
}

/* Collapsed state */
.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-details { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; }
.sidebar.collapsed .user-info { justify-content: center; }
.sidebar.collapsed .sidebar-actions { justify-content: center; }

/* Sidebar header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px;
    border-bottom: 1px solid var(--sidebar-border);
}

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

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563EB, #7C3AED);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.logo-text {
    font-weight: 800;
    font-size: 16px;
    color: #FFFFFF;
    letter-spacing: -0.3px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.2s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

/* Sidebar navigation */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 2px;
    transition: all 0.2s;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #E2E8F0;
    text-decoration: none;
}
.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
}

.nav-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563EB, #7C3AED);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: #E2E8F0; }
.user-role { font-size: 11px; color: var(--sidebar-text); }

.sidebar-actions {
    display: flex;
    gap: 6px;
}

.theme-toggle,
.btn-logout {
    flex: 1;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    border: none;
    border-radius: 8px;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 16px;
    text-align: center;
    transition: background 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover,
.btn-logout:hover { background: rgba(255,255,255,0.1); }
.btn-logout:hover { background: rgba(239,68,68,0.2); color: #F87171; }

/* Theme icon toggle */
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }


/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 250px;
    min-height: 100vh;
    min-width: 0;       /* Critical: allows flex child to shrink below content size */
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed ~ .main-content,
.sidebar.collapsed + .main-content {
    margin-left: 70px;
}

/* Top bar */
.top-bar {
    background: var(--bg-secondary);
    padding: 14px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-email {
    font-size: 13px;
    color: var(--text-muted);
}

.role-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.role-admin { background: var(--accent-light); color: var(--accent); }
.role-staff { background: rgba(124,58,237,0.1); color: #7C3AED; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px;
}

/* Content area */
.content-area {
    padding: 28px;
    flex: 1;
    min-width: 0;       /* Critical: allows flex child content to overflow */
    overflow-x: hidden; /* Contain overflow at this level */
    overflow-y: auto;
}


/* ═══════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-2px); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-icon { font-size: 20px; }
.card-value { font-size: 26px; font-weight: 800; }

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


/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border-color);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 6px 8px; font-size: 14px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }


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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--input-border);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-input::placeholder { color: var(--text-light); }

.form-textarea { min-height: 80px; resize: vertical; }
.form-select { cursor: pointer; }

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

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}


/* ─── Search Bar ─────────────────────────────────────────────── */
.search-bar {
    position: relative;
    max-width: 420px;
}
.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 15px;
    pointer-events: none;
}
.search-bar input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    font-size: 14px;
    outline: none;
    font-family: inherit;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.2s;
}
.search-bar input:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.search-bar input::placeholder { color: var(--text-light); }


/* ─── Toolbar ────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}


/* ═══════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════ */

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

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

/* When table is inside scroll wrapper, allow natural width overflow */
.table-scroll-wrapper .data-table {
    width: max-content;
    min-width: 100%;
}

/* Ensure cells have minimum widths to prevent crushing */
.table-scroll-wrapper .data-table td,
.table-scroll-wrapper .data-table th {
    white-space: nowrap;
    min-width: 80px;
}

.table-scroll-wrapper .data-table td[data-col="tracking_number"],
.table-scroll-wrapper .data-table th[data-sort="tracking_number"] { min-width: 130px; }

.table-scroll-wrapper .data-table td[data-col="consignee"],
.table-scroll-wrapper .data-table th[data-sort="consignee"] { min-width: 160px; }

.table-scroll-wrapper .data-table td[data-col="notes"],
.table-scroll-wrapper .data-table th[data-sort="notes"] { min-width: 120px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

.table-scroll-wrapper .data-table td[data-col="delivery_status"],
.table-scroll-wrapper .data-table th[data-sort="delivery_status"] { min-width: 130px; }

.table-scroll-wrapper .data-table td[data-col="delivery_date_range"],
.table-scroll-wrapper .data-table th[data-sort="delivery_date_range"] { min-width: 140px; }

.table-scroll-wrapper .data-table td[data-col="delivery_status_details"],
.table-scroll-wrapper .data-table th[data-sort="delivery_status_details"] { min-width: 120px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* Table header */
.data-table thead th {
    padding: 10px 12px;
    text-align: left;
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 2;
}
.data-table thead th:hover { color: var(--text-primary); }

.data-table thead th .sort-arrow {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.4;
}
.data-table thead th.sorted-asc .sort-arrow,
.data-table thead th.sorted-desc .sort-arrow { opacity: 1; }

/* Column filter row */
.data-table thead .filter-row th {
    padding: 4px 6px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    cursor: default;
    position: sticky;
    top: 38px;
    z-index: 2;
}

.col-filter {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 11px;
    outline: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
}
.col-filter:focus {
    border-color: var(--accent);
}

/* Table body */
.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.clickable { cursor: pointer; }

.data-table tbody td {
    padding: 10px 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table .empty-row td {
    padding: 40px;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}

.table-actions {
    display: flex;
    gap: 4px;
}


/* ═══════════════════════════════════════════════════════════════
   STATUS BADGES
   ═══════════════════════════════════════════════════════════════ */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Light theme badges */
.status-in-transit       { background: #EEF2FF; color: #4338CA; border: 1.5px solid #A5B4FC; }
.status-out-for-delivery { background: #FFF7ED; color: #C2410C; border: 1.5px solid #FDBA74; }
.status-delivered        { background: #F0FDF4; color: #15803D; border: 1.5px solid #86EFAC; }
.status-problematic      { background: #FEF2F2; color: #B91C1C; border: 1.5px solid #FCA5A5; }
.status-for-branch-collect { background: #FFFBEB; color: #B45309; border: 1.5px solid #FCD34D; }
.status-payment-collected  { background: #ECFDF5; color: #047857; border: 1.5px solid #6EE7B7; }

/* Dark theme badge overrides */
[data-theme="dark"] .status-in-transit       { background: rgba(67,56,202,0.15); border-color: rgba(165,180,252,0.3); }
[data-theme="dark"] .status-out-for-delivery { background: rgba(194,65,12,0.15); border-color: rgba(253,186,116,0.3); }
[data-theme="dark"] .status-delivered        { background: rgba(21,128,61,0.15); border-color: rgba(134,239,172,0.3); }
[data-theme="dark"] .status-problematic      { background: rgba(185,28,28,0.15); border-color: rgba(252,165,165,0.3); }
[data-theme="dark"] .status-for-branch-collect { background: rgba(180,83,9,0.15); border-color: rgba(252,211,77,0.3); }
[data-theme="dark"] .status-payment-collected  { background: rgba(4,120,87,0.15); border-color: rgba(110,231,183,0.3); }


/* ═══════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.modal-overlay.active {
    display: block;
    opacity: 1;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    width: 540px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 210;
    box-shadow: var(--shadow-lg);
    display: none;
    opacity: 0;
    transition: all 0.2s;
}
.modal.active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.modal.wide { width: 750px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

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


/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
    max-width: 420px;
}
.toast-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.toast-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.toast-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border); }
.toast-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }


/* ═══════════════════════════════════════════════════════════════
   MISC COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* Chart container */
.chart-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}
.chart-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-tertiary);
}
.upload-area:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-area .upload-text { font-size: 14px; color: var(--text-muted); }
.upload-area .upload-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius-md);
}
[data-theme="dark"] .loading-overlay { background: rgba(15,23,42,0.7); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}
.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}
.pagination button:hover { background: var(--bg-hover); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .page-info { font-size: 13px; color: var(--text-muted); margin: 0 8px; }

/* Permission grid (users page) */
.perm-grid { display: grid; gap: 6px; margin-top: 8px; }
.perm-category {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
    margin-bottom: 4px;
}

/* User cards (users page) */
.user-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 18px 24px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    transition: all 0.2s;
}
.user-card:hover { box-shadow: var(--shadow-sm); }
.user-card-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.user-card-email { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Date range filter */
.date-range {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.date-range .form-group { margin-bottom: 0; }

/* Summary total badge */
.summary-total {
    background: var(--success-bg);
    border: 1.5px solid var(--success-border);
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-weight: 700;
    color: var(--success);
    font-size: 15px;
}

/* Hidden file input */
.file-input-hidden { display: none; }

/* ═══════════════════════════════════════════════════════════════
   BRANCH COLLECT - PASTE ZONE
   ═══════════════════════════════════════════════════════════════ */

.bc-paste-zone {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.bc-paste-zone:focus-within {
    border-color: var(--primary);
}

.bc-paste-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.bc-paste-header .btn-ghost {
    font-size: 20px;
    padding: 0 6px;
    line-height: 1;
    min-width: auto;
}

.bc-paste-textarea {
    width: 100%;
    min-height: 120px;
    max-height: 250px;
    resize: vertical;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.5;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    color: var(--text-primary);
}

.bc-paste-textarea::placeholder {
    color: var(--text-light);
    font-style: italic;
}

.bc-paste-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.bc-paste-results {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.bc-paste-results ul {
    list-style: disc;
    line-height: 1.8;
}

/* Claim date display in table */
.claim-date-display:hover {
    color: var(--primary);
}


/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 400px;
    max-width: 95vw;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
}
[data-theme="dark"] .login-box { background: var(--bg-secondary); }

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563EB, #7C3AED);
    margin-bottom: 16px;
    font-size: 28px;
}
.login-logo h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}
.login-logo p {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}


/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp 0.3s ease; }


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 250px !important;
    }
    .sidebar.mobile-open { transform: translateX(0); }

    .main-content { margin-left: 0 !important; }
    .mobile-menu-btn { display: block; }
    .top-bar-right .user-email { display: none; }

    .content-area { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-bar { max-width: 100%; }
    .modal { width: 95vw; }
    .date-range { flex-direction: column; width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .content-area { padding: 12px; }
    .login-box { padding: 32px 24px; }
}


/* ═══════════════════════════════════════════════════════════════
   SHIPMENT TOOLBAR (Responsive)
   ═══════════════════════════════════════════════════════════════ */

.shipment-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.shipment-toolbar .search-bar {
    flex: 1 1 200px;
    min-width: 180px;
    max-width: 400px;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    flex: 0 1 auto;
}

.toolbar-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 12px;
    padding: 7px 12px;
}

.toolbar-actions .btn .btn-icon-only {
    font-size: 14px;
    line-height: 1;
}

/* Paste / Drop Zone */
.paste-drop-zone {
    margin-bottom: 16px;
    padding: 24px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.paste-drop-zone:hover,
.paste-drop-zone.drag-active {
    border-color: var(--accent);
    background: var(--accent-light, rgba(37,99,235,0.05));
}

/* Small spinner for inline buttons */
.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-light);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

/* ─── Responsive: Tablet ─────────────────────────────────────── */
@media (max-width: 1200px) {
    .shipment-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .shipment-toolbar .search-bar {
        max-width: 100%;
        flex: 1 1 100%;
    }
    .toolbar-actions {
        justify-content: flex-start;
        width: 100%;
    }
}

/* ─── Responsive: Small Tablet ───────────────────────────────── */
@media (max-width: 768px) {
    .toolbar-actions .btn .btn-label {
        display: none;
    }
    .toolbar-actions .btn {
        padding: 8px 10px;
        min-width: 38px;
        justify-content: center;
    }
    .toolbar-actions .btn .btn-icon-only {
        font-size: 16px;
    }
}

/* ─── Responsive: Mobile ─────────────────────────────────────── */
@media (max-width: 640px) {
    .toolbar-actions {
        justify-content: center;
        gap: 8px;
    }
    .toolbar-actions .btn {
        padding: 10px 12px;
        min-width: 42px;
    }
    .toolbar-actions .btn .btn-icon-only {
        font-size: 18px;
    }
    .paste-drop-zone {
        padding: 16px;
    }
}


/* ═══════════════════════════════════════════════════════════════
   SCROLLABLE TABLE WITH STICKY COLUMNS
   ═══════════════════════════════════════════════════════════════ */

.table-scroll-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    position: relative;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: calc(100vw - 250px - 60px); /* viewport - sidebar - content padding */
}

/* When sidebar is collapsed */
.sidebar.collapsed ~ .main-content .table-scroll-wrapper,
.sidebar.collapsed + .main-content .table-scroll-wrapper {
    max-width: calc(100vw - 70px - 60px);
}

@media (max-width: 768px) {
    .table-scroll-wrapper {
        max-width: calc(100vw - 32px);
    }
}

/* Scrollbar styling */
.table-scroll-wrapper::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}
.table-scroll-wrapper::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 5px;
}
.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 5px;
}
.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sticky header rows */
.table-scroll-wrapper .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-secondary);
}

.table-scroll-wrapper .data-table thead tr:nth-child(2) th {
    top: 38px; /* height of first header row */
}

/* Checkbox column - sticky left */
.sticky-col {
    position: sticky !important;
    left: 0;
    z-index: 2;
    background: var(--bg-primary) !important;
}

thead .sticky-col {
    z-index: 5 !important;
    background: var(--bg-tertiary) !important;
}

/* Actions column - sticky right */
.sticky-col-right {
    position: sticky !important;
    right: 0;
    z-index: 2;
    background: var(--bg-primary) !important;
    box-shadow: -3px 0 6px rgba(0,0,0,0.08);
}

thead .sticky-col-right {
    z-index: 5 !important;
    background: var(--bg-tertiary) !important;
}

/* Checkbox column sizing */
.col-checkbox {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    text-align: center;
    padding: 6px 8px !important;
}

.col-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Actions column sizing */
.col-actions {
    min-width: 100px;
}


/* ═══════════════════════════════════════════════════════════════
   MASS DELETE BAR
   ═══════════════════════════════════════════════════════════════ */

.mass-delete-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--danger-bg, #fef2f2);
    border: 1.5px solid var(--danger-border, #fca5a5);
    border-radius: var(--radius-lg);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mass-delete-info {
    font-size: 14px;
    font-weight: 600;
    color: var(--danger, #b91c1c);
}

.mass-delete-info span {
    font-size: 18px;
    font-weight: 800;
}

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

/* Selected row highlight */
.data-table tbody tr.row-selected {
    background: var(--accent-light, rgba(37,99,235,0.06)) !important;
}

.data-table tbody tr.row-selected td {
    background: inherit;
}

.data-table tbody tr.row-selected .sticky-col,
.data-table tbody tr.row-selected .sticky-col-right {
    background: var(--accent-light, rgba(37,99,235,0.06));
}

/* Hover on selected rows */
.data-table tbody tr.row-selected:hover {
    background: var(--accent-light, rgba(37,99,235,0.1)) !important;
}

.data-table tbody tr.row-selected:hover .sticky-col,
.data-table tbody tr.row-selected:hover .sticky-col-right {
    background: var(--accent-light, rgba(37,99,235,0.1));
}

/* ─── Responsive mass delete bar ─────────────────────────────── */
@media (max-width: 640px) {
    .mass-delete-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    .mass-delete-actions {
        width: 100%;
        justify-content: center;
    }
}


/* ═══════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════ */

@media print {
    .sidebar,
    .top-bar,
    .toolbar,
    .btn,
    .table-actions,
    .pagination,
    .toast-container,
    .modal-overlay,
    .modal { display: none !important; }

    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0; }
    .data-table { font-size: 10px; }

    body { background: #fff; color: #000; }
}
