/* ============================================================
   MWMS — Premium Light Theme
   Inspired by clean modern dashboards with vibrant accents
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
    --sidebar-width:      260px;
    --topbar-height:      68px;

    /* Brand Colors (Modern Electric Violet & Indigo) */
    --primary:            #7c3aed; /* Electric Violet */
    --primary-dark:       #6d28d9;
    --primary-light:      #f5f3ff;
    --primary-lighter:    #faf5ff;
    
    /* Gradients */
    --primary-gradient:   linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
    --primary-glow:       0 0 16px rgba(124, 58, 237, 0.25);

    /* Backgrounds */
    --body-bg:            #ffffff;
    --sidebar-bg:         #ffffff; /* Pure white sidebar */
    --topbar-bg:          rgba(255, 255, 255, 0.9);
    --card-bg:            #ffffff;

    /* Text */
    --text-dark:          #0f172a; /* Slate 900 */
    --text-body:          #334155; /* Slate 700 */
    --text-muted:         #64748b; /* Slate 500 */

    /* Borders & Shadows */
    --border-color:       #e2e8f0; /* Slate 200 */
    --border-light:       #f1f5f9; /* Slate 100 */
    --card-shadow:        0 10px 30px rgba(124, 58, 237, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
    --card-shadow-hover:  0 16px 36px rgba(124, 58, 237, 0.08), 0 4px 12px rgba(0, 0, 0, 0.03);
    
    --card-radius:        16px;
    --btn-radius:         10px;
    --input-radius:       10px;

    --transition:         0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    margin: 0;
    font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .92rem;
    color: var(--text-body);
    background: var(--body-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { 
    color: var(--primary); 
    text-decoration: none; 
    transition: color var(--transition);
}
a:hover { 
    color: var(--primary-dark); 
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--body-bg);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Brand / Logo */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}
.sidebar-brand-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.sidebar-brand-sub {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Nav sections */
.sidebar-nav {
    flex: 1;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-section-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding: 12px 10px 6px;
    margin-top: 4px;
}

/* Collapsible sidebar groups */
.sidebar-accordion {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-group--home {
    margin-bottom: 6px;
}
.sidebar-group {
    margin: 2px 0;
}
.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text-body);
    font-size: .84rem;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: none;
    transition: background var(--transition), color var(--transition);
    outline: none;
    appearance: none;
}
.sidebar-group-toggle:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}
.sidebar-group-toggle:focus-visible {
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.sidebar-group-toggle__label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.sidebar-group-toggle__chevron {
    font-size: .78rem;
    opacity: .85;
    transition: transform var(--transition);
}
.sidebar-group-toggle:not(.collapsed) {
    color: var(--primary);
    background: var(--primary-lighter);
    box-shadow: none;
}
.sidebar-group-toggle:not(.collapsed) .sidebar-group-toggle__chevron {
    transform: rotate(180deg);
}
.sidebar-group-menu {
    padding: 4px 0;
}
.sidebar-group-menu .sidebar-link {
    margin: 2px 0 0 14px;
    border-radius: 8px;
    font-size: .84rem;
    padding: 8px 12px;
    width: calc(100% - 14px);
}
.sidebar-group-menu .sidebar-link:not(.active) {
    background: transparent;
    border: 0;
}
.sidebar-group-menu .sidebar-link.active {
    border: 0;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.18);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--text-body);
    font-weight: 600;
    font-size: .875rem;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
    cursor: pointer;
    white-space: nowrap;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.sidebar-link:hover {
    background: var(--primary-lighter);
    color: var(--primary);
    text-decoration: none;
}
.sidebar-link.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25);
}
.sidebar-link.active:hover {
    color: #ffffff;
}
.sidebar-link .nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: .85;
}
.sidebar-link.active .nav-icon { opacity: 1; }
.sidebar-link .nav-badge {
    margin-left: auto;
    font-size: .68rem;
    padding: .2em .6em;
    border-radius: 20px;
    background: rgba(255,255,255,.25);
    color: #fff;
    font-weight: 700;
}
.sidebar-link:not(.active) .nav-badge {
    background: var(--primary-light);
    color: var(--primary);
}

