/* ============================================
   Digital-Receiving System - Global Styles
   ============================================ */

:root {
    color-scheme:   dark;
    --bg:           #0a0f1e;
    --surface:      #111827;
    --surface-2:    #1a2235;
    --border:       rgba(255, 255, 255, 0.07);
    --primary:      #3b82f6;
    --primary-dim:  rgba(59, 130, 246, 0.12);
    --danger:       #ef4444;
    --danger-dim:   rgba(239, 68, 68, 0.12);
    --success:      #10b981;
    --success-dim:  rgba(16, 185, 129, 0.12);
    --warning:      #f59e0b;
    --warning-dim:  rgba(245, 158, 11, 0.12);
    --text:         #f1f5f9;
    --text-muted:   #64748b;
    --text-subtle:  #94a3b8;
    --sidebar-w:            260px;
    --sidebar-collapsed-w:  72px;
    --topbar-h:             64px;
    --radius:       12px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

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

html, body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    background-image:
        radial-gradient(at 20% 20%, rgba(59,130,246,0.15) 0, transparent 50%),
        radial-gradient(at 80% 80%, rgba(139,92,246,0.1) 0, transparent 50%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-icon {
    width: 52px; height: 52px;
    background: var(--primary-dim);
    border: 1px solid rgba(59,130,246,0.3);
    border-radius: 14px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.login-logo p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-subtle);
    margin-bottom: 0.5rem;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-group input::placeholder { color: var(--text-muted); }

select option {
    background-color: #111827 !important;
    color: #f1f5f9 !important;
}

/* ============================================
   DATE & TIME PICKERS (GLOBAL DARK THEME)
   ============================================ */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"] {
    color-scheme: dark !important;
    cursor: pointer;
}

/* Calendar picker indicator button (Chrome, Edge, Safari) */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    border-radius: 6px;
    padding: 3px 5px;
    margin-left: 6px;
    opacity: 0.9;
    filter: brightness(0) invert(1);
    background-color: rgba(59, 130, 246, 0.22);
    border: 1px solid rgba(59, 130, 246, 0.45);
    transition: all 0.2s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background-color: rgba(59, 130, 246, 0.45);
    border-color: rgba(59, 130, 246, 0.8);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover { background: #2563eb; box-shadow: 0 4px 12px rgba(59,130,246,0.35); }

.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-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-subtle);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-full { width: 100%; }
.btn:active { transform: scale(0.98); }

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.dashboard-layout,
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: var(--topbar-h);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo svg {
    flex-shrink: 0;
}

.sidebar-collapse-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-color: var(--border);
}

.collapse-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-mobile-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-mobile-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-role-badge {
    margin: 1rem 1.5rem 0.5rem;
}

.sidebar-role-badge span {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    background: var(--primary-dim);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 1px solid rgba(59,130,246,0.2);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Custom Thin Dark Scrollbar for containers */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.nav-links { list-style: none; padding: 0 0.75rem; }

.nav-links li { margin-bottom: 2px; }

.nav-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.875rem;
    border-radius: 8px;
    color: var(--text-subtle);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-links a:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-links a.active { background: var(--primary-dim); color: var(--primary); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

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

.nav-logout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--danger);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.25rem;
    transition: opacity 0.2s;
}

.nav-logout:hover { opacity: 0.7; }

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

/* Main Area */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0; /* Prevents overflow from wide flex children like tables */
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-brand-mobile {
    display: none;
    align-items: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-subtle);
    cursor: pointer;
    padding: 0.45rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-right: 0.25rem;
}

.hamburger:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.15);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-left: auto;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 2px rgba(16,185,129,0.3);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 2px rgba(16,185,129,0.3); }
    50%       { box-shadow: 0 0 0 4px rgba(16,185,129,0.1); }
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
}

.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
}

.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.user-role { font-size: 0.72rem; color: var(--text-muted); }

/* Content */
.content-area { padding: 1.75rem; flex: 1; }

.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.3px; color: var(--text); }
.page-header p  { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ============================================
   CARDS & PANELS
   ============================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1.25rem;
}

.card-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon.blue   { background: var(--primary-dim); color: var(--primary); }
.card-icon.green  { background: var(--success-dim); color: var(--success); }
.card-icon.amber  { background: var(--warning-dim); color: var(--warning); }
.card-icon.red    { background: var(--danger-dim);  color: var(--danger);  }

.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Stats Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ============================================
   TOLERANCE SEGMENTED SWITCH & TOOLBAR
   ============================================ */
