:root {
    --primary: #1e293b;
    --primary-light: #334155;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --bg: #f8fafc;
    --text: #334155;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --white: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sidebar-width: 240px;
    --sidebar-collapsed: 72px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    margin: 0;
    display: flex;
    height: 100vh;
    color: var(--text);
    line-height: 1.5;
    position: relative;
}

/* Hamburger Menu Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    box-shadow: var(--card-shadow);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Sidebar Layout */
.sidebar {
    width: var(--sidebar-collapsed);
    background-color: var(--primary);
    border-right: none;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease, transform 0.3s ease;
    z-index: 1000;
    overflow: hidden;
    position: relative;
}

.sidebar.expanded {
    width: var(--sidebar-width);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 24px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
}

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 800;
    color: white;
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
    white-space: nowrap;
}

.sidebar.expanded .sidebar-logo-text {
    opacity: 1;
}


.close-sidebar {
    display: none;
    cursor: pointer;
    font-size: 24px;
    color: var(--text-light);
}

.menu-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.menu-item .menu-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.menu-item .menu-label {
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
    white-space: nowrap;
}

.sidebar.expanded .menu-item .menu-label {
    opacity: 1;
}

.menu-item:hover {
    background-color: rgba(255,255,255,0.12);
    color: white;
}

.menu-item.active {
    background-color: var(--accent);
    color: white;
}

.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3 {
    color: var(--primary);
    margin-top: 0;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.page-subtitle {
    color: var(--text-lighter);
    margin-bottom: 30px;
}

/* Components */
.card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    gap: 8px;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-light);
}

