/* --- GLOBAL VARIABLES --- */
:root { 
    --primary: #0f172a; 
    --accent: #3b82f6; 
    --bg: #f8fafc; 
    --white: #fff; 
    --text: #334155; 
    --danger: #ef4444; 
    --success: #10b981; 
    --warning: #f59e0b;
}

/* =========================================
   1. DASHBOARD STYLES (The Cockpit)
   ========================================= */
.c360-wrap { padding: 25px; background: #f1f5f9; min-height: 100vh; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; box-sizing: border-box; }
.c360-title-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.c360-date-pill { background: white; padding: 8px 15px; border-radius: 20px; font-weight: bold; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

/* KPI Grid */
.c360-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.c360-kpi-card { background: var(--white); padding: 25px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); display: flex; align-items: center; gap: 15px; border-left: 5px solid var(--primary); }
.c360-kpi-card .icon { font-size: 24px; background: #f1f5f9; padding: 10px; border-radius: 50%; width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; }
.c360-kpi-card h3 { margin: 0; font-size: 12px; color: #94a3b8; text-transform: uppercase; font-weight: 700; }
.c360-kpi-card .num { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.2; }
.c360-kpi-card.warning { border-color: var(--warning); }
.c360-kpi-card.danger { border-color: var(--danger); }
.c360-kpi-card.success { border-color: var(--success); }

/* Charts Layout */
.c360-charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 25px; margin-bottom: 25px; }
.c360-chart-box { background: white; padding: 25px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.c360-chart-box.large { grid-column: span 1; }
.chart-container { position: relative; height: 250px; width: 100%; }

/* Table Styles */
.c360-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.c360-table th { text-align: left; color: #94a3b8; font-size: 11px; text-transform: uppercase; padding: 10px; border-bottom: 2px solid #e2e8f0; }
.c360-table td { padding: 12px; border-bottom: 1px solid #f1f5f9; color: var(--text); font-size: 13px; }
.c360-badge { padding: 4px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; display: inline-block; }
.c360-badge.low { background: #dcfce7; color: #166534; }
.c360-badge.medium { background: #fef3c7; color: #92400e; }
.c360-badge.high { background: #ffedd5; color: #9a3412; }
.c360-badge.critical { background: #fee2e2; color: #991b1b; }
.c360-badge.pending { background: #f1f5f9; color: #475569; }

/* =========================================
   2. WORKBENCH STYLES (Admin Interface)
   ========================================= */
.c360-workbench { background: #fff; border: 1px solid #d1d5db; border-radius: 4px; overflow: hidden; }

/* Tabs */
.c360-tabs { background: #f9fafb; border-bottom: 1px solid #e5e7eb; display: flex; }
.c360-tab { flex: 1; padding: 15px; cursor: pointer; border: none; background: none; font-weight: 600; color: #6b7280; transition: 0.2s; border-right: 1px solid #e5e7eb; }
.c360-tab:hover { background: #f3f4f6; color: #111; }
.c360-tab.active { background: #fff; color: var(--accent); border-bottom: 2px solid var(--accent); }
.c360-tab-content { display: none; padding: 30px; }
.c360-tab-content.active { display: block; animation: fadeIn 0.3s; }

/* Sub-Tabs (Tools) */
.c360-sub-tabs { display: flex; margin-bottom: 20px; border-bottom: 1px solid #e2e8f0; }
.c360-sub-tab { padding: 8px 15px; border: 1px solid transparent; background: none; cursor: pointer; color: #64748b; font-size: 13px; font-weight: 600; margin-right: 5px; border-radius: 4px 4px 0 0; }
.c360-sub-tab:hover { background: #f1f5f9; color: var(--primary); }
.c360-sub-tab.active { background: #fff; border-color: #e2e8f0; border-bottom-color: #fff; color: var(--accent); position: relative; top: 1px; }

.c360-tool-content { display: none; }
.c360-tool-content.active { display: block; }

/* Risk Matrix */
.c360-section { margin-bottom: 30px; }
.c360-risk-matrix { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; background: #fff; border: 1px solid #e5e7eb; max-width: 500px; margin: 0 auto; }
.mtx-h { background: #f3f4f6; font-size: 11px; font-weight: bold; text-align: center; padding: 10px; color: #4b5563; display: flex; align-items: center; justify-content: center; }
.cell { padding: 15px; text-align: center; font-weight: bold; cursor: pointer; color: rgba(0,0,0,0.3); transition: 0.2s; font-size: 12px; }
.cell:hover { opacity: 0.8; transform: scale(1.05); color: #000; box-shadow: 0 0 10px rgba(0,0,0,0.1); z-index: 2; }
.cell.selected { border: 2px solid #000; opacity: 1; transform: scale(1.1); color: #000; z-index: 3; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.cell.low { background: #86efac; }
.cell.med { background: #fde047; }
.cell.high { background: #fdba74; }
.cell.crit { background: #fca5a5; }

/* Form Inputs */
.c360-h4 { margin: 0 0 15px 0; font-size: 13px; text-transform: uppercase; color: var(--primary); border-bottom: 2px solid #f3f4f6; padding-bottom: 8px; }
.c360-textarea { width: 100%; padding: 12px; border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit; background: #f9fafb; resize: vertical; box-sizing: border-box; }
.c360-input { width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 6px; box-sizing: border-box; }
.c360-table-input { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
.c360-table-input td { padding: 5px; vertical-align: middle; }
.c360-input.why-input { padding: 12px; border-left: 4px solid var(--accent); background: #f8fafc; }

/* AI & CAPA */
#c360-capa-table th { background: #f1f5f9; padding: 10px; text-align: left; font-size: 12px; }
#c360-capa-table td { padding: 5px; border-bottom: 1px solid #eee; }
#c360-critique-box { font-family: monospace; color: #856404; font-size: 13px; line-height: 1.5; }

/* =========================================
   3. PROFESSIONAL SAFETY ALERT (Frontend)
   ========================================= */
.c360-alert-pro { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); margin-bottom: 30px; background: #fff; }
.c360-alert-header { background: var(--danger); color: white; padding: 25px; text-align: center; }
.c360-alert-sub { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: bold; opacity: 0.9; }
.c360-alert-title { margin: 10px 0 0 0; color: white; font-size: 24px; font-weight: 800; }

.c360-alert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.c360-alert-box { padding: 25px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; }
.c360-alert-box h4 { margin-top: 0; text-transform: uppercase; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.c360-alert-box p { color: var(--text); line-height: 1.6; font-size: 15px; margin-bottom: 0; }

.c360-box-what h4 { color: var(--danger); }
.c360-box-cause { background: #f8fafc; }
.c360-box-cause h4 { color: var(--accent); }
.c360-box-controls { background: #f8fafc; }
.c360-box-controls h4 { color: var(--success); }
.c360-box-lesson h4 { color: #d97706; }

.c360-alert-footer { background: var(--primary); color: #94a3b8; padding: 10px 20px; font-size: 11px; text-align: right; }

/* =========================================
   4. FRONTEND WIZARD PORTAL
   ========================================= */
.c360-portal-container { max-width: 800px; margin: 40px auto; background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); overflow: hidden; font-family: -apple-system, sans-serif; }
.c360-portal-header { background: var(--primary); padding: 30px; text-align: center; color: white; }
.c360-portal-header h2 { margin: 0; color: white; font-size: 22px; }
.c360-portal-header p { color: #94a3b8; margin: 5px 0 0 0; }

.c360-portal-body { padding: 30px; }
.c360-wizard-steps { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 25px; background: #f8fafc; }
.c360-step { flex: 1; text-align: center; padding: 15px; font-size: 13px; font-weight: bold; color: #94a3b8; cursor: pointer; border-bottom: 2px solid transparent; transition: 0.2s; margin-bottom: -2px; }
.c360-step.active { color: var(--accent); border-bottom-color: var(--accent); background: white; }
.c360-step:hover { background: #f1f5f9; color: var(--primary); }

.c360-step-content { display: none; animation: fadeIn 0.3s; }
.c360-step-content.active { display: block; }

.c360-group { margin-bottom: 20px; }
.c360-group label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text); font-size: 14px; }
.c360-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

/* Wizard Buttons */
.c360-nav-btns { display: flex; justify-content: space-between; margin-top: 30px; padding-top: 20px; border-top: 1px solid #f1f5f9; }
.c360-btn-next { padding: 12px 25px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; background: var(--primary); color: white; }
.c360-btn-prev { padding: 12px 25px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; background: #e2e8f0; color: #475569; }
.c360-btn-submit { width: 100%; padding: 15px; background: var(--accent); color: white; border: none; border-radius: 6px; font-weight: bold; font-size: 16px; cursor: pointer; transition: 0.2s; }
.c360-btn-submit:hover { background: #2563eb; }

/* Utility */
.c360-info-box { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 15px; border-radius: 6px; margin-bottom: 20px; font-size: 13px; }
.c360-alert.success { background: #dcfce7; color: #166534; padding: 15px; text-align: center; margin-bottom: 20px; border-radius: 6px; font-weight: bold; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 800px) { 
    .c360-charts-grid { grid-template-columns: 1fr; } 
    .c360-risk-matrix { max-width: 100%; overflow-x: auto; }
    .c360-alert-grid { grid-template-columns: 1fr; }
    .c360-grid-2 { grid-template-columns: 1fr; }
}