.tolerance-toolbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.45rem 0.85rem;
    border-radius: 10px;
    flex-wrap: wrap;
}

.tolerance-segmented-switch {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.tolerance-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    padding: 0.32rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.2;
}

.tolerance-toggle-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.tolerance-toggle-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.tolerance-toggle-btn.mode-negative.active {
    background: #f59e0b;
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.tolerance-toggle-btn.mode-positive.active {
    background: #10b981;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

/* ============================================
   TABLE SEARCH COMPONENT
   ============================================ */
.table-search-wrapper {
    position: relative;
    width: 290px;
    max-width: 100%;
}

.table-search-wrapper svg.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.table-search-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 2.2rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.table-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.table-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: 4px;
    display: none;
    line-height: 1;
    transition: color 0.15s, background-color 0.15s;
}

.table-search-clear:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   TABLE
   ============================================ */
.table-wrap { overflow-x: auto; border-radius: 8px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(10, 15, 30, 0.5);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-subtle);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* Status badges & UI Chips */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.28rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

/* Green / Success / Verified */
.badge-green, .badge-success, .bg-green {
    background: var(--success-dim, rgba(16,185,129,0.15));
    color: var(--success, #10b981);
    border: 1px solid rgba(16,185,129,0.25);
}

/* Red / Danger / Reversed */
.badge-red, .badge-danger, .badge-rejected, .bg-red {
    background: var(--danger-dim, rgba(239,68,68,0.15));
    color: var(--danger, #ef4444);
    border: 1px solid rgba(239,68,68,0.25);
}

/* Amber / Yellow / Warning / Pending */
.badge-amber, .badge-yellow, .badge-warning, .badge-pending, .bg-yellow {
    background: var(--warning-dim, rgba(245,158,11,0.15));
    color: var(--warning, #f59e0b);
    border: 1px solid rgba(245,158,11,0.25);
}

/* Blue / Primary / Info */
.badge-blue, .badge-primary, .badge-info, .bg-blue {
    background: var(--primary-dim, rgba(59,130,246,0.15));
    color: var(--primary, #3b82f6);
    border: 1px solid rgba(59,130,246,0.25);
}

/* Orange / Notice */
.badge-orange {
    background: rgba(249,115,22,0.15);
    color: #f97316;
    border: 1px solid rgba(249,115,22,0.25);
}

/* Gray / Secondary / Neutral */
.badge-gray, .badge-secondary, .badge-neutral, .bg-secondary {
    background: rgba(255,255,255,0.08);
    color: var(--text-subtle, #94a3b8);
    border: 1px solid rgba(255,255,255,0.12);
}

/* Icon Buttons & Table Actions */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}
.btn-icon:hover {
    background: var(--surface-hover, rgba(255,255,255,0.06));
    color: var(--text);
    border-color: var(--border);
}
.btn-icon.text-red, .btn-icon.danger {
    color: var(--danger, #ef4444);
    background: transparent;
}
.btn-icon.text-red:hover, .btn-icon.danger:hover {
    background: var(--danger-dim, rgba(239,68,68,0.15));
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}
.btn-icon.text-primary, .btn-icon.primary {
    color: var(--primary, #3b82f6);
    background: transparent;
}
.btn-icon.text-primary:hover, .btn-icon.primary:hover {
    background: var(--primary-dim, rgba(59,130,246,0.15));
    border-color: rgba(59,130,246,0.3);
    color: #60a5fa;
}
.btn-icon.success {
    color: var(--success, #10b981);
    background: transparent;
}
.btn-icon.success:hover {
    background: var(--success-dim, rgba(16,185,129,0.15));
    border-color: rgba(16,185,129,0.3);
    color: #34d399;
}
.btn-icon.warning {
    color: var(--warning, #f59e0b);
    background: transparent;
}
.btn-icon.warning:hover {
    background: var(--warning-dim, rgba(245,158,11,0.15));
    border-color: rgba(245,158,11,0.3);
    color: #fbbf24;
}

/* ============================================
   FORM GRID
   ============================================ */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ============================================
   FOOTER
   ============================================ */
.main-footer {
    text-align: center;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   SIDEBAR COLLAPSED MODE (DESKTOP ICON ONLY)
   ============================================ */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
}

.sidebar-collapsed .main-area {
    margin-left: var(--sidebar-collapsed-w);
}

.sidebar-collapsed .sidebar-header {
    padding: 1rem 0.4rem;
    justify-content: center;
    gap: 0.35rem;
}

.sidebar-collapsed .sidebar-logo {
    gap: 0;
}

.sidebar-collapsed .logo-text {
    display: none !important;
}

.sidebar-collapsed .sidebar-collapse-btn .collapse-icon {
    transform: rotate(180deg);
}

.sidebar-collapsed .sidebar-role-badge {
    display: none !important;
}

.sidebar-collapsed .nav-links {
    padding: 0 0.5rem;
}

.sidebar-collapsed .nav-links > li > a {
    justify-content: center;
    padding: 0.75rem 0;
    position: relative;
}

.sidebar-collapsed .nav-links > li > a > span {
    display: none !important;
}

.sidebar-collapsed .nav-dropdown-toggle {
    justify-content: center;
    padding: 0.75rem 0;
    position: relative;
}

.sidebar-collapsed .nav-dropdown-toggle-left {
    justify-content: center;
    gap: 0;
}

.sidebar-collapsed .nav-dropdown-toggle-left > span {
    display: none !important;
}

.sidebar-collapsed .chevron-icon {
    display: none !important;
}

.sidebar-collapsed .nav-logout {
    justify-content: center;
    padding: 0.75rem 0;
    position: relative;
}

.sidebar-collapsed .nav-logout > span {
    display: none !important;
}

/* Tooltip on hover for single links & logout when collapsed */
.sidebar-collapsed .nav-links > li > a:hover::after,
.sidebar-collapsed .nav-logout:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #f8fafc;
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 9999;
    pointer-events: none;
    animation: sidebarTooltipFade 0.15s ease-out;
}

@keyframes sidebarTooltipFade {
    from { opacity: 0; transform: translateY(-50%) translateX(-6px); }
    to { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* Dropdown Accordion Flyout Menu when collapsed */
.sidebar-collapsed .nav-dropdown {
    position: relative;
}

.sidebar-collapsed .nav-dropdown-menu {
    position: absolute;
    left: calc(100% + 8px);
    top: 0;
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.7);
    min-width: 220px;
    padding: 0.5rem;
    z-index: 9999;
    display: none;
    max-height: none !important;
    opacity: 1 !important;
}

/* Show floating flyout when hovering the dropdown */
.sidebar-collapsed .nav-dropdown:hover .nav-dropdown-menu {
    display: block !important;
    animation: sidebarFlyoutFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sidebarFlyoutFade {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}

.sidebar-collapsed .nav-dropdown-menu .nav-sub-item {
    margin-bottom: 2px;
}

.sidebar-collapsed .nav-dropdown-menu .nav-sub-link {
    margin-left: 0 !important;
    padding: 0.6rem 0.85rem !important;
    border-left: none !important;
    border-radius: 6px !important;
    font-size: 0.83rem !important;
    color: var(--text-subtle) !important;
    white-space: nowrap;
}

.sidebar-collapsed .nav-dropdown-menu .nav-sub-link:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

.sidebar-collapsed .nav-dropdown-menu .nav-sub-link.active {
    background: var(--primary-dim) !important;
    color: var(--primary) !important;
    font-weight: 600;
}

/* ============================================
   RESPONSIVE MEDIA QUERIES (TABLET & MOBILE)
   ============================================ */

/* Tablet & Smaller Screens (<= 992px) */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        z-index: 1050 !important;
        box-shadow: none;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.85) !important;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.75);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 1040 !important;
        opacity: 0;
        transition: opacity 0.25s ease;
    }

    .sidebar-overlay.open {
        display: block !important;
        opacity: 1 !important;
    }

    .main-area {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
    }

    .dashboard-layout,
    .app-layout {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

    .sidebar-mobile-close-btn {
        display: flex !important;
    }

    .topbar-brand-mobile {
        display: flex;
    }

    .data-table {
        min-width: 960px;
    }

    /* Reset collapsed overrides on tablet/mobile so offcanvas drawer is full-sized */
    .sidebar-collapsed .sidebar {
        width: 280px !important;
        max-width: 85vw !important;
    }
    .sidebar-collapsed .main-area {
        margin-left: 0 !important;
    }
    .sidebar-collapsed .sidebar-header {
        padding: 1.15rem 1.25rem !important;
        justify-content: space-between !important;
    }
    .sidebar-collapsed .logo-text,
    .sidebar-collapsed .sidebar-role-badge,
    .sidebar-collapsed .nav-links > li > a > span,
    .sidebar-collapsed .nav-dropdown-toggle-left > span,
    .sidebar-collapsed .chevron-icon,
    .sidebar-collapsed .nav-logout > span {
        display: inline !important;
    }
    .sidebar-collapsed .nav-links {
        padding: 0 0.75rem !important;
    }
    .sidebar-collapsed .nav-links > li > a,
    .sidebar-collapsed .nav-dropdown-toggle,
    .sidebar-collapsed .nav-logout {
        justify-content: flex-start !important;
        padding: 0.7rem 0.875rem !important;
    }
    .sidebar-collapsed .nav-dropdown-toggle-left {
        justify-content: flex-start !important;
        gap: 0.75rem !important;
    }
    .sidebar-collapsed .nav-dropdown-menu {
        position: static !important;
        box-shadow: none !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        min-width: auto !important;
        display: block !important;
        max-height: 0 !important;
        overflow: hidden !important;
        opacity: 0 !important;
    }
    .sidebar-collapsed .nav-dropdown.open .nav-dropdown-menu {
        max-height: 600px !important;
        opacity: 1 !important;
    }
    .sidebar-collapsed .nav-dropdown-menu .nav-sub-link {
        margin-left: 1.25rem !important;
        border-left: 2px solid rgba(255, 255, 255, 0.08) !important;
        padding: 0.55rem 0.875rem 0.55rem 2.4rem !important;
    }
    .sidebar-collapsed .nav-links > li > a:hover::after,
    .sidebar-collapsed .nav-logout:hover::after {
        display: none !important;
    }

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

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
    .content-area {
        padding: 0.875rem;
    }

    .topbar {
        padding: 0 0.875rem;
    }

    .topbar-status {
        display: none;
    }

    .user-info {
        display: none;
    }

    .page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.875rem !important;
        margin-bottom: 1.25rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .page-header p {
        font-size: 0.82rem;
    }

    .page-header-actions,
    .verifications-filter-bar,
    .page-header > div:last-child {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 0.65rem !important;
    }

    .page-header-actions > div,
    .verifications-filter-bar > div,
    .page-header > div:last-child > div {
        width: 100% !important;
        box-sizing: border-box;
    }

    .tolerance-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.65rem !important;
        width: 100% !important;
        padding: 0.75rem !important;
        box-sizing: border-box;
    }

    .tolerance-toolbar > div {
        width: 100%;
        justify-content: space-between;
    }

    .tolerance-segmented-switch {
        width: 100% !important;
        display: flex !important;
    }

    .tolerance-segmented-switch .tolerance-toggle-btn {
        flex: 1 !important;
        text-align: center !important;
        justify-content: center !important;
        font-size: 0.75rem !important;
        padding: 0.4rem 0.25rem !important;
    }

    .card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 10px;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .card-header .table-search-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
    }

    .card-header > div:last-child {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 8px;
        width: 100%;
    }

    .data-table {
        min-width: 900px !important;
    }

    .data-table th, .data-table td {
        padding: 0.5rem 0.55rem !important;
        font-size: 0.8rem !important;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .tabs-header {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 6px;
        margin-bottom: 1rem;
        scrollbar-width: thin;
    }

    .tab-btn {
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        padding: 0.5rem 0.85rem !important;
        font-size: 0.82rem !important;
    }

    .modal-content-card {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 1.15rem !important;
        margin: 0.75rem auto !important;
    }

    .swal2-popup {
        width: 94vw !important;
        max-width: 95vw !important;
        padding: 1.15rem !important;
        border-radius: 12px !important;
    }

    .swal2-title {
        font-size: 1.15rem !important;
    }

    .swal2-html-container {
        font-size: 0.85rem !important;
    }

    .swal2-actions {
        width: 100% !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .swal2-actions button {
        width: 100% !important;
        margin: 0 !important;
        height: 38px !important;
    }
}

/* Small Mobile Phones (<= 480px) */
@media (max-width: 480px) {
    .content-area {
        padding: 0.65rem;
    }

    .topbar {
        padding: 0 0.65rem;
    }

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

    .stat-card {
        padding: 0.875rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.55rem 0.75rem;
        font-size: 0.8rem;
    }

    .badge {
        font-size: 0.68rem;
        padding: 0.15rem 0.45rem;
    }
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    font-weight: 500;
}
.alert-success { background: rgba(16,185,129,0.12); color: #10b981; border: 1px solid rgba(16,185,129,0.2); }
.alert-error   { background: rgba(239,68,68,0.12);  color: #ef4444; border: 1px solid rgba(239,68,68,0.2);  }
.alert-warning { background: rgba(245,158,11,0.12); color: #f59e0b; border: 1px solid rgba(245,158,11,0.2); }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.875rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #10b981; }
.toast-error   { background: #ef4444; }

/* ============================================
   SELECT2 DARK THEME OVERRIDES
   ============================================ */
.select2-container--default .select2-selection--single {
    background-color: var(--bg, #0b1120) !important;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.15)) !important;
    border-radius: 8px !important;
    height: 42px !important;
    display: flex !important;
    align-items: center !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #f8fafc !important;
    padding-left: 0.75rem !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px !important;
    right: 8px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #94a3b8 transparent transparent transparent !important;
}

/* Dropdown Container */
.select2-dropdown {
    background-color: #1e293b !important;
    border: 1px solid rgba(59, 130, 246, 0.4) !important;
    border-radius: 8px !important;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7) !important;
    z-index: 999999 !important;
    overflow: hidden !important;
}

/* Search Box inside Dropdown */
.select2-search--dropdown {
    padding: 0.6rem !important;
    background-color: #1e293b !important;
}
.select2-search--dropdown .select2-search__field {
    background-color: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    color: #ffffff !important;
    padding: 0.6rem 0.75rem !important;
    font-size: 0.875rem !important;
    outline: none !important;
}
.select2-search--dropdown .select2-search__field:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25) !important;
}

/* Options List Container & Custom Dark Scrollbar */
.select2-results__options {
    background-color: #1e293b !important;
    padding: 0.25rem !important;
    max-height: 240px !important;
}
.select2-results__options::-webkit-scrollbar {
    width: 6px;
}
.select2-results__options::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 4px;
}
.select2-results__options::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}
.select2-results__options::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Regular Options */
.select2-results__option {
    color: #cbd5e1 !important;
    padding: 0.6rem 0.85rem !important;
    font-size: 0.85rem !important;
    border-radius: 6px !important;
    margin-bottom: 2px !important;
    transition: background 0.15s ease, color 0.15s ease !important;
}

/* Hovered / Highlighted Option */
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #2563eb !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}

/* Selected Option State (Fix for invisible white text on light gray) */
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: rgba(59, 130, 246, 0.22) !important;
    color: #60a5fa !important;
    font-weight: 600 !important;
}

/* Selected + Highlighted Option State */
.select2-container--default .select2-results__option--highlighted[aria-selected=true] {
    background-color: #2563eb !important;
    color: #ffffff !important;
}

/* ============================================
   SIDEBAR EXPANDABLE ACCORDION MENU
   ============================================ */
.nav-dropdown {
    margin-bottom: 2px;
}

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.7rem 0.875rem;
    border-radius: 8px;
    color: var(--text-subtle);
    background: transparent;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.nav-dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.nav-dropdown.active-parent .nav-dropdown-toggle,
.nav-dropdown.open .nav-dropdown-toggle {
    color: var(--text);
}

.nav-dropdown.active-parent .nav-dropdown-toggle {
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary);
}

.nav-dropdown-toggle-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chevron-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
}

.nav-dropdown.open .chevron-icon {
    transform: rotate(180deg);
    color: var(--primary);
}

.nav-dropdown-menu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-dropdown.open .nav-dropdown-menu {
    max-height: 600px;
    opacity: 1;
    margin-top: 2px;
    margin-bottom: 4px;
}

.nav-sub-item {
    margin-bottom: 2px;
}

.nav-sub-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.875rem 0.55rem 2.4rem;
    border-left: 2px solid rgba(255, 255, 255, 0.08);
    margin-left: 1.25rem;
    border-radius: 0 6px 6px 0;
    color: var(--text-subtle);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 400;
    transition: all 0.15s ease;
}

.nav-sub-link:hover {
    color: var(--text);
    border-left-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.03);
}

.nav-sub-link.active {
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
    background: var(--primary-dim);
}

.nav-sub-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.8;
}

/* ─── Verification Engine Table Sorting Styles ───────────────────────────────── */
.table-sort-wrapper {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
}
.table-sort-select {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}
.table-sort-select option {
    background-color: #111827;
    color: #f1f5f9;
}
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}
th.sortable:hover {
    color: var(--primary) !important;
    background: rgba(59, 130, 246, 0.05);
}
th.sortable .sort-indicator {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.72rem;
    opacity: 0.45;
    transition: all 0.15s ease;
}
th.sortable:hover .sort-indicator,
th.sortable.sorted-asc .sort-indicator,
th.sortable.sorted-desc .sort-indicator {
    opacity: 1;
    color: var(--primary);
}