/* Sidebar bottom (logout) */
.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.15);
    z-index: 999;
    backdrop-filter: blur(4px);
}
.sidebar-overlay.show { display: block; }

/* Mobile drawer header + close */
.sidebar-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary-lighter);
    flex-shrink: 0;
}
.sidebar-drawer-head__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
}
.sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    color: var(--text-body);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.sidebar-close:hover {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
}

/* Topbar hamburger */
.sidebar-toggle__icon {
    line-height: 1;
}
.sidebar-toggle__icon--close {
    display: none;
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle__icon--open {
    display: none;
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle__icon--close {
    display: inline-block;
}

/* Nav group expand/collapse animation */
.sidebar-group-menu.collapsing {
    transition: height 0.25s ease;
}

/* ── Main wrapper ─────────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    gap: 16px;
}

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

.topbar-date {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-body);
    font-weight: 600;
    font-size: .88rem;
    white-space: nowrap;
}
.topbar-date i { 
    color: var(--primary); 
}

/* Sidebar hamburger toggle (mobile) */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1.1rem;
    color: var(--text-body);
    cursor: pointer;
    line-height: 1;
    transition: background var(--transition), border-color var(--transition);
}
.sidebar-toggle:hover {
    background: var(--primary-lighter);
    border-color: var(--primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Search box */
.topbar-search {
    position: relative;
}
.topbar-search input {
    width: 220px;
    height: 40px;
    padding: 0 16px 0 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    background: #f8fafc;
    font-size: .85rem;
    color: var(--text-body);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
    background: #fff;
}
.topbar-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .9rem;
    pointer-events: none;
}
.topbar-search input::placeholder { color: var(--text-muted); }

/* Notification bell */
.topbar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-body);
    font-size: 1.05rem;
    cursor: pointer;
    position: relative;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    text-decoration: none;
}
.topbar-btn:hover {
    background: var(--primary-lighter);
    border-color: var(--primary);
    color: var(--primary);
}
.topbar-btn .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* User avatar */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 10px 4px 4px;
    border-radius: 40px;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    transition: background var(--transition), border-color var(--transition);
    text-decoration: none;
}
.topbar-user:hover {
    background: var(--primary-lighter);
    border-color: var(--primary);
}
.topbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .82rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}
.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.topbar-user-name {
    font-size: .84rem;
    font-weight: 600;
    color: var(--text-dark);
}
.topbar-user-role {
    font-size: .7rem;
    color: var(--text-muted);
    text-transform: capitalize;
    font-weight: 500;
}

/* ── Page content ─────────────────────────────────────────────── */
.page-content {
    flex: 1;
    padding: 30px;
    background: var(--body-bg);
}

/* Page heading */
.page-heading {
    margin-bottom: 26px;
}
.page-heading h4 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-dark);
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}
.page-heading p {
    color: var(--text-muted);
    font-size: .88rem;
    margin: 0;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    color: var(--text-dark);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}
.card-body { padding: 24px; }
.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

