/* ============================================
   SafetyPro HSE Platform - Design System
   ============================================ */

/* ---------- Accessibility Helpers ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 12px 24px;
  background: var(--accent, #F7941D);
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

/* CSS Variables */
:root {
  --primary: #1B2A4A;
  --primary-light: #2D4A7A;
  --primary-dark: #0F1A2E;
  --accent: #F7941D;
  --accent-hover: #E8850A;
  --accent-light: #FFF3E0;
  --success: #27AE60;
  --success-light: #E8F5E9;
  --warning: #F39C12;
  --warning-light: #FFF8E1;
  --danger: #E74C3C;
  --danger-light: #FFEBEE;
  --info: #3498DB;
  --info-light: #E3F2FD;
  --critical: #9C27B0;
  --critical-light: #F3E5F5;

  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --surface-hover: #F8F9FA;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;

  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --transition: 0.2s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; overflow-x: auto; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }
img { max-width: 100%; }

/* ============================================
   Login Screen
   ============================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #0a1628 100%);
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(247,148,29,0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.login-screen::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(52,152,219,0.1) 0%, transparent 70%);
  border-radius: 50%;
}
.login-container {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo { margin-bottom: 16px; }
.login-brand h1 { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.login-brand p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; font-weight: 500; margin-bottom: 6px; color: var(--text); font-size: 0.9rem; }
.login-form input, .login-form select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: var(--transition);
  background: var(--surface);
}
.login-form input:focus, .login-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247,148,29,0.15);
}
.login-hint { text-align: center; color: var(--text-muted); font-size: 0.8rem; margin-top: 16px; }
.password-input-wrapper { position: relative; }
.password-input-wrapper input { padding-right: 44px; }
.password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--text-muted); display: flex; align-items: center;
}
.password-toggle:hover { color: var(--text); }
.login-options {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; font-size: 0.85rem;
}
.remember-me { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; font-weight: 400; margin: 0; }
.remember-me input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); cursor: pointer; }
#login-forgot-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
#login-forgot-link:hover { text-decoration: underline; }

/* ============================================
   Layout
   ============================================ */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-info,
.sidebar.collapsed .sidebar-project { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .nav-icon { margin-right: 0; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 16px 8px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-title { font-weight: 700; font-size: 1.2rem; letter-spacing: -0.5px; }
.sidebar-toggle { color: rgba(255,255,255,0.6); padding: 4px; border-radius: 4px; transition: var(--transition); }
.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,0.1); }

.sidebar-project {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.project-select {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}
.project-select option { background: var(--primary); color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}
/* Nav group categories */
.nav-group { margin-bottom: 6px; }
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.55);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s, background 0.15s;
  border-radius: var(--radius);
  margin-bottom: 2px;
  margin-top: 4px;
  border-left: 3px solid transparent;
}
.nav-group-header:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.06); }
.nav-group:not(.collapsed) > .nav-group-header { color: var(--accent); border-left-color: var(--accent); }
.nav-group-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.6;
}
.nav-group.collapsed .nav-group-chevron { transform: rotate(-90deg); }
.nav-group-items {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}
.nav-group.collapsed .nav-group-items {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
.nav-group-platform { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); }

/* Collapsed sidebar: hide group headers, show flat icons */
.sidebar.collapsed .nav-group-header { display: none; }
.sidebar.collapsed .nav-group.collapsed .nav-group-items { max-height: 500px; opacity: 1; pointer-events: auto; }
.sidebar.collapsed .nav-group { margin-bottom: 0; }

.nav-item {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.7);
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition);
  margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { width: 20px; height: 20px; margin-right: 12px; flex-shrink: 0; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 12px 16px; }

.sidebar-user {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  gap: 10px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 0.75rem; color: rgba(255,255,255,0.5); }

/* Main Content */
.main-content {
  margin-inline-start: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  transition: margin var(--transition), width var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
}
.sidebar.collapsed ~ .main-content { margin-inline-start: var(--sidebar-collapsed); width: calc(100% - var(--sidebar-collapsed)); }

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.mobile-menu-btn { display: none; color: var(--text); }
.topbar-breadcrumb { flex: 1; font-weight: 600; font-size: 1.1rem; color: var(--text); }
.topbar-breadcrumb span + span::before { content: ' / '; color: var(--text-muted); font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
}
.topbar-search input {
  border: none;
  background: none;
  outline: none;
  width: 200px;
  color: var(--text);
}
.topbar-search svg { color: var(--text-muted); flex-shrink: 0; }
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 24px;
  width: 100%;
  overflow-x: visible;
  min-width: 0;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
  white-space: nowrap;
  border: 1.5px solid transparent;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-text { color: var(--accent); font-weight: 500; }
.btn-text:hover { text-decoration: underline; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 16px 20px; border-top: 1px solid var(--border-light); }

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-clickable:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(247,148,29,0.2); }
.kpi-clickable:active { transform: translateY(0); }
.kpi-card.active { border-color: var(--primary); box-shadow: 0 4px 12px rgba(27,42,74,0.18); background: linear-gradient(135deg, var(--surface) 80%, rgba(27,42,74,0.04)); }
.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 24px; height: 24px; }
.kpi-icon.blue { background: var(--info-light); color: var(--info); }
.kpi-icon.green { background: var(--success-light); color: var(--success); }
.kpi-icon.orange { background: var(--accent-light); color: var(--accent); }
.kpi-icon.red { background: var(--danger-light); color: var(--danger); }
.kpi-icon.purple { background: var(--critical-light); color: var(--critical); }
.kpi-content { flex: 1; }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; color: var(--text); }
.kpi-label { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.kpi-trend { font-size: 0.8rem; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

/* ============================================
   Tables
   ============================================ */
.table-container { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface-hover); }
.data-table tr:last-child td { border-bottom: none; }

.table-actions { display: flex; gap: 4px; }
.table-actions .btn-icon { width: 32px; height: 32px; }

/* ============================================
   Badges & Status
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-low { background: var(--success-light); color: var(--success); }
.badge-medium { background: var(--warning-light); color: #b87300; }
.badge-high { background: #FFF0E0; color: #D35400; }
.badge-critical { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-muted { background: #f3f4f6; color: #6b7280; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #b87300; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-primary { background: #E8EAF6; color: var(--primary); }
.badge-purple { background: var(--critical-light); color: var(--critical); }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.green { background: var(--success); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red { background: var(--danger); }
.status-dot.blue { background: var(--info); }
.status-dot.gray { background: var(--text-muted); }

/* ============================================
   Forms
   ============================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: var(--transition);
  background: var(--surface);
  color: var(--text);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247,148,29,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; }
.form-section h4 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; color: var(--primary); }

.checkbox-group, .radio-group { display: flex; flex-wrap: wrap; gap: 12px; }
.checkbox-label, .radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.checkbox-label:hover, .radio-label:hover { background: var(--bg); }
.checkbox-label input:checked ~ span, .radio-label input:checked ~ span { color: var(--accent); font-weight: 500; }
.checkbox-label:has(input:checked), .radio-label:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }

/* File Upload */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface-hover);
}
.file-upload:hover { border-color: var(--accent); background: var(--accent-light); }
.file-upload svg { margin-bottom: 8px; color: var(--text-muted); }
.file-upload p { color: var(--text-secondary); font-size: 0.85rem; }

/* ============================================
   Risk Matrix
   ============================================ */
.risk-matrix {
  display: grid;
  grid-template-columns: 40px repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr) 40px;
  gap: 2px;
  max-width: 400px;
  aspect-ratio: 1.1;
}
.risk-matrix-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  color: #fff;
  min-height: 40px;
}
.risk-matrix-cell:hover { opacity: 0.85; transform: scale(1.05); }
.risk-matrix-cell.selected { outline: 3px solid var(--primary); outline-offset: 1px; }
.risk-matrix-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.risk-low { background: #4CAF50; }
.risk-medium { background: #FFC107; color: #333; }
.risk-high { background: #FF9800; }
.risk-critical { background: #F44336; }

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal.modal-lg { max-width: 900px; }
.modal.modal-xl { max-width: 1100px; }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-secondary);
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  gap: 0;
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 10px 20px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
  font-size: 0.9rem;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================
   Page Headers
   ============================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* Filters */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-bar .form-control { width: auto; min-width: 160px; padding: 7px 12px; font-size: 0.85rem; }
.filters-bar .btn { padding: 7px 14px; font-size: 0.85rem; }

/* ============================================
   Charts
   ============================================ */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.chart-card { min-height: 320px; }
.chart-card .card-body { height: 260px; position: relative; }
.chart-card canvas { max-height: 100%; }

/* ============================================
   Wizard / Steps — Enhanced
   ============================================ */

/* Form Grid — 2-column responsive layout */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full-width { grid-column: 1 / -1; }

/* Wizard container subtle gradient */
.wizard-container .card-body { background: linear-gradient(180deg, #FFFFFF 0%, #F8F9FB 100%); }

/* Step indicator bar */
.wizard-steps {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-bottom: 36px;
  padding: 20px 8px 0;
  position: relative;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
  z-index: 1;
}
.wizard-step::after {
  content: '';
  position: absolute;
  top: 20px;
  left: calc(50% + 24px);
  right: calc(-50% + 24px);
  height: 3px;
  background: var(--border);
  z-index: 0;
  border-radius: 2px;
  transition: background 0.4s ease;
}
.wizard-step:last-child::after { display: none; }
.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  border: 2.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  transition: all 0.3s ease;
}
.step-number svg { width: 16px; height: 16px; }
.wizard-step.active .step-number {
  background: linear-gradient(135deg, var(--accent) 0%, #E8850A 100%);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(247,148,29,0.18);
  transform: scale(1.12);
}
.wizard-step.completed .step-number {
  background: linear-gradient(135deg, var(--success) 0%, #1E8449 100%);
  border-color: var(--success);
  color: #fff;
}
.wizard-step.completed::after { background: var(--success); }
.step-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: center;
  transition: color 0.3s ease;
}
.wizard-step.active .step-label { color: var(--accent); font-weight: 700; }
.wizard-step.completed .step-label { color: var(--success); }
.step-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 90px;
  line-height: 1.3;
}

/* Step content header */
.wizard-step-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}
.wizard-step-header::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.wizard-step-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wizard-step-icon svg { width: 24px; height: 24px; }
.wizard-step-icon.blue    { background: var(--info-light); color: var(--info); }
.wizard-step-icon.orange  { background: var(--accent-light); color: var(--accent); }
.wizard-step-icon.green   { background: var(--success-light); color: var(--success); }
.wizard-step-icon.red     { background: var(--danger-light); color: var(--danger); }
.wizard-step-icon.purple  { background: var(--critical-light); color: var(--critical); }
.wizard-step-icon.primary { background: #E8EAF6; color: var(--primary); }
.wizard-step-header-text h3 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.wizard-step-header-text .step-counter {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  display: block;
}
.wizard-step-header-text p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.4; margin: 0; }

/* Section groups within steps */
.wiz-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.wiz-section:last-child { margin-bottom: 0; }
.wiz-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}
.wiz-section-header svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.wiz-section-header h4 { font-size: 0.92rem; font-weight: 600; color: var(--primary); margin: 0; }

/* Enhanced navigation */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  gap: 16px;
}
.wizard-nav .btn { min-width: 160px; }
.btn-nav-prev {
  background: transparent !important;
  border: 1.5px solid var(--border) !important;
  color: var(--text-secondary) !important;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}
.btn-nav-prev:hover { background: var(--bg) !important; color: var(--text) !important; border-color: var(--text-muted) !important; }
.btn-nav-next {
  background: linear-gradient(135deg, var(--accent) 0%, #E8850A 100%) !important;
  color: #fff !important;
  border: none !important;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(247,148,29,0.3);
}
.btn-nav-next:hover { box-shadow: 0 4px 14px rgba(247,148,29,0.4); transform: translateY(-1px); }
.btn-nav-label { font-size: 0.72rem; opacity: 0.8; display: block; font-weight: 400; }
.wizard-progress-bar { width: 100%; height: 4px; background: var(--border-light); border-radius: 2px; margin-top: 16px; overflow: hidden; }
.wizard-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--success)); border-radius: 2px; transition: width 0.4s ease; }

/* Pill-style radio toggle */
.radio-pill-group {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 6px;
}
.radio-pill-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  border-right: 1px solid var(--border);
  margin: 0;
}
.radio-pill-group label:last-child { border-right: none; }
.radio-pill-group label:hover { background: var(--bg); }
.radio-pill-group input[type="radio"] { display: none; }
.radio-pill-group label.selected-yes { background: var(--success-light); color: var(--success); font-weight: 600; }
.radio-pill-group label.selected-no { background: var(--danger-light); color: var(--danger); font-weight: 600; }

/* Checkbox cards for immediate actions */
.checkbox-card-group { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.checkbox-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface);
}
.checkbox-card:hover { border-color: var(--accent); background: var(--accent-light); }
.checkbox-card.checked { border-color: var(--success); background: var(--success-light); }
.checkbox-card input[type="checkbox"] { display: none; }
.checkbox-card-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}
.checkbox-card.checked .checkbox-card-icon { background: var(--success); color: #fff; }
.checkbox-card-text { font-size: 0.85rem; font-weight: 500; color: var(--text); }

/* Person row cards (witnesses, team) */
.person-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.person-row:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.person-row .form-control { flex: 1; }
.person-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0;
}

/* Body map layout */
.body-map-layout { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.body-map-svg-container {
  flex: 1 1 480px;
  max-width: 560px;
  text-align: center;
  padding: 16px 8px;
  background: var(--bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
}
.body-map-svg-container svg { width: 100%; height: auto; }
.body-map-details { flex: 1; min-width: 280px; }
.body-part-detail-card {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--danger);
  transition: box-shadow 0.2s ease;
}
.body-part-detail-card:hover { box-shadow: var(--shadow-sm); }

/* Section action header */
.wiz-section-action-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.wiz-section-action-header h4 { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--primary); }

/* Step slide-in animation */
@keyframes wizSlideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
.wizard-step-content { animation: wizSlideIn 0.3s ease-out; }

/* ============================================
   Photo Gallery & Document Upload
   ============================================ */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.photo-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 24px;
  background: var(--bg);
}
.photo-upload-zone:hover { border-color: var(--accent); background: var(--accent-light); }
.photo-upload-zone-sm { min-height: 120px; padding: 16px; }

.photo-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.photo-card:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.photo-card-img {
  position: relative;
  height: 140px;
  overflow: hidden;
  background: var(--bg);
}
.photo-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.photo-card:hover .photo-card-remove { opacity: 1; }
.photo-card-remove:hover { background: var(--danger); }
.photo-card-body { padding: 10px 12px; }
.photo-card-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo-card-comment {
  font-size: 0.82rem !important;
  padding: 8px 10px !important;
  resize: vertical;
  min-height: 48px;
}

/* Document upload zone */
.doc-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 24px;
  background: var(--bg);
}
.doc-upload-zone:hover { border-color: var(--accent); background: var(--accent-light); }

/* Document cards */
.doc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.doc-card:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.doc-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.doc-card-info { flex: 1; min-width: 0; }
.doc-card-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Photo gallery in detail view */
.incident-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.incident-photo-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.incident-photo-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.incident-photo-card img:hover { transform: scale(1.03); }
.incident-photo-card .photo-caption {
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  border-top: 1px solid var(--border-light);
}

/* ============================================
   Notification Panel
   ============================================ */
.notification-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  width: 380px;
  max-height: calc(100vh - var(--topbar-height));
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow-y: auto;
}
.notification-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notification-panel-header h3 { font-size: 1rem; font-weight: 600; }
.notification-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition);
}
.notification-item:hover { background: var(--surface-hover); }
.notification-item.unread { background: var(--accent-light); }
.notification-item .n-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 2px; }
.notification-item .n-text { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.notification-item .n-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ============================================
   Toasts
   ============================================ */
.toast-container {
  position: fixed;
  top: 24px;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast-container .toast {
  pointer-events: auto;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  min-width: 300px;
  animation: slideDown 0.3s ease forwards;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-20px); }
  to { transform: translateY(0); }
}

/* ============================================
   Timeline
   ============================================ */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}
.timeline-item:last-child { margin-bottom: 0; border-bottom: none; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}
.timeline-item .t-time { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.timeline-item .t-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; }
.timeline-item .t-desc { font-size: 0.85rem; color: var(--text-secondary); }

/* ============================================
   Empty States
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* ============================================
   Grid Layouts
   ============================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ============================================
   Detail Grid
   ============================================ */
.detail-grid { display: flex; flex-direction: column; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; min-width: 100px; }
.detail-value { font-size: 0.85rem; color: var(--text); text-align: right; }

/* ============================================
   Incident Detail View
   ============================================ */
