/* =============================================
   ClinixQM - Quality Management System
   Master Stylesheet
   ============================================= */

:root {
    /* Primary Brand */
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --primary-subtle: rgba(30, 64, 175, 0.1);
    
    /* Secondary */
    --secondary: #0d9488;
    --secondary-dark: #0f766e;
    --secondary-light: #14b8a6;
    --secondary-subtle: rgba(13, 148, 136, 0.1);
    
    /* Status Colors */
    --success: #16a34a;
    --success-subtle: rgba(22, 163, 74, 0.1);
    --warning: #d97706;
    --warning-subtle: rgba(217, 119, 6, 0.1);
    --danger: #dc2626;
    --danger-subtle: rgba(220, 38, 38, 0.1);
    --info: #0284c7;
    --info-subtle: rgba(2, 132, 199, 0.1);
    
    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    
    /* Effects */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-100);
    min-height: 100vh;
}

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

/* Utilities */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--primary-dark) 50%, var(--secondary-dark) 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 50%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.3; }
}

.login-card {
    background: white;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    padding: 48px;
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.login-form { margin-top: 24px; }

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition-fast);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.form-control::placeholder { color: var(--gray-400); }

.form-hint {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.938rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm { padding: 8px 14px; font-size: 0.875rem; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn-block { width: 100%; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition-normal);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.sidebar-title h1 {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-title p {
    font-size: 0.688rem;
    opacity: 0.6;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 0.688rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    padding: 12px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 2px 0;
    color: rgba(255,255,255,0.7);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item svg, .nav-item .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active svg, .nav-item.active .nav-icon {
    opacity: 1;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.688rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 12px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    color: var(--gray-500);
}

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

/* Header */
.header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.header-breadcrumb span { color: var(--gray-400); }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--gray-100);
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.header-user:hover { background: var(--gray-200); }

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 24px;
}

/* =============================================
   CARDS & PANELS
   ============================================= */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }
.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* =============================================
   DASHBOARD SPECIFIC
   ============================================= */

/* Product Header */
.product-header {
    background: linear-gradient(135deg, var(--gray-900), var(--primary-dark));
    color: white;
    border-radius: var(--radius-xl);
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-info { display: flex; align-items: center; gap: 20px; }

.product-icon {
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.product-details h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.product-meta {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    opacity: 0.8;
}

.product-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.readiness-score {
    text-align: center;
}

.readiness-value {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.readiness-label {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: 4px;
}

.readiness-bar {
    width: 120px;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.readiness-fill {
    height: 100%;
    background: var(--secondary-light);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Compliance Grid */
.compliance-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.compliance-category {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.compliance-category-header {
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.compliance-category-header .icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.compliance-items { padding: 12px; }

.compliance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--gray-50);
    cursor: pointer;
    transition: var(--transition-fast);
}

.compliance-item:last-child { margin-bottom: 0; }
.compliance-item:hover { background: var(--gray-100); }

.compliance-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.compliance-item-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.compliance-item-detail {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.compliance-item-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compliance-bar {
    width: 80px;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.compliance-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.compliance-bar-fill.good { background: var(--success); }
.compliance-bar-fill.warning { background: var(--warning); }
.compliance-bar-fill.danger { background: var(--danger); }

.compliance-percent {
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

/* Action Items */
.action-list { display: flex; flex-direction: column; gap: 8px; }

.action-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--gray-300);
    transition: var(--transition-fast);
}

.action-item:hover { background: var(--gray-100); }
.action-item.critical { border-left-color: var(--danger); background: var(--danger-subtle); }
.action-item.warning { border-left-color: var(--warning); background: var(--warning-subtle); }
.action-item.info { border-left-color: var(--info); background: var(--info-subtle); }

.action-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.action-item.critical .action-icon { background: var(--danger); color: white; }
.action-item.warning .action-icon { background: var(--warning); color: white; }
.action-item.info .action-icon { background: var(--info); color: white; }

.action-content { flex: 1; min-width: 0; }

.action-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.action-subtitle {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.action-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.action-btn:hover { background: var(--gray-100); }

/* AI Panel */
.ai-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message.assistant { flex-direction: row; }
.ai-message.user { flex-direction: row-reverse; }

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.ai-message.assistant .ai-avatar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.ai-message.user .ai-avatar {
    background: var(--gray-200);
}

.ai-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ai-message.assistant .ai-bubble {
    background: var(--gray-100);
    border-bottom-left-radius: var(--radius-sm);
}

.ai-message.user .ai-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.ai-input-area {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.ai-input-wrapper {
    display: flex;
    gap: 10px;
}

.ai-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 20px;
    font-size: 0.875rem;
    resize: none;
    max-height: 100px;
}

.ai-input:focus {
    outline: none;
    border-color: var(--primary);
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.ai-send-btn:hover { background: var(--primary-dark); }
.ai-send-btn:disabled { background: var(--gray-300); cursor: not-allowed; }

/* Module Cards */
.module-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.module-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    color: inherit;
}

.module-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
}

.module-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.module-card-icon.docs { background: var(--primary-subtle); }
.module-card-icon.risks { background: var(--warning-subtle); }
.module-card-icon.capas { background: var(--secondary-subtle); }
.module-card-icon.training { background: var(--info-subtle); }
.module-card-icon.files { background: var(--success-subtle); }

.module-card-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.module-card-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--gray-600);
}

.module-card-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.module-card-stat .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.module-card-stat .dot.success { background: var(--success); }
.module-card-stat .dot.warning { background: var(--warning); }
.module-card-stat .dot.danger { background: var(--danger); }

/* Charts */
.chart-container {
    position: relative;
    height: 200px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary { background: var(--primary-subtle); color: var(--primary); }
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-info { background: var(--info-subtle); color: var(--info); }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }

/* Progress */
.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }
.progress-bar.primary { background: var(--primary); }

/* Tables */
.table-container { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

tr:hover td { background: var(--gray-50); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* Tooltips */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--gray-900);
    color: white;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
}

.tooltip:hover::after { opacity: 1; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--gray-500);
    transition: var(--transition-fast);
}

.modal-close:hover { background: var(--gray-200); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--gray-50);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px 18px;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.toast.success .toast-icon { background: var(--success); color: white; }
.toast.warning .toast-icon { background: var(--warning); color: white; }
.toast.error .toast-icon { background: var(--danger); color: white; }
.toast.info .toast-icon { background: var(--info); color: white; }

.toast-message { flex: 1; font-size: 0.875rem; }

/* Responsive */
@media (max-width: 1200px) {
    .compliance-grid { grid-template-columns: repeat(2, 1fr); }
    .module-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .compliance-grid { grid-template-columns: 1fr; }
    .module-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    .module-cards { grid-template-columns: 1fr; }
    .product-header { flex-direction: column; text-align: center; gap: 20px; }
}

/* =============================================
   NAVIGATION SECTION HEADERS
   ============================================= */
.nav-section-header {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-400);
    padding: 16px 16px 6px 16px;
    margin-top: 4px;
}

.nav-section-header:first-child {
    margin-top: 0;
}

/* =============================================
   GLOBAL SEARCH BAR
   ============================================= */
.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
}

.global-search {
    position: relative;
    width: 100%;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 0 12px;
    transition: var(--transition-fast);
}

.search-input-wrapper:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.search-icon {
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    flex-shrink: 0;
}

#global-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 12px;
    font-size: 0.875rem;
    outline: none;
    min-width: 0;
}