/* ── Stat cards ───────────────────────────────────────────────── */
.stat-card {
    border-radius: var(--card-radius);
    padding: 24px;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    background: #ffffff;
    box-shadow: var(--card-shadow);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--primary);
}
.stat-card-blue   { border-left: 4px solid #3b82f6; }
.stat-card-purple { border-left: 4px solid var(--primary); }
.stat-card-green  { border-left: 4px solid #10b981; }
.stat-card-orange { border-left: 4px solid #f97316; }
.stat-card-pink   { border-left: 4px solid #ec4899; }
.stat-card-red    { border-left: 4px solid #ef4444; }
.stat-card-gray   { border-left: 4px solid #64748b; }

.stat-card-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.stat-card-value {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    color: var(--text-dark);
}

.stat-card-blue   .stat-card-value  { color: #2563eb; }
.stat-card-purple .stat-card-value  { color: var(--primary); }
.stat-card-green  .stat-card-value  { color: #059669; }
.stat-card-orange .stat-card-value  { color: #ea580c; }
.stat-card-pink   .stat-card-value  { color: #db2777; }
.stat-card-red    .stat-card-value  { color: #dc2626; }
.stat-card-gray   .stat-card-value  { color: var(--text-dark); }

.stat-card-sub {
    font-size: .8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.stat-card-icon {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2rem;
    opacity: .08;
    color: var(--text-dark);
}

/* ── Tables ───────────────────────────────────────────────────── */
.table {
    font-size: .88rem;
    color: var(--text-body);
}
.table th {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 18px;
    white-space: nowrap;
    background: #f8fafc;
}
.table td {
    padding: 14px 18px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { 
    background: var(--primary-lighter) !important; 
}

/* Table inside card — flush borders */
.card .table { margin: 0; }
.card .table th:first-child,
.card .table td:first-child { padding-left: 24px; }
.card .table th:last-child,
.card .table td:last-child { padding-right: 24px; }

/* Overflow wrapper */
.table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
    font-size: .72em;
    font-weight: 700;
    letter-spacing: .03em;
    padding: .4em .75em;
    border-radius: 6px;
}

/* ── Global pastel badge overrides ──────────────────────────── */
.badge.bg-primary {
    background: #f5f3ff !important;
    color: #6d28d9 !important;
    border: 1px solid #ddd6fe;
}
.badge.bg-success {
    background: #ecfdf5 !important;
    color: #047857 !important;
    border: 1px solid #a7f3d0;
}
.badge.bg-danger {
    background: #fef2f2 !important;
    color: #b91c1c !important;
    border: 1px solid #fecaca;
}
.badge.bg-warning {
    background: #fffbeb !important;
    color: #b45309 !important;
    border: 1px solid #fde68a;
}
.badge.bg-info {
    background: #f0f9ff !important;
    color: #0369a1 !important;
    border: 1px solid #bae6fd;
}
.badge.bg-secondary {
    background: #f8fafc !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1;
}
.badge.bg-dark {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1;
}
.badge.bg-warning.text-dark {
    color: #b45309 !important;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    border-radius: var(--btn-radius);
    font-size: .86rem;
    font-weight: 600;
    transition: all var(--transition);
    padding: .5rem 1.15rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #ffffff;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-gradient);
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.22);
}
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--primary-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.18);
}
.btn-outline-secondary {
    color: var(--text-body);
    border-color: var(--border-color);
}
.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.btn-sm { font-size: .82rem; padding: .4rem .9rem; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--input-radius);
    border-color: var(--border-color);
    font-size: .88rem;
    color: var(--text-body);
    background: #f8fafc;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
    background: #fff;
}
.form-label {
    font-size: .84rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: .4rem;
}
.form-text { color: var(--text-muted); font-size: .8rem; }
.form-control::placeholder, .form-select option[value=""] { color: var(--text-muted); }

/* Barcode input */
.barcode-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.05rem;
    letter-spacing: .02em;
    border: 2px solid var(--primary);
    background: var(--primary-lighter);
    font-weight: 500;
}
.barcode-input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}
@keyframes scanPulse {
    0%, 100% { box-shadow: 0 0 0 0   rgba(124, 58, 237, .45); }
    50%        { box-shadow: 0 0 0 9px rgba(124, 58, 237, 0);   }
}
.barcode-input.scanning {
    animation: scanPulse 1.1s ease-in-out infinite;
}

/* Progress bar */
.progress { 
    background: var(--border-light); 
    border-radius: 8px;
    height: 8px !important;
}
.progress-bar { 
    transition: width .5s ease; 
    background: var(--primary-gradient);
}

/* Pagination */
.page-link {
    border-radius: 8px !important;
    border-color: var(--border-color);
    color: var(--primary);
    font-size: .84rem;
    margin: 0 2px;
    padding: .35rem .75rem;
    font-weight: 600;
}
.page-link:hover { 
    background: var(--primary-lighter); 
    border-color: var(--primary); 
    color: var(--primary); 
}
.page-item.active .page-link { 
    background: var(--primary-gradient); 
    border-color: transparent; 
    color: #fff;
}

/* Alerts */
.alert {
    border: 1px solid transparent;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.02);
}
.alert-success {
    background-color: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}
.alert-danger {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}
.alert-warning {
    background-color: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

/* Toast */
.toast { border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }

/* ── Loading spinner ──────────────────────────────────────────── */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(4px);
}

/* ── Dropdown menu ────────────────────────────────────────────── */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    padding: 6px;
    background: #ffffff;
}
.dropdown-item {
    border-radius: 8px;
    font-size: .86rem;
    padding: .55rem .9rem;
    color: var(--text-body);
    font-weight: 500;
}
.dropdown-item:hover { background: var(--primary-lighter); color: var(--primary); }
.dropdown-item.text-danger:hover { background: #fee2e2; color: #b91c1c; }
.dropdown-divider { border-color: var(--border-color); }

/* ── Utility ──────────────────────────────────────────────────── */
.min-w-0 { min-width: 0; }
.font-monospace { font-family: 'JetBrains Mono', monospace !important; }
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }

/* ── Responsive — mobile sidebar ────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-105%);
        width: min(var(--sidebar-width), 88vw);
        z-index: 1050;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
    }
    .sidebar-overlay {
        z-index: 1040;
    }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .topbar-search input { width: 160px; }
    .topbar-user-info { display: none; }
    .page-content { padding: 18px; }
}

/* Rack mobile list (racks/index.php) */
.rack-mobile-list {
    display: grid;
    gap: 0.75rem;
}
.rack-mobile-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    background: #fff;
    box-shadow: var(--card-shadow);
}
.rack-mobile-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}
.rack-mobile-metric .label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
}
.rack-mobile-metric .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}
.rack-mobile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