.btn-outline:hover {
    background-color: #f8fafc;
    color: var(--primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Tables */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.table-toolbar .selection-info {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
    margin-right: auto;
}

.kop-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.kop-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 14px;
}

.kop-table th {
    background-color: #f8fafc;
    color: var(--text-light);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.kop-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.kop-table tr.selected {
    background-color: #eff6ff;
}

.kop-table tr:last-child td {
    border-bottom: none;
}

.kop-table tr:hover {
    background-color: #fcfdfe;
}

.kop-table tr.selected:hover {
    background-color: #e0f2fe;
}

/* Checkbox styling in table */
.kop-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--primary-light);
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pending, .status-waiting_approval { background: #fef3c7; color: #92400e; }
.status-approved, .status-fulfilled { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-draft { background: #f1f5f9; color: #475569; }
.status-open { background: #e0f2fe; color: #0369a1; }
.status-placed { background: #e0e7ff; color: #4338ca; }
.status-closed { background: #f8fafc; color: #94a3b8; border: 1px solid var(--border); }

/* Dashboard Cards (Specific) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

.kpi-icon {
    font-size: 24px;
    margin-bottom: 12px;
}

.kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
}

/* Dashboard Summary Panels */
.summary-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-panel {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.summary-panel .panel-title {
    background: #f8fafc;
    padding: 15px 20px;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border);
}

.summary-panel .panel-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 20px;
    padding: 20px;
}

.kpi-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-item .kpi-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

.kpi-item .kpi-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-dark);
    word-break: break-word;
}

.text-success { color: #10b981 !important; }
.text-danger { color: #ef4444 !important; }
.text-primary { color: #3b82f6 !important; }

.nav-card {
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    height: 140px;
}

.nav-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Badges & Chips */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.badge.pending { background: #e2e8f0; color: #475569; }
.badge.in_progress { background: #fef08a; color: #854d0e; }
.badge.passed, .badge.success { background: #dcfce7; color: #166534; }
.badge.failed, .badge.danger { background: #fee2e2; color: #991b1b; }
.badge.rework, .badge.warning { background: #ffedd5; color: #c2410c; }

.nav-card .badge {
    position: absolute;
    top: 20px;
    right: 20px;
    display: none;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.nav-card .badge.active {
    display: inline-flex;
}

.chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 11px;
    margin-left: 4px;
    color: var(--text-light);
}

.badge-empty {
    display: inline-block;
    background: var(--bg);
    color: var(--text-light);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    border: 1px dashed var(--border);
}

/* Checklist UI */
.checklist-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.checklist-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.critical-badge {
    background: #fee2e2;
    color: #991b1b;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.checklist-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-radio {
    flex: 1;
    padding: 12px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.btn-radio.pass.selected { background: #22c55e; color: white; border-color: #16a34a; }
.btn-radio.fail.selected { background: #ef4444; color: white; border-color: #dc2626; }
.btn-radio.na.selected { background: #64748b; color: white; border-color: #475569; }

.checklist-notes {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
}

/* Utility Classes */
.flex-gap-10 { display: flex; gap: 10px; }
.pos-abs-tr-15 { position: absolute; top: 15px; right: 15px; }
.icon-lg { font-size: 32px; margin-bottom: 15px; }
.text-desc-sm { color: var(--text-lighter); font-size: 14px; margin-top: 5px; }
.mt-20 { margin-top: 20px; }
.mt-10 { margin-top: 10px; }
.w-full { width: 100%; }
.border-collapse { border-collapse: collapse; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.p-10 { padding: 10px; }
.p-20 { padding: 20px; }
.border-b-2 { border-bottom: 2px solid #eee; }
.border-b-1 { border-bottom: 1px solid #eee; }


/* Utilities */
.status-bar {
    margin-top: auto;
    padding: 15px;
    background: #f1f5f9;
    color: var(--text-light);
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    border: 1px solid var(--border);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .sidebar-toggle-btn {
        display: none !important;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
        box-shadow: 10px 0 15px -3px rgba(0,0,0,0.2);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open .menu-label,
    .sidebar.open .sidebar-logo-text,
    .sidebar.open .sidebar-user-info,
    .sidebar.open .sidebar-logout-btn .menu-label {
        opacity: 1;
    }

    .main-content {
        padding: 60px 20px 20px 20px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    width: 220px;
    padding: 8px 0;
    display: none;
}

.context-menu-item {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background-color: #f1f5f9;
    color: var(--accent);
}

.context-menu-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: var(--text-light);
}

.context-menu-item:hover i {
    color: var(--accent);
}

.context-menu-separator {
    height: 1px;
    background-color: var(--border);
    margin: 4px 0;
}

/* Modal Enhancements for Details */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 850px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Detail Sections */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.detail-item label {
    color: var(--text-lighter);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    display: block;
}

.detail-item .value {
    font-weight: 600;
    font-size: 15px;
    color: var(--primary);
}

.detail-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin: 32px 0 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-section-title i {
    color: var(--accent);
}

.detail-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.history-table th {
    text-align: left;
    color: var(--text-light);
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.history-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}

.usage-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}
/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Sidebar User */
.sidebar-user {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.sidebar-user-info {
    padding: 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
    white-space: nowrap;
}

.sidebar.expanded .sidebar-user-info {
    opacity: 1;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.sidebar-user-role {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    letter-spacing: 0.05em;
}

.sidebar-logout-btn {
    all: unset;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(239,68,68,0.85);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logout-btn:hover {
    background-color: rgba(239,68,68,0.15);
    color: #ef4444;
}

/* Sidebar Toggle Button styling */
.sidebar-toggle-btn {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: rgba(255,255,255,0.65);
    margin-top: auto; /* Push it to the bottom of the nav container! */
}

.sidebar-toggle-btn:hover {
    background-color: rgba(255,255,255,0.12);
    color: white;
}

.sidebar-logout-btn .menu-label {
    opacity: 0;
    transition: opacity 0.2s ease 0.05s;
}

.sidebar.expanded .sidebar-logout-btn .menu-label {
    opacity: 1;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

.usage-active { background: #dcfce7; color: #166534; }
.usage-spare { background: #f1f5f9; color: #475569; }

/* Sidebar Role Switcher */
.sidebar-role-switcher {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 12px 12px 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.role-switcher-title {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.role-switcher-title .menu-label {
    transition: opacity 0.2s ease 0.05s;
}

.sidebar:not(.expanded) .role-switcher-title {
    justify-content: center;
}

.sidebar:not(.expanded) .role-switcher-title .menu-label {
    display: none;
}

.role-switcher-select-container {
    transition: all 0.3s ease;
}

.sidebar:not(.expanded) .role-switcher-select-container {
    display: none;
}

.role-switcher-select {
    width: 100%;
    background-color: var(--primary-light);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.role-switcher-select:hover {
    background-color: rgba(255,255,255,0.15);
    border-color: var(--accent);
}

.role-switcher-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.role-switcher-select option {
    background-color: var(--primary);
    color: white;
}

/* Collapsed Role Switch Button */
.role-switcher-collapsed-btn {
    all: unset;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background-color: rgba(255, 255, 255, 0.08);
    transition: all 0.2s;
    margin: 0 auto;
}

.role-switcher-collapsed-btn:hover {
    background-color: var(--accent);
    transform: scale(1.05);
}

.sidebar.expanded .role-switcher-collapsed-btn {
    display: none;
}