#global-search-input::placeholder {
    color: var(--gray-400);
}

.search-shortcut {
    background: var(--gray-200);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--gray-500);
    font-family: inherit;
    border: none;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.active {
    display: block;
}

.search-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    padding: 10px 14px 6px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--gray-50);
}

.search-result-item .result-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    font-size: 16px;
    flex-shrink: 0;
}

.search-result-item .nav-icon-small {
    width: 16px;
    height: 16px;
}

.search-result-item .nav-icon-small svg {
    width: 100%;
    height: 100%;
}

.search-result-item.ai-action .result-icon {
    background: var(--primary-subtle);
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-desc {
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* =============================================
   QUICK HELPER BUTTON
   ============================================= */
.quick-helper-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-right: 12px;
}

.quick-helper-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.quick-helper-icon {
    font-size: 16px;
}

.quick-helper-text {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .quick-helper-text { display: none; }
    .quick-helper-btn { padding: 8px 10px; }
    .header-center { display: none; }
}

/* =============================================
   QUICK HELPER MODAL
   ============================================= */
.quick-helper-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.quick-helper-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.quick-helper-modal {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.quick-helper-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.quick-helper-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-helper-icon-large {
    font-size: 28px;
}

.quick-helper-title h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.quick-helper-subtitle {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.quick-helper-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--gray-500);
    transition: var(--transition-fast);
}

.quick-helper-close:hover {
    background: var(--gray-200);
}

.quick-helper-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 200px;
    max-height: 400px;
}