@media (max-width: 575.98px) {
    .topbar { padding: 0 16px; }
    .topbar-search { display: none; }
    .page-content { padding: 14px; }
    .stat-card-value { font-size: 1.8rem; }
    .dashboard-scan-btn {
        min-width: 96px;
        padding-left: .8rem !important;
        padding-right: .8rem !important;
    }
    .dashboard-scan-meta {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 4px !important;
    }
}

/* ── Print ────────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, form { display: none !important; }
    .main-wrapper { margin-left: 0; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    body { background: #fff; }
}

/* ── Search bar in filter forms ──────────────────────────────── */
.search-bar-wrapper { position: relative; }
.search-bar-wrapper .search-icon {
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: .9rem;
}
.search-bar-wrapper input { padding-left: 2.3rem; }

/* ── Dashboard quick scan bar ────────────────────────────────── */
.dashboard-scan-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}
.dashboard-scan-group {
    border: 1px solid rgba(124, 58, 237, .16);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(124, 58, 237, .04);
}
.dashboard-scan-icon {
    background: var(--primary-gradient);
    color: #fff;
    border: 0;
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dashboard-scan-input {
    border: 0 !important;
    background: #fff !important;
    font-size: 1.05rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: .01em;
}
.dashboard-scan-input:focus {
    box-shadow: none !important;
}
.dashboard-scan-btn {
    border: 0;
    border-radius: 0;
    min-width: 120px;
    font-weight: 700;
}
.dashboard-scan-meta {
    font-size: .82rem;
}
.dashboard-scan-meta .btn-link {
    text-decoration: none;
}
.dashboard-scan-meta .btn-link:hover {
    text-decoration: underline;
}

/* ── Malaysia state badge style ─────────────────────────────── */
.my-state-flag {
    background: #f8fafc;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    font-weight: 600;
}
.my-state-flag .bi-flag-fill {
    color: #ef4444;
}
.my-state-code {
    background: #1d4ed8;
    color: #fff;
    border-radius: 999px;
    padding: 1px 6px;
    font-size: .68rem;
    letter-spacing: .04em;
}

/* ── Meters table emphasis ───────────────────────────────────── */
.meter-serial-link {
    font-size: .95rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}
.meter-type-badge {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .03em;
    border: 1px solid transparent;
}
.meter-type-rf1 {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}
.meter-type-rf3 {
    background: #f5f3ff;
    color: #6d28d9;
    border-color: #ddd6fe;
}
.meter-type-cell1 {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}
.meter-type-cell3 {
    background: #fff7ed;
    color: #c2410c;
    border-color: #ffedd5;
}
.meter-type-wc {
    background: #fdf2f8;
    color: #be185d;
    border-color: #fbcfe8;
}
.meter-type-ncm {
    background: #ecfeff;
    color: #0e7490;
    border-color: #a5f3fc;
}
.meter-type-others,
.meter-type-default {
    background: #f8fafc;
    color: #475569;
    border-color: #cbd5e1;
}

/* ── Meter detail records panel ──────────────────────────────── */
.meter-detail-panel {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}
.meter-detail-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.meter-detail-panel__title {
    margin: 0;
    font-size: .88rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dark);
}
.meter-detail-list {
    display: grid;
    gap: 12px;
}
.meter-detail-record {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.02);
}
.meter-detail-record__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.meter-detail-record__meta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: .8rem;
}
.meter-detail-record__time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.meter-detail-record__author {
    background: #f1f5f9;
    color: var(--text-body);
    border-radius: 999px;
    padding: 2px 10px;
    font-weight: 600;
}
.meter-detail-ticket {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .02em;
    padding: 4px 12px;
}
.meter-detail-record__actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.meter-detail-edit-btn {
    white-space: nowrap;
}
.meter-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.meter-detail-field {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 0;
}
.meter-detail-field__label {
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 700;
}
.meter-detail-field__value {
    display: block;
    font-size: .84rem;
    color: var(--text-dark);
    line-height: 1.4;
    overflow-wrap: anywhere;
    font-weight: 500;
}
.meter-detail-notes {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}
.meter-detail-note {
    border-left: 3px solid #ddd6fe;
    background: #faf5ff;
    border-radius: 8px;
    padding: 10px 12px;
}
.meter-detail-note__label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 4px;
}
.meter-detail-note__text {
    font-size: .84rem;
    line-height: 1.5;
    color: var(--text-body);
    overflow-wrap: anywhere;
}
.meter-detail-empty {
    border: 1px dashed #ddd6fe;
    border-radius: 10px;
    background: #faf5ff;
    color: var(--primary);
    font-size: .84rem;
    padding: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}
