* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Color Palette - Deep Slate & Vibrant Accents */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --accent-blue: #38bdf8;
    --accent-indigo: #6366f1;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-green: #22c55e;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    overflow-x: hidden;
    width: 100%;
}

/* Landing Portal Redesign */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 1000;
    transition: var(--transition-smooth);
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-direction: column !important;
    padding: 1.5rem;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
}

#login-screen.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

.portal-header {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 2rem auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.8s ease-out;
}

.portal-content {
    display: flex;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    gap: 2rem;
    align-items: center;
    flex: 1;
    min-height: fit-content;
    padding-bottom: 5vh;
}

.portal-hero {
    flex: 1;
    animation: slideRight 1s ease-out;
}

.hp-photo-uploader.drag-over {
    border-color: var(--accent-indigo) !important;
    background: rgba(99, 102, 241, 0.1) !important;
    transform: scale(1.02);
}

.hp-photo-uploader.drag-over i {
    transform: translateY(-5px);
}

.portal-hero h1 {
    font-size: 2.5rem;
    line-height: 1.1;
    margin-bottom: 1rem;
    font-weight: 800;
}

.portal-hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 480px;
}

.login-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideLeft 1s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideRight {
    from {
        transform: translateX(-50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideLeft {
    from {
        transform: translateX(50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.login-card .brand {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.login-card .brand img {
    max-width: 100%;
    height: auto;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-input {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    width: 100%;
}

.login-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1);
}

.login-btn {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: white;
    border: none;
    padding: 0.8rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-top: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(56, 189, 248, 0.3);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(56, 189, 248, 0.4);
    filter: brightness(1.1);
}

.login-btn:active {
    transform: translateY(0) scale(0.98);
}

.install-btn {
    background: linear-gradient(135deg, #22c55e, #10b981);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 20px -5px rgba(34, 197, 94, 0.4);
}

.install-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 20px 30px -10px rgba(34, 197, 94, 0.5);
    filter: brightness(1.1);
}

.install-btn i {
    width: 20px;
    height: 20px;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Feature tags for the landing */
.portal-tags {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Sub-navigation for tasks within areas */
.area-tabs {
    display: flex; flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.sub-tab {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.sub-tab:hover {
    color: var(--text-primary);
}

.sub-tab.active {
    background: var(--glass-bg);
    color: var(--accent-blue);
}

/* Notification Badge Standard - v3 (Cache Busting) */
.notif-badge-v3 {
    position: absolute !important;
    top: -12px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: var(--accent-red) !important;
    color: white !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
    font-size: 0.6rem !important;
    display: none; /* Controlled by JS */
    align-items: center !important;
    justify-content: center !important;
    font-weight: 800 !important;
    border: 2px solid var(--bg-primary) !important;
    z-index: 10 !important;
}

/* Visual Inspection Stage Tabs */
.stage-tab {
    flex: 1;
    padding: 0.75rem 1rem; /* Slightly more padding for balance (v3.39) */
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 700; /* Bolder for professional look */
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    letter-spacing: 0.5px;
    text-transform: uppercase; /* Professional tab style */
}

.stage-tab:hover {
    color: var(--text-primary);
}

.stage-tab.active {
    background: var(--bg-secondary);
    color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.task-view {
    display: none;
}

.task-view.active {
    display: block;
}

.functional-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.triple-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Grid layout for QC forms (v1.93) */
.qc-form-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem; /* Reduced gap from 1.5rem for better aspect */
    margin: 0 auto 2rem auto; /* Centered as requested */
    max-width: 700px; /* Increased slightly from 650px for better fit (v3.38) */
}

.qc-form-grid .input-group.span-2 { grid-column: span 2; }
.qc-form-grid .input-group.span-3 { grid-column: span 3; }
.qc-form-grid .input-group.span-4 { grid-column: span 4; }
.qc-form-grid .input-group.full { grid-column: span 6; }

@media (max-width: 1024px) {
    .qc-form-grid {
        grid-template-columns: 1fr;
    }
    .qc-form-grid .input-group {
        grid-column: span 1 !important;
    }
}

.input-group {
    display: flex; flex-wrap: wrap;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.input-field {
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    width: 100%;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.input-field[type="date"]::-webkit-calendar-picker-indicator,
.input-field[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.8;
    transition: var(--transition-smooth);
}

.input-field[type="date"]::-webkit-calendar-picker-indicator:hover,
.input-field[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    transform: scale(1.1);
}

#inv-ent-desc-container, #inv-sal-desc-container {
    width: 100%;
}

.certificate-preview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
    backdrop-filter: blur(8px);
}

.certificate-preview.active {
    display: flex; flex-wrap: wrap;
}

.certificate-modal-content {
    background: white;
    color: #0f172a;
    border-radius: 8px;
    width: 100%;
    max-width: 850px;
    margin: auto; /* For vertical centering in overflow */
    position: relative;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-cert-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex; flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #475569;
}

.close-cert-modal:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

.cert-header {
    text-align: center;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.cert-header h2 {
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.cert-body {
    line-height: 1.6;
}

.cert-row {
    display: flex; flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 1rem;
    border-bottom: 1px dotted #cbd5e1;
}

.cert-label {
    font-weight: 700;
}

.cert-footer {
    margin-top: 3rem;
    display: flex; flex-wrap: wrap;
    justify-content: space-around;
    text-align: center;
}

.cert-sign {
    border-top: 1px solid #0f172a;
    padding-top: 0.5rem;
    width: 200px;
    font-size: 0.8rem;
}

.portal-tag-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex; flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

#login-screen {
    overflow-x: hidden;
}

/* Sidebar Navigation */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: fixed;
    height: 100dvh;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.sidebar::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
}

.brand {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: var(--transition-smooth);
}

.brand:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.brand img {
    max-width: 200px;
    height: auto;
}

.sidebar .brand img {
    max-width: 100%;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
    transition: var(--transition-smooth);
}

.sidebar .brand img:hover {
    transform: scale(1.03);
}

.header-logo {
    max-height: 80px;
    width: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: var(--transition-smooth);
}

.header-logo:hover {
    transform: scale(1.05);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.65rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition-smooth);
    display: flex; flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    position: relative; /* Added for badge positioning */
}

.sidebar-badge {
    position: absolute;
    right: 1.2rem;
    background: #ef4444;
    color: white;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.nav-item:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(99, 102, 241, 0.1));
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

/* Main Content Area */
.main-content {
    margin-left: 280px;
    flex: 1;
    padding: 2.5rem;
}

header {
    margin-bottom: 3rem;
    display: flex; flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.header-info h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header-info p {
    color: var(--text-secondary);
}

/* Dashboard Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
    position: relative;
    overflow: visible;
}

.card:hover {
    transform: translateY(-5px);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-header {
    display: flex; flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.card-meta {
    font-size: 0.875rem;
    color: var(--accent-blue);
}

/* Section visibility */
section {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Placeholder for visuals */
.visual-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

/* Form Controls */
.form-group {
    margin-bottom: 2rem;
    display: flex; flex-wrap: wrap;
    flex-direction: column;
    gap: 0.75rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex; flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.form-select {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Compact versions for specific form areas (v3.38) */
.compact-select {
    padding: 0.6rem 2.5rem 0.6rem 0.75rem !important;
    font-size: 0.875rem !important;
    border-radius: 8px !important;
}

.compact-label {
    font-size: 0.75rem !important;
    margin-bottom: 0.25rem !important;
}

/* Checklist Styles */
.checklist-container {
    display: flex; flex-wrap: wrap;
    flex-direction: column;
    gap: 1.5rem;
}

.step-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex; flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
}

.step-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.step-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-group {
    display: flex; flex-wrap: wrap;
    gap: 0.75rem;
}

.status-btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.status-btn.pass:hover,
.status-btn.pass.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border-color: #22c55e;
}

.status-btn.fail:hover,
.status-btn.fail.active {
    background: rgba(239, 44, 44, 0.1);
    color: #ef4444;
    border-color: #ef4444;
}

/* Status Badges for Details Viewer (High Contrast) */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-block;
}

.status-badge.active {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Checklist Grouping */
.step-card-group {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--glass-border);
}

.group-header {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    font-weight: 600;
}

.sub-step {
    border-color: rgba(255, 255, 255, 0.05) !important;
    padding: 0.75rem 1rem !important;
    background: transparent !important;
    margin-bottom: 0.5rem !important;
}

.sub-step:last-child {
    margin-bottom: 0 !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-top: 1rem;
    align-self: flex-start;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(56, 189, 248, 0.3);
}

/* QC History specific actions */
.btn-qc-action {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 10px;
    display: flex; flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    border: none;
    color: white;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-qc-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.btn-qc-action.red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-qc-action.orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-qc-action.green {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

/* History Table */
.history-section {
    margin-top: 3rem;
}

.table-wrapper {
    overflow-x: auto;
    background: var(--glass-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.95rem;
}

.tag {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tag.pass {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.tag.fail {
    background: rgba(239, 44, 44, 0.1);
    color: #ef4444;
}

.tag.warning {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.product-tag {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-indigo);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Login Failure Overlay Styles */
.failure-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    animation: fadeIn 0.4s ease-out;
}

.failure-overlay.active {
    display: flex; flex-wrap: wrap;
}

.failure-card {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 3rem;
    border-radius: 24px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
    to {
        transform: scale(1);
    }
}

.failure-icon {
    width: 64px;
    height: 64px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 50%;
    display: flex; flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
}

.failure-icon i {
    width: 32px;
    height: 32px;
}

.failure-card h2 {
    font-size: 1.5rem;
    color: #f8fafc;
    margin-bottom: 1rem;
}

.failure-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.btn-retry {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
}

.btn-retry:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.3);
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.settings-btn {
    width: 100%;
    max-width: 220px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
    color: var(--accent-indigo);
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.settings-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-indigo);
}

.logout-btn {
    width: 100%;
    max-width: 220px;
    background: rgba(239, 44, 44, 0.05);
    border: 1px solid rgba(239, 44, 44, 0.1);
    color: #ef4444;
    padding: 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.logout-btn:hover {
    background: rgba(239, 44, 44, 0.1);
    border-color: #ef4444;
}

/* --- Responsive Media Queries (v1.6) --- */

@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        padding: 0.75rem 1rem;
        flex-direction: row;
        flex-wrap: wrap; /* Allow wrapping */
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        background: rgba(30, 41, 59, 0.95);
        backdrop-filter: blur(10px);
    }

    .sidebar .brand {
        margin-bottom: 0;
        width: auto;
        order: 1;
    }
    
    .sidebar .brand img {
        max-width: 160px;
    }

    .sidebar-footer {
        margin-top: 0;
        padding-top: 0;
        width: auto;
        flex-direction: row;
        order: 2;
    }
    
    .sidebar nav {
        order: 3;
        flex: 1 1 100%;
        min-width: 0; /* CRITICAL: Allows flex item to shrink below content width */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: thin;
        scrollbar-color: var(--accent-indigo) transparent;
    }
    
    .sidebar nav::-webkit-scrollbar {
        height: 4px;
        display: block;
    }

    .sidebar nav::-webkit-scrollbar-thumb {
        background-color: var(--accent-indigo);
        border-radius: 10px;
    }

    .nav-links {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.5rem;
        width: max-content;
    }

    .nav-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        white-space: nowrap;
        gap: 6px;
    }
    
    .nav-item i {
        width: 14px;
        height: 14px;
    }

    .logout-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
        white-space: nowrap;
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    header {
        margin-bottom: 2rem;
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-logo {
        max-height: 50px;
    }
    
    .header-info h1 {
        font-size: 1.75rem;
    }
    
    .grid-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .portal-content {
        flex-direction: column;
        text-align: center;
    }
    
    .portal-hero h1 {
        font-size: 1.75rem;
    }
    
    .portal-tags {
        justify-content: center;
    }
    
    .functional-fields {
        grid-template-columns: 1fr;
    }
    
    .visual-grid {
        grid-template-columns: 1fr;
    }
    
    /* Adapt standard date/time header in Visual inspection */
    #visual-product-group > div {
        grid-template-columns: 1fr !important;
    }
}
/* Historial de Pruebas - Upload Area */
.sub-tab-btn {
    padding: 0.6rem 1.2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sub-tab-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.sub-tab-btn.active {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.hp-photo-uploader {
    position: relative;
    width: 100%;
    height: 300px;
    border: 2px dashed var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    display: flex; flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: rgba(15, 23, 42, 0.4);
}

.hp-photo-uploader:hover {
    border-color: var(--accent-blue);
    background: rgba(15, 23, 42, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -10px rgba(56, 189, 248, 0.2);
}

.hp-photo-uploader img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.hp-photo-uploader:hover img {
    transform: scale(1.02);
}

.hp-history-img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.hp-history-img:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Document Repository Specific Styles */
#documentos-task table tr:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}

#documentos-task .btn-icon:hover {
    transform: translateY(-2px) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#hp-doc-uploader:hover i {
    transform: translateY(-5px);
    opacity: 0.8 !important;
}

#hp-doc-uploader i {
    transition: var(--transition-smooth);
}

/* Quality Certificate Action Buttons (v3.36) */
.cert-actions-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
}

.cert-action-btn {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid var(--glass-border);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    width: 100%;
}

.cert-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.cert-action-btn:active {
    transform: translateY(0);
}

.cert-action-btn.print {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.cert-action-btn.download {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
}

.cert-action-btn.save {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: white;
    border: none;
}

}

/* --- Notification Animations --- */
@keyframes blink-red {
    0% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    50% { opacity: 0.5; transform: scale(1.05); box-shadow: 0 0 10px 4px rgba(239, 68, 68, 0.4); }
    100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

}

.blink-badge {
    animation: blink-red 1.5s infinite;
    background: #ef4444 !important;
    color: white !important;
    font-weight: 900 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

@keyframes pulse-highlight {
    0% { background-color: rgba(245, 158, 11, 0.1); }
    50% { background-color: rgba(245, 158, 11, 0.25); }
    100% { background-color: rgba(245, 158, 11, 0.1); }
}
i n p u t [ t y p e = " p a s s w o r d " ] : : - m s - r e v e a l ,   i n p u t [ t y p e = " p a s s w o r d " ] : : - m s - c l e a r   {   d i s p l a y :   n o n e ;   }  
 
/* Custom Row and Badge styles for QC Visual History depending on Stage (v4.73) */
.visual-row-embalaje {
    border-left: 4px solid #22c55e !important;
    background: rgba(34, 197, 94, 0.02) !important;
}
.visual-row-embalaje:hover {
    background: rgba(34, 197, 94, 0.06) !important;
}

.visual-row-inyeccion {
    border-left: 4px solid #ef4444 !important;
    background: rgba(239, 68, 68, 0.02) !important;
}
.visual-row-inyeccion:hover {
    background: rgba(239, 68, 68, 0.06) !important;
}

.visual-row-ensamble {
    border-left: 4px solid #fbbf24 !important;
    background: rgba(251, 191, 36, 0.02) !important;
}
.visual-row-ensamble:hover {
    background: rgba(251, 191, 36, 0.06) !important;
}

.stage-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stage-badge.embalaje {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.stage-badge.inyeccion {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.stage-badge.ensamble {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.25);
}

.visual-row-pulido {
    border-left: 4px solid #8b5cf6 !important;
    background: rgba(139, 92, 246, 0.02) !important;
}
.visual-row-pulido:hover {
    background: rgba(139, 92, 246, 0.06) !important;
}

.stage-badge.pulido {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

/* Bitacora Styles (v6.50) */
.bitacora-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (max-width: 768px) {
    .bitacora-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive adjustments for Almacén forms */
.almacen-ff-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.almacen-ff-2col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.almacen-ff-etiquetas {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.almacen-form-row-1 {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 0.8fr 5fr;
    gap: 1rem;
    align-items: end;
}
.almacen-form-row-2 {
    display: grid;
    grid-template-columns: 1.8fr 1fr 1fr 1.2fr;
    gap: 1rem;
    align-items: end;
}
.almacen-form-row-3 {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    gap: 1rem;
}

@media (max-width: 1024px) {
    .almacen-ff-3col {
        grid-template-columns: 1fr 1fr;
    }
    .almacen-form-row-1 {
        grid-template-columns: 1fr 1fr;
    }
    .almacen-form-row-2 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .almacen-ff-3col {
        grid-template-columns: 1fr;
    }
    .almacen-ff-2col {
        grid-template-columns: 1fr;
    }
    .almacen-ff-etiquetas {
        grid-template-columns: 1fr;
    }
    .almacen-form-row-1 {
        grid-template-columns: 1fr;
    }
    .almacen-form-row-2 {
        grid-template-columns: 1fr;
    }
    .almacen-form-row-3 {
        grid-template-columns: 1fr;
    }
}