.helper-message {
    display: flex;
    gap: 12px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.helper-message .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.helper-message.assistant .message-avatar {
    background: var(--primary-subtle);
}

.helper-message.user .message-avatar {
    background: var(--gray-200);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
}

.helper-message .message-content {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 100%;
}

.helper-message.user .message-content {
    background: var(--primary);
    color: white;
}

.helper-message .message-content p {
    margin: 0 0 8px 0;
}

.helper-message .message-content p:last-child {
    margin-bottom: 0;
}

.helper-message .message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.helper-message .message-content li {
    margin: 4px 0;
}

.message-action {
    margin-top: 12px;
}

.message-action .btn {
    font-size: 0.8rem;
}

/* Typing indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.quick-helper-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.quick-helper-suggestions button {
    padding: 6px 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition-fast);
}

.quick-helper-suggestions button:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary);
}

.quick-helper-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

#quick-helper-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition-fast);
}

#quick-helper-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

#quick-helper-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition-fast);
}

#quick-helper-send:hover {
    background: var(--primary-dark);
}

#quick-helper-send svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* =============================================
   TUTORIAL / ONBOARDING SYSTEM
   ============================================= */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
}

.tutorial-overlay.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to { opacity: 0; }
}

.tutorial-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}

.tutorial-highlight {
    position: absolute;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    border-radius: var(--radius-lg);
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 1;
}

.tutorial-highlight::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--primary);
    border-radius: calc(var(--radius-lg) + 4px);
    animation: tutorialPulse 2s infinite;
}

@keyframes tutorialPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(30, 64, 175, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(30, 64, 175, 0); }
}

.tutorial-tooltip {
    position: fixed;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 340px;
    z-index: 2;
    pointer-events: auto;
    animation: tooltipAppear 0.3s ease;
}

@keyframes tooltipAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tutorial-tooltip.position-center {
    transform: translate(-50%, -50%);
    width: 400px;
}

.tutorial-tooltip::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
}

.tutorial-tooltip.position-right::before {
    left: -6px;
    top: 20px;
}

.tutorial-tooltip.position-left::before {
    right: -6px;
    top: 20px;
}

.tutorial-tooltip.position-bottom::before,
.tutorial-tooltip.position-bottom-left::before {
    top: -6px;
    left: 30px;
}

.tutorial-tooltip.position-top::before {
    bottom: -6px;
    left: 30px;
}

.tutorial-tooltip.position-center::before {
    display: none;
}

.tutorial-tooltip-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.tutorial-icon {
    font-size: 28px;
}

.tutorial-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.tutorial-skip {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 8px;
}

.tutorial-skip:hover {
    color: var(--gray-600);
}

.tutorial-content {
    padding: 16px 20px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--gray-700);
}