.inc-detail-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light, #e5e7eb); }
.inc-detail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.inc-section-title { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 12px; }
.inc-section-title svg { width: 16px; height: 16px; opacity: 0.6; }
.inc-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.inc-detail-field { padding: 8px 0 8px 12px; border-left: 3px solid var(--border-light, #e5e7eb); }
.inc-detail-label { display: block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); margin-bottom: 3px; }
.inc-detail-value { display: block; font-size: 0.92rem; font-weight: 500; color: var(--text); line-height: 1.4; }
.inc-detail-desc { border-left: 4px solid var(--accent, #F7941D); padding: 14px 18px; background: var(--bg-secondary, #f9fafb); border-radius: 0 8px 8px 0; margin-top: 16px; font-size: 0.92rem; line-height: 1.6; color: var(--text); }
.inc-card-header { display: flex; align-items: center; gap: 10px; }
.inc-card-header svg { width: 20px; height: 20px; color: var(--accent, #F7941D); flex-shrink: 0; }
.inc-card-header h3 { margin: 0; }
.inc-card-header .count-badge { background: var(--bg-secondary, #f0f0f0); color: var(--text-secondary); font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.inc-approval-card { border-left: 4px solid var(--warning, #F7941D); }
.inc-approval-card.review { border-left-color: var(--info, #3498db); }
.inc-approval-card.approved { border-left-color: var(--success, #22c55e); }
.inc-approval-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.inc-approval-actions .btn { padding: 10px 24px; font-size: 0.95rem; font-weight: 600; }
@media (max-width: 768px) {
  .inc-detail-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Projects Grid
   ============================================ */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.project-card { transition: transform var(--transition), box-shadow var(--transition); }
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ============================================
   Permission Toggles
   ============================================ */
.permission-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.permission-item:last-child { border-bottom: none; }
.permission-toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.permission-toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border); border-radius: 22px; transition: var(--transition); }
.toggle-slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: var(--transition); }
.permission-toggle input:checked + .toggle-slider { background: var(--success); }
.permission-toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.permission-toggle input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   Reminder Banner
   ============================================ */
.reminder-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  margin-bottom: 20px;
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius);
}
.reminder-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text);
}
.reminder-content svg { flex-shrink: 0; color: var(--warning); margin-top: 2px; }

/* ============================================
   Date Range Bar
   ============================================ */
.date-range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.date-range-inputs .form-control-sm {
  width: auto;
  min-width: 140px;
  padding: 6px 10px;
  font-size: 0.85rem;
}
.date-range-summary {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 600; }
.font-sm { font-size: 0.85rem; }
.font-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ============================================
   Body Map (Incident Investigation)
   ============================================ */
.body-map-container {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.body-map {
  width: 200px;
  flex-shrink: 0;
}
.body-map svg { width: 100%; }
.body-part { cursor: pointer; fill: #e0e0e0; stroke: #999; stroke-width: 0.5; transition: var(--transition); }
.body-part:hover { fill: #ffcc80; }
.body-part.selected { fill: var(--danger); stroke: #c0392b; }
.body-part-list { flex: 1; }

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
}
.pagination-info { font-size: 0.85rem; color: var(--text-secondary); }
.pagination-btns { display: flex; gap: 4px; }
.pagination-btns button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: var(--transition);
  border: 1px solid var(--border);
}
.pagination-btns button:hover { background: var(--bg); }
.pagination-btns button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============================================
   Workflow Status
   ============================================ */
.workflow-status {
  display: flex;
  align-items: center;
  gap: 4px;
}
.workflow-step-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.workflow-step-item.active { color: var(--accent); font-weight: 600; }
.workflow-step-item.done { color: var(--success); }
.workflow-step-item + .workflow-step-item::before { content: '->'; margin: 0 2px; color: var(--text-muted); }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-inline-start: 0 !important; width: 100% !important; }
  .mobile-menu-btn { display: block; }
  .page-content { padding: 16px; }
  .topbar-search { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .wizard-steps { overflow-x: auto; }
  .step-label { display: none; }
  .step-desc { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .checkbox-card-group { grid-template-columns: 1fr; }
  .wizard-step-header { flex-direction: column; gap: 12px; }
  .wizard-step-icon { width: 40px; height: 40px; }
  .wizard-nav .btn { min-width: auto; flex: 1; }
  .body-map-layout { flex-direction: column; }
  .body-map-svg-container { width: 100%; }
  .person-row { flex-wrap: wrap; }
  .photo-gallery { grid-template-columns: 1fr 1fr; }
  .incident-photo-grid { grid-template-columns: 1fr 1fr; }
  .modal { margin: 8px; max-height: 95vh; }
  .notification-panel { width: 100%; }
  .filters-bar { flex-direction: column; }
  .filters-bar .form-control { width: 100%; }
  .reminder-banner { flex-direction: column; align-items: flex-start; }
  .date-range-row { flex-direction: column; align-items: flex-start; }
  .date-range-inputs { width: 100%; }
  .date-range-inputs .form-control-sm { flex: 1; min-width: 0; }

  /* Dashboard: force inline grids to 2-col on mobile */
  .page-content > div > div[style*="repeat(4"],
  .page-content div[style*="repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* Dashboard: quick action buttons wrap in grid */
  .page-content > div[style*="space-between"] {
    flex-direction: column !important;
  }
  .page-content > div[style*="space-between"] > div[style*="display:flex;gap:8px"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    width: 100% !important;
  }

  /* AI Copilot bar full width */
  .ai-copilot-bar { width: 100% !important; max-width: 100% !important; }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* PTW Workflow Stepper — sized for 7 stages */
.ptw-workflow .wizard-steps { gap: 0; }
.ptw-workflow .wizard-step { flex: 1; min-width: 0; padding: 0 4px; }
.ptw-workflow .wizard-step .step-number { width: 36px; height: 36px; font-size: 0.8rem; }
.ptw-workflow .wizard-step .step-label { font-size: 0.72rem; max-width: 90px; }
.ptw-workflow .wizard-step .step-desc { font-size: 0.62rem; max-width: 90px; color: var(--text-muted); margin-top: 2px; }
.ptw-workflow .wizard-step::after { top: 18px; }
.ptw-workflow .wizard-step.active .step-number { animation: pulse 2s infinite; }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-sm {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
.spinner-lg {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================
   Date Range Presets
   ============================================ */
.btn-preset {
  padding: 3px 10px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-preset:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============================================
   Manpower Calendar Table
   ============================================ */
.mp-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-hover);
}
.mp-month-label {
  font-size: 1.05rem;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}
.mp-month-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.mp-stat { font-weight: 600; }
.mp-stat-logged { color: var(--success); }
.mp-stat-missing { color: #b87300; }
.mp-stat-weekend { color: var(--text-muted); }

/* Compact calendar grid cells */
.btn-mp-add-missing:hover { background: #fee2e2 !important; transform: scale(1.05); z-index: 1; }
.btn-mp-edit:hover { background: #dcfce7 !important; transform: scale(1.05); z-index: 1; }

.btn-xs {
  padding: 2px 10px;
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}

.mp-completion-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.mp-completion-badge.complete { background: #e8f5e9; color: var(--success); }
.mp-completion-badge.incomplete { background: var(--warning-light); color: #b87300; }

/* ============================================
   Template Builder — Drag & Drop
   ============================================ */
/* =====================================================
   SafetyCulture-Inspired Form Builder — Redesigned
   ===================================================== */

/* --- Section Cards --- */
.tpl-section-card {
  margin-bottom: 16px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.07);
  border-left: 4px solid #F7941D;
  transition: box-shadow 0.22s ease, transform 0.18s ease, opacity 0.18s ease;
  position: relative;
  overflow: visible;
}
.tpl-section-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
}
.tpl-section-card.tpl-dragging {
  opacity: 0.45;
  transform: scale(0.98) rotate(-0.4deg);
  filter: blur(0.8px);
  box-shadow: 0 8px 32px rgba(27,42,74,0.18);
  z-index: 10;
}

/* Drop indicator — animated blue line with circle dot */
.tpl-section-card.tpl-drop-above::before,
.tpl-section-card.tpl-drop-below::after {
  content: '';
  position: absolute;
  left: -4px;
  right: 0;
  height: 3px;
  background: #2563eb;
  border-radius: 2px;
  animation: tpl-drop-pulse 0.8s ease-in-out infinite alternate;
  z-index: 20;
}
.tpl-section-card.tpl-drop-above::before {
  top: -8px;
}
.tpl-section-card.tpl-drop-above::after {
  content: '';
  position: absolute;
  left: -10px;
  top: -14px;
  width: 12px;
  height: 12px;
  background: #2563eb;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #2563eb;
  z-index: 21;
}
.tpl-section-card.tpl-drop-below::after {
  bottom: -8px;
  left: -4px;
}
.tpl-section-card.tpl-drop-below::before {
  content: '';
  position: absolute;
  left: -10px;
  bottom: -14px;
  width: 12px;
  height: 12px;
  background: #2563eb;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #2563eb;
  z-index: 21;
}
@keyframes tpl-drop-pulse {
  from { opacity: 0.7; }
  to   { opacity: 1; box-shadow: 0 0 6px rgba(37,99,235,0.5); }
}

/* --- Section Header --- */
.tpl-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 0;
  background: #1B2A4A;
  border-radius: 6px 6px 0 0;
  min-height: 48px;
  position: relative;
  user-select: none;
}
.tpl-section-collapsed .tpl-section-header {
  border-radius: 6px;
}

/* Section name input — white text on dark header */
.tpl-section-name {
  border: none !important;
  background: transparent !important;
  font-weight: 600;
  padding: 4px 6px !important;
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
  color: #fff !important;
  outline: none;
  border-radius: 4px;
  transition: background 0.15s;
}
.tpl-section-name:focus {
  background: rgba(255,255,255,0.12) !important;
  outline: none;
}
.tpl-section-name::placeholder {
  color: rgba(255,255,255,0.45);
}

/* Section count badge */
.tpl-section-count {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
  border-radius: 20px;
  padding: 2px 9px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Section actions (collapse chevron + menu) */
.tpl-section-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.tpl-section-actions .btn-icon {
  color: rgba(255,255,255,0.7);
  background: transparent;
  border: none;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.tpl-section-actions .btn-icon:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

/* Collapse chevron rotation */
.tpl-collapse-btn svg {
  transition: transform 0.22s ease;
}
.tpl-section-collapsed .tpl-collapse-btn svg {
  transform: rotate(-90deg);
}

/* --- Section Body --- */
.tpl-section-body {
  padding: 14px 16px 8px 16px;
  min-height: 48px;
  background: #fff;
  border-radius: 0 0 6px 6px;
  transition: background 0.2s;
}
.tpl-section-body.tpl-drag-over {
  background: rgba(247, 148, 29, 0.05);
  outline: 2px dashed rgba(247,148,29,0.55);
  outline-offset: -3px;
  border-radius: 0 0 6px 6px;
}

/* Collapsed: hide body */
.tpl-section-collapsed .tpl-section-body {
  display: none;
}

/* --- Drag Handles --- */
.tpl-drag-handle {
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 12px 8px;
  min-width: 36px;
  min-height: 48px;
  opacity: 0;
  transition: opacity 0.18s ease, color 0.15s;
  color: rgba(255,255,255,0.5);
  position: relative;
}
.tpl-drag-handle::before {
  /* 6-dot grid pattern */
  content: '';
  display: block;
  width: 10px;
  height: 16px;
  background-image:
    radial-gradient(circle, currentColor 1.5px, transparent 1.5px),
    radial-gradient(circle, currentColor 1.5px, transparent 1.5px),
    radial-gradient(circle, currentColor 1.5px, transparent 1.5px),
    radial-gradient(circle, currentColor 1.5px, transparent 1.5px),
    radial-gradient(circle, currentColor 1.5px, transparent 1.5px),
    radial-gradient(circle, currentColor 1.5px, transparent 1.5px);
  background-position: 0 0, 5px 0, 0 6px, 5px 6px, 0 12px, 5px 12px;
  background-repeat: no-repeat;
  background-size: 3px 3px, 3px 3px, 3px 3px, 3px 3px, 3px 3px, 3px 3px;
}
.tpl-section-card:hover .tpl-drag-handle,
.tpl-question-row:hover .tpl-drag-handle {
  opacity: 1;
}
.tpl-drag-handle:hover {
  opacity: 1;
  color: #F7941D;
}
.tpl-drag-handle:active {
  cursor: grabbing;
}

/* Section grip — inherits from .tpl-drag-handle, larger */
.tpl-section-grip {
  min-height: 48px;
  color: rgba(255,255,255,0.45);
}
.tpl-section-card:hover .tpl-section-grip {
  opacity: 1;
}
.tpl-section-grip:hover {
  color: rgba(255,255,255,0.9);
}

/* --- Question Rows --- */
.tpl-question-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 10px 10px 10px 6px;
  background: #fff;
  border-radius: 7px;
  border: 1px solid rgba(0,0,0,0.07);
  border-left: 3px solid #e5e7eb;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s, opacity 0.18s;
  position: relative;
}
.tpl-question-row:hover {
  border-left-color: #F7941D;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  transform: translateY(-1px);
}
.tpl-question-row.tpl-dragging {
  opacity: 0.38;
  transform: scale(0.98) rotate(-0.3deg);
  filter: blur(0.6px);
  box-shadow: 0 6px 24px rgba(27,42,74,0.14);
  z-index: 10;
}

/* Question drop indicators — blue animated line */
.tpl-question-row.tpl-drop-above::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -6px;
  height: 3px;
  background: #2563eb;
  border-radius: 2px;
  animation: tpl-drop-pulse 0.8s ease-in-out infinite alternate;
  z-index: 20;
}
.tpl-question-row.tpl-drop-above::after {
  content: '';
  position: absolute;
  left: -6px;
  top: -12px;
  width: 10px;
  height: 10px;
  background: #2563eb;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #2563eb;
  z-index: 21;
}
.tpl-question-row.tpl-drop-below::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -6px;
  height: 3px;
  background: #2563eb;
  border-radius: 2px;
  animation: tpl-drop-pulse 0.8s ease-in-out infinite alternate;
  z-index: 20;
}
.tpl-question-row.tpl-drop-below::before {
  content: '';
  position: absolute;
  left: -6px;
  bottom: -12px;
  width: 10px;
  height: 10px;
  background: #2563eb;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #2563eb;
  z-index: 21;
}

/* --- Question Number Badge --- */
.tpl-q-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: #1B2A4A;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
  letter-spacing: 0;
  line-height: 1;
  transition: background 0.18s;
}
.tpl-question-row:hover .tpl-q-num {
  background: #F7941D;
}

/* --- Question Actions — floating toolbar, hidden until hover --- */
.tpl-q-actions {
  display: flex;
  flex-direction: row;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
  padding: 2px 4px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.09);
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform: translateX(4px);
  position: absolute;
  right: 8px;
  top: 50%;
  translate: 0 -50%;
  z-index: 5;
}
.tpl-question-row:hover .tpl-q-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.tpl-q-actions .btn-icon {
  padding: 3px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: #6b7280;
  transition: color 0.14s, background 0.14s;
}
.tpl-q-actions .btn-icon:hover {
  color: #1B2A4A;
  background: #f3f4f6;
}

/* --- Move-to-section select — icon button style --- */
.tpl-move-to-select {
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 0px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 5px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='16 3 21 3 21 8'/%3E%3Cline x1='4' y1='20' x2='21' y2='3'/%3E%3Cpolyline points='21 16 21 21 16 21'/%3E%3Cline x1='15' y1='15' x2='21' y2='21'/%3E%3C/svg%3E") center/14px no-repeat;
  cursor: pointer;
  color: transparent;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.tpl-move-to-select:hover {
  border-color: #1B2A4A;
  background-color: #f3f4f6;
}

/* --- Add Question Button --- */
.tpl-add-question-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 0;
  border: 2px dashed rgba(27,42,74,0.2);
  border-radius: 7px;
  background: transparent;
  color: #6b7280;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.tpl-add-question-btn:hover {
  border-color: #F7941D;
  color: #F7941D;
  background: rgba(247,148,29,0.04);
}

/* --- Drag Drop Placeholder --- */
.tpl-drop-placeholder {
  margin-bottom: 8px;
  border: 2px dashed #2563eb;
  border-radius: 7px;
  background: rgba(37,99,235,0.05);
  min-height: 52px;
  animation: tpl-placeholder-pulse 1s ease-in-out infinite alternate;
  position: relative;
}
.tpl-drop-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: repeating-linear-gradient(
    90deg,
    rgba(37,99,235,0.08) 0px,
    rgba(37,99,235,0.08) 8px,
    transparent 8px,
    transparent 16px
  );
}
@keyframes tpl-placeholder-pulse {
  from { background: rgba(37,99,235,0.04); border-color: #2563eb; }
  to   { background: rgba(37,99,235,0.10); border-color: #60a5fa; }
}

/* --- Responsive for modal-xl (1100px) --- */
@media (max-width: 1200px) {
  .tpl-section-header {
    min-height: 44px;
  }
  .tpl-q-actions {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    box-shadow: none;
    border: none;
    background: transparent;
    flex-direction: column;
    padding: 0;
    translate: none;
    top: auto;
    right: auto;
  }
  .tpl-question-row {
    padding-right: 6px;
  }
}

/* ============================================
   Inspection Wizard Steps (Enhanced)
   ============================================ */
.insp-wizard-steps {
  display: flex; align-items: center; justify-content: center; gap: 0;
  padding: 24px 16px 28px; margin-bottom: 24px; border-bottom: 1px solid var(--border-light);
}
.insp-wizard-step {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  border-radius: 12px; transition: all 0.3s; cursor: default;
}
.insp-wizard-step .insp-step-icon {
  width: 40px; height: 40px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; background: #e5e7eb;
  color: #9ca3af; transition: all 0.3s; flex-shrink: 0;
}
.insp-wizard-step .insp-step-text { display: flex; flex-direction: column; }
.insp-wizard-step .insp-step-label {
  font-size: 0.85rem; font-weight: 600; color: #9ca3af; transition: color 0.3s;
}
.insp-wizard-step .insp-step-desc {
  font-size: 0.7rem; color: #c0c4cc; margin-top: 1px; transition: color 0.3s;
}
.insp-wizard-step.active {
  background: linear-gradient(135deg, #eef4ff, #e8f0fe);
}
.insp-wizard-step.active .insp-step-icon {
  background: linear-gradient(135deg, var(--primary), #1a5db6);
  color: white; box-shadow: 0 3px 10px rgba(46,134,222,0.35);
}
.insp-wizard-step.active .insp-step-label { color: var(--primary); }
.insp-wizard-step.active .insp-step-desc { color: var(--text-muted); }
.insp-wizard-step.completed .insp-step-icon {
  background: var(--success); color: white;
}
.insp-wizard-step.completed .insp-step-label { color: var(--success); }
.insp-wizard-step.completed .insp-step-desc { color: #8bc7a0; }
.insp-wizard-connector {
  width: 40px; height: 3px; background: #e5e7eb; border-radius: 2px;
  transition: background 0.3s; flex-shrink: 0;
}
.insp-wizard-connector.completed { background: var(--success); }

/* ============================================
   Worker Search Dropdown
   ============================================ */
.worker-search-wrap { position: relative; }
.worker-dropdown { position: fixed; max-height: 220px; overflow-y: auto; background: #ffffff; border: 1px solid #d1d5db; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.1); z-index: 99999; display: none; min-width: 280px; }
.worker-dropdown.open { display: block; }
.worker-dd-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f0f0f0; font-size: 0.82rem; transition: background 0.15s; background: #ffffff; }
.worker-dd-item:hover, .worker-dd-item.active { background: #f0f7ff; }
.worker-dd-item .worker-dd-name { font-weight: 600; color: #1a1a2e; }
.worker-dd-item .worker-dd-meta { font-size: 0.72rem; color: #6b7280; margin-top: 2px; }
.worker-dd-group { padding: 6px 14px; font-size: 0.7rem; font-weight: 700; color: #6b7280; background: #f8f9fa; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #e5e7eb; }
.worker-dd-empty { padding: 14px; text-align: center; font-size: 0.8rem; color: #9ca3af; font-style: italic; background: #ffffff; }

/* Hazard Library Dropdown */
.hazard-dropdown { position: fixed; max-height: 260px; overflow-y: auto; background: #ffffff; border: 1px solid #d1d5db; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.1); z-index: 99999; display: none; min-width: 350px; }
.hazard-dropdown.open { display: block; }
.hazard-dd-item { padding: 8px 14px; cursor: pointer; border-bottom: 1px solid #f0f0f0; font-size: 0.82rem; transition: background 0.15s; background: #ffffff; }
.hazard-dd-item:hover { background: #fef3c7; }
.hazard-dd-item .hazard-dd-name { font-weight: 600; color: #1a1a2e; }
.hazard-dd-item .hazard-dd-meta { font-size: 0.72rem; color: #6b7280; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hazard-dd-group { padding: 6px 14px; font-size: 0.7rem; font-weight: 700; color: #92400e; background: #fffbeb; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #fde68a; position: sticky; top: 0; z-index: 1; }
.hazard-dd-empty { padding: 10px 14px; text-align: center; font-size: 0.8rem; color: #9ca3af; font-style: italic; background: #ffffff; }

/* ============================================
   Manpower Roster
   ============================================ */
.mp-group { border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.mp-group-hdr { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; cursor: pointer; background: var(--bg); border-radius: var(--radius); transition: background 0.15s; }
.mp-group-hdr:hover { background: var(--bg-secondary); }
.mp-group-hdr .mp-group-title { font-weight: 600; font-size: 0.9rem; }
.mp-group-hdr .mp-group-count { font-size: 0.78rem; color: var(--text-muted); background: var(--bg-secondary); padding: 2px 8px; border-radius: 10px; }
.mp-group-hdr .mp-group-chevron { transition: transform 0.2s; font-size: 0.7rem; color: var(--text-muted); }
.mp-group.open .mp-group-chevron { transform: rotate(90deg); }
.mp-group-body { display: none; border-top: 1px solid var(--border-light); }
.mp-group.open .mp-group-body { display: block; }

.roster-tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--bg); padding: 4px; border-radius: var(--radius); }
.roster-tab { padding: 8px 16px; border: none; background: transparent; cursor: pointer; border-radius: var(--radius); font-size: 0.82rem; font-weight: 500; color: var(--text-muted); transition: all 0.2s; }
.roster-tab:hover { color: var(--text-primary); }
.roster-tab.active { background: var(--bg-primary); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.08); font-weight: 600; }

.roster-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.roster-filters select, .roster-filters input { font-size: 0.82rem; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); }

/* ============================================
   KPI Targets & Comparison
   ============================================ */
.kpi-targets-section { margin-top: 16px; }
.kpi-targets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.kpi-target-card { background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 12px; }
.kpi-target-card .kpi-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.kpi-target-card .kpi-values { display: flex; justify-content: space-between; align-items: baseline; }
.kpi-target-card .kpi-actual { font-size: 1.2rem; font-weight: 700; }
.kpi-target-card .kpi-target { font-size: 0.8rem; color: var(--text-muted); }
.kpi-target-card .kpi-bar { height: 4px; background: var(--border-light); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.kpi-target-card .kpi-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }
.kpi-met { color: var(--success); }
.kpi-not-met { color: var(--danger); }
.kpi-bar-fill.met { background: var(--success); }
.kpi-bar-fill.not-met { background: var(--danger); }
.kpi-bar-fill.warning { background: var(--warning); }

.kpi-section-title { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--border-light); text-transform: uppercase; letter-spacing: 0.5px; }

/* KPI edit inputs in modal */
.kpi-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi-edit-grid .form-group { margin-bottom: 0; }
.kpi-edit-grid .form-group label { font-size: 0.78rem; }
.kpi-edit-grid .form-group input { font-size: 0.85rem; padding: 6px 8px; }

/* ============================================
   HSE Objectives
   ============================================ */
.obj-status-badge { padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 600; }
.obj-status-badge.on-track { background: #e8f5e9; color: #2e7d32; }
.obj-status-badge.at-risk { background: #fff3e0; color: #e65100; }
.obj-status-badge.behind { background: #ffebee; color: #c62828; }
.obj-status-badge.achieved { background: #e0f2f1; color: #00695c; }

/* Collapsible sections in modals */
.collapsible-section { border: 1px solid var(--border-light); border-radius: var(--radius); margin-top: 12px; }
.collapsible-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; cursor: pointer; background: var(--bg); border-radius: var(--radius); font-weight: 600; font-size: 0.88rem; }
.collapsible-header:hover { background: var(--bg-secondary); }
.collapsible-header .chevron { transition: transform 0.2s; font-size: 0.7rem; }
.collapsible-section.open .chevron { transform: rotate(90deg); }
.collapsible-body { display: none; padding: 14px; border-top: 1px solid var(--border-light); }
.collapsible-section.open .collapsible-body { display: block; }

/* CSV upload preview */
.csv-preview-table { max-height: 300px; overflow: auto; margin-top: 12px; }
.csv-preview-table table { font-size: 0.8rem; }
.csv-row-error { background: #fff5f5 !important; }
.csv-row-error td { color: var(--danger); }
.csv-validation-msg { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.csv-validation-msg.error { color: var(--danger); }

/* ============================================
   Print
   ============================================ */
@media print {
  .sidebar, .topbar, .notification-panel, .toast-container,
  .btn, button, .page-header-actions, .chat-container,
  .tab-nav, .filter-bar, .modal-backdrop { display: none !important; }
  .main-content { margin-inline-start: 0 !important; padding: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; margin-bottom: 12px; }
  .card-header { background: #f5f5f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { font-size: 11pt; color: #000 !important; background: #fff !important; }
  .page-header { border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 16px; }
  .page-header h2 { font-size: 18pt; color: #000 !important; }
  .badge, .status-badge { border: 1px solid #999 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .data-table { border-collapse: collapse; width: 100%; font-size: 9pt; }
  .data-table th, .data-table td { border: 1px solid #ccc !important; padding: 4px 8px; }
  .data-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .grid-2, .grid-3, .grid-4 { display: block !important; }
  .grid-2 > *, .grid-3 > *, .grid-4 > * { margin-bottom: 12px; }
  .detail-grid { page-break-inside: avoid; }
  .detail-row { border-bottom: 1px solid #eee; }
  a { color: #000 !important; text-decoration: none !important; }
  .permit-print-header { display: block !important; text-align: center; margin-bottom: 16px; }
  canvas { max-width: 100% !important; height: auto !important; }
  @page { margin: 15mm; size: A4; }
}

/* ============================================
   Permit Search Dropdown
   ============================================ */
.permit-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.permit-dd-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.permit-dd-item:last-child { border-bottom: none; }
.permit-dd-item:hover { background: var(--bg-secondary); }

/* ============================================
   Timeline Dot Variants
   ============================================ */
.timeline-dot.approved { background: var(--success) !important; border-color: var(--success) !important; }
.timeline-dot.submitted { background: var(--info) !important; border-color: var(--info) !important; }

/* ============================================
   Workflow Bar (Incident Detail)
   ============================================ */
.workflow-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 16px 0;
}
.workflow-bar .workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}
.workflow-bar .workflow-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.workflow-bar .workflow-step.active .workflow-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.workflow-bar .workflow-step.completed .workflow-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.workflow-bar .workflow-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}
.workflow-bar .workflow-step.active .workflow-label {
  color: var(--text);
  font-weight: 600;
}
.workflow-bar .workflow-line {
  height: 2px;
  flex: 1;
  background: var(--border);
  min-width: 20px;
}
.workflow-bar .workflow-line.completed {
  background: var(--success);
}

/* ============================================
   Internal Chat Module
   ============================================ */
.chat-container {
  display: flex;
  height: calc(100vh - var(--topbar-height) - 100px);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.chat-sidebar {
  width: 340px;
  min-width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.chat-sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.chat-search { position: relative; }
.chat-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--bg);
  box-sizing: border-box;
}
.chat-search input:focus { outline: none; border-color: var(--accent); }
.chat-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted);
}
.chat-tabs {
  display: flex; padding: 0 8px; border-bottom: 1px solid var(--border); gap: 0;
}
.chat-tab {
  padding: 10px 12px; font-size: 0.78rem; font-weight: 500; color: var(--text-secondary);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
  background: none; border-top: none; border-left: none; border-right: none;
  transition: color 0.15s, border-color 0.15s;
}
.chat-tab:hover { color: var(--text); }
.chat-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.chat-tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 0.68rem; font-weight: 600; margin-left: 5px;
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04); transition: background 0.15s;
}
.chat-list-item:hover { background: #f8f9fa; }
.chat-list-item.active {
  background: rgba(247,148,29,0.08); border-left: 3px solid var(--accent); padding-left: 13px;
}
.chat-list-item.unread { background: #fafbff; }
.chat-list-item.unread .chat-list-name { font-weight: 700; }
.chat-list-item.unread .chat-list-preview { color: var(--text); font-weight: 500; }
.chat-avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
  font-size: 0.85rem; flex-shrink: 0; position: relative;
}
.chat-avatar.online::after {
  content: ''; position: absolute; bottom: 1px; right: 1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--success); border: 2px solid var(--surface);
}
.chat-avatar.group { background: var(--info); font-size: 1.1rem; }
.chat-avatar.channel { background: var(--accent); font-size: 1.1rem; }
.chat-avatar.announcement { background: #364fc7; font-size: 1.1rem; }
.chat-avatar.linked { background: #7048e8; font-size: 1.1rem; }
.chat-avatar-sm { width: 32px; height: 32px; font-size: 0.7rem; }
.chat-list-info { flex: 1; min-width: 0; }
.chat-list-name {
  font-weight: 600; font-size: 0.88rem; display: flex; align-items: center; gap: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-list-preview {
  font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.chat-list-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-list-time { font-size: 0.7rem; color: var(--text-muted); }
.chat-unread-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.chat-main {
  flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f5f6fa;
}
.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.chat-header-status { font-size: 0.78rem; color: var(--text-secondary); }
.chat-header-actions { display: flex; gap: 4px; }
.chat-header-actions button {
  padding: 6px 8px; border-radius: 6px; background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 0.85rem; transition: background 0.15s;
}
.chat-header-actions button:hover { background: var(--bg); color: var(--text); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 2px;
}
.chat-date-divider { text-align: center; margin: 16px 0 10px; }
.chat-date-divider span {
  background: #dfe2e8; padding: 4px 14px; border-radius: 12px;
  font-size: 0.72rem; color: var(--text-secondary); font-weight: 500;
}
.chat-msg {
  display: flex; gap: 8px; max-width: 72%; margin-bottom: 2px; position: relative;
}
.chat-msg.outgoing { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.incoming { align-self: flex-start; }
.chat-bubble {
  padding: 8px 14px; border-radius: 14px; font-size: 0.9rem; line-height: 1.5;
  position: relative; word-wrap: break-word; overflow-wrap: break-word;
}
.chat-msg.outgoing .chat-bubble {
  background: var(--primary); color: #fff; border-bottom-right-radius: 4px;
}
.chat-msg.incoming .chat-bubble {
  background: var(--surface); color: var(--text); border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.chat-bubble-sender { font-size: 0.74rem; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.chat-bubble-time {
  font-size: 0.66rem; opacity: 0.7; margin-top: 4px;
  display: flex; align-items: center; gap: 4px; justify-content: flex-end;
}
.chat-msg.outgoing .chat-bubble-time { color: rgba(255,255,255,0.7); }
.chat-msg.incoming .chat-bubble-time { color: var(--text-muted); }
.chat-bubble-reply {
  background: rgba(0,0,0,0.06); border-left: 3px solid var(--accent);
  padding: 4px 8px; margin-bottom: 6px; border-radius: 4px; font-size: 0.78rem;
}
.chat-msg.outgoing .chat-bubble-reply { background: rgba(255,255,255,0.15); }
.chat-msg-system {
  align-self: center; max-width: 85%; text-align: center; padding: 5px 16px;
  background: #e8eaf0; border-radius: 12px; font-size: 0.76rem;
  color: var(--text-secondary); margin: 8px 0;
}
.chat-msg.chat-priority-important .chat-bubble { border-left: 3px solid var(--warning); }
.chat-msg.chat-priority-urgent .chat-bubble { border-left: 3px solid var(--danger); }
.chat-msg.chat-priority-emergency .chat-bubble {
  border: 2px solid var(--danger); animation: chat-pulse 1.5s infinite;
}
@keyframes chat-pulse {
  0%, 100% { border-color: var(--danger); }
  50% { border-color: rgba(231,76,60,0.3); }
}
.chat-linked-record {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: 8px; padding: 10px 14px; margin: 4px 0; cursor: pointer;
  transition: background 0.15s; min-width: 200px;
}
.chat-linked-record:hover { background: #f8f9fa; }
.chat-linked-record-type {
  font-size: 0.68rem; text-transform: uppercase; font-weight: 600;
  color: var(--info); letter-spacing: 0.5px;
}
.chat-linked-record-title { font-weight: 600; font-size: 0.86rem; margin: 4px 0; color: var(--text); }
.chat-linked-record-meta {
  display: flex; gap: 10px; font-size: 0.76rem; color: var(--text-secondary);
}
.chat-msg.outgoing .chat-linked-record { border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); }
.chat-msg.outgoing .chat-linked-record-type { color: rgba(255,255,255,0.8); }
.chat-msg.outgoing .chat-linked-record-title { color: #fff; }
.chat-msg.outgoing .chat-linked-record-meta { color: rgba(255,255,255,0.7); }
.chat-reactions { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.chat-reaction {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px;
  border-radius: 12px; background: rgba(0,0,0,0.05); font-size: 0.75rem;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
}
.chat-reaction:hover { background: rgba(0,0,0,0.08); }
.chat-reaction.mine { background: rgba(247,148,29,0.12); border-color: rgba(247,148,29,0.3); }
.chat-msg-actions {
  position: absolute; top: -8px; display: none; gap: 2px;
  background: var(--surface); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: 3px; z-index: 10;
}
.chat-msg.outgoing .chat-msg-actions { left: 0; }
.chat-msg.incoming .chat-msg-actions { right: 0; }
.chat-msg:hover .chat-msg-actions { display: flex; }
.chat-msg-actions button {
  width: 28px; height: 28px; border-radius: 6px; background: none; border: none;
  cursor: pointer; font-size: 0.85rem; display: flex; align-items: center;
  justify-content: center; color: var(--text-secondary); transition: background 0.15s;
}
.chat-msg-actions button:hover { background: var(--bg); color: var(--text); }
.chat-input-area {
  border-top: 1px solid var(--border); padding: 10px 20px 12px;
  background: var(--surface); flex-shrink: 0;
}
.chat-reply-preview {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg); border-left: 3px solid var(--accent);
  border-radius: 4px; margin-bottom: 8px; font-size: 0.82rem;
}
.chat-reply-preview .close-reply {
  cursor: pointer; color: var(--text-muted); margin-left: auto; font-size: 1.1rem;
}
.chat-reply-preview .close-reply:hover { color: var(--danger); }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-input-row textarea {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 0.88rem; resize: none; max-height: 120px; min-height: 40px;
  line-height: 1.4; font-family: inherit; box-sizing: border-box;
}
.chat-input-row textarea:focus { outline: none; border-color: var(--accent); }
.chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; border: none; transition: background 0.15s, transform 0.1s;
  font-size: 1.1rem;
}
.chat-send-btn:hover { background: #e8850a; transform: scale(1.05); }
.chat-input-toolbar { display: flex; gap: 2px; padding-top: 6px; }
.chat-input-toolbar button {
  padding: 4px 10px; border-radius: 6px; background: none; border: none;
  color: var(--text-secondary); font-size: 0.78rem; cursor: pointer; transition: background 0.15s;
}
.chat-input-toolbar button:hover { background: var(--bg); color: var(--text); }
.chat-emoji-picker {
  position: absolute; bottom: 100%; right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 12px; display: grid; grid-template-columns: repeat(10, 1fr);
  gap: 2px; width: 320px; z-index: 100; margin-bottom: 8px;
}
.chat-emoji-picker button {
  width: 32px; height: 32px; border: none; background: none; border-radius: 6px;
  cursor: pointer; font-size: 1.15rem; display: flex; align-items: center;
  justify-content: center; transition: background 0.1s;
}
.chat-emoji-picker button:hover { background: var(--bg); }
.chat-context-menu {
  position: fixed; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 6px 0; min-width: 180px; z-index: 1000;
}
.chat-context-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 16px;
  border: none; background: none; font-size: 0.85rem; cursor: pointer;
  color: var(--text); transition: background 0.1s; text-align: left;
}
.chat-context-menu button:hover { background: var(--bg); }
.chat-context-menu button.danger { color: var(--danger); }
.chat-context-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.chat-welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--text-muted); padding: 40px; text-align: center;
}
.chat-welcome-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.4; }
.chat-announcement-card {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0ff 100%);
  border: 1px solid #c3d4f7; border-left: 4px solid #364fc7; border-radius: 10px;
  padding: 14px 18px; margin: 6px 0; max-width: 85%; align-self: center;
}
.chat-announcement-card .ack-btn {
  margin-top: 10px; padding: 6px 16px; border-radius: 6px; background: #364fc7;
  color: #fff; border: none; font-size: 0.82rem; cursor: pointer; transition: background 0.15s;
}
.chat-announcement-card .ack-btn:hover { background: #2b3daa; }
.chat-announcement-card .ack-btn.done { background: var(--success); cursor: default; }
.chat-image-msg {
  max-width: 280px; border-radius: 8px; cursor: pointer; transition: opacity 0.15s;
}
.chat-image-msg:hover { opacity: 0.9; }
.chat-file-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: rgba(0,0,0,0.04); border-radius: 8px; min-width: 200px;
}
.chat-file-icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--info); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
  font-weight: 600; flex-shrink: 0;
}
.chat-msg.outgoing .chat-file-card { background: rgba(255,255,255,0.12); }
.chat-mention {
  background: rgba(247,148,29,0.15); color: var(--accent); font-weight: 600;
  padding: 1px 4px; border-radius: 3px; cursor: pointer;
}
.chat-msg.outgoing .chat-mention { background: rgba(255,255,255,0.2); color: #fff; }
.chat-pinned-indicator {
  font-size: 0.7rem; color: var(--accent); display: flex; align-items: center; gap: 3px; margin-bottom: 2px;
}
.chat-lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 10000; cursor: pointer;
}
.chat-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 4px 30px rgba(0,0,0,0.5); }
@media (max-width: 768px) {
  .chat-container { height: calc(100vh - var(--topbar-height) - 20px); }
  .chat-sidebar { width: 100%; }
  .chat-msg { max-width: 88%; }
}

/* ============================================
   My Tasks Module Styles
   ============================================ */
.my-tasks-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.my-tasks-stats { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.my-tasks-stat { flex: 1; min-width: 140px; text-align: center; padding: 16px 12px; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border-light); transition: box-shadow 0.2s; }
.my-tasks-stat:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.my-tasks-stat.overdue { border-color: #fecaca; background: #FFF5F5; }
.my-tasks-stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.my-tasks-stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.my-tasks-filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.my-tasks-tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: var(--radius); }
.my-tasks-tab { padding: 6px 14px; border: none; background: none; border-radius: var(--radius); font-size: 0.82rem; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all 0.2s; display: flex; align-items: center; }
.my-tasks-tab:hover { color: var(--text); background: var(--surface); }
.my-tasks-tab.active { background: var(--primary); color: white; font-weight: 600; }
.my-tasks-list { display: flex; flex-direction: column; gap: 8px; }
.my-tasks-card { display: flex; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border-light); overflow: hidden; transition: all 0.2s; }
.my-tasks-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); transform: translateY(-1px); border-color: var(--border); }
.my-tasks-card-priority { width: 5px; flex-shrink: 0; }
.my-tasks-card-body { flex: 1; padding: 14px 16px; }
.my-tasks-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.my-tasks-card-desc { font-size: 0.9rem; color: var(--text); margin-bottom: 8px; line-height: 1.4; }
.my-tasks-card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.my-tasks-type-badge { font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--primary); color: white; text-transform: uppercase; letter-spacing: 0.3px; }
.my-tasks-source-badge { font-size: 0.7rem; font-weight: 600; padding: 2px 7px; border-radius: 4px; }
.my-tasks-priority-badge { font-size: 0.7rem; font-weight: 600; padding: 2px 7px; border-radius: 4px; }
.my-tasks-view-btn { font-size: 0.78rem; font-weight: 600; color: var(--primary); margin-left: auto; white-space: nowrap; }
.my-tasks-view-btn:hover { text-decoration: underline; }
.my-tasks-empty { text-align: center; padding: 60px 24px; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border-light); }
.my-tasks-badge { position: absolute; top: 4px; right: 8px; min-width: 18px; height: 18px; border-radius: 10px; background: #E74C3C; color: white; font-size: 0.68rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }
@media (max-width: 768px) {
  .my-tasks-stats { gap: 8px; }
  .my-tasks-stat { min-width: 100px; padding: 12px 8px; }
  .my-tasks-stat-value { font-size: 1.4rem; }
  .my-tasks-filters { flex-direction: column; align-items: stretch; }
  .my-tasks-card-top { flex-direction: column; align-items: flex-start; }
}

/* ============================================
   Report Template Builder Styles
   ============================================ */
.tpl-builder { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; min-height: calc(100vh - 160px); }
.tpl-builder-config { overflow-y: auto; max-height: calc(100vh - 160px); padding-right: 8px; }
.tpl-builder-preview { position: sticky; top: 20px; align-self: start; }
@media (max-width: 1024px) { .tpl-builder { grid-template-columns: 1fr; } .tpl-builder-preview { position: static; } }

/* Builder toolbar */
.tpl-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.tpl-toolbar .tpl-name-input { flex: 1; min-width: 200px; font-size: 1.1rem; font-weight: 600; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text); }
.tpl-toolbar .tpl-name-input:focus { border-color: var(--accent); outline: none; }

/* Config sections */
.tpl-config-section { margin-bottom: 24px; border: 1px solid var(--border-light); border-radius: var(--radius-lg); background: var(--bg-primary); overflow: hidden; }
.tpl-config-section-hdr { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--bg); border-bottom: 1px solid var(--border-light); cursor: pointer; user-select: none; }
.tpl-config-section-hdr h4 { margin: 0; font-size: 0.92rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.tpl-config-section-hdr .tpl-chevron { transition: transform 0.2s; font-size: 0.8rem; color: var(--text-muted); }
.tpl-config-section.collapsed .tpl-config-section-body { display: none; }
.tpl-config-section.collapsed .tpl-chevron { transform: rotate(-90deg); }
.tpl-config-section-body { padding: 16px 18px; }

/* Header row editor */
.tpl-header-rows { display: flex; flex-direction: column; gap: 8px; }
.tpl-header-row { display: flex; gap: 8px; padding: 10px; background: var(--bg); border-radius: var(--radius); align-items: center; border: 1px solid var(--border-light); }
.tpl-header-cell { flex: 1; border: 1px dashed var(--border); border-radius: 4px; padding: 8px 10px; font-size: 0.8rem; cursor: pointer; text-align: center; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 4px; background: var(--bg-primary); transition: all 0.15s; }
.tpl-header-cell:hover { border-color: var(--accent); background: rgba(247,148,29,0.04); }
.tpl-header-cell .cell-icon { font-size: 1rem; opacity: 0.5; }
.tpl-header-cell .cell-label { font-size: 0.72rem; color: var(--text-muted); }
.tpl-header-row-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Color pickers */
.tpl-color-row { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.tpl-color-group { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); }
.tpl-color-group input[type="color"] { width: 32px; height: 28px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; padding: 1px; }

/* Section cards in builder */
.tpl-section-list { display: flex; flex-direction: column; gap: 6px; }
.tpl-section-card { border: 1px solid var(--border-light); border-radius: var(--radius); display: flex; align-items: center; padding: 10px 14px; gap: 10px; background: var(--bg-primary); transition: all 0.15s; }
.tpl-section-card:hover { border-color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.tpl-section-card.hidden-section { opacity: 0.5; }
.tpl-section-handle { color: var(--text-muted); font-size: 1rem; cursor: grab; flex-shrink: 0; }
.tpl-section-info { flex: 1; min-width: 0; }
.tpl-section-title { font-weight: 600; font-size: 0.86rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-section-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.tpl-section-type { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.tpl-condition-badge { font-size: 0.68rem; padding: 1px 6px; border-radius: 8px; background: #e0f2fe; color: #0369a1; }
.tpl-section-actions { display: flex; gap: 2px; flex-shrink: 0; }
.tpl-section-actions button { background: none; border: none; cursor: pointer; padding: 4px 6px; border-radius: 4px; color: var(--text-muted); font-size: 0.82rem; }
.tpl-section-actions button:hover { background: var(--bg); color: var(--text); }
.tpl-section-actions button.delete-btn:hover { color: var(--danger); }

/* Add section button */
.tpl-add-section-btn { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border: 2px dashed var(--border); border-radius: var(--radius); background: transparent; cursor: pointer; color: var(--text-muted); font-size: 0.84rem; font-weight: 500; width: 100%; margin-top: 8px; transition: all 0.15s; }
.tpl-add-section-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(247,148,29,0.03); }

/* Footer config */
.tpl-footer-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.tpl-footer-grid .form-group { margin-bottom: 0; }

/* Preview pane */
.tpl-preview-wrapper { background: var(--bg); padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--border-light); }
.tpl-preview-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.tpl-preview-page { background: #fff; border: 1px solid #ddd; box-shadow: 0 2px 12px rgba(0,0,0,0.08); padding: 20px; font-size: 0.65rem; color: #333; min-height: 500px; max-height: 700px; overflow-y: auto; font-family: Arial, sans-serif; }
.tpl-preview-header { margin-bottom: 12px; border-bottom: 2px solid #F7941D; padding-bottom: 8px; }
.tpl-preview-header-row { display: flex; align-items: center; margin-bottom: 4px; }
.tpl-preview-header-cell { flex: 1; padding: 3px 6px; }
.tpl-preview-header-cell.align-left { text-align: left; }
.tpl-preview-header-cell.align-center { text-align: center; }
.tpl-preview-header-cell.align-right { text-align: right; }
.tpl-preview-logo { max-height: 30px; max-width: 80px; }
.tpl-preview-section { margin-bottom: 10px; }
.tpl-preview-section h5 { font-size: 0.72rem; font-weight: 700; margin: 0 0 4px 0; color: #1B2A4A; border-bottom: 1px solid #F7941D; padding-bottom: 2px; }
.tpl-preview-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.tpl-preview-field-label { font-size: 0.6rem; color: #999; }
.tpl-preview-field-value { font-size: 0.62rem; font-weight: 600; }
.tpl-preview-table { width: 100%; border-collapse: collapse; font-size: 0.6rem; }
.tpl-preview-table th { background: #f0f0f0; padding: 3px 6px; border: 1px solid #ddd; font-weight: 600; text-align: left; }
.tpl-preview-table td { padding: 3px 6px; border: 1px solid #ddd; }
.tpl-preview-footer { margin-top: 12px; padding-top: 6px; border-top: 1px solid #ccc; display: flex; justify-content: space-between; font-size: 0.58rem; color: #999; }
.tpl-preview-placeholder { background: #f8f9fa; border: 1px dashed #ddd; padding: 8px; text-align: center; color: #aaa; font-size: 0.6rem; border-radius: 4px; margin-bottom: 6px; }
.tpl-preview-photo-grid { display: grid; gap: 4px; }
.tpl-preview-photo-grid.grid-2 { grid-template-columns: 1fr 1fr; }
.tpl-preview-photo-grid.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.tpl-preview-photo-item { background: #f0f0f0; height: 40px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 0.55rem; color: #aaa; }
.tpl-preview-sig { display: flex; align-items: center; gap: 8px; }
.tpl-preview-sig-box { width: 80px; height: 30px; border: 1px solid #ddd; border-radius: 3px; background: #fafafa; }

/* Template list page */
.tpl-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.tpl-list-filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tpl-list-filters select { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text); font-size: 0.85rem; }

/* Field checklist in section edit modal */
.tpl-field-checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-height: 300px; overflow-y: auto; }
.tpl-field-check { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 0.84rem; }
.tpl-field-check:hover { background: var(--bg); }
.tpl-field-check input[type="checkbox"] { accent-color: var(--accent); }

/* Condition editor */
.tpl-condition-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tpl-condition-row select, .tpl-condition-row input { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.82rem; background: var(--bg-primary); color: var(--text); }
.tpl-condition-row select { min-width: 120px; }
.tpl-condition-row input { flex: 1; }

/* Header cell edit modal */
.tpl-cell-type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.tpl-cell-type-option { padding: 12px 8px; border: 2px solid var(--border-light); border-radius: var(--radius); text-align: center; cursor: pointer; font-size: 0.8rem; transition: all 0.15s; }
.tpl-cell-type-option:hover { border-color: var(--accent); }
.tpl-cell-type-option.selected { border-color: var(--accent); background: rgba(247,148,29,0.08); }
.tpl-cell-type-option .cell-type-icon { font-size: 1.4rem; margin-bottom: 4px; }
.tpl-cell-type-option .cell-type-label { font-size: 0.72rem; color: var(--text-secondary); }

/* Version history */
.tpl-history-list { max-height: 300px; overflow-y: auto; }
.tpl-history-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 0.82rem; }
.tpl-history-version { font-weight: 700; color: var(--accent); }
.tpl-history-meta { color: var(--text-muted); font-size: 0.78rem; }

/* ── Content Builder ── */
.cb-sidebar { width: 280px; min-width: 280px; overflow-y: auto; max-height: calc(100vh - 120px); background: var(--surface); border-right: 1px solid var(--border); }
.cb-sidebar-module { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.cb-sidebar-module:hover { border-color: var(--accent); }
.cb-sidebar-module.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(247,148,29,0.15); background: #FFF7ED; }
.cb-sidebar-module-header { display: flex; align-items: center; gap: 6px; padding: 8px 10px; cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.cb-sidebar-module-header .cb-chevron { transition: transform 0.2s; font-size: 0.7rem; color: var(--text-muted); }
.cb-sidebar-module-header .cb-chevron.collapsed { transform: rotate(-90deg); }
.cb-sidebar-lessons { padding: 0 6px 6px; }
.cb-sidebar-lessons.collapsed { display: none; }
.cb-sidebar-lesson { display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 24px; border-radius: var(--radius); cursor: pointer; font-size: 0.82rem; transition: background 0.12s; }
.cb-sidebar-lesson:hover { background: var(--bg); }
.cb-sidebar-lesson.selected { background: #EFF6FF; color: var(--primary); font-weight: 600; }
.cb-sidebar-lesson .cb-lesson-badge { font-size: 0.68rem; background: var(--bg); color: var(--text-muted); padding: 1px 6px; border-radius: 10px; margin-left: auto; }

.cb-block { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; position: relative; }
.cb-block:hover { border-color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.cb-block-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg); border-radius: var(--radius) var(--radius) 0 0; cursor: grab; user-select: none; }
.cb-block-header .cb-block-type { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.cb-block-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.cb-block:hover .cb-block-actions { opacity: 1; }
.cb-block-actions button { background: none; border: none; padding: 4px 6px; border-radius: 4px; cursor: pointer; color: var(--text-muted); font-size: 0.78rem; transition: background 0.1s, color 0.1s; }
.cb-block-actions button:hover { background: var(--border); color: var(--primary); }
.cb-block-actions button.danger:hover { background: #FEE2E2; color: #DC2626; }
.cb-block-menu-btn { background: none; border: none; padding: 4px 6px; border-radius: 4px; cursor: pointer; color: var(--text-muted); font-size: 1rem; line-height: 1; }
.cb-block-menu-btn:hover { background: var(--border); color: var(--primary); }
.cb-block-body { padding: 12px 16px; }
.cb-block-body.collapsed { display: none; }

.cb-inline-rename { background: transparent; border: none; border-bottom: 2px solid transparent; font: inherit; font-weight: 600; padding: 0 2px; outline: none; width: 100%; transition: border-color 0.15s; }
.cb-inline-rename:focus { border-bottom-color: var(--accent); background: var(--bg); }

.cb-drop-indicator-top { border-top: 3px solid var(--accent) !important; }
.cb-drop-indicator-bottom { border-bottom: 3px solid var(--accent) !important; }
.cb-drag-ghost { opacity: 0.4; transform: scale(0.98); }

.cb-picker-search { width: 100%; padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; margin-bottom: 16px; outline: none; transition: border-color 0.15s; }
.cb-picker-search:focus { border-color: var(--accent); }
.cb-picker-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s; text-align: center; }
.cb-picker-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.08); transform: translateY(-1px); }
.cb-picker-card .cb-picker-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; font-size: 1.1rem; }
.cb-picker-card .cb-picker-label { font-size: 0.78rem; font-weight: 600; color: var(--primary); }
.cb-picker-card .cb-picker-preview { height: 30px; margin-top: 6px; overflow: hidden; font-size: 0.65rem; color: var(--text-muted); }

.cb-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.cb-empty-state .cb-empty-icon { width: 80px; height: 80px; background: var(--bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.cb-empty-state .cb-empty-icon svg { width: 36px; height: 36px; color: var(--text-muted); }
.cb-empty-state h3 { font-size: 1.1rem; color: var(--primary); margin: 0 0 8px; }
.cb-empty-state p { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 20px; max-width: 360px; }
.cb-empty-state .cb-quick-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.cb-empty-state .cb-quick-btn { padding: 10px 18px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); transition: border-color 0.15s, color 0.15s, background 0.15s; display: flex; align-items: center; gap: 6px; }
.cb-empty-state .cb-quick-btn:hover { border-color: var(--accent); color: var(--accent); background: #FFF7ED; }

.cb-save-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; padding: 3px 10px; border-radius: 12px; transition: opacity 0.3s, background 0.3s; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.cb-save-badge.saving { background: #FEF3C7; color: #D97706; }
.cb-save-badge.saved { background: #D1FAE5; color: #059669; }
.cb-save-badge.idle { opacity: 0.5; }

.cb-floating-toolbar { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 4px; display: flex; gap: 2px; z-index: 1000; transform: translateX(-50%); }
.cb-floating-toolbar button { background: none; border: none; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 0.82rem; color: var(--primary); transition: background 0.1s; }
.cb-floating-toolbar button:hover { background: var(--bg); }
.cb-floating-toolbar button.active { background: var(--accent); color: #fff; }

.cb-context-menu { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 4px; min-width: 180px; z-index: 1000; }
.cb-context-menu button { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 0.82rem; text-align: left; color: var(--primary); transition: background 0.1s; }
.cb-context-menu button:hover { background: var(--bg); }
.cb-context-menu button.danger { color: #DC2626; }
.cb-context-menu button.danger:hover { background: #FEE2E2; }
.cb-context-menu .cb-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.cb-kbd { font-size: 0.65rem; padding: 1px 5px; background: var(--bg); border: 1px solid var(--border); border-radius: 3px; color: var(--text-muted); margin-left: auto; font-family: monospace; }

/* ---------- AI Assistant Dropdown & Menu ---------- */
.trn-ai-menu-btn { display: flex; flex-direction: column; width: 100%; background: none; border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 0.85rem; font-weight: 600; color: var(--primary, #1B2A4A); transition: background 0.12s; line-height: 1.3; }
.trn-ai-menu-btn:hover { background: #EEF2FF; }
.trn-ai-menu-btn small { font-size: 0.72rem; font-weight: 400; color: var(--text-muted, #999); margin-top: 1px; }
.trn-diff-btn { transition: all 0.15s; }
.trn-diff-btn.active { transform: scale(1.05); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

/* ---------- Loading Skeleton ---------- */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}
.loading-skeleton { padding: 32px; }
.skeleton-header { margin-bottom: 32px; }
.skeleton-line { background: var(--border, #E2E8F0); border-radius: 6px; animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-title { width: 240px; height: 24px; margin-bottom: 12px; }
.skeleton-subtitle { width: 360px; height: 16px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.skeleton-card { height: 140px; background: var(--border, #E2E8F0); border-radius: 12px; animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-status { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 28px; color: var(--text-secondary, #64748b); font-size: 0.875rem; }
.skeleton-status-spinner { width: 16px; height: 16px; border: 2px solid var(--border, #E2E8F0); border-top-color: var(--primary, #1B2A4A); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }

/* ============================================
   Safety Brain - AI Assistant
   ============================================ */
.sb-container { display: flex; height: calc(100vh - 80px); margin: -24px; background: var(--surface, #fff); border-radius: 0; overflow: hidden; }

/* Sidebar */
.sb-sidebar { width: 260px; background: var(--primary-dark, #0F1A2E); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.sb-sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sb-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.sb-logo-icon { width: 28px; height: 28px; color: var(--accent, #F7941D); }
.sb-new-chat { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); color: #fff; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.sb-new-chat:hover { background: rgba(255,255,255,0.2); }
.sb-sidebar-body { flex: 1; overflow-y: auto; padding: 12px; }
.sb-history-empty { color: rgba(255,255,255,0.4); font-size: 13px; text-align: center; padding: 24px 12px; }

/* Main area */
.sb-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--background, #F8FAFC); }

/* Welcome screen */
.sb-welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.sb-welcome-icon { margin-bottom: 20px; }
.sb-brain-icon { width: 80px; height: 80px; }
.sb-welcome-title { font-size: 28px; font-weight: 800; color: var(--primary, #1B2A4A); margin: 0 0 8px; }
.sb-welcome-subtitle { font-size: 15px; color: var(--text-secondary, #64748B); max-width: 520px; text-align: center; margin: 0 0 32px; line-height: 1.5; }

/* Prompt cards */
.sb-prompts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; max-width: 560px; width: 100%; }
.sb-prompt-card { background: var(--surface, #fff); border: 1px solid var(--border, #E2E8F0); border-radius: 12px; padding: 14px 16px; cursor: pointer; text-align: left; display: flex; align-items: flex-start; gap: 10px; transition: all 0.2s; font-size: 13px; line-height: 1.4; }
.sb-prompt-card:hover { border-color: var(--accent, #F7941D); background: var(--accent-light, #FFF3E0); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.sb-prompt-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.sb-prompt-text { color: var(--text-primary, #1E293B); }

/* Messages */
.sb-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.sb-message { display: flex; gap: 12px; max-width: 800px; width: 100%; margin: 0 auto; }
.sb-message-user { flex-direction: row-reverse; }
.sb-message-user .sb-bubble { background: var(--primary, #1B2A4A); color: #fff; border-radius: 16px 16px 4px 16px; }
.sb-message-user .sb-bubble strong { color: #fff; }
.sb-message-assistant .sb-bubble { background: var(--surface, #fff); color: var(--text-primary, #1E293B); border-radius: 16px 16px 16px 4px; border: 1px solid var(--border, #E2E8F0); }

/* Avatars */
.sb-avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 700; font-size: 14px; }
.sb-avatar-user { background: var(--accent, #F7941D); color: #fff; }
.sb-avatar-ai { background: linear-gradient(135deg, var(--primary, #1B2A4A), var(--accent, #F7941D)); color: #fff; }

/* Bubble */
.sb-bubble { padding: 14px 18px; font-size: 14px; line-height: 1.65; flex: 1; min-width: 0; position: relative; }
.sb-bubble h1 { font-size: 18px; font-weight: 700; margin: 16px 0 8px; }
.sb-bubble h2 { font-size: 16px; font-weight: 700; margin: 14px 0 6px; }
.sb-bubble h3 { font-size: 15px; font-weight: 600; margin: 12px 0 4px; }
.sb-bubble h4 { font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
.sb-bubble h1:first-child, .sb-bubble h2:first-child, .sb-bubble h3:first-child { margin-top: 0; }
.sb-bubble p { margin: 0 0 8px; }
.sb-bubble p:last-child { margin-bottom: 0; }
.sb-bubble ul, .sb-bubble ol { margin: 8px 0; padding-left: 20px; }
.sb-bubble li { margin: 4px 0; }
.sb-bubble hr { border: none; border-top: 1px solid var(--border, #E2E8F0); margin: 12px 0; }
.sb-bubble strong { font-weight: 600; }

/* Code */
.sb-code { background: #1E293B; color: #E2E8F0; padding: 14px 16px; border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.5; margin: 8px 0; }
.sb-inline-code { background: rgba(0,0,0,0.06); padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: 'Consolas', 'Monaco', monospace; }
.sb-message-user .sb-inline-code { background: rgba(255,255,255,0.15); }

/* Message actions */
.sb-msg-actions { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity 0.2s; }
.sb-bubble:hover .sb-msg-actions { opacity: 1; }
.sb-action-btn { background: none; border: 1px solid var(--border, #E2E8F0); color: var(--text-secondary, #64748B); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.sb-action-btn:hover { background: var(--background, #F8FAFC); color: var(--text-primary, #1E293B); }

/* Thinking animation */
.sb-thinking { display: flex; align-items: center; gap: 10px; }
.sb-thinking-dots { display: flex; gap: 4px; }
.sb-thinking-dots span { width: 8px; height: 8px; background: var(--accent, #F7941D); border-radius: 50%; animation: sb-bounce 1.4s infinite ease-in-out; }
.sb-thinking-dots span:nth-child(2) { animation-delay: 0.16s; }
.sb-thinking-dots span:nth-child(3) { animation-delay: 0.32s; }
.sb-thinking-text { color: var(--text-secondary, #64748B); font-size: 13px; }
@keyframes sb-bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* Input area */
.sb-input-area { padding: 16px 24px 20px; background: var(--background, #F8FAFC); border-top: 1px solid var(--border, #E2E8F0); }
.sb-input-wrap { display: flex; align-items: flex-end; gap: 8px; max-width: 800px; margin: 0 auto; background: var(--surface, #fff); border: 2px solid var(--border, #E2E8F0); border-radius: 14px; padding: 8px 8px 8px 16px; transition: border-color 0.2s; }
.sb-input-wrap:focus-within { border-color: var(--accent, #F7941D); box-shadow: 0 0 0 3px rgba(247,148,29,0.12); }
.sb-textarea { flex: 1; border: none; outline: none; resize: none; font-size: 14px; line-height: 1.5; font-family: inherit; background: none; color: var(--text-primary, #1E293B); max-height: 150px; padding: 4px 0; }
.sb-textarea::placeholder { color: var(--text-secondary, #94A3B8); }
.sb-send-btn { background: var(--accent, #F7941D); color: #fff; border: none; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.sb-send-btn:hover:not(:disabled) { background: var(--accent-hover, #E8850A); transform: scale(1.05); }
.sb-send-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Spinner */
.sb-spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: sb-spin 0.8s linear infinite; }
@keyframes sb-spin { to { transform: rotate(360deg); } }

/* Footer */
.sb-input-footer { display: flex; align-items: center; justify-content: space-between; max-width: 800px; margin: 6px auto 0; padding: 0 4px; }
.sb-model-badge { font-size: 11px; font-weight: 600; color: var(--accent, #F7941D); background: var(--accent-light, #FFF3E0); padding: 2px 8px; border-radius: 4px; }
.sb-disclaimer { font-size: 11px; color: var(--text-secondary, #94A3B8); }

/* Image upload */
.sb-attach-btn { background: none; border: none; color: var(--text-secondary, #94A3B8); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.2s; }
.sb-attach-btn:hover { color: var(--accent, #F7941D); background: var(--accent-light, #FFF3E0); }
.sb-image-preview { display: flex; align-items: center; gap: 10px; max-width: 800px; margin: 0 auto 8px; padding: 8px 12px; background: var(--accent-light, #FFF3E0); border: 1px solid var(--accent, #F7941D); border-radius: 10px; }
.sb-image-preview img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border, #E2E8F0); }
.sb-image-info { flex: 1; font-size: 13px; color: var(--text-primary, #1E293B); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-image-remove { background: none; border: none; color: var(--text-secondary, #94A3B8); font-size: 20px; cursor: pointer; line-height: 1; padding: 0 4px; }
.sb-image-remove:hover { color: var(--danger, #EF4444); }
.sb-msg-image { margin-bottom: 8px; }
.sb-msg-image img { max-width: 300px; max-height: 200px; border-radius: 8px; border: 1px solid var(--border, #E2E8F0); cursor: pointer; transition: transform 0.2s; }
.sb-msg-image img:hover { transform: scale(1.02); }

/* Tabs */
.sb-tabs { display: flex; gap: 2px; padding: 8px 16px 0; background: var(--surface, #fff); border-bottom: 1px solid var(--border, #E2E8F0); }
.sb-tab { display: flex; align-items: center; gap: 6px; padding: 10px 18px; border: none; background: none; color: var(--text-secondary, #94A3B8); font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; font-family: inherit; }
.sb-tab:hover { color: var(--text-primary, #1E293B); }
.sb-tab-active { color: var(--accent, #F7941D); border-bottom-color: var(--accent, #F7941D); }
.sb-tab-content { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.sb-tab-chat { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.sb-tab-kb { padding: 20px 24px; overflow-y: auto; flex: 1; }

/* Knowledge Base */
.kb-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.kb-title { font-size: 20px; font-weight: 700; color: var(--text-primary, #1E293B); margin: 0 0 4px; }
.kb-subtitle { font-size: 13px; color: var(--text-secondary, #94A3B8); margin: 0; }
.kb-stats { display: flex; gap: 16px; margin-bottom: 16px; }
.kb-stat { display: flex; flex-direction: column; align-items: center; padding: 12px 20px; background: var(--surface, #fff); border: 1px solid var(--border, #E2E8F0); border-radius: 10px; min-width: 90px; }
.kb-stat-num { font-size: 22px; font-weight: 700; color: var(--accent, #F7941D); }
.kb-stat-label { font-size: 11px; color: var(--text-secondary, #94A3B8); text-transform: uppercase; letter-spacing: 0.5px; }
.kb-filters { display: flex; gap: 10px; margin-bottom: 16px; }
.kb-list { display: grid; gap: 12px; }
.kb-card { background: var(--surface, #fff); border: 1px solid var(--border, #E2E8F0); border-radius: 10px; padding: 16px; cursor: pointer; transition: all 0.15s; }
.kb-card:hover { border-color: var(--accent, #F7941D); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.kb-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.kb-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary, #1E293B); }
.kb-card-meta { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.kb-card-preview { font-size: 13px; color: var(--text-secondary, #94A3B8); line-height: 1.5; margin-bottom: 8px; }
.kb-card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.kb-card-footer { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary, #94A3B8); }
.kb-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.kb-status-active { background: #ECFDF5; color: #059669; }
.kb-status-archived { background: #F1F5F9; color: #64748B; }
.kb-badge-cat { background: #EFF6FF; color: #3B82F6; }
.kb-badge-indexed { background: #F0FDF4; color: #16A34A; }
.kb-badge-pending { background: #FEF3C7; color: #D97706; }
.kb-badge-qhse { background: #EDE9FE; color: #7C3AED; }
.kb-badge-custom { background: #FFF7ED; color: #EA580C; }
.kb-badge-file { background: #FEE2E2; color: #DC2626; font-weight: 700; }
.kb-badge-file-ready { background: #DBEAFE; color: #2563EB; }
.kb-badge-metadata { background: #F1F5F9; color: #64748B; }
.kb-index-btn { padding: 2px 10px !important; font-size: 11px !important; }
.kb-sync-progress { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.kb-sync-bar { flex: 1; height: 6px; background: var(--border, #E2E8F0); border-radius: 3px; overflow: hidden; }
.kb-sync-fill { height: 100%; width: 0; background: linear-gradient(90deg, #F7941D, #1B2A4A); border-radius: 3px; transition: width 0.3s; }
.kb-sync-text { font-size: 12px; color: var(--text-secondary, #94A3B8); white-space: nowrap; }
.kb-tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; background: var(--background, #F8FAFC); color: var(--text-secondary, #94A3B8); border: 1px solid var(--border, #E2E8F0); }
.kb-empty { text-align: center; padding: 40px 20px; color: var(--text-secondary, #94A3B8); font-size: 14px; }
.kb-content-actions { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.kb-char-count { font-size: 12px; color: var(--text-secondary, #94A3B8); }
.kb-content-textarea { font-family: 'Courier New', monospace; font-size: 13px; line-height: 1.6; min-height: 250px; }
.kb-detail-meta { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.kb-detail-info { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary, #94A3B8); margin-bottom: 12px; }
.kb-detail-content { font-size: 13px; line-height: 1.7; color: var(--text-primary, #1E293B); max-height: 400px; overflow-y: auto; padding: 12px; background: var(--background, #F8FAFC); border: 1px solid var(--border, #E2E8F0); border-radius: 8px; white-space: pre-wrap; word-break: break-word; }

/* ── Offline Queue Banner ── */
.offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 10000; display: none; transition: transform 0.3s ease, opacity 0.3s ease; }
.offline-banner-content { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 16px; font-size: 13px; font-weight: 500; }
.offline-banner .offline-icon { flex-shrink: 0; }
.offline-banner .offline-count { opacity: 0.8; font-weight: 400; }
.offline-banner-offline { background: linear-gradient(135deg, #DC2626, #B91C1C); color: #FFF; }
.offline-banner-offline .offline-count { background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.offline-banner-pending { background: linear-gradient(135deg, #F59E0B, #D97706); color: #FFF; }
.offline-banner-syncing { background: linear-gradient(135deg, #3B82F6, #2563EB); color: #FFF; }
.offline-banner-syncing .offline-icon { animation: offline-spin 1s linear infinite; }
@keyframes offline-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.offline-banner-synced { background: linear-gradient(135deg, #10B981, #059669); color: #FFF; }

/* Responsive */
@media (max-width: 768px) {
  .sb-sidebar { display: none; }
  .sb-container { margin: -16px; }
  .sb-prompts { grid-template-columns: 1fr; }
  .sb-welcome { padding: 24px 16px; }
  .sb-messages { padding: 16px; }
  .sb-input-area { padding: 12px 16px 16px; }
  .sb-brain-icon { width: 60px; height: 60px; }
  .sb-welcome-title { font-size: 22px; }
}

/* ============================================
   Safety Brain Inline — AI Writing Assistant
   ============================================ */

/* Toolbar (appears above textarea on focus) */
.sbi-toolbar { position: fixed; z-index: 100001; display: flex; align-items: center; gap: 2px; background: var(--surface, #fff); border: 1px solid var(--border, #E2E8F0); border-radius: 10px; padding: 4px 6px; box-shadow: 0 4px 20px rgba(0,0,0,0.12); backdrop-filter: blur(8px); }
.sbi-toolbar-label { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--accent, #F7941D); padding: 0 6px 0 4px; border-right: 1px solid var(--border, #E2E8F0); margin-right: 2px; white-space: nowrap; }
.sbi-toolbar-actions { display: flex; gap: 1px; flex-wrap: nowrap; }
.sbi-action { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border: none; background: none; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--text-secondary, #64748B); white-space: nowrap; transition: all 0.15s; }
.sbi-action:hover { background: var(--accent-light, #FFF3E0); color: var(--accent, #F7941D); }
.sbi-action-icon { font-size: 13px; }
.sbi-action-label { font-weight: 500; }

/* Field loading overlay */
.sbi-loading { opacity: 0.5; }
.sbi-field-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(255,255,255,0.85); border-radius: inherit; z-index: 5; font-size: 13px; color: var(--accent, #F7941D); font-weight: 600; backdrop-filter: blur(2px); }
.sbi-field-spinner { width: 16px; height: 16px; border: 2px solid var(--border, #E2E8F0); border-top-color: var(--accent, #F7941D); border-radius: 50%; animation: sb-spin 0.7s linear infinite; }

/* Undo banner */
.sbi-undo-banner { position: absolute; bottom: -32px; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 4px 10px; background: var(--primary, #1B2A4A); color: #fff; border-radius: 6px; font-size: 12px; z-index: 6; animation: sbi-slideup 0.2s ease; }
.sbi-undo-btn { background: var(--accent, #F7941D); color: #fff; border: none; padding: 2px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; cursor: pointer; }
.sbi-undo-btn:hover { background: var(--accent-hover, #E8850A); }
.sbi-undo-close { background: none; border: none; color: rgba(255,255,255,0.6); font-size: 16px; cursor: pointer; margin-left: auto; line-height: 1; }
@keyframes sbi-slideup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive — toolbar only */
@media (max-width: 768px) {
  .sbi-toolbar { max-width: calc(100vw - 16px); overflow-x: auto; }
  .sbi-action-label { display: none; }
}

/* ============================================
   Safety Brain — RAG Sources Panel
   ============================================ */
.sb-sources { margin-top: 10px; border: 1px solid var(--border, #E2E8F0); border-radius: 8px; overflow: hidden; font-size: 12px; }
.sb-sources-header { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--background, #F8FAFC); cursor: pointer; user-select: none; color: var(--text-secondary, #64748B); font-weight: 600; }
.sb-sources-header:hover { background: var(--accent-light, #FFF3E0); color: var(--accent, #F7941D); }
.sb-sources-chevron { margin-left: auto; transition: transform 0.2s; }
.sb-sources-open .sb-sources-chevron { transform: rotate(180deg); }
.sb-sources-list { display: none; padding: 6px; }
.sb-sources-open .sb-sources-list { display: block; }
.sb-source-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; flex-wrap: wrap; }
.sb-source-item:hover { background: var(--background, #F8FAFC); }
.sb-source-module { font-weight: 600; color: var(--primary, #1B2A4A); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; min-width: 80px; }
.sb-source-title { font-weight: 600; color: var(--accent, #F7941D); }
.sb-source-tag { background: var(--background, #F8FAFC); border: 1px solid var(--border, #E2E8F0); padding: 1px 6px; border-radius: 4px; font-size: 10px; color: var(--text-secondary, #64748B); }
.sb-source-sim { margin-left: auto; font-size: 10px; color: var(--text-secondary, #64748B); opacity: 0.7; }

/* Feedback buttons */
.sb-feedback-btn { opacity: 0.4; transition: all 0.2s; }
.sb-feedback-btn:hover { opacity: 1; color: var(--accent, #F7941D); }
.sb-feedback-active { opacity: 1 !important; color: var(--accent, #F7941D) !important; }

/* Inline panel sources badge */
.sbi-sources-badge { display: inline-block; margin-top: 6px; padding: 2px 8px; background: var(--accent-light, #FFF3E0); color: var(--accent, #F7941D); border-radius: 4px; font-size: 10px; font-weight: 600; }

/* ============================================
   AI Embedded Intelligence Components
   ============================================ */

/* AI Briefing Card */
.ai-briefing-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, #F7941D);
  position: relative;
  overflow: hidden;
}
.ai-briefing-card .ai-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.ai-briefing-card .ai-card-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-briefing-body { padding: 16px 20px; }

/* AI card collapse/expand */
.ai-collapsible.ai-collapsed {
  display: none !important;
}
.ai-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: white;
  cursor: pointer;
  transition: transform 0.3s ease, background 0.2s;
  flex-shrink: 0;
}
.ai-toggle-btn:hover {
  background: rgba(255,255,255,0.2);
}
.ai-toggle-btn.ai-toggled {
  transform: rotate(-90deg);
}

/* AI sparkle icon pulse */
.ai-sparkle { animation: ai-pulse 2s ease-in-out infinite; }
@keyframes ai-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Briefing sections */
.ai-section { margin-bottom: 16px; }
.ai-section:last-child { margin-bottom: 0; }
.ai-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-summary-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary, #1B2A4A);
}
.ai-insight-item {
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--info, #3182CE);
  margin-bottom: 6px;
  font-size: 0.84rem;
  line-height: 1.5;
}
.ai-insight-item.positive { border-left-color: var(--success, #38A169); }
.ai-insight-item.warning { border-left-color: var(--accent, #F7941D); }
.ai-insight-item.neutral { border-left-color: var(--info, #3182CE); }
.ai-anomaly-item {
  padding: 8px 12px;
  background: #FFF8E1;
  border-radius: var(--radius);
  border-left: 3px solid #F7941D;
  margin-bottom: 6px;
  font-size: 0.84rem;
  line-height: 1.5;
}
.ai-anomaly-item.critical { background: #FEE2E2; border-left-color: #DC2626; }
.ai-recommendation-item {
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--success, #38A169);
  margin-bottom: 6px;
  font-size: 0.84rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ai-recommendation-item .ai-rec-priority {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.ai-rec-priority.high { background: #FEE2E2; color: #991B1B; }
.ai-rec-priority.medium { background: #FFF3E0; color: #9A3412; }
.ai-rec-priority.low { background: #DCFCE7; color: #166534; }

/* Risk Level Badge */
.ai-risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ai-risk-badge.low { background: #DCFCE7; color: #166534; }
.ai-risk-badge.medium { background: #FFF3E0; color: #9A3412; }
.ai-risk-badge.high { background: #FEE2E2; color: #991B1B; }
.ai-risk-badge.critical { background: #991B1B; color: #fff; }

/* KPI Highlights in briefing */
.ai-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.ai-kpi-item {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
}
.ai-kpi-item .ai-kpi-value {
  font-size: 1.1rem;
  font-weight: 800;
}
.ai-kpi-item .ai-kpi-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.ai-kpi-item.good .ai-kpi-value { color: var(--success, #38A169); }
.ai-kpi-item.warning .ai-kpi-value { color: var(--accent, #F7941D); }
.ai-kpi-item.critical .ai-kpi-value { color: var(--danger, #DC2626); }

/* AI Skeleton Loading */
.ai-skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: ai-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
  height: 14px;
  margin-bottom: 10px;
}
@keyframes ai-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* AI Classify Card (Incident Wizard) */
.ai-classify-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, #F7941D);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.ai-classify-card .ai-classify-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ai-classify-card .ai-classify-header h4 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-classify-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
  font-size: 0.84rem;
}
.ai-classify-row:last-child { border-bottom: none; }
.ai-classify-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 130px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.ai-classify-value { color: var(--text); }
.ai-classify-actions-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ai-classify-actions-list li {
  padding: 4px 0;
  font-size: 0.84rem;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.ai-classify-actions-list li::before {
  content: '→';
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}
.ai-confidence-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.ai-confidence-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* AI Button styles */
.btn-ai {
  background: linear-gradient(135deg, #1B2A4A 0%, #2D4A7A 100%);
  color: #fff;
  border: none;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ai:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ai .ai-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Generate Briefing button */
.btn-ai-generate {
  background: linear-gradient(135deg, #1B2A4A 0%, #2D4A7A 100%);
  color: #fff;
  border: none;
  font-size: 0.75rem;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-ai-generate:hover { opacity: 0.9; }
.btn-ai-generate:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   Environmental Management & ESG Module
   ============================================ */
.env-module { padding: 0; }

.env-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.env-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  padding: 4px;
  overflow-x: auto;
  margin-bottom: 24px;
}

.env-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #64748b);
  font-size: 13px;
  font-weight: 500;
  border-radius: calc(var(--radius, 8px) - 2px);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.env-tab:hover { background: var(--bg-hover, #f1f5f9); color: var(--text, #1e293b); }
.env-tab.active {
  background: var(--primary, #1B2A4A);
  color: #fff;
}

.env-content { min-height: 400px; }

/* KPI Grid */
.env-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.env-kpi {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  padding: 20px;
  text-align: center;
  border-top: 3px solid var(--border, #e2e8f0);
}
.env-kpi-green  { border-top-color: #22c55e; }
.env-kpi-blue   { border-top-color: #3b82f6; }
.env-kpi-amber  { border-top-color: #f59e0b; }
.env-kpi-red    { border-top-color: #ef4444; }
.env-kpi-navy   { border-top-color: #1B2A4A; }
.env-kpi-orange { border-top-color: #F7941D; }
.env-kpi-purple { border-top-color: #8b5cf6; }
.env-kpi-teal   { border-top-color: #14b8a6; }

.env-kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text, #1e293b);
  line-height: 1.2;
}
.env-kpi-title {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
}
.env-kpi-sub {
  font-size: 11px;
  color: var(--text-secondary, #94a3b8);
  margin-top: 2px;
}

/* Cards */
.env-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.env-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  padding: 20px;
}
.env-card-half { /* used on env-row children, no extra needed */ }

.env-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.env-card-header h3,
.env-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #1e293b);
  margin: 0;
}

/* Scope bar (GHG) */
.env-scope-bar {
  display: flex;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}
.env-scope-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 30px;
  transition: width 0.5s ease;
}
.env-scope-s1 { background: #ef4444; }
.env-scope-s2 { background: #f59e0b; }
.env-scope-s3 { background: #3b82f6; }

.env-scope-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.env-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}
.env-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Tables */
.env-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.env-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-hover, #f8fafc);
  border-bottom: 2px solid var(--border, #e2e8f0);
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.env-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  color: var(--text, #1e293b);
}
.env-table tr:hover td { background: var(--bg-hover, #f8fafc); }

/* Badges */
.env-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.env-badge-green { background: #dcfce7; color: #15803d; }
.env-badge-amber { background: #fef3c7; color: #92400e; }
.env-badge-red   { background: #fee2e2; color: #b91c1c; }
.env-badge-blue  { background: #dbeafe; color: #1d4ed8; }
.env-badge-navy  { background: #1B2A4A; color: #fff; }

/* Description text */
.env-desc {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Forms */
.env-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}
.env-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.env-form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
}
.env-form-group input,
.env-form-group select,
.env-form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  font-size: 13px;
  background: var(--surface, #fff);
  color: var(--text, #1e293b);
}
.env-form-group textarea { min-height: 80px; resize: vertical; }

/* Calculator result */
.env-calc-result {
  background: var(--bg-hover, #f0f9ff);
  border: 1px solid #bae6fd;
  border-radius: var(--radius, 8px);
  padding: 16px;
  text-align: center;
  margin-top: 16px;
}
.env-calc-val {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary, #1B2A4A);
}
.env-calc-detail {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
}

/* Progress bars */
.env-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--border, #e2e8f0);
  border-radius: 4px;
  overflow: hidden;
}
.env-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: #22c55e;
  transition: width 0.5s ease;
}

/* Empty state */
.env-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary, #94a3b8);
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  .env-tabs { flex-wrap: nowrap; }
  .env-tab { padding: 6px 10px; font-size: 12px; }
  .env-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .env-row { grid-template-columns: 1fr; }
  .env-form-row { grid-template-columns: 1fr; }
  .env-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .env-kpi-grid { grid-template-columns: 1fr; }
  .env-kpi-value { font-size: 22px; }
}

/* ========== AI Agents Dashboard ========== */
.ai-agents-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border, #e2e8f0);
  margin-bottom: 20px;
  overflow-x: auto;
}
.ai-agent-tab {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}
.ai-agent-tab:hover { color: var(--text-primary, #1e293b); }
.ai-agent-tab.active {
  color: var(--primary, #1B2A4A);
  border-bottom-color: var(--accent, #F7941D);
  font-weight: 600;
}
.ai-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.ai-kpi-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  padding: 16px;
  text-align: center;
  border-top: 3px solid var(--border, #e2e8f0);
}
.ai-kpi-card.ai-kpi-blue   { border-top-color: #3b82f6; }
.ai-kpi-card.ai-kpi-green  { border-top-color: #22c55e; }
.ai-kpi-card.ai-kpi-orange { border-top-color: #f59e0b; }
.ai-kpi-card.ai-kpi-red    { border-top-color: #ef4444; }
.ai-kpi-card.ai-kpi-purple { border-top-color: #8b5cf6; }
.ai-kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
  line-height: 1.2;
}
.ai-kpi-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.ai-kpi-sub {
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}
.ai-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  padding: 20px;
  margin-bottom: 16px;
}
.ai-card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
}
.ai-agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.ai-agent-card {
  text-align: center;
  padding: 24px 16px;
}
.ai-agent-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.ai-agent-card h4 {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
}
.ai-agent-stats {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-bottom: 12px;
}
.ai-agent-auto-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
  font-style: italic;
}
.ai-agent-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  margin-top: 8px;
}
.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.ai-status-dot.active    { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.ai-status-dot.scheduled { background: #3b82f6; box-shadow: 0 0 6px rgba(59,130,246,0.4); }
.ai-status-dot.idle      { background: #94a3b8; }
.btn-ai {
  background: linear-gradient(135deg, #1B2A4A, #2d4a7a);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius, 8px);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-ai:hover { opacity: 0.9; }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.ai-trend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary, #1e293b);
  padding: 8px 12px;
  background: var(--bg, #f8fafc);
  border-radius: var(--radius, 8px);
}
.ai-trend-arrow { font-weight: 700; font-size: 15px; }
.ai-trend-arrow.trend-up   { color: #ef4444; }
.ai-trend-arrow.trend-down { color: #22c55e; }
.ai-trend-arrow.trend-flat { color: #64748b; }
.ai-trend-arrow.trend-good { color: #22c55e; }
.ai-trend-arrow.trend-bad  { color: #ef4444; }

/* Badge variants used in AI agents tables */
.badge-critical { background: #fef2f2; color: #dc2626; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-high     { background: #fff7ed; color: #ea580c; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-medium   { background: #fefce8; color: #ca8a04; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-low      { background: #f0fdf4; color: #16a34a; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-info     { background: #eff6ff; color: #2563eb; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }

/* AI Agents responsive */
@media (max-width: 768px) {
  .ai-agents-tabs { flex-wrap: nowrap; }
  .ai-agent-tab { padding: 8px 12px; font-size: 12px; }
  .ai-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ai-agents-grid { grid-template-columns: 1fr; }
  .ai-trend-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .ai-kpi-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════
   Process Safety Module
   ═══════════════════════════════════════════════════════════════════ */

/* Tabs */
.ps-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.ps-tab { padding: 8px 16px; border: none; background: transparent; color: var(--text-secondary); font-size: 13px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; border-radius: 6px 6px 0 0; }
.ps-tab:hover { background: var(--surface); color: var(--text-primary); }
.ps-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--surface); font-weight: 600; }

/* KPI grid */
.ps-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.ps-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; border-top: 3px solid var(--primary); }
.ps-kpi .ps-kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.ps-kpi .ps-kpi-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.ps-kpi.ps-kpi-danger { border-top-color: #DC2626; }
.ps-kpi.ps-kpi-warning { border-top-color: #F59E0B; }
.ps-kpi.ps-kpi-success { border-top-color: #16A34A; }

/* Cards */
.ps-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.ps-card h3 { margin: 0 0 12px 0; font-size: 15px; font-weight: 600; color: var(--text-primary); }

/* Grid layouts */
.ps-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ps-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Empty state */
.ps-empty { color: var(--text-secondary); font-size: 13px; font-style: italic; padding: 16px 0; text-align: center; }

/* Bar charts */
.ps-bar-chart { display: flex; flex-direction: column; gap: 8px; }
.ps-bar-row { display: flex; align-items: center; gap: 8px; }
.ps-bar-label { font-size: 12px; color: var(--text-secondary); min-width: 100px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-bar-track { flex: 1; height: 20px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.ps-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; min-width: 2px; }
.ps-bar-count { font-size: 12px; font-weight: 600; color: var(--text-primary); min-width: 28px; text-align: right; }

/* Study header */
.ps-study-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.ps-study-header h2 { margin: 0; font-size: 18px; }

/* ─── BowTie Diagram ─── */
.ps-bt-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.ps-bt-ctrl-group { display: flex; align-items: center; gap: 6px; }
.ps-bt-ctrl-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.ps-bt-ctrl-group .form-control { max-width: 280px; }

.ps-bt-canvas-wrap { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; padding: 8px; }
.ps-bt-svg { width: 100%; min-height: 400px; cursor: default; }
.ps-bt-svg text { font-family: inherit; pointer-events: none; }
.ps-bt-node { cursor: pointer; }
.ps-bt-node:hover rect { filter: brightness(1.1); }
.ps-bt-barrier { cursor: pointer; }
.ps-bt-barrier:hover rect { filter: brightness(1.15); stroke-width: 2.5; }

/* BowTie threat/consequence panels */
.ps-bt-item { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.ps-bt-item-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ps-bt-item-header strong { font-size: 14px; }
.ps-bt-item-desc { font-size: 12px; color: var(--text-secondary); margin: 6px 0 0; }
.ps-bt-barriers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ps-bt-barrier-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 12px; cursor: pointer; min-width: 140px; transition: box-shadow 0.15s; }
.ps-bt-barrier-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.ps-bt-barrier-name { font-weight: 600; margin-bottom: 4px; }
.ps-bt-barrier-meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--text-secondary); font-size: 11px; }
.ps-bt-barrier-owner { color: var(--primary); }
.ps-bt-critical { background: #FEE2E2; color: #DC2626; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 10px; display: inline-block; margin-bottom: 4px; }

/* Escalation Factors */
.ps-bt-ef-list { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.ps-bt-ef-item { font-size: 11px; color: var(--text-secondary); padding: 2px 0; }
.ps-bt-ef-diamond { color: #F59E0B; font-size: 10px; }
.ps-bt-ef-controls { color: var(--primary); font-size: 10px; }
.ps-bt-ef { cursor: pointer; }
.ps-bt-ef:hover polygon { filter: brightness(1.2); }

/* ─── BowTie Accordion (Advanced Form) ─── */
.bt-accord { border-bottom: 1px solid var(--border); }
.bt-accord:last-child { border-bottom: none; }
.bt-accord-hdr { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; cursor: pointer; transition: background 0.15s; gap: 8px; }
.bt-accord-hdr:hover { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.bt-accord-open { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.bt-accord-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.bt-accord-chevron { font-size: 10px; color: var(--text-secondary); transition: transform 0.2s; width: 14px; flex-shrink: 0; }
.bt-accord-num { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bt-accord-name { font-weight: 600; font-size: 14px; color: var(--text-primary); line-height: 1.3; }
.bt-accord-meta { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.bt-accord-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.bt-accord-body { padding: 0 16px 14px 16px; }
.bt-accord-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; padding: 8px 12px; background: var(--bg); border-radius: 6px; line-height: 1.5; }

/* Barrier table inside accordion */
.bt-barrier-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bt-barrier-table thead th { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; padding: 7px 8px; border: 1px solid var(--border); color: var(--text-secondary); }
.bt-barrier-table tbody td { padding: 8px 8px; border: 1px solid var(--border); vertical-align: top; }
.bt-barrier-row { transition: background 0.15s; }
.bt-barrier-row:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.bt-barrier-name-cell { font-weight: 600; color: var(--text-primary); }
.bt-type-tag { display: inline-block; background: color-mix(in srgb, var(--primary) 10%, var(--surface)); color: var(--text-primary); padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; text-transform: capitalize; }
.bt-ef-row { font-size: 11px; color: var(--text-secondary); padding: 1px 0; }
.bt-ef-diamond { color: #F59E0B; font-size: 10px; }
.bt-ef-ctrl-count { color: var(--primary); font-size: 10px; font-weight: 600; }
.bt-no-ef { color: var(--text-secondary); font-size: 11px; opacity: 0.6; }

/* ─── HAZOP ─── */
.ps-hazop-node { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.ps-hazop-node-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ps-hazop-node-header h4 { margin: 0; font-size: 14px; }
.ps-hazop-deviation { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-top: 8px; font-size: 13px; }
.ps-hazop-deviation-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ps-hazop-guideword { font-weight: 600; color: var(--primary); }

/* ─── Risk Assessment — Standard Form ─── */

/* Analysis grid — matrix left, stats right */
.ra-analysis-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; }
.ra-matrix-panel { padding: 16px; border-right: 1px solid var(--border); }
.ra-stats-panel { padding: 16px; }
.ra-panel-title { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }

/* Summary stat cards */
.ra-summary-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.ra-stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; text-align: center; }
.ra-stat-num { font-size: 22px; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.ra-stat-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }
.ra-stat-critical { border-left: 3px solid #DC2626; }
.ra-stat-critical .ra-stat-num { color: #DC2626; }
.ra-stat-high { border-left: 3px solid #EA580C; }
.ra-stat-high .ra-stat-num { color: #EA580C; }
.ra-stat-open { border-left: 3px solid #F59E0B; }
.ra-stat-open .ra-stat-num { color: #F59E0B; }

/* New Risk Matrix (inside form) */
.ra-matrix { border-collapse: collapse; width: 100%; max-width: 460px; margin: 0 auto; }
.ra-matrix-corner { width: 90px; background: transparent !important; border: none !important; position: relative; }
.ra-axis-label-y { position: absolute; left: 4px; top: 50%; transform: rotate(-90deg) translateX(-50%); transform-origin: left center; font-size: 10px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.ra-axis-label-x { text-align: center; font-size: 10px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.ra-matrix-hdr { background: color-mix(in srgb, var(--primary) 10%, var(--surface)) !important; color: var(--text-primary) !important; font-size: 10px !important; font-weight: 600 !important; padding: 6px 4px !important; text-align: center !important; border: 1px solid var(--border) !important; }
.ra-matrix-row-hdr { background: color-mix(in srgb, var(--primary) 10%, var(--surface)) !important; color: var(--text-primary) !important; font-size: 11px !important; font-weight: 600 !important; text-align: right !important; padding: 6px 8px !important; white-space: nowrap; border: 1px solid var(--border) !important; }
.ra-matrix-cell { color: #fff; text-align: center; font-weight: 700; cursor: pointer; border: 2px solid rgba(255,255,255,0.25) !important; padding: 4px !important; height: 44px; vertical-align: middle; transition: transform 0.15s, box-shadow 0.15s; position: relative; }
.ra-matrix-cell:hover { transform: scale(1.06); box-shadow: 0 2px 8px rgba(0,0,0,0.3); z-index: 2; }
.ra-cell-score { font-size: 14px; display: block; line-height: 1.2; }
.ra-cell-count { display: inline-block; background: rgba(0,0,0,0.35); font-size: 10px; padding: 1px 6px; border-radius: 10px; margin-top: 1px; }
.ra-matrix-footer { background: transparent !important; border: none !important; font-size: 10px; color: var(--text-secondary); text-align: center; font-weight: 600; padding: 4px 0 !important; }

/* Distribution bars */
.ra-dist-chart { display: flex; flex-direction: column; gap: 6px; }
.ra-dist-row { display: flex; align-items: center; gap: 8px; }
.ra-dist-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); min-width: 65px; text-align: right; }
.ra-dist-track { flex: 1; height: 18px; background: var(--bg); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.ra-dist-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; min-width: 3px; }
.ra-dist-count { font-size: 12px; font-weight: 700; min-width: 24px; text-align: right; }

/* Risk Register table */
.ra-register-table { width: 100%; border-collapse: collapse; }
.ra-register-table thead th { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--text-primary); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; padding: 10px 8px; text-align: left; border: 1px solid var(--border); white-space: nowrap; }
.ra-register-table tbody td { padding: 10px 8px; border: 1px solid var(--border); vertical-align: top; font-size: 12px; }
.ra-register-row:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.ra-col-num { text-align: center !important; width: 42px; }
.ra-col-activity { width: 13%; }
.ra-col-hazard { width: 15%; }
.ra-col-affected { width: 10%; }
.ra-col-init, .ra-col-resid { width: 9%; text-align: center !important; }
.ra-col-controls { width: 20%; }
.ra-col-resp { width: 8%; }
.ra-col-status { width: 7%; text-align: center !important; }
.ra-col-actions { width: 56px; text-align: center !important; }
.ra-affected-text { font-size: 11px; color: var(--text-secondary); }

/* Risk badge (used in table cells) */
.ra-risk-badge { display: inline-flex; flex-direction: column; align-items: center; padding: 4px 10px; border-radius: 8px; color: #fff; line-height: 1.2; min-width: 60px; }
.ra-risk-score { font-size: 16px; font-weight: 800; }
.ra-risk-level { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; opacity: 0.9; }
.ra-reduction { text-align: center; font-size: 10px; font-weight: 700; color: #16A34A; margin-top: 3px; }

/* Legacy matrix (keep for other views) */
.ps-risk-matrix { border-collapse: collapse; width: 100%; max-width: 500px; margin: 16px auto; }
.ps-risk-matrix th, .ps-risk-matrix td { width: 48px; height: 40px; text-align: center; font-size: 12px; font-weight: 600; border: 1px solid rgba(255,255,255,0.3); }
.ps-risk-matrix th { background: var(--surface); color: var(--text-secondary); font-weight: 500; }
.ps-risk-cell { cursor: pointer; color: #fff; transition: transform 0.1s; border-radius: 2px; }
.ps-risk-cell:hover { transform: scale(1.08); box-shadow: 0 0 0 2px rgba(0,0,0,0.2); }
.ps-risk-cell.selected { box-shadow: 0 0 0 3px #1B2A4A, 0 0 0 5px #F7941D; }

.ps-risk-legend { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 12px; }
.ps-risk-legend span { display: flex; align-items: center; gap: 4px; }
.ps-risk-legend .ps-legend-dot { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

/* Risk Assessment cards */
.ps-ra-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.ps-ra-card-header { display: flex; justify-content: space-between; align-items: center; }
.ps-ra-card h4 { margin: 0 0 4px; font-size: 14px; }
.ps-ra-risk-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; color: #fff; }

/* Responsive RA */
@media (max-width: 900px) {
  .ra-analysis-grid { grid-template-columns: 1fr; }
  .ra-matrix-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .ra-summary-cards { grid-template-columns: repeat(2, 1fr); }
  .ra-register-table { display: block; overflow-x: auto; }
}

/* ─── JSA / JHA Standard Form ─── */
.jsa-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.jsa-toolbar-left, .jsa-toolbar-right { display: flex; align-items: center; gap: 8px; }
.jsa-status-badge { font-size: 12px; }

.jsa-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* Document header */
.jsa-doc-header { display: flex; justify-content: space-between; align-items: stretch; border-bottom: 3px solid var(--primary); background: linear-gradient(135deg, var(--primary) 0%, #2a3f6a 100%); color: #fff; }
.jsa-doc-title-block { flex: 1; padding: 20px 24px; }
.jsa-doc-title { font-size: 20px; font-weight: 800; letter-spacing: 1px; margin: 0 0 4px 0; color: #fff; }
.jsa-doc-subtitle { font-size: 14px; opacity: 0.85; margin: 0; }
.jsa-doc-meta-block { padding: 12px 20px; display: flex; align-items: center; background: rgba(0,0,0,0.15); border-left: 1px solid rgba(255,255,255,0.15); }
.jsa-meta-table { border-collapse: collapse; }
.jsa-meta-table td { padding: 2px 10px; font-size: 12px; white-space: nowrap; border: none; }
.jsa-meta-label { color: rgba(255,255,255,0.65); text-align: right; font-weight: 600; }
.jsa-meta-value { color: #fff; font-weight: 700; }

/* Sections */
.jsa-section { border-top: 1px solid var(--border); }
.jsa-section-title { font-size: 12px; font-weight: 800; letter-spacing: 0.5px; color: #fff; background: var(--primary); padding: 8px 16px; margin: 0; text-transform: uppercase; }
.jsa-section-title-row { display: flex; justify-content: space-between; align-items: center; background: var(--primary); padding: 6px 16px; }
.jsa-section-title-row .jsa-section-title { padding: 0; background: none; }
.jsa-section-title-row .btn { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); font-size: 12px; }
.jsa-section-title-row .btn:hover { background: rgba(255,255,255,0.25); }

/* Info table (Job Information & Sign-off) */
.jsa-info-table { width: 100%; border-collapse: collapse; }
.jsa-info-table td, .jsa-info-table th { padding: 8px 12px; border: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.jsa-info-label { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); font-weight: 600; color: var(--text-primary); width: 15%; white-space: nowrap; font-size: 12px; }
.jsa-info-table th { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); font-weight: 600; color: var(--text-primary); font-size: 12px; text-align: left; }
.jsa-field { width: 100%; border: none; background: transparent; padding: 2px 0; font-size: 13px; color: var(--text-primary); outline: none; font-family: inherit; }
.jsa-field:focus { border-bottom: 2px solid var(--accent); }
.jsa-field::placeholder { color: var(--text-secondary); opacity: 0.6; }
.jsa-sign-table td { height: 44px; }

/* Risk pills */
.jsa-risk-pill { display: inline-block; padding: 3px 12px; border-radius: 12px; font-size: 11px; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 0.3px; }
.jsa-risk-low { background: #27ae60; }
.jsa-risk-medium { background: #f39c12; }
.jsa-risk-high { background: #e67e22; }
.jsa-risk-extreme { background: #e74c3c; }
.jsa-risk-na, .jsa-risk-n\/a { background: #999; }

/* Steps table */
.jsa-steps-table { width: 100%; border-collapse: collapse; }
.jsa-steps-table thead th { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--text-primary); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; padding: 10px 10px; text-align: left; border: 1px solid var(--border); white-space: nowrap; }
.jsa-steps-table tbody td { padding: 10px 10px; border: 1px solid var(--border); vertical-align: top; font-size: 13px; }
.jsa-step-row:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.jsa-col-num { text-align: center !important; width: 44px; }
.jsa-col-task { width: 18%; }
.jsa-col-hazards { width: 22%; }
.jsa-col-risk { width: 72px; text-align: center !important; }
.jsa-col-controls { width: 24%; }
.jsa-col-ppe { width: 12%; }
.jsa-col-actions { width: 50px; text-align: center !important; }
.jsa-step-number { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--primary); color: #fff; border-radius: 50%; font-size: 12px; font-weight: 700; }
.jsa-cell-title { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; line-height: 1.4; }
.jsa-cell-text { color: var(--text-primary); line-height: 1.5; white-space: pre-line; }
.jsa-cell-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; line-height: 1.4; }
.jsa-cell-sub strong { color: var(--text-primary); }

/* Step action buttons */
.jsa-action-btns { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.jsa-act-btn { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); transition: all 0.15s; }
.jsa-act-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.jsa-act-del:hover { background: #e74c3c; border-color: #e74c3c; }

/* Empty state */
.jsa-empty-steps { text-align: center; padding: 48px 24px; color: var(--text-secondary); }
.jsa-empty-steps p { margin: 8px 0 0 0; font-size: 14px; }
.jsa-empty-hint { font-size: 12px !important; opacity: 0.7; }

/* Legacy — keep for other views */
.ps-jsa-step { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; position: relative; }
.ps-jsa-step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.ps-jsa-step-num { background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ps-jsa-step-title { font-weight: 600; font-size: 14px; flex: 1; }
.ps-jsa-step-controls { display: flex; gap: 4px; }
.ps-jsa-detail-row { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.ps-jsa-detail-row strong { color: var(--text-primary); }

/* Responsive JSA form */
@media (max-width: 900px) {
  .jsa-doc-header { flex-direction: column; }
  .jsa-doc-meta-block { border-left: none; border-top: 1px solid rgba(255,255,255,0.15); }
  .jsa-steps-table { display: block; overflow-x: auto; }
  .jsa-info-table td, .jsa-info-table th { padding: 6px 8px; font-size: 12px; }
}

/* ─── Barrier Library ─── */
.ps-barrier-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.ps-barrier-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ps-barrier-card h4 { margin: 0; font-size: 14px; }
.ps-barrier-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.ps-barrier-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.ps-barrier-badge.eff-High { background: #DCFCE7; color: #16A34A; }
.ps-barrier-badge.eff-Medium { background: #FEF9C3; color: #CA8A04; }
.ps-barrier-badge.eff-Low { background: #FEE2E2; color: #DC2626; }
.ps-barrier-badge.eff-Failed { background: #FEE2E2; color: #991B1B; }
.ps-barrier-badge.st-Active { background: #DCFCE7; color: #16A34A; }
.ps-barrier-badge.st-Degraded { background: #FEF9C3; color: #CA8A04; }
.ps-barrier-badge.st-Failed { background: #FEE2E2; color: #DC2626; }
.ps-barrier-badge.st-Planned { background: #DBEAFE; color: #2563EB; }

/* ─── PHA ─── */
.ps-pha-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.ps-pha-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }

/* ─── Actions Table ─── */
.ps-actions-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ps-actions-table th { background: var(--bg); padding: 8px 10px; text-align: left; font-weight: 600; font-size: 12px; color: var(--text-secondary); border-bottom: 2px solid var(--border); }
.ps-actions-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.ps-actions-table tr:hover { background: var(--bg); }

/* Status badges */
.ps-status { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.ps-status-draft { background: #E5E7EB; color: #4B5563; }
.ps-status-inprogress { background: #DBEAFE; color: #2563EB; }
.ps-status-review { background: #FEF9C3; color: #CA8A04; }
.ps-status-approved { background: #DCFCE7; color: #16A34A; }
.ps-status-closed { background: #F3F4F6; color: #6B7280; }
.ps-status-open { background: #DBEAFE; color: #2563EB; }
.ps-status-completed { background: #DCFCE7; color: #16A34A; }
.ps-status-overdue { background: #FEE2E2; color: #DC2626; }
.ps-status-cancelled { background: #F3F4F6; color: #9CA3AF; }

/* Priority badges */
.ps-priority-critical { background: #FEE2E2; color: #DC2626; }
.ps-priority-high { background: #FFEDD5; color: #EA580C; }
.ps-priority-medium { background: #FEF9C3; color: #CA8A04; }
.ps-priority-low { background: #DCFCE7; color: #16A34A; }

/* AI loading indicator */
.ps-ai-loading { display: inline-block; padding: 8px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text-secondary); animation: ps-pulse 1.5s infinite; }
@keyframes ps-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ─── AI Study Assistant Panel ─── */
.ps-ai-fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #1B2A4A, #2d4a7a); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 20px rgba(27,42,74,0.4); z-index: 9998; transition: transform 0.2s, box-shadow 0.2s; }
.ps-ai-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(27,42,74,0.5); }
.ps-ai-fab-badge { position: absolute; top: -2px; right: -2px; background: #F7941D; color: #fff; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 8px; letter-spacing: 0.5px; }

.ps-ai-panel { position: fixed; bottom: 24px; right: 24px; width: 420px; max-height: 620px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 48px rgba(0,0,0,0.15); z-index: 9999; display: flex; flex-direction: column; overflow: hidden; }
@media (max-width: 480px) { .ps-ai-panel { width: calc(100vw - 16px); right: 8px; bottom: 8px; max-height: 80vh; } }

.ps-ai-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: linear-gradient(135deg, #1B2A4A, #2d4a7a); color: #fff; flex-shrink: 0; }
.ps-ai-header span { color: #fff; }

.ps-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--bg); }
.ps-ai-chip { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 16px; font-size: 0.72rem; cursor: pointer; background: var(--surface); color: var(--text-primary); transition: all 0.15s; white-space: nowrap; }
.ps-ai-chip:hover { background: #1B2A4A; color: #fff; border-color: #1B2A4A; }

.ps-ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 200px; }
.ps-ai-msg { display: flex; gap: 8px; align-items: flex-start; animation: ps-ai-fadein 0.3s ease; }
@keyframes ps-ai-fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.ps-ai-msg-user { flex-direction: row-reverse; }
.ps-ai-msg-user .ps-ai-bubble { background: #1B2A4A; color: #fff; border-radius: 14px 14px 4px 14px; }

.ps-ai-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #F7941D, #e67e00); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; flex-shrink: 0; }
.ps-ai-avatar-user { background: linear-gradient(135deg, #1B2A4A, #3a5a8a); }

.ps-ai-bubble { max-width: 320px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; font-size: 0.84rem; line-height: 1.5; word-wrap: break-word; }
.ps-ai-bubble ul { margin: 4px 0; padding-left: 18px; }
.ps-ai-bubble li { margin: 2px 0; }

.ps-ai-thinking span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #64748b; margin: 0 2px; animation: ps-ai-dot 1.2s infinite; }
.ps-ai-thinking span:nth-child(2) { animation-delay: 0.2s; }
.ps-ai-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ps-ai-dot { 0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); } 30% { opacity: 1; transform: scale(1.2); } }

.ps-ai-input-wrap { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.ps-ai-input { flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; font-size: 0.84rem; resize: none; min-height: 38px; max-height: 100px; font-family: inherit; background: var(--bg); }
.ps-ai-input:focus { outline: none; border-color: #1B2A4A; box-shadow: 0 0 0 2px rgba(27,42,74,0.15); }
.ps-ai-send { width: 38px; height: 38px; border-radius: 50%; background: #1B2A4A; color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s; }
.ps-ai-send:hover { background: #2d4a7a; }

.ps-ai-item { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 4px; background: var(--surface); }
.ps-ai-item:hover { background: var(--bg); }

.ps-ai-apply-btn { padding: 6px 16px; border: none; border-radius: 8px; background: #059669; color: #fff; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.ps-ai-apply-btn:hover { background: #047857; }
.ps-ai-apply-all-btn { padding: 6px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-primary); font-size: 0.8rem; cursor: pointer; transition: all 0.15s; }
.ps-ai-apply-all-btn:hover { background: var(--bg); }

/* ─── Universal AI HSE Expert (aix-*) — shared across all modules ─── */
.aix-fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #1B2A4A, #2d4a7a); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 20px rgba(27,42,74,0.4); z-index: 9998; transition: transform 0.2s, box-shadow 0.2s; }
.aix-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(27,42,74,0.5); }
.aix-fab-badge { position: absolute; top: -2px; right: -2px; background: #F7941D; color: #fff; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 8px; letter-spacing: 0.5px; }
.aix-panel { position: fixed; bottom: 24px; right: 24px; width: 420px; max-height: 620px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 48px rgba(0,0,0,0.15); z-index: 9999; display: flex; flex-direction: column; overflow: hidden; }
@media (max-width: 480px) { .aix-panel { width: calc(100vw - 16px); right: 8px; bottom: 8px; max-height: 80vh; } }
.aix-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: linear-gradient(135deg, #1B2A4A, #2d4a7a); color: #fff; flex-shrink: 0; }
.aix-header span { color: #fff; }
.aix-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--bg); }
.aix-chip { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 16px; font-size: 0.72rem; cursor: pointer; background: var(--surface); color: var(--text-primary); transition: all 0.15s; white-space: nowrap; }
.aix-chip:hover { background: #1B2A4A; color: #fff; border-color: #1B2A4A; }
.aix-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 200px; }
.aix-msg { display: flex; gap: 8px; align-items: flex-start; animation: ps-ai-fadein 0.3s ease; }
.aix-msg-user { flex-direction: row-reverse; }
.aix-msg-user .aix-bubble { background: #1B2A4A; color: #fff; border-radius: 14px 14px 4px 14px; }
.aix-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #F7941D, #e67e00); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; flex-shrink: 0; }
.aix-avatar-user { background: linear-gradient(135deg, #1B2A4A, #3a5a8a); }
.aix-bubble { max-width: 320px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; font-size: 0.84rem; line-height: 1.5; word-wrap: break-word; }
.aix-bubble ul { margin: 4px 0; padding-left: 18px; }
.aix-bubble li { margin: 2px 0; }
.aix-thinking span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #64748b; margin: 0 2px; animation: ps-ai-dot 1.2s infinite; }
.aix-thinking span:nth-child(2) { animation-delay: 0.2s; }
.aix-thinking span:nth-child(3) { animation-delay: 0.4s; }
.aix-input-wrap { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.aix-input { flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; font-size: 0.84rem; resize: none; min-height: 38px; max-height: 100px; font-family: inherit; background: var(--bg); }
.aix-input:focus { outline: none; border-color: #1B2A4A; box-shadow: 0 0 0 2px rgba(27,42,74,0.15); }
.aix-send { width: 38px; height: 38px; border-radius: 50%; background: #1B2A4A; color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s; }
.aix-send:hover { background: #2d4a7a; }
.aix-item { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 4px; background: var(--surface); }
.aix-item:hover { background: var(--bg); }
.aix-apply-btn { padding: 6px 16px; border: none; border-radius: 8px; background: #059669; color: #fff; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.aix-apply-btn:hover { background: #047857; }
.aix-apply-all-btn { padding: 6px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-primary); font-size: 0.8rem; cursor: pointer; transition: all 0.15s; }
.aix-apply-all-btn:hover { background: var(--bg); }

/* ---------- Contractor Management ---------- */
.ctr-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ctr-kpi-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; text-align: center; transition: all 0.15s; }
.ctr-kpi-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); transform: translateY(-1px); }
.ctr-kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.ctr-kpi-title { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.ctr-kpi-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; opacity: 0.7; }
.ctr-kpi-green .ctr-kpi-value { color: #059669; }
.ctr-kpi-amber .ctr-kpi-value { color: #D97706; }
.ctr-kpi-red .ctr-kpi-value { color: #DC2626; }
.ctr-kpi-blue .ctr-kpi-value { color: #2563EB; }
.ctr-kpi-purple .ctr-kpi-value { color: #7C3AED; }

.ctr-filter-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.ctr-filter-bar .form-control { min-width: 140px; font-size: 0.85rem; }
.ctr-filter-bar input[type="text"] { flex: 1; min-width: 180px; }

.ctr-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; }
.ctr-badge-green { background: #ECFDF5; color: #059669; }
.ctr-badge-amber { background: #FFFBEB; color: #D97706; }
.ctr-badge-red { background: #FEF2F2; color: #DC2626; }
.ctr-badge-blue { background: #EFF6FF; color: #2563EB; }
.ctr-badge-gray { background: #F3F4F6; color: #6B7280; }
.ctr-badge-purple { background: #F5F3FF; color: #7C3AED; }

.ctr-score-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; min-width: 80px; }
.ctr-score-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }

.ctr-onsite-roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-bottom: 16px; }
.ctr-onsite-card { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; border-left: 4px solid #059669; }
.ctr-onsite-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.ctr-onsite-info { flex: 1; min-width: 0; }
.ctr-onsite-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctr-onsite-meta { font-size: 0.75rem; color: var(--text-muted); }

.ctr-analytics-bar { height: 20px; border-radius: 4px; background: var(--border); overflow: hidden; position: relative; margin: 4px 0; }
.ctr-analytics-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; font-size: 0.65rem; font-weight: 700; color: #fff; min-width: 20px; }

.ctr-expiry-timeline { display: flex; flex-direction: column; gap: 8px; }
.ctr-expiry-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; font-size: 0.82rem; border: 1px solid var(--border); }
.ctr-expiry-days { min-width: 60px; text-align: center; font-weight: 700; border-radius: 6px; padding: 4px 8px; font-size: 0.78rem; }

@media (max-width: 768px) {
  .ctr-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ctr-onsite-roster { grid-template-columns: 1fr; }
  .ctr-filter-bar { flex-direction: column; }
}

/* ---------- Global Templates ---------- */
.gt-container { }
.gt-category-grid {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.gt-cat-card {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: all 0.15s; background: var(--bg-light);
  font-size: 0.82rem; font-weight: 500; user-select: none;
}
.gt-cat-card:hover { border-color: var(--gt-cat-color, var(--accent)); background: #fff; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.gt-cat-card.active { border-color: var(--gt-cat-color, var(--accent)); background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.gt-cat-icon { font-size: 1.1rem; }
.gt-cat-label { font-weight: 600; }
.gt-cat-count { background: var(--bg-secondary); padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); }
.gt-cat-card.active .gt-cat-count { background: var(--gt-cat-color, var(--accent)); color: #fff; }

.gt-search-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.gt-search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.gt-search-input { padding-left: 36px !important; }
.gt-filter-select { width: auto; min-width: 160px; }
.gt-result-count { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }

.gt-template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.gt-template-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: #fff;
  transition: all 0.15s; display: flex; flex-direction: column;
}
.gt-template-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0,0,0,0.07); transform: translateY(-2px); }
.gt-tpl-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.gt-tpl-cat-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 6px; font-size: 0.72rem; font-weight: 600; }
.gt-tpl-popularity { font-size: 0.75rem; letter-spacing: -1px; }
.gt-tpl-name { font-size: 0.95rem; font-weight: 700; margin: 0 0 6px; color: var(--text-primary); line-height: 1.3; }
.gt-tpl-desc { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 12px; line-height: 1.45; flex: 1; }
.gt-tpl-meta { display: flex; gap: 12px; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 12px; flex-wrap: wrap; }
.gt-tpl-meta span { display: flex; align-items: center; gap: 3px; }
.gt-tpl-meta span::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--border); }
.gt-tpl-meta span:first-child::before { display: none; }
.gt-tpl-actions { display: flex; gap: 8px; margin-top: auto; }
.gt-tpl-actions .btn { flex: 1; text-align: center; font-size: 0.8rem; }

@media (max-width: 768px) {
  .gt-template-grid { grid-template-columns: 1fr; }
  .gt-category-grid { gap: 6px; }
  .gt-cat-card { padding: 6px 10px; font-size: 0.75rem; }
  .gt-search-bar { flex-direction: column; }
  .gt-filter-select { width: 100%; }
}

/* ---------- LOPA / SIL Analysis ---------- */
.ps-lopa-sil-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; letter-spacing: 0.5px; }
.ps-lopa-sil-badge.sil-0 { background: #E8F5E9; color: #2E7D32; }
.ps-lopa-sil-badge.sil-1 { background: #FFF8E1; color: #F57F17; }
.ps-lopa-sil-badge.sil-2 { background: #FFF3E0; color: #E65100; }
.ps-lopa-sil-badge.sil-3 { background: #FFEBEE; color: #C62828; }
.ps-lopa-sil-badge.sil-4 { background: #F3E5F5; color: #6A1B9A; }

.ps-lopa-calc-results { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 12px; }
.ps-lopa-calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.ps-lopa-calc-item { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; text-align: center; }
.ps-lopa-calc-highlight { border-color: var(--primary); background: #F0F4FF; }
.ps-lopa-calc-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.ps-lopa-calc-value { font-size: 18px; font-weight: 700; color: var(--text-primary); font-family: 'Courier New', monospace; }

.ps-lopa-gauge { position: relative; height: 32px; border-radius: 16px; overflow: visible; display: flex; margin: 8px 0; }
.ps-lopa-gauge-bar { display: flex; width: 100%; border-radius: 16px; overflow: hidden; }
.ps-lopa-gauge-seg { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.ps-lopa-gauge-seg:first-child { border-radius: 16px 0 0 16px; }
.ps-lopa-gauge-seg:last-child { border-radius: 0 16px 16px 0; }
.ps-lopa-gauge-arrow { position: absolute; top: -6px; transform: translateX(-50%); font-size: 18px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); z-index: 2; }

.ps-lopa-ipl-row { display: grid; grid-template-columns: 1fr 140px 120px 120px 1fr; gap: 8px; align-items: start; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; }
.ps-lopa-ipl-row .form-control { font-size: 12px; padding: 6px 8px; }
.ps-lopa-ipl-row select.form-control { padding: 6px 4px; }

.ps-lopa-cm-grid { display: grid; grid-template-columns: 1fr 120px 1fr; gap: 8px; align-items: center; }
.ps-lopa-cm-grid label { font-size: 12px; font-weight: 500; }

.ps-lopa-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 16px 0; }
.ps-lopa-summary-item { text-align: center; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.ps-lopa-summary-count { font-size: 28px; font-weight: 800; }
.ps-lopa-summary-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* Responsive */
@media (max-width: 768px) {
  .ps-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .ps-tab { padding: 6px 10px; font-size: 11px; white-space: nowrap; }
  .ps-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ps-grid-2 { grid-template-columns: 1fr; }
  .ps-grid-3 { grid-template-columns: 1fr; }
  .ps-bt-controls { flex-direction: column; align-items: stretch; }
  .ps-bt-ctrl-group .form-control { max-width: 100%; }
  .ps-risk-matrix { max-width: 100%; }
}
@media (max-width: 480px) {
  .ps-kpi-grid { grid-template-columns: 1fr; }
}

/* ============================================
   AI Safety Scanner — Enhanced Styles
   ============================================ */

/* ── Hero Header ─────────────────────────── */
.ais-hero {
  background: linear-gradient(135deg, #1B2A4A 0%, #2D4A7A 50%, #1B2A4A 100%);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  color: #fff;
}
.ais-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -40px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(247,148,29,0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.ais-hero::after {
  content: '';
  position: absolute;
  bottom: -30px; left: 20%;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(59,130,246,0.1) 0%, transparent 70%);
  border-radius: 50%;
}
.ais-hero h2 { margin: 0 0 4px; font-size: 1.6rem; font-weight: 700; position: relative; z-index: 1; }
.ais-hero p { margin: 0; font-size: 13px; opacity: 0.7; position: relative; z-index: 1; }
.ais-hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: rgba(247,148,29,0.2); color: #F7941D;
  margin-bottom: 10px; position: relative; z-index: 1;
}
.ais-hero-badge svg { animation: ais-pulse 2s ease-in-out infinite; }
@keyframes ais-pulse { 0%,100%{opacity:1;} 50%{opacity:0.5;} }

/* ── Tabs ────────────────────────────────── */
.ais-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface); border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 24px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.ais-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  background: transparent; border: none; cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.ais-tab:hover { background: var(--surface-hover); color: var(--text); }
.ais-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(27,42,74,0.25);
}
.ais-tab svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Stat Cards ──────────────────────────── */
.ais-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.ais-stat {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: all 0.2s ease; position: relative; overflow: hidden;
}
.ais-stat:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.ais-stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ais-stat-icon svg { width: 22px; height: 22px; }
.ais-stat-info { flex: 1; min-width: 0; }
.ais-stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--text); }
.ais-stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.ais-stat::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 0 0 80px;
  opacity: 0.05;
}

/* ── Upload Zone ─────────────────────────── */
.ais-upload-zone {
  border: 2px dashed var(--border);
  border-radius: 16px; padding: 48px 32px;
  text-align: center; cursor: pointer;
  background: linear-gradient(180deg, var(--surface) 0%, rgba(59,130,246,0.02) 100%);
  transition: all 0.3s ease; position: relative;
}
.ais-upload-zone:hover {
  border-color: var(--primary); background: rgba(27,42,74,0.03);
  transform: translateY(-1px);
}
.ais-upload-zone.dragover {
  border-color: var(--accent); border-style: solid;
  background: rgba(247,148,29,0.05);
  box-shadow: 0 0 0 4px rgba(247,148,29,0.1);
}
.ais-upload-icon {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, #1B2A4A, #2D4A7A);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px; box-shadow: 0 4px 12px rgba(27,42,74,0.2);
}
.ais-upload-icon svg { width: 28px; height: 28px; stroke: #fff; }
.ais-upload-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.ais-upload-sub { font-size: 13px; color: var(--text-secondary); }
.ais-upload-or {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 16px; font-size: 12px; color: var(--text-muted);
}
.ais-upload-or::before, .ais-upload-or::after {
  content: ''; width: 40px; height: 1px; background: var(--border);
}
.ais-upload-cam-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  transition: all 0.2s;
}
.ais-upload-cam-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* ── Zone Selector ───────────────────────── */
.ais-zone-bar {
  display: flex; gap: 12px; align-items: center;
  flex-wrap: wrap; margin-top: 16px;
  padding: 12px 16px; border-radius: 10px;
  background: var(--surface-hover); border: 1px solid var(--border-light);
}
.ais-zone-bar label { font-weight: 600; font-size: 13px; white-space: nowrap; }

/* ── Ergonomics Layout ───────────────────── */
.ais-ergo-grid {
  display: grid; grid-template-columns: 1fr 340px;
  gap: 24px; margin-bottom: 24px;
}
@media (max-width: 900px) { .ais-ergo-grid { grid-template-columns: 1fr; } }

.ais-ergo-camera {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); overflow: hidden;
}
.ais-ergo-camera-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.ais-ergo-camera-header h3 { margin: 0; font-size: 15px; }
.ais-ergo-camera-body {
  position: relative; background: #0a0f1a;
  aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
}
.ais-ergo-camera-body video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.ais-ergo-camera-body canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; transform: scaleX(-1); }
.ais-ergo-camera-placeholder {
  text-align: center; color: #475569;
}
.ais-ergo-camera-placeholder svg { opacity: 0.3; margin-bottom: 8px; }
.ais-ergo-camera-placeholder p { font-size: 13px; margin: 0; }

/* ── REBA Panel ──────────────────────────── */
.ais-reba-panel {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); display: flex; flex-direction: column;
}
.ais-reba-main {
  padding: 20px; text-align: center;
  border-bottom: 1px solid var(--border);
}
.ais-reba-score-ring {
  width: 100px; height: 100px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 8px; position: relative;
}
.ais-reba-score-ring::before {
  content: ''; position: absolute; inset: 0;
  border-radius: 50%; border: 4px solid var(--border);
}
.ais-reba-score-val { font-size: 36px; font-weight: 800; line-height: 1; position: relative; z-index: 1; }
.ais-reba-score-label { font-size: 12px; font-weight: 600; margin-top: 2px; }
.ais-reba-action { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

.ais-reba-joints {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0; flex: 1;
}
.ais-reba-joint {
  padding: 12px; text-align: center;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
}
.ais-reba-joint:nth-child(even) { border-right: none; }
.ais-reba-joint:nth-last-child(-n+2) { border-bottom: none; }
.ais-reba-joint-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.ais-reba-joint-value { font-size: 22px; font-weight: 700; margin-top: 2px; color: var(--text); }

/* ── Info Card (Ergonomics) ──────────────── */
.ais-info-card {
  background: linear-gradient(135deg, rgba(59,130,246,0.05) 0%, rgba(139,92,246,0.05) 100%);
  border: 1px solid rgba(59,130,246,0.15);
  border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 24px;
}
.ais-info-card h3 { margin: 0 0 6px; font-size: 16px; }
.ais-info-card p { margin: 0 0 12px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.ais-tech-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.ais-tech-tag {
  padding: 5px 14px; border-radius: 20px; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}

/* ── REBA Reference Table ────────────────── */
.ais-reba-ref {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); overflow: hidden;
}
.ais-reba-ref h3 { margin: 0; padding: 14px 18px; font-size: 14px; border-bottom: 1px solid var(--border); }
.ais-reba-ref table { width: 100%; border-collapse: collapse; }
.ais-reba-ref th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 16px; background: var(--surface-hover); color: var(--text-secondary); text-align: left; }
.ais-reba-ref td { padding: 10px 16px; font-size: 13px; border-top: 1px solid var(--border-light); }
.ais-reba-ref tr:hover td { background: var(--surface-hover); }

/* ── CCTV Card ───────────────────────────── */
.ais-cctv-info {
  background: linear-gradient(135deg, rgba(139,92,246,0.05) 0%, rgba(59,130,246,0.05) 100%);
  border: 1px solid rgba(139,92,246,0.15);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px;
}
.ais-cctv-info h3 { margin: 0 0 8px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.ais-cctv-info p { margin: 0 0 14px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }

/* ── Section Headers ─────────────────────── */
.ais-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.ais-section-header h3 {
  margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px;
}
.ais-section-count {
  font-size: 12px; font-weight: 600; padding: 2px 10px;
  border-radius: 12px; background: var(--primary); color: #fff;
}

/* ── Empty States ────────────────────────── */
.ais-empty {
  text-align: center; padding: 48px 24px;
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.ais-empty-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--surface-hover);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.ais-empty-icon svg { width: 28px; height: 28px; stroke: var(--text-muted); }
.ais-empty h4 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.ais-empty p { margin: 0; font-size: 13px; color: var(--text-secondary); }

/* ── Trends Cards ────────────────────────── */
.ais-trends-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 768px) { .ais-trends-grid { grid-template-columns: 1fr; } }
.ais-chart-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 20px; margin-bottom: 20px;
}
.ais-chart-card h3 { margin: 0 0 16px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.ais-chart-card h3 svg { width: 18px; height: 18px; color: var(--primary); }

/* ============================================
   Safety Digital Twin
   ============================================ */
.dt-zone-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
@keyframes dt-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.dt-pulse { animation: dt-pulse-border 2s infinite; }
@keyframes dt-pulse-border { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); } 50% { box-shadow: 0 0 0 4px rgba(220,38,38,0.1); } }

/* ============================================
   AI Findings Badges & Smart Links
   ============================================ */
.ai-finding-badge { display:inline-flex; align-items:center; gap:3px; padding:1px 7px; border-radius:10px; font-size:0.68rem; font-weight:700; background:linear-gradient(135deg,#7c3aed20,#6366f120); color:#7c3aed; border:1px solid #7c3aed30; cursor:pointer; vertical-align:middle; margin-left:6px; transition:all 0.15s; }
.ai-finding-badge:hover { background:#7c3aed25; transform:scale(1.05); }
.ai-finding-badge svg { width:12px; height:12px; }
.ai-finding-badge.severity-critical { background:linear-gradient(135deg,#dc262620,#ef444420); color:#dc2626; border-color:#dc262630; }
.ai-finding-badge.severity-high { background:linear-gradient(135deg,#f9731620,#f5940420); color:#ea580c; border-color:#ea580c30; }
.ai-related-card { border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-top:14px; background:linear-gradient(135deg,#f8f7ff,#fff); }
.ai-related-item { display:flex; gap:8px; align-items:center; padding:6px 0; border-bottom:1px solid var(--border); font-size:0.82rem; cursor:pointer; }
.ai-related-item:last-child { border-bottom:none; }
.ai-related-item:hover { color:var(--primary); }
.ai-insight-card { background:linear-gradient(135deg,#f0f0ff,#fff); border:1px solid #7c3aed20; border-radius:var(--radius); padding:14px; margin-top:10px; }
.ai-insight-card h4 { margin:0 0 8px; font-size:0.85rem; color:#7c3aed; display:flex; align-items:center; gap:6px; }
.ai-insight-card p { margin:0 0 6px; font-size:0.82rem; line-height:1.5; }
.ai-rec-item { display:flex; gap:8px; padding:6px 0; border-bottom:1px solid #7c3aed10; font-size:0.8rem; }
.ai-rec-item:last-child { border-bottom:none; }

/* ============================================
   AI Safety Copilot Bar
   ============================================ */
.ai-copilot-bar { background: linear-gradient(135deg, #f8f7ff 0%, #fff 100%); border: 1px solid #7c3aed20; border-radius: var(--radius, 8px); margin-bottom: 16px; overflow: hidden; transition: all 0.2s; }
.ai-copilot-bar.ai-copilot-pulse { animation: ai-copilot-pulse 0.6s ease 2; }
@keyframes ai-copilot-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(124,58,237,0); } 50% { box-shadow: 0 0 0 4px rgba(124,58,237,0.15); } }

.ai-copilot-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; user-select: none; }
.ai-copilot-header:hover { background: rgba(124,58,237,0.03); }
.ai-copilot-icon { display: flex; align-items: center; color: #7c3aed; }
.ai-copilot-label { font-size: 0.82rem; font-weight: 700; color: #7c3aed; }
.ai-copilot-status { font-size: 0.72rem; color: var(--text-secondary, #64748B); margin-left: auto; }
.ai-copilot-status--alert { color: #dc2626; font-weight: 600; }
.ai-copilot-chevron { font-size: 0.65rem; color: var(--text-secondary, #94A3B8); margin-left: 4px; }

.ai-copilot-body { padding: 0 14px 12px; }
.ai-copilot-collapsed .ai-copilot-body { display: none; }

.ai-copilot-cards { display: flex; flex-direction: column; gap: 8px; }
.ai-copilot-card { display: flex; gap: 10px; padding: 10px 12px; border-radius: 6px; border-left: 3px solid #3b82f6; background: #fff; transition: opacity 0.2s, transform 0.2s; }
.ai-copilot-card--warning { border-left-color: #f59e0b; background: #fffbeb; }
.ai-copilot-card--action { border-left-color: #10b981; background: #f0fdf4; }
.ai-copilot-card--info { border-left-color: #3b82f6; background: #eff6ff; }
.ai-copilot-card--high { border-left-width: 4px; }
.ai-copilot-card-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.4; }
.ai-copilot-card-content { flex: 1; min-width: 0; }
.ai-copilot-card-content strong { font-size: 0.8rem; display: block; margin-bottom: 2px; color: var(--text-primary, #1E293B); }
.ai-copilot-card-content p { font-size: 0.75rem; color: var(--text-secondary, #64748B); margin: 0; line-height: 1.45; }
.ai-copilot-card-dismiss { background: none; border: none; color: var(--text-secondary, #94A3B8); font-size: 1rem; cursor: pointer; padding: 0 2px; line-height: 1; flex-shrink: 0; align-self: flex-start; }
.ai-copilot-card-dismiss:hover { color: var(--text-primary, #1E293B); }

.ai-copilot-empty { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: #10b981; padding: 6px 0; }
.ai-copilot-empty svg { flex-shrink: 0; color: #10b981; }

.ai-copilot-ask { display: flex; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(124,58,237,0.1); }
.ai-copilot-ask input { flex: 1; border: 1px solid var(--border, #E2E8F0); border-radius: 6px; padding: 7px 10px; font-size: 0.78rem; font-family: inherit; outline: none; background: #fff; transition: border-color 0.2s; }
.ai-copilot-ask input:focus { border-color: #7c3aed; }
.ai-copilot-ask-btn { background: #7c3aed; color: #fff; border: none; padding: 7px 14px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 0.15s; }
.ai-copilot-ask-btn:hover { background: #6d28d9; }

.ai-copilot-answer { background: linear-gradient(135deg, #faf5ff, #fff); border: 1px solid #7c3aed20; border-radius: 6px; padding: 10px 12px; margin-bottom: 4px; }
.ai-copilot-answer-q { font-size: 0.78rem; color: #7c3aed; margin-bottom: 6px; }
.ai-copilot-answer-a { font-size: 0.78rem; color: var(--text-primary, #1E293B); line-height: 1.5; }

.ai-copilot-dots { display: inline-flex; gap: 3px; }
.ai-copilot-dots span { width: 5px; height: 5px; background: #7c3aed; border-radius: 50%; animation: sb-bounce 1.4s infinite ease-in-out; }
.ai-copilot-dots span:nth-child(2) { animation-delay: 0.16s; }
.ai-copilot-dots span:nth-child(3) { animation-delay: 0.32s; }

.ai-copilot-shimmer { padding: 4px 0; }
.ai-copilot-shimmer-line { height: 10px; background: linear-gradient(90deg, #f0f0ff 25%, #e8e5ff 50%, #f0f0ff 75%); background-size: 200% 100%; border-radius: 4px; animation: ai-shimmer 1.5s infinite; margin-bottom: 6px; }
.ai-copilot-shimmer-line.short { width: 60%; }
@keyframes ai-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Copilot quick-action chips */
.ai-copilot-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-copilot-chip {
  background: #f5f3ff; color: #7c3aed; border: 1px solid #7c3aed30;
  padding: 4px 10px; border-radius: 14px; font-size: 0.7rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.ai-copilot-chip:hover { background: #7c3aed; color: #fff; border-color: #7c3aed; }

/* Copilot module guide cards */
.ai-copilot-guide {
  background: linear-gradient(135deg, #faf5ff, #f0ebff);
  border: 1px solid #7c3aed25; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 6px;
}
.ai-copilot-guide-title {
  font-size: 0.85rem; font-weight: 700; color: #7c3aed;
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #7c3aed20;
}
.ai-copilot-guide-steps { display: flex; flex-direction: column; gap: 8px; }
.ai-copilot-guide-step {
  display: flex; gap: 10px; align-items: flex-start;
}
.ai-copilot-guide-step-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: #7c3aed; color: #fff; font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.ai-copilot-guide-step strong { font-size: 0.78rem; color: #4c1d95; display: block; margin-bottom: 2px; }
.ai-copilot-guide-step p { font-size: 0.73rem; color: #475569; line-height: 1.45; margin: 0; }
.ai-copilot-guide-quickstart { font-size: 0.78rem; color: #475569; line-height: 1.5; margin: 0; }
.ai-copilot-guide-tips { margin: 0; padding-left: 16px; }
.ai-copilot-guide-tips li {
  font-size: 0.75rem; color: #475569; line-height: 1.5;
  margin-bottom: 6px; padding-left: 4px;
}
.ai-copilot-guide-tips li::marker { color: #7c3aed; }

@media (max-width: 768px) {
  .ai-copilot-bar { margin-bottom: 12px; }
  .ai-copilot-header { padding: 8px 10px; }
  .ai-copilot-body { padding: 0 10px 10px; }
  .ai-copilot-chips { gap: 4px; }
  .ai-copilot-chip { font-size: 0.65rem; padding: 3px 8px; }
}

/* ============================================
   Incident AI Reconstruction
   ============================================ */
.inc-recon-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000; background: rgba(0,0,0,0.6);
  overflow-y: auto; backdrop-filter: blur(4px);
}
.inc-recon-container {
  max-width: 1100px; margin: 24px auto; background: var(--surface, #fff);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.inc-recon-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: linear-gradient(135deg, #1B2A4A, #2d3e5f);
  color: #fff; position: sticky; top: 0; z-index: 10;
}
.inc-recon-header-left { display: flex; align-items: center; gap: 12px; }
.inc-recon-header-left svg { flex-shrink: 0; stroke: #F7941D; }
.inc-recon-header-left h1 { margin: 0; font-size: 18px; font-weight: 700; }
.inc-recon-subtitle { font-size: 13px; opacity: 0.75; }
.inc-recon-header-right { display: flex; gap: 8px; }
.inc-recon-header-right .btn { color: #fff; border-color: rgba(255,255,255,0.3); font-size: 13px; }
.inc-recon-header-right .btn:hover { background: rgba(255,255,255,0.1); }

.inc-recon-context {
  display: flex; flex-wrap: wrap; gap: 16px; padding: 12px 24px;
  background: var(--surface-alt, #f7f8fa); border-bottom: 1px solid var(--border, #e2e8f0);
  font-size: 13px; color: var(--text-secondary, #64748b);
}

.inc-recon-section {
  padding: 24px; border-bottom: 1px solid var(--border, #e2e8f0);
}
.inc-recon-section:last-child { border-bottom: none; }
.inc-recon-section h2 {
  margin: 0 0 16px; font-size: 17px; font-weight: 700;
  color: var(--text-primary, #1a202c);
}

.inc-recon-narrative {
  font-size: 15px; line-height: 1.7; color: var(--text-primary, #1a202c);
  max-width: 800px;
}

/* Timeline */
.inc-recon-timeline {
  display: flex; gap: 0; overflow-x: auto; padding: 16px 0;
  position: relative;
}
.inc-recon-timeline::before {
  content: ''; position: absolute; top: 38px; left: 0; right: 0;
  height: 3px; background: var(--border, #e2e8f0);
}
.inc-recon-event {
  min-width: 200px; max-width: 240px; flex-shrink: 0;
  background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0);
  border-left: 4px solid #718096; border-radius: 10px;
  padding: 12px; margin: 0 8px; position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}
.inc-recon-event:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.inc-recon-event-dot {
  width: 32px; height: 32px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 14px;
  color: #fff; margin: 0 auto 8px; position: relative; z-index: 1;
}
.inc-recon-event-time {
  font-size: 11px; font-weight: 700; color: var(--text-secondary, #64748b);
  text-align: center; margin-bottom: 4px;
}
.inc-recon-event-title {
  font-size: 13px; font-weight: 700; color: var(--text-primary, #1a202c);
  margin-bottom: 4px;
}
.inc-recon-event-desc { font-size: 12px; color: var(--text-secondary, #64748b); line-height: 1.4; }
.inc-recon-event-photo {
  width: 100%; height: 80px; object-fit: cover; border-radius: 6px;
  margin-top: 8px; cursor: pointer; border: 1px solid var(--border, #e2e8f0);
}

/* Swiss Cheese */
.inc-recon-swiss-wrap { overflow-x: auto; padding: 8px 0; }
.inc-recon-swiss { width: 100%; min-width: 700px; height: auto; }
.inc-recon-trajectory {
  font-size: 14px; color: var(--text-secondary, #64748b);
  margin-top: 12px; padding: 12px 16px; background: #FFF5F5;
  border-left: 4px solid #E53E3E; border-radius: 6px;
}

/* Contributing Factors */
.inc-recon-factors-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.inc-recon-factor-card {
  background: var(--surface-alt, #f7f8fa); border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px; padding: 14px;
}
.inc-recon-factor-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.inc-recon-factor-icon { font-size: 20px; }
.inc-recon-factor-cat {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-secondary, #64748b); letter-spacing: 0.5px;
}
.inc-recon-factor-name { font-size: 14px; font-weight: 600; color: var(--text-primary, #1a202c); margin-bottom: 4px; }
.inc-recon-factor-detail { font-size: 12px; color: var(--text-secondary, #64748b); line-height: 1.4; }

/* Lessons Learned */
.inc-recon-lesson {
  border-left: 4px solid #718096; padding: 14px 16px; margin-bottom: 10px;
  background: var(--surface-alt, #f7f8fa); border-radius: 0 8px 8px 0;
}
.inc-recon-lesson-header { margin-bottom: 6px; }
.inc-recon-lesson-prio {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 10px; font-weight: 700; color: #fff; letter-spacing: 0.5px;
}
.inc-recon-lesson-text { font-size: 14px; font-weight: 600; color: var(--text-primary, #1a202c); margin-bottom: 6px; }
.inc-recon-lesson-rec { font-size: 13px; color: var(--text-secondary, #64748b); }

/* Training Scenario */
.inc-recon-scenario {
  background: linear-gradient(135deg, #EBF4FF, #F0FFF4);
  border: 1px solid #BEE3F8; border-radius: 12px; padding: 20px;
}
.inc-recon-scenario h3 { margin: 0 0 12px; font-size: 16px; color: #2B6CB0; }
.inc-recon-scenario-text { font-size: 14px; line-height: 1.6; color: var(--text-primary, #1a202c); margin-bottom: 16px; }
.inc-recon-scenario-questions { font-size: 13px; }
.inc-recon-scenario-questions ol { margin: 8px 0 0; padding-left: 20px; }
.inc-recon-scenario-questions li { margin-bottom: 6px; color: var(--text-primary, #1a202c); }

/* Loading */
.inc-recon-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh; color: #fff; text-align: center;
}
.inc-recon-loading h2 { margin: 16px 0 8px; font-size: 22px; }
.inc-recon-loading p { opacity: 0.7; max-width: 400px; font-size: 14px; }
.inc-recon-spinner {
  width: 56px; height: 56px; border: 4px solid rgba(255,255,255,0.2);
  border-top-color: #F7941D; border-radius: 50%;
  animation: inc-recon-spin 1s linear infinite;
}
@keyframes inc-recon-spin { to { transform: rotate(360deg); } }

/* Print */
@media print {
  .inc-recon-overlay { position: static; background: #fff; backdrop-filter: none; overflow: visible; }
  .inc-recon-container { margin: 0; box-shadow: none; border-radius: 0; }
  .inc-recon-header-right { display: none; }
  .inc-recon-header { position: static; background: #1B2A4A !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inc-recon-section { break-inside: avoid; }
  .inc-recon-timeline { flex-wrap: wrap; overflow: visible; }
  .inc-recon-event { break-inside: avoid; }
  .inc-recon-swiss-wrap { overflow: visible; }
}

/* ============================================
   IoT Gateway & Wearable Hub — Enhanced
   ============================================ */

/* Hero Banner */
.iot-hero {
  position: relative; border-radius: 16px; overflow: hidden;
  margin-bottom: 20px; padding: 28px 32px;
  background: linear-gradient(135deg, #1B2A4A 0%, #2d4a7a 50%, #1B2A4A 100%);
  color: #fff;
}
.iot-hero-bg {
  position: absolute; inset: 0; opacity: 0.06;
  background-image: radial-gradient(circle at 20% 50%, #F7941D 1px, transparent 1px),
    radial-gradient(circle at 80% 20%, #4299E1 1px, transparent 1px),
    radial-gradient(circle at 60% 80%, #38A169 1px, transparent 1px);
  background-size: 60px 60px, 80px 80px, 50px 50px;
  animation: iot-hero-drift 20s linear infinite;
}
@keyframes iot-hero-drift { from { background-position: 0 0, 0 0, 0 0; } to { background-position: 60px 60px, -80px 80px, 50px -50px; } }
.iot-hero-content { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; gap: 24px; flex-wrap: wrap; }
.iot-hero-left h1 { margin: 0 0 6px; font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.iot-hero-left h1 svg { stroke: #F7941D; }
.iot-hero-left p { margin: 0; font-size: 13px; opacity: 0.7; max-width: 480px; }
.iot-hero-right { display: flex; align-items: center; gap: 20px; }
.iot-hero-ring { flex-shrink: 0; }
.iot-ring-fill { transition: stroke-dasharray 1s ease; }
.iot-hero-actions { display: flex; flex-direction: column; gap: 8px; }
.iot-hero-btn {
  padding: 7px 16px; font-size: 12px; font-weight: 600; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25); color: #fff; background: rgba(255,255,255,0.08);
  cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all 0.2s;
}
.iot-hero-btn:hover { background: rgba(255,255,255,0.15); }
.iot-hero-btn-primary { background: #F7941D; border-color: #F7941D; }
.iot-hero-btn-primary:hover { background: #e0850f; }

/* Stats Grid */
.iot-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.iot-stat-card {
  background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px; padding: 16px 14px; text-align: center;
  transition: transform 0.2s, box-shadow 0.2s; position: relative; overflow: hidden;
}
.iot-stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.iot-stat-icon { font-size: 22px; margin-bottom: 4px; position: relative; display: inline-block; }
.iot-stat-value { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.iot-stat-label { font-size: 11px; color: var(--text-secondary, #64748b); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.iot-stat-bar { height: 4px; background: var(--border, #e2e8f0); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.iot-stat-bar-fill { height: 100%; border-radius: 2px; transition: width 1s ease; }
.iot-pulse { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; animation: iot-pulse-anim 2s infinite; }
@keyframes iot-pulse-anim { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(1.8); } }

/* Tabs */
.iot-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border, #e2e8f0);
  margin-bottom: 20px; overflow-x: auto;
}
.iot-tab {
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary, #64748b); text-decoration: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: all 0.2s;
}
.iot-tab:hover { color: var(--primary, #1B2A4A); background: var(--surface-alt, #f7f8fa); }
.iot-tab.active { color: var(--accent, #F7941D); border-bottom-color: var(--accent, #F7941D); }

/* Network Topology */
.iot-topology { overflow-x: auto; padding: 8px 0; }
.iot-topology-svg { width: 100%; min-width: 700px; height: auto; }
.iot-topo-orbit { animation: iot-orbit 12s linear infinite; transform-origin: 450px 140px; }
@keyframes iot-orbit { from { transform: rotate(0deg); transform-origin: 450px 140px; } to { transform: rotate(360deg); transform-origin: 450px 140px; } }
.iot-topo-flow { animation: iot-dash-flow 2s linear infinite; }
@keyframes iot-dash-flow { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -20; } }

/* Device Type Chips */
.iot-type-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.iot-type-chip {
  display: flex; align-items: center; gap: 6px; padding: 6px 14px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--surface-alt, #f7f8fa); border: 1px solid var(--border, #e2e8f0);
  color: var(--text-secondary, #64748b); transition: all 0.2s;
}
.iot-type-active { background: #EBF8FF; border-color: #4299E1; color: #2B6CB0; }
.iot-type-chip-icon { font-size: 16px; }
.iot-type-chip-count {
  background: #4299E1; color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 10px; margin-left: 2px;
}

/* Device Grid — Enhanced */
.iot-device-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.iot-device-card {
  background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px; padding: 18px; cursor: pointer;
  transition: all 0.25s ease; position: relative; overflow: hidden;
}
.iot-device-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent, #F7941D), transparent);
  opacity: 0; transition: opacity 0.3s;
}
.iot-device-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.12); }
.iot-device-card:hover::before { opacity: 1; }
.iot-device-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.iot-device-icon { font-size: 32px; }
.iot-device-status-wrap { display: flex; align-items: center; gap: 6px; }
.iot-pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  animation: iot-pulse-anim 2s infinite;
}
.iot-device-status {
  display: inline-block; padding: 3px 10px; border-radius: 10px;
  font-size: 10px; font-weight: 700; color: #fff; letter-spacing: 0.3px;
}
.iot-device-name { font-size: 15px; font-weight: 700; color: var(--text-primary, #1a202c); margin-bottom: 6px; }
.iot-device-meta { display: flex; gap: 6px; margin-bottom: 6px; }
.iot-device-type-badge, .iot-device-proto-badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 600;
}
.iot-device-type-badge { background: #EBF8FF; color: #2B6CB0; }
.iot-device-proto-badge { background: #F0FFF4; color: #276749; }
.iot-device-location {
  font-size: 12px; color: var(--text-secondary, #64748b); margin-bottom: 4px;
  display: flex; align-items: center; gap: 4px;
}
.iot-device-location svg { stroke: var(--text-secondary, #64748b); flex-shrink: 0; }

/* Sparkline */
.iot-spark { width: 100%; height: 30px; margin: 8px 0 4px; display: block; }

/* Device reading row */
.iot-device-reading {
  font-size: 13px; margin-top: 6px; padding-top: 8px;
  border-top: 1px solid var(--border, #e2e8f0);
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.iot-reading-param { font-size: 11px; color: var(--text-secondary, #64748b); font-weight: 600; text-transform: uppercase; }
.iot-reading-value { font-size: 16px; font-weight: 800; color: var(--text-primary, #1a202c); }
.iot-reading-value small { font-size: 11px; font-weight: 500; color: var(--text-secondary, #64748b); }
.iot-reading-ago { font-size: 10px; color: var(--text-secondary, #64748b); }

/* Empty state */
.iot-empty-hero { text-align: center; padding: 40px 20px; }
.iot-empty-hero svg { margin-bottom: 16px; }
.iot-empty-hero h3 { margin: 0 0 8px; font-size: 18px; color: var(--text-primary, #1a202c); }
.iot-empty-hero p { margin: 0 0 20px; color: var(--text-secondary, #64748b); font-size: 14px; max-width: 400px; display: inline-block; }

/* Protocol Cards */
.iot-protocol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.iot-protocol-card {
  padding: 18px; background: var(--surface-alt, #f7f8fa);
  border: 1px solid var(--border, #e2e8f0); border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.iot-protocol-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.iot-protocol-name { font-size: 16px; font-weight: 800; color: var(--primary, #1B2A4A); margin-bottom: 6px; }
.iot-protocol-desc { font-size: 12px; color: var(--text-secondary, #64748b); margin-bottom: 10px; line-height: 1.5; }
.iot-protocol-card code { font-size: 11px; background: var(--surface, #fff); padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border, #e2e8f0); display: inline-block; }

/* Tables */
.iot-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.iot-table th { text-align: left; padding: 10px 12px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-secondary, #64748b); border-bottom: 2px solid var(--border, #e2e8f0); letter-spacing: 0.5px; }
.iot-table td { padding: 10px 12px; border-bottom: 1px solid var(--border, #e2e8f0); }
.iot-table tr { transition: background 0.15s; }
.iot-table tr:hover { background: var(--surface-alt, #f7f8fa); }

/* Rule cards */
.iot-rule-example {
  padding: 14px 18px; background: linear-gradient(135deg, #EBF4FF, #F0FFF4);
  border: 1px solid #BEE3F8; border-radius: 12px; margin-bottom: 16px;
  font-size: 13px;
}
.iot-rule-example code { background: rgba(0,0,0,0.06); padding: 3px 8px; border-radius: 6px; font-size: 12px; }
.iot-rules-list { display: flex; flex-direction: column; gap: 10px; }
.iot-rule-card {
  padding: 18px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px; background: var(--surface, #fff);
  transition: box-shadow 0.2s;
}
.iot-rule-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.iot-rule-disabled { opacity: 0.45; }
.iot-rule-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.iot-rule-name { font-size: 15px; font-weight: 700; }
.iot-rule-condition { margin-bottom: 6px; }
.iot-rule-condition code { font-size: 13px; color: var(--primary, #1B2A4A); background: var(--surface-alt, #f7f8fa); padding: 5px 10px; border-radius: 6px; display: inline-block; }
.iot-rule-action { font-size: 12px; color: var(--text-secondary, #64748b); }

/* Alert cards */
.iot-alert-card {
  padding: 16px 18px; border-left: 4px solid #718096;
  background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0);
  border-radius: 0 12px 12px 0; margin-bottom: 10px;
  transition: box-shadow 0.2s;
}
.iot-alert-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.iot-alert-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.iot-alert-time { font-size: 12px; color: var(--text-secondary, #64748b); flex: 1; }
.iot-alert-body { font-size: 13px; color: var(--text-primary, #1a202c); line-height: 1.5; }

/* Detail page */
.iot-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.iot-detail-grid > div { font-size: 13px; }
.iot-detail-grid strong { display: block; font-size: 10px; text-transform: uppercase; color: var(--text-secondary, #64748b); letter-spacing: 0.5px; margin-bottom: 4px; font-weight: 700; }

.iot-endpoint-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.iot-endpoint { padding: 14px; background: var(--surface-alt, #f7f8fa); border-radius: 10px; border: 1px solid var(--border, #e2e8f0); font-size: 13px; }
.iot-endpoint pre { font-size: 11px; background: var(--surface, #fff); padding: 10px; border-radius: 6px; border: 1px solid var(--border, #e2e8f0); margin-top: 8px; overflow-x: auto; white-space: pre; }

@media (max-width: 768px) {
  .iot-hero-content { flex-direction: column; text-align: center; }
  .iot-hero-right { flex-direction: column; }
  .iot-stats-grid { grid-template-columns: repeat(3, 1fr); }
  .iot-device-grid { grid-template-columns: 1fr; }
  .iot-protocol-grid { grid-template-columns: 1fr; }
  .iot-tabs { gap: 0; }
  .iot-tab { padding: 8px 12px; font-size: 12px; }
  .iot-topology-svg { min-width: 600px; }
  .iot-type-grid { gap: 6px; }
  .wbgt-sites-grid { grid-template-columns: 1fr !important; }
}

/* ============================================
   WBGT Heat Stress Monitor
   ============================================ */
.wbgt-sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 20px;
}
.wbgt-site-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
}
.wbgt-site-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.wbgt-site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}
.wbgt-site-header h3 { margin: 0 0 4px; font-size: 16px; }
.wbgt-risk-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.wbgt-detail {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: var(--bg-secondary, #f7f8fa);
  border-radius: 8px;
}
.wbgt-detail-label { font-size: 11px; color: var(--text-secondary, #718096); margin-bottom: 2px; }
.wbgt-detail-value { font-size: 15px; font-weight: 600; color: var(--text-primary, #1a202c); }
.wbgt-site-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-secondary, #718096);
  font-size: 14px;
}
.wbgt-site-loading .spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border, #e2e8f0);
  border-top-color: var(--primary, #F7941D);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   My Profile Module
   ============================================ */

.prof-page { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* Header Card */
.prof-header-card { position: relative; border-radius: 16px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); }
.prof-header-bg { height: 120px; background: linear-gradient(135deg, #1B2A4A 0%, #2d4a7a 50%, #F7941D 150%); }
.prof-header-content { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 28px 24px; margin-top: -48px; position: relative; z-index: 2; flex-wrap: wrap; gap: 20px; }
.prof-header-left { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.prof-avatar-wrapper { position: relative; }
.prof-avatar { border-radius: 50%; background: linear-gradient(135deg, #F7941D, #E8850A); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; border: 4px solid var(--surface); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.prof-avatar-upload { position: absolute; bottom: 2px; right: 2px; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; border: 2px solid var(--surface); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; padding: 0; }
.prof-avatar-upload:hover { background: #E8850A; transform: scale(1.1); }
.prof-header-info { padding-bottom: 4px; }
.prof-name { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: 0; line-height: 1.3; }
.prof-role-badge { display: inline-block; padding: 3px 12px; background: rgba(247,148,29,0.12); color: #F7941D; border-radius: 50px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin: 6px 0; }
.prof-meta { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-secondary, #64748B); flex-wrap: wrap; }
.prof-meta svg { width: 14px; height: 14px; opacity: 0.6; }
.prof-meta-projects { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.prof-project-tag { padding: 2px 10px; background: var(--bg, #f1f5f9); border: 1px solid var(--border); border-radius: 50px; font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); }
.prof-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.prof-header-actions .btn { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }

/* Stats Grid */
.prof-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.prof-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; transition: all 0.2s; }
.prof-stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.prof-stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.prof-stat-value { font-size: 1.5rem; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.prof-stat-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* Two-Column Grid */
.prof-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Cards */
.prof-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.prof-card-muted { opacity: 0.85; }
.prof-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.prof-card-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; margin: 0; }
.prof-card-header h3 svg { opacity: 0.5; }
.prof-card-body { padding: 20px; }

/* Module Activity Bars */
.prof-module-bar { margin-bottom: 14px; }
.prof-module-bar:last-child { margin-bottom: 0; }
.prof-module-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 0.85rem; }
.prof-module-label span { color: var(--text-secondary); }
.prof-module-label strong { color: var(--text); font-size: 0.9rem; }
.prof-bar-track { height: 6px; background: var(--bg, #f1f5f9); border-radius: 3px; overflow: hidden; }
.prof-bar-fill { height: 100%; border-radius: 3px; transition: width 0.8s ease; min-width: 2px; }

/* Safety Culture Section */
.prof-culture-body { display: flex; align-items: center; gap: 28px; }
.prof-culture-ring { position: relative; flex-shrink: 0; }
.prof-culture-ring-val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; color: #F7941D; line-height: 1; }
.prof-culture-ring-val small { font-size: 0.65rem; font-weight: 600; opacity: 0.6; margin-top: 2px; }
.prof-culture-info { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.prof-level-badge { display: inline-block; padding: 4px 14px; border-radius: 50px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.prof-level-reactive { background: #FEE2E2; color: #DC2626; }
.prof-level-dependent { background: #FEF3C7; color: #D97706; }
.prof-level-independent { background: #D1FAE5; color: #059669; }
.prof-level-interdependent { background: #DBEAFE; color: #2563EB; }
.prof-culture-stat { display: flex; justify-content: space-between; font-size: 0.875rem; }
.prof-culture-stat span { color: var(--text-secondary); }
.prof-culture-stat strong { color: var(--text); }

/* Activity Feed */
.prof-activity-feed { max-height: 500px; overflow-y: auto; }
.prof-activity-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.prof-activity-item:last-child { border-bottom: none; }
.prof-activity-icon { width: 36px; height: 36px; min-width: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.prof-activity-content { flex: 1; min-width: 0; }
.prof-activity-title { font-size: 0.875rem; font-weight: 500; color: var(--text); line-height: 1.4; }
.prof-activity-meta { display: flex; gap: 10px; align-items: center; margin-top: 4px; font-size: 0.75rem; color: var(--text-secondary); }
.prof-activity-status { padding: 1px 8px; border-radius: 50px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; }
.prof-status-open, .prof-status-pending { background: #FEF3C7; color: #D97706; }
.prof-status-closed, .prof-status-completed, .prof-status-approved { background: #D1FAE5; color: #059669; }
.prof-status-in-progress, .prof-status-active { background: #DBEAFE; color: #2563EB; }
.prof-activity-more { text-align: center; padding: 12px; font-size: 0.8rem; color: var(--text-secondary); }

/* Info Grid */
.prof-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prof-info-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: var(--bg, #f8fafc); border-radius: 8px; }
.prof-info-label { font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.prof-info-value { font-size: 0.875rem; font-weight: 600; color: var(--text); }

/* Empty State */
.prof-empty { text-align: center; padding: 32px; color: var(--text-secondary); font-size: 0.9rem; }

/* Back Bar */
.prof-back-bar { display: flex; align-items: center; gap: 16px; }
.prof-back-bar h2 { font-size: 1.25rem; font-weight: 700; color: var(--text); margin: 0; }

/* Form */
.prof-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.prof-form-grid-1 { grid-template-columns: 1fr; max-width: 400px; }
.prof-form-group { display: flex; flex-direction: column; gap: 6px; }
.prof-form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.prof-required { color: #EF4444; }
.prof-form-actions { display: flex; gap: 10px; padding-top: 8px; }
.prof-pw-requirements { margin-bottom: 16px; font-size: 0.8rem; color: var(--text-secondary); }

/* Toggle Preferences */
.prof-prefs-list { display: flex; flex-direction: column; gap: 0; }
.prof-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 0.9rem; color: var(--text); }
.prof-toggle-row:last-child { border-bottom: none; }
.prof-toggle-input { display: none; }
.prof-toggle-switch { width: 44px; height: 24px; background: var(--border); border-radius: 12px; position: relative; transition: all 0.2s; flex-shrink: 0; }
.prof-toggle-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.prof-toggle-input:checked + .prof-toggle-switch { background: #F7941D; }
.prof-toggle-input:checked + .prof-toggle-switch::after { left: 23px; }

/* Security Log */
.prof-security-log { display: flex; flex-direction: column; gap: 0; }
.prof-sec-event { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.prof-sec-event:last-child { border-bottom: none; }
.prof-sec-event-icon { width: 36px; height: 36px; min-width: 36px; background: rgba(59,130,246,0.1); color: #3B82F6; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.prof-sec-event-time { margin-left: auto; font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; }

/* Permissions Grid */
.prof-perms-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.prof-perm-tag { padding: 4px 12px; background: var(--bg, #f1f5f9); border: 1px solid var(--border); border-radius: 50px; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }

/* Profile Responsive */
@media (max-width: 768px) {
  .prof-header-content { flex-direction: column; align-items: flex-start; }
  .prof-header-left { flex-direction: column; align-items: flex-start; }
  .prof-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .prof-grid-2 { grid-template-columns: 1fr; }
  .prof-info-grid { grid-template-columns: 1fr; }
  .prof-form-grid { grid-template-columns: 1fr; }
  .prof-culture-body { flex-direction: column; text-align: center; }
  .prof-header-actions { width: 100%; }
}

/* ══════════════════════════════════════════════
   Contractor Module — Card Grid & Passport
   ═══════���══════════════════════════════════════ */
.con-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}
.con-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.con-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
  border-color: var(--accent, #F7941D);
}
.con-card-stat {
  text-align: center;
  padding: 8px 4px;
  background: var(--bg-secondary, #f4f5f7);
  border-radius: 8px;
}
.con-card-stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text, #1a1a2e);
  line-height: 1.2;
}
.con-card-stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary, #888);
  font-weight: 500;
  margin-top: 2px;
}
.con-passport-card {
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

@media (max-width: 768px) {
  .con-card-grid { grid-template-columns: 1fr; }
  .con-passport-card [style*="grid-template-columns:repeat(5"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .con-passport-card [style*="grid-template-columns:1fr 1fr;"] {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   Report Template — Branding-Only Editor (v2)
   ========================================================================== */
.rt-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.rt-editor-form h3 {
  font-size: 0.9rem;
  color: var(--text-primary, #1B2A4A);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.rt-editor-form label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary, #64748b);
  margin-bottom: 10px;
}
.rt-editor-form input[type="text"],
.rt-editor-form input[type="number"],
.rt-editor-form select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 6px;
  font-size: 0.85rem;
  margin-top: 4px;
  background: #fff;
}
.rt-editor-form input[type="color"] {
  width: 100%;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 6px;
  margin-top: 4px;
  cursor: pointer;
}
.rt-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.rt-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.rt-logo-drop {
  border: 1px dashed var(--border-light, #e2e8f0);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfc;
}
.rt-logo-drop label { margin-bottom: 2px; }
.rt-logo-drop .btn { font-size: 0.75rem; padding: 4px 10px; }
.rt-token-chip {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  margin: 2px 1px;
  border: 1px solid transparent;
  transition: border-color 0.1s;
}
.rt-token-chip:hover { border-color: #6366f1; }

/* Sticky live preview panel */
.rt-editor-preview {
  position: sticky;
  top: 0;
}
.rt-preview-frame {
  background: #fff;
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  min-height: 420px;
  max-height: 70vh;
  overflow: auto;
}
.rt-page {
  aspect-ratio: 210 / 297; /* A4 */
  padding: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.rt-page-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 10px 14px;
  font-size: 0.8em;
  font-weight: 500;
  min-height: 38px;
}
.rt-h-cell { display: flex; align-items: center; }
.rt-h-left   { justify-content: flex-start; }
.rt-h-center { justify-content: center; text-align: center; }
.rt-h-right  { justify-content: flex-end; text-align: right; }
.rt-accent-bar { height: 3px; }
.rt-page-body {
  flex: 1;
  padding: 18px;
  font-size: 0.85em;
  color: #334155;
  line-height: 1.5;
}
.rt-page-body p { margin: 2px 0; }
.rt-page-footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 8px 14px;
  font-size: 0.72em;
  border-top: 1px solid #f1f5f9;
}
.rt-f-cell { display: flex; align-items: center; }
.rt-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-35deg);
  font-size: 3rem;
  font-weight: 800;
  color: rgba(0, 0, 0, 0.06);
  pointer-events: none;
  letter-spacing: 0.1em;
  white-space: nowrap;
  z-index: 1;
}
@media (max-width: 900px) {
  .rt-editor-layout { grid-template-columns: 1fr; }
  .rt-grid-2, .rt-grid-3 { grid-template-columns: 1fr; }
  .rt-editor-preview { position: static; }
}