.meter-detail-attachments__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.meter-detail-attachment-image {
    width: 72px;
    height: 72px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    display: inline-flex;
    box-shadow: 0 1px 3px rgba(0,0,0,.02);
}
.meter-detail-attachment-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.meter-detail-file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    padding: 8px 12px;
    font-size: .8rem;
    color: var(--text-body);
    text-decoration: none;
    max-width: 240px;
    box-shadow: 0 1px 3px rgba(0,0,0,.02);
    font-weight: 500;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.meter-detail-file-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.meter-detail-file-link:hover {
    border-color: #ddd6fe;
    color: var(--primary);
    background: var(--primary-lighter);
}
.meter-detail-file-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-light);
    border: 1px solid #ddd6fe;
    color: var(--primary);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .03em;
    line-height: 1.1;
}
.meter-detail-attachment-list {
    padding-left: 18px;
}
.meter-detail-attachment-list li {
    font-size: .8rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.meter-detail-attachment-list a {
    color: var(--primary);
    text-decoration: none;
    word-break: break-word;
    font-weight: 600;
}
.meter-detail-attachment-list a:hover {
    text-decoration: underline;
}

/* Footer layout details */
.footer-bar {
    background: var(--topbar-bg);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
}

@media (max-width: 991.98px) {
    .meter-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .meter-detail-panel {
        padding: 12px;
    }
    .meter-detail-panel__header {
        flex-direction: column;
        align-items: stretch;
    }
    .meter-detail-panel__header .btn {
        width: 100%;
    }
    .meter-detail-grid {
        grid-template-columns: 1fr;
    }
    .meter-detail-record {
        padding: 12px;
    }
    .meter-detail-record__actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ── List group ───────────────────────────────────────────────── */
.list-group-item {
    border-color: var(--border-color);
    color: var(--text-body);
    font-weight: 500;
}
.list-group-item-action:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}

/* ── Ticket Lab Reports Styles ─────────────────────────────────── */
.btn-xs {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    border-radius: 4px;
}
.ticket-detail-panel .table-responsive {
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.ticket-detail-panel .table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.ticket-detail-panel .table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}