.tutorial-content kbd {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--gray-200);
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.tutorial-progress {
    flex: 1;
}

#tutorial-progress-text {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 4px;
    display: block;
}

.tutorial-progress-bar {
    width: 100px;
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
}

.tutorial-progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

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

/* First time welcome modal */
.first-time-welcome {
    text-align: center;
    padding: 20px 0;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.first-time-welcome p {
    margin: 0 0 12px;
    font-size: 1rem;
}

/* =============================================
   CONTEXTUAL HELP PANEL
   ============================================= */
.contextual-help-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: white;
    box-shadow: var(--shadow-xl);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.contextual-help-panel.open {
    right: 0;
}

.help-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.help-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.help-panel-icon {
    font-size: 24px;
}

.help-panel-title h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.help-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.help-panel-close:hover {
    background: var(--gray-300);
}

.help-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.help-section {
    margin-bottom: 24px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section-content {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.6;
}

.help-section-content ul,
.help-section-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.help-section-content li {
    margin: 6px 0;
}

.help-section-content strong {
    color: var(--gray-800);
}

/* ALARP Diagram */
.alarp-diagram {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 12px 0;
}

.alarp-zone {
    padding: 12px;
    text-align: center;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
}

.alarp-zone.unacceptable {
    background: var(--danger-subtle);
    color: var(--danger);
}

.alarp-zone.tolerable {
    background: var(--warning-subtle);
    color: var(--warning);
}

.alarp-zone.acceptable {
    background: var(--success-subtle);
    color: var(--success);
}

.alarp-zone small {
    display: block;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 4px;
}

/* Lifecycle Diagram */
.lifecycle-diagram {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 12px 0;
    font-size: 0.8rem;
}

.lifecycle-step {
    background: var(--primary-subtle);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
}

/* Example Box */
.example-box {
    background: var(--gray-50);
    border-left: 3px solid var(--primary);
    padding: 12px;
    margin: 12px 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.85rem;
}

.example-box p {
    margin: 4px 0;
}

/* Quiz Section */
.help-quiz {
    background: var(--info-subtle);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 20px;
}

.help-quiz h4 {
    color: var(--info);
    margin-bottom: 12px;
}

.quiz-question {
    margin-bottom: 16px;
}

.quiz-question-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-800);
    margin: 0 0 10px;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-option {
    text-align: left;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.quiz-option:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.quiz-option:disabled {
    cursor: default;
}

.quiz-option.correct {
    background: var(--success-subtle);
    border-color: var(--success);
    color: var(--success);
}

.quiz-option.incorrect {
    background: var(--danger-subtle);
    border-color: var(--danger);
    color: var(--danger);
}

.quiz-feedback {
    margin-top: 10px;
    font-size: 0.85rem;
}

.feedback-correct {
    color: var(--success);
    font-weight: 500;
}

.feedback-incorrect {
    color: var(--danger);
}

.help-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* =============================================
   MICRO-LEARNING TOOLTIPS
   ============================================= */
.field-help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--info);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    transition: var(--transition-fast);
}

.field-help-trigger:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.field-tooltip {
    position: absolute;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 280px;
    z-index: 1000;
    animation: tooltipAppear 0.2s ease;
}

.field-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font-size: 0.85rem;
    font-weight: 500;
}

.field-tooltip-header button {
    background: none;
    border: none;
    color: white;
    opacity: 0.8;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}

.field-tooltip-header button:hover {
    opacity: 1;
}

.field-tooltip-content {
    padding: 12px 14px;
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.5;
}

.field-tooltip-example {
    padding: 10px 14px;
    background: var(--gray-50);
    font-size: 0.8rem;
    color: var(--gray-600);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Help Button on Forms */
.form-help-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--info-subtle);
    color: var(--info);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.form-help-btn:hover {
    background: var(--info);
    color: white;
}

/* Help Link in Cards */
.help-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--info);
    cursor: pointer;
}

.help-link:hover {
    text-decoration: underline;
}
