/* ============================================================
   EMOJI FONT FALLBACK FIX - Prevents "�" characters
   Must be FIRST in the file to take precedence
   ============================================================ */

/* Force emoji rendering with fallback fonts - PRIMARY FIX */
body, 
button, 
input, 
select, 
textarea,
.status-badge, 
.criticality-badge, 
.form-section-header,
.nav-item,
.card-header h3,
[data-i18n],
.sidebar-user .name,
.sidebar-user .role,
.toast,
.modal h3,
.breadcrumb-bar,
.topbar h1,
.comment-meta,
.participant-name,
.assign-title,
.dev-title,
.stat-card .stat-label,
.voice-panel h3,
.ocr-modal-title,
.ocr-drop-title,
.att-badge,
.ocr-badge,
.sc-badge-btn,
.participant-badge,
.badge,
.priority-badge {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "EmojiOne Color", "Twemoji Mozilla", "Windows 10 Emoji", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif !important;
}

/* Specific fix for elements that might contain emoji-only content */
.emoji-only, 
[class*="icon-"],
.status-badge::before,
.criticality-badge::before {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif !important;
}

/* Windows 7/8 fallback - use system-ui which may have basic emoji support */
@supports not (font-family: "Segoe UI Emoji") {
  body, button, input, select, textarea {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif !important;
  }
}

/* Ensure monospace fonts don't break emoji display */
code, pre, .mono, .dev-id, .batch-badge, .ocr-raw-text {
  font-family: "Consolas", "Courier New", "SF Mono", monospace !important;
}

/* Fix for any remaining symbol characters - broad coverage */
* {
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
}

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --blue: #3b82f6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  /* ✅ FIX: Added emoji/symbol fonts to prevent "�" characters */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}

/* ---- Login ---- */
.login-page {
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}
.login-logo h1 { font-size: 28px; margin-top: 10px; font-weight: 700; }
.login-logo p { opacity: 0.85; margin-top: 4px; }

.login-card {
  background: white;
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 24px; color: var(--gray-800); }

.mfa-hint { color: var(--gray-500); font-size: 14px; margin-bottom: 20px; }
.otp-input { text-align: center; font-size: 24px; letter-spacing: 8px; font-weight: 700; }

/* ---- Password Toggle ---- */
.pwd-wrap { position: relative; display: flex; align-items: center; }
.pwd-wrap input { width: 100%; padding-right: 42px !important; }
.pwd-eye {
  position: absolute;
  right: 9px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  flex-shrink: 0;
  line-height: 0;
}
.pwd-eye:hover { color: var(--gray-700); background: var(--gray-100); }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
input[list]::-webkit-calendar-picker-indicator { display: none !important; }
input[list] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 16px;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.2s;
  outline: none;
  font-family: var(--font);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}
.form-group textarea { resize: none; min-height: 80px; overflow: hidden; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
  font-family: var(--font);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1.5px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; margin-top: 8px; }

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-logo-text h2 { font-size: 16px; font-weight: 700; }
.sidebar-logo-text p { font-size: 11px; color: var(--gray-400); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.nav-section { padding: 8px 16px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gray-400); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav-admin-section, #nav-vtest-section, #nav-regulatory-section, #nav-compliance-section {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.10);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  margin: 2px 6px;
  min-height: 34px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--gray-400);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-radius: 8px;
  text-decoration: none;
  box-sizing: border-box;
  overflow: hidden;
}
.nav-item > span[data-i18n] {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.nav-item > span[id] {
  flex-shrink: 0;
  margin-left: auto;
  max-width: 40px;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: rgba(26,115,232,0.25); color: var(--primary); font-weight: 600; border-right: none; }
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }
.btn-logout { background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 4px; border-radius: 4px; }
.btn-logout:hover { color: white; }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---- Breadcrumb Bar ---- */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 24px;
  height: 34px;
  background: var(--gray-50, #f9fafb);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
}
.bc-home {
  display: flex;
  align-items: center;
  color: var(--gray-400);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.bc-home:hover { color: var(--primary); }
.bc-crumbs { display: flex; align-items: center; gap: 0; overflow: hidden; }
.bc-sep { color: var(--gray-300); margin: 0 4px; flex-shrink: 0; font-size: 14px; line-height: 1; }
.bc-item { display: inline-flex; align-items: center; }
.bc-link {
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
  border-radius: 4px;
  padding: 2px 4px;
  transition: background 0.15s;
  white-space: nowrap;
}
.bc-link:hover { background: rgba(26,115,232,0.08); }
.bc-group {
  color: var(--gray-500);
  font-weight: 500;
  white-space: nowrap;
}
.bc-current {
  color: var(--gray-700);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page { flex: 1; overflow-y: auto; padding: 24px; display: none; }
.page.active { display: block; }

/* ---- Dashboard ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card .stat-label { font-size: 12px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--gray-800); }
.stat-card .stat-icon { font-size: 24px; }

/* ---- Deviations List ---- */
.card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 16px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 700; flex: 1; }
.card-body { padding: 20px; }

.deviation-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.deviation-item:last-child { border-bottom: none; }
.deviation-item:hover { background: var(--gray-50); }
.deviation-item .dev-id { font-size: 12px; color: var(--gray-400); font-weight: 600; white-space: nowrap; }
.deviation-item .dev-title { flex: 1; font-size: 14px; font-weight: 600; color: var(--gray-800); }
.deviation-item .dev-meta { font-size: 12px; color: var(--gray-500); white-space: nowrap; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.status-development { background: #fef3c7; color: #92400e; }
.status-review { background: #dbeafe; color: #1e40af; }
.status-approval { background: #ede9fe; color: #5b21b6; }
.status-approved    { background: #d1fae5; color: #065f46; }
.status-closed      { background: #d1fae5; color: #14532d; }
.status-awaiting_qa { background: #ffedd5; color: #9a3412; }
.status-rejected    { background: #fee2e2; color: #991b1b; }

/* ---- Split Screen Deviation Editor ---- */
.split-screen {
  display: flex;
  gap: 16px;
  min-height: 600px;
  align-items: flex-start;
}
.split-screen .editor-panel { order: 1; }
.split-screen .voice-panel  { order: 2; }

.voice-panel {
  flex: 1;
  min-width: 0;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  gap: 20px;
  position: sticky;
  top: 20px;
  align-self: flex-start;
  height: 60vh;
  min-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(100,100,100,.2) transparent;
}
.voice-panel::-webkit-scrollbar { width: 6px; }
.voice-panel::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.voice-panel::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
.voice-panel::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

/* Action buttons at top of voice panel (Save / PDF / Print) */
.voice-panel-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--gray-200);
}

.voice-panel h3 { font-size: 14px; font-weight: 700; color: var(--gray-700); text-align: center; }

/* Voice panel tab content */
.voice-webapi-content,
.voice-win-content {
  width: 100%;
}

/* Voice mode tabs */
.voice-mode-tabs { display: flex; gap: 4px; background: var(--gray-100); border-radius: 8px; padding: 3px; width: 100%; }
.voice-mode-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 4px; font-size: 11px; font-weight: 600; border: none; border-radius: 6px;
  background: transparent; color: var(--gray-500); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.voice-mode-tab:hover { background: rgba(255,255,255,.7); color: var(--gray-700); }
.voice-mode-tab.active { background: white; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

#voicePanelWebspeech, #voicePanelWinh, #voicePanelOsdictate { width: 100%; }

.voice-field-selector { width: 100%; }
.voice-field-selector label { font-size: 12px; font-weight: 600; color: var(--gray-500); display: block; margin-bottom: 6px; }
.voice-field-selector select { width: 100%; }

.mic-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.mic-rings {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(26, 115, 232, 0.2);
  transition: all 0.3s;
}
.mic-ring-1 { width: 140px; height: 140px; }
.mic-ring-2 { width: 110px; height: 110px; }
.mic-ring-3 { width: 80px; height: 80px; }

.mic-btn {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,115,232,0.4);
  transition: all 0.2s;
}
.mic-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.mic-btn.recording { background: var(--danger); animation: pulse-mic 1.2s infinite; }
.mic-btn svg { color: white; }

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 4px 20px rgba(239,68,68,0.4); }
  50% { box-shadow: 0 4px 40px rgba(239,68,68,0.8); }
}

.mic-ring.active {
  animation: ring-pulse 1.2s ease-out infinite;
  border-color: rgba(239,68,68,0.4);
}
.mic-ring-2.active { animation-delay: 0.2s; }
.mic-ring-3.active { animation-delay: 0.4s; }

@keyframes ring-pulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.1); opacity: 0; }
}

.voice-status { font-size: 12px; color: var(--gray-500); text-align: center; }
.voice-status.listening { color: var(--danger); font-weight: 600; }

.voice-transcript {
  width: 100%;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  color: var(--gray-600);
  min-height: 60px;
  word-break: break-word;
}

/* ---- Workflow Buttons ---- */
.workflow-buttons {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  margin-bottom: 16px;
}
.workflow-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: 10px;
  border: 2px solid var(--gray-200);
  background: white;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  color: var(--gray-600);
  font-family: var(--font);
}
.workflow-btn:hover:not(:disabled) { transform: translateY(-1px); }
.workflow-btn.wf-dev { border-color: #f59e0b; }
.workflow-btn.wf-dev:hover, .workflow-btn.wf-dev.current { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.workflow-btn.wf-review { border-color: #3b82f6; }
.workflow-btn.wf-review:hover, .workflow-btn.wf-review.current { background: #dbeafe; color: #1e40af; border-color: #3b82f6; }
.workflow-btn.wf-approval { border-color: #8b5cf6; }
.workflow-btn.wf-approval:hover, .workflow-btn.wf-approval.current { background: #ede9fe; color: #5b21b6; border-color: #8b5cf6; }
.workflow-btn.wf-awaiting_qa { border-color: #f97316; }
.workflow-btn.wf-awaiting_qa:hover, .workflow-btn.wf-awaiting_qa.current { background: #ffedd5; color: #9a3412; border-color: #f97316; }
.workflow-btn.wf-closed { border-color: #22c55e; }
.workflow-btn.wf-closed:hover, .workflow-btn.wf-closed.current { background: #dcfce7; color: #14532d; border-color: #22c55e; }
.workflow-btn.current { font-weight: 800; }
.workflow-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.workflow-arrow { color: var(--gray-300); font-size: 16px; flex-shrink: 0; }

/* ---- Workflow Participants (Reviewers / Approvers) ---- */
.wa-checklist { border: 1.5px solid var(--gray-200); border-radius: 8px; max-height: 160px; overflow-y: auto; background: #fff; }
.wa-checklist-empty { padding: 10px 12px; font-size: 12px; color: var(--gray-400); font-style: italic; }
.wa-checklist label { display: flex; align-items: center; gap: 9px; padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--gray-700); border-radius: 0; transition: background .1s; }
.wa-checklist label:hover { background: var(--gray-50); }
.wa-checklist label input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--primary); flex-shrink: 0; cursor: pointer; }
.wa-checklist label .wa-role-tag { font-size: 11px; color: var(--gray-400); margin-left: 2px; }
.wa-section-label { font-size: 12px; font-weight: 700; color: var(--gray-600); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.participants-card { border: 1.5px solid var(--gray-200); border-radius: 10px; overflow: hidden; }
.participants-card-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--gray-50); font-size: 12px; font-weight: 700; color: var(--gray-600); border-bottom: 1px solid var(--gray-200); }
.participants-list { padding: 0; }
.participants-empty { padding: 12px 14px; font-size: 12px; color: var(--gray-400); font-style: italic; }
.participant-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.participant-row:last-child { border-bottom: none; }
.participant-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.participant-info { flex: 1; min-width: 0; }
.participant-name { font-weight: 600; color: var(--gray-800); font-size: 13px; }
.participant-role { font-size: 11px; color: var(--gray-500); margin-top: 1px; }
.participant-status { margin-left: auto; }
.participant-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-completed { background: #dcfce7; color: #14532d; }
.badge-approved { background: #dcfce7; color: #14532d; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-qa { background: #ffedd5; color: #9a3412; }
.badge-approved.badge-qa { background: #dcfce7; color: #14532d; }
.badge-rejected.badge-qa  { background: #fee2e2; color: #991b1b; }
.participant-actions { display: flex; gap: 6px; flex-shrink: 0; }
.participant-actions .btn { font-size: 11px; padding: 4px 10px; }

/* ---- Editor Panel ---- */
.editor-panel {
  flex: 2;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: visible;
  min-width: 0;
}

.editor-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}
.editor-header h3 { font-size: 17px; font-weight: 700; flex: 1; }
.deviation-ref-top {
  font-size: 28px;
  font-weight: 800;
  color: #1e40af;
  letter-spacing: -0.5px;
  line-height: 1.15;
}
.deviation-ref-top[data-is-new="true"] {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  letter-spacing: 0;
}
.deviation-ref-bottom {
  font-size: 14px;
  color: #6b7280;
  text-align: center;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--gray-100);
  border-radius: 8px;
  margin: 20px 0 4px;
  font-weight: 500;
}
.deviation-ref-bottom span:last-child {
  font-weight: 700;
  color: #1e40af;
}

/* Bottom reference bar — deviation & change control */
.bottom-reference {
  text-align: center;
  padding: 16px;
  margin-top: 20px;
  border-top: 1px solid #e5e7eb;
  font-size: 14px;
  color: #6b7280;
}
.bottom-reference .dev-id {
  font-weight: bold;
  color: #1e40af;
}
.bottom-reference .dev-status {
  font-weight: normal;
}

.editor-body { padding: 20px; border-radius: 0 0 12px 12px; }

.editor-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ---- Form Sections (collapsible) ---- */
.form-section {
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: visible;
}
.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--gray-50);
  cursor: pointer;
  user-select: none;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--gray-200);
  transition: background 0.15s;
  border-radius: 9px 9px 0 0;
}
.form-section-header:hover { background: #e8f0fe; }
.section-chevron { transition: transform 0.2s; color: var(--gray-400); flex-shrink: 0; }
.form-section-body { padding: 16px; border-radius: 0 0 9px 9px; }
.badge-reviewer {
  font-size: 10px;
  font-weight: 600;
  background: #fef3c7;
  color: #d97706;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.field-highlight {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15) !important;
}

/* ---- Comments ---- */
.comments-section { margin-top: 20px; }
.comment-item {
  padding: 12px;
  background: var(--gray-50);
  border-radius: 8px;
  margin-bottom: 8px;
}
.comment-meta { font-size: 11px; color: var(--gray-400); margin-bottom: 4px; }
.comment-content { font-size: 13px; color: var(--gray-700); }
.comment-input-row { display: flex; gap: 8px; margin-top: 12px; }
.comment-input-row input { flex: 1; }
.sc-badge-btn {
  display: inline-flex; align-items: center; gap: 3px;
  margin-left: auto; margin-right: 8px; flex-shrink: 0;
  padding: 0; border: none; background: none;
  font-size: 16px; cursor: pointer;
  transition: transform 0.15s;
}
.sc-badge-btn:hover { transform: scale(1.2); }

/* ---- Analytics ---- */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  padding: 20px;
}
.chart-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--gray-700); }

.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--gray-600); width: 120px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 22px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; }
.bar-count { font-size: 11px; font-weight: 700; color: white; }

.pie-chart { display: flex; flex-wrap: wrap; gap: 8px; }
.pie-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.pie-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ---- Admin ---- */
.users-table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.users-table th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--gray-200); background: var(--gray-50); white-space: nowrap; }
.users-table td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: none; }
.users-table tbody tr:nth-child(even) { background: #f9fafb; }
.users-table tbody tr:hover { background: #eff6ff; }
.users-table .action-cell { display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; }
.badge-active   { display:inline-block;padding:2px 8px;border-radius:12px;font-size:11px;font-weight:600;background:#d1fae5;color:#065f46; }
.badge-disabled { display:inline-block;padding:2px 8px;border-radius:12px;font-size:11px;font-weight:600;background:#fee2e2;color:#991b1b; }

/* ---- AI Writing Assistant ---- */
.ai-panel-header { display:flex;align-items:center;gap:10px;padding:10px 12px;background:linear-gradient(135deg,#ede9fe 0%,#dbeafe 100%);border-radius:10px;margin-bottom:12px;border:1px solid #c4b5fd; }
.ai-action-grid { 
  display: grid !important; 
  grid-template-columns: repeat(4, 1fr) !important; 
  gap: 8px !important; 
  width: 100% !important; 
}
.ai-action-btn { 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  padding: 8px 6px !important; 
  background: #f8fafc; 
  border: 1px solid #e2e8f0; 
  border-radius: 8px; 
  font-size: 12px; 
  font-weight: 500; 
  color: #334155; 
  cursor: pointer; 
  transition: all .15s; 
  text-align: center !important; 
  justify-content: center !important; 
  width: 100% !important; 
  white-space: nowrap !important; 
}
.ai-action-btn:hover { background:#eff6ff;border-color:#93c5fd;color:#1d4ed8; }
.ai-action-btn:active { transform:scale(.97); }
.ai-action-btn:disabled { opacity:.4;cursor:not-allowed; }
.ai-suggestion-box { font-size:13px;color:#1e293b;line-height:1.7;padding:12px;background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;min-height:60px;max-height:220px;overflow-y:auto;white-space:pre-wrap;word-break:break-word; }
.ai-output-actions { display:flex;gap:12px;margin-top:16px;padding-top:12px;border-top:1px solid #e5e7eb;flex-wrap:wrap; }
.ai-output-actions .btn-accept { padding:8px 20px;font-size:14px;font-weight:500;border-radius:6px;cursor:pointer;transition:all .2s;background:#22c55e;color:#fff;border:none; }
.ai-output-actions .btn-accept:hover { background:#16a34a; }
.ai-output-actions .btn-copy { padding:8px 20px;font-size:14px;font-weight:500;border-radius:6px;cursor:pointer;transition:all .2s;background:#3b82f6;color:#fff;border:none; }
.ai-output-actions .btn-copy:hover { background:#2563eb; }
.ai-output-actions .btn-dismiss { padding:8px 20px;font-size:14px;font-weight:500;border-radius:6px;cursor:pointer;transition:all .2s;background:#ef4444;color:#fff;border:none; }
.ai-output-actions .btn-dismiss:hover { background:#dc2626; }
.ai-spinner { width:28px;height:28px;border:3px solid #e2e8f0;border-top-color:#7c3aed;border-radius:50%;animation:spin .7s linear infinite;margin:0 auto; }
@keyframes spin { to { transform:rotate(360deg); } }
.field-highlight { animation:fieldPulse .6s; }
@keyframes fieldPulse { 0%,100%{box-shadow:none} 50%{box-shadow:0 0 0 3px #a5b4fc;} }

/* ---- MFA Setup ---- */
.mfa-setup { text-align: center; }
.mfa-qr { display: inline-block; padding: 12px; background: white; border: 1px solid var(--gray-200); border-radius: 8px; }
.mfa-secret { font-family: monospace; background: var(--gray-100); padding: 8px 12px; border-radius: 6px; font-size: 12px; letter-spacing: 2px; word-break: break-all; margin: 12px 0; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal {
  background: white;
  border-radius: 16px;
  padding: 30px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---- Toast ---- */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

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

/* ---- Empty States ---- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state svg { margin-bottom: 12px; }
.empty-state p { font-size: 15px; font-weight: 500; }
.empty-state span { font-size: 13px; }

/* ---- Role badge ---- */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.role-writer { background: #fef3c7; color: #92400e; }
.role-reviewer { background: #dbeafe; color: #1e40af; }
.role-approver { background: #d1fae5; color: #065f46; }
.role-admin { background: #fee2e2; color: #991b1b; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-gray { color: var(--gray-500); }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }

/* ---- OCR Upload Modal ---- */
.ocr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  padding: 16px;
}

.ocr-modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 1100px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  overflow: hidden;
}

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

.ocr-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ocr-modal-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 3px;
}

.ocr-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

.ocr-left-panel {
  width: 42%;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--gray-50);
  overflow: hidden;
}

.ocr-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

.ocr-panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-400);
  margin-bottom: 10px;
}

.ocr-preview-area {
  flex: 1;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: white;
  display: flex;
  flex-direction: column;
}

.ocr-right-content {
  flex: 1;
  overflow-y: auto;
}

.ocr-drop-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  gap: 8px;
  min-height: 200px;
}

.ocr-drop-zone:hover, .ocr-drop-zone.drag-over {
  background: var(--primary-light);
}

.ocr-drop-icon { font-size: 48px; }
.ocr-drop-title { font-size: 15px; font-weight: 600; color: var(--gray-700); }
.ocr-drop-subtitle { font-size: 12px; color: var(--gray-400); }

.ocr-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.ocr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  height: 100%;
}

.ocr-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
}

.ocr-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.ocr-progress-bar {
  width: 100%;
  max-width: 300px;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.ocr-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #5ba4ff);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.ocr-results {
  padding: 4px 0;
}

.ocr-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ocr-raw-text {
  width: 100%;
  height: 140px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  color: var(--gray-700);
  resize: vertical;
  background: var(--gray-50);
  line-height: 1.5;
}

.ocr-raw-text:focus {
  outline: none;
  border-color: var(--primary);
}

.ocr-error {
  padding: 30px;
  text-align: center;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}

/* ---- OCR source badge ---- */
.ocr-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.att-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  margin-left: 6px;
  cursor: pointer;
  vertical-align: middle;
}

/* ---- Criticality badges ---- */
.criticality-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid;
}
.crit-incident {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}
.crit-minor {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}
.crit-major {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}
.crit-critical {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
  font-weight: 800;
}

/* ---- Criticality radio group in editor ---- */
.crit-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.crit-radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  flex: 1 1 180px;
  min-width: 160px;
  background: #fff;
  transition: border-color .15s, background .15s, box-shadow .15s;
  user-select: none;
}
.crit-radio-option:hover {
  border-color: #1a73e8;
  background: #f0f6ff;
}
.crit-radio-option.selected {
  border-width: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.crit-radio-option.selected[data-val="incident"] { border-color: #0369a1; background: #f0f9ff; }
.crit-radio-option.selected[data-val="minor"]    { border-color: #15803d; background: #f0fdf4; }
.crit-radio-option.selected[data-val="major"]    { border-color: #c2410c; background: #fff7ed; }
.crit-radio-option.selected[data-val="critical"] { border-color: #b91c1c; background: #fef2f2; }
.crit-radio-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2.5px solid transparent;
}
.crit-radio-dot.crit-incident { background: #bae6fd; border-color: #0369a1; }
.crit-radio-dot.crit-minor    { background: #bbf7d0; border-color: #15803d; }
.crit-radio-dot.crit-major    { background: #fed7aa; border-color: #c2410c; }
.crit-radio-dot.crit-critical { background: #fecaca; border-color: #b91c1c; }
.crit-radio-text { display: flex; flex-direction: column; gap: 1px; }
.crit-radio-label { font-weight: 700; font-size: 13px; color: #1e293b; }
.crit-radio-desc  { font-size: 11px; color: var(--gray-400); }
.crit-radio-group.disabled .crit-radio-option {
  pointer-events: none;
  opacity: .55;
}

/* Large modal for view original */
.modal.modal-lg {
  max-width: 860px;
  width: 95%;
}

/* ---- Bulk Export / Selection ---- */
.export-drop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  border-radius: 6px;
  text-align: left;
  transition: background 0.12s;
}
.export-drop-item:hover { background: var(--gray-100); }

.deviation-item .dev-checkbox {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.deviation-item .dev-checkbox input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
}
.deviation-item.selected {
  background: #eff6ff;
  border-left: 3px solid var(--primary);
}
.deviation-item.selected:hover { background: #dbeafe; }

.dev-row-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

/* ── List column-header rows ─────────────────────────────────────────── */
.col-hdr {
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  position: sticky;
  top: 0;
  z-index: 3;
  user-select: none;
}
.col-hdr > * { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* ─── Shared table scroll wrapper ─── */
.deviations-table-wrap,
.recent-table-wrap,
.assign-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}
.deviations-table-wrap > div,
.recent-table-wrap > div,
.assign-table-wrap > div { min-width: min-content; }

/* ─── All Deviations: ☐ | ID | Title | Criticality | Status | Location | Due | Created ─── */
.col-hdr-devs,
.dev-grid-row  { grid-template-columns: 28px 82px minmax(120px,200px) 90px 90px 100px 82px 84px; min-width: 772px; }
.dev-grid-row  { display: grid !important; gap: 8px; align-items: center; cursor: pointer; }
.dev-grid-row > * { min-width: 0; overflow: hidden; }
.dev-grid-row .dev-col-trunc { text-overflow: ellipsis; white-space: nowrap; }

/* ─── Dashboard Recent: ID | Title | Status | Created By | Date ─── */
.col-hdr-recent,
.recent-grid-row { grid-template-columns: 82px minmax(120px,1fr) 90px 160px 84px; min-width: 608px; }
.recent-grid-row { display: grid !important; gap: 8px; align-items: center; cursor: pointer; }
.recent-grid-row > * { min-width: 0; overflow: hidden; }
.recent-grid-row .recent-title { text-overflow: ellipsis; white-space: nowrap; }

/* ─── My Assignments: ID | Title | Criticality | Due Date | Task ─── */
.col-hdr-assign,
.assign-grid-row { grid-template-columns: 82px minmax(120px,220px) 90px 110px 160px; min-width: 634px; }
.assign-grid-row { display: grid !important; gap: 8px; align-items: center; cursor: default; }
.assign-grid-row > * { min-width: 0; overflow: hidden; }
.assign-grid-row .assign-title { text-overflow: ellipsis; white-space: nowrap; }
.assign-grid-row button { white-space: nowrap; font-size: 11px; padding: 5px 10px; }

/* Export Modal Filters */
.export-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.export-filter-grid .form-group { margin: 0; }
.export-filter-grid label { font-size: 12px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 4px; }
.export-filter-grid input, .export-filter-grid select {
  width: 100%; padding: 7px 10px; border-radius: 6px;
  border: 1.5px solid var(--gray-200); font-size: 13px; box-sizing: border-box;
}
.export-statuses { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.export-statuses label { display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }

/* ---- Custom Scrollbar — subtle and modern ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(100, 100, 100, 0.3);
  border-radius: 10px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 100, 100, 0.5);
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 100, 100, 0.3) transparent;
}

/* ---- Panel Save button ---- */
.floating-save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
  transition: background .15s, box-shadow .15s;
  font-family: var(--font);
}
.floating-save-btn:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.floating-save-btn:active {
  background: #1e40af;
}

.submit-review-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: #eab308;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  font-family: var(--font);
  transition: background .15s;
}
.submit-review-btn:hover {
  background-color: #ca8a04;
}
.submit-review-btn:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

/* ─── Table-based list layouts ─────────────────────────────────────────── */
.all-deviations-table,
.my-assignments-table,
.dashboard-recent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Sticky column headers */
.all-deviations-table thead,
.my-assignments-table thead,
.dashboard-recent-table thead {
  position: sticky;
  top: 0;
  z-index: 3;
}
.all-deviations-table th,
.my-assignments-table th,
.dashboard-recent-table th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  padding: 7px 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}

/* Table data cells */
.all-deviations-table td,
.my-assignments-table td,
.dashboard-recent-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  overflow: hidden;
}
.all-deviations-table tbody tr:last-child td,
.my-assignments-table tbody tr:last-child td,
.dashboard-recent-table tbody tr:last-child td { border-bottom: none; }

/* Row hover */
.all-deviations-table tbody tr:hover,
.dashboard-recent-table tbody tr:hover { background: var(--gray-50); }
.my-assignments-table tbody tr:not(.assign-section-hdr):hover { background: var(--gray-50); }

/* Selected rows (All Deviations) */
.all-deviations-table tr.selected { background: #eff6ff !important; }
.all-deviations-table tr.selected:hover { background: #dbeafe !important; }

/* Overdue rows (All Deviations) */
.all-deviations-table tr.overdue-row { background: #fff8f8 !important; }
.all-deviations-table tr.overdue-row td:first-child { border-left: 3px solid #dc2626; }

/* Checkbox cell */
.all-deviations-table .dev-checkbox { text-align: center; }
.all-deviations-table .dev-checkbox input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary);
}

/* Truncated text cells */
.all-deviations-table .dev-col-trunc,
.my-assignments-table .assign-title,
.dashboard-recent-table .recent-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 1px;
}

/* Min-widths & column widths — All Deviations */
.all-deviations-table         { min-width: 700px; }
.all-deviations-table th:nth-child(1) { width: 28px; }
.all-deviations-table th:nth-child(2) { width: 88px; }
.all-deviations-table th:nth-child(4) { width: 90px; }
.all-deviations-table th:nth-child(5) { width: 95px; }
.all-deviations-table th:nth-child(6) { width: 100px; }
.all-deviations-table th:nth-child(7) { width: 86px; }
.all-deviations-table th:nth-child(8) { width: 86px; }

/* Min-widths & column widths — Dashboard Recent */
.dashboard-recent-table         { min-width: 550px; }
.dashboard-recent-table th:nth-child(1) { width: 88px; }
.dashboard-recent-table th:nth-child(3) { width: 95px; }
.dashboard-recent-table th:nth-child(4) { width: 140px; }
.dashboard-recent-table th:nth-child(5) { width: 86px; }

/* Min-widths & column widths — My Assignments */
.my-assignments-table         { min-width: 580px; }
.my-assignments-table th:nth-child(1) { width: 88px; }
.my-assignments-table th:nth-child(3) { width: 90px; }
.my-assignments-table th:nth-child(4) { width: 110px; }
.my-assignments-table th:nth-child(5) { width: 160px; }

/* Section header rows in My Assignments */
.assign-section-hdr td {
  padding: 8px 10px 4px !important;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--gray-50) !important;
  border-top: 1px solid var(--gray-200);
}

/* Action button inside My Assignments */
.assign-action-btn {
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: inline-block;
}
.assign-action-btn:hover { opacity: .88; }

/* ── CC Editor: Match Deviation Module Font Sizes ─────────────────────────────
   Scoped to #cc-editor-root so the Deviation module is untouched.
   !important is required to override the many inline styles in the CC form JS.
───────────────────────────────────────────────────────────────────────────── */

/* Field labels */
#cc-editor-root label {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: #1f2937 !important;
  margin-bottom: 6px !important;
  display: block !important;
}

/* Inputs, selects, textareas — section form fields */
#cc-editor-root input:not([type="checkbox"]),
#cc-editor-root select,
#cc-editor-root textarea {
  font-size: 16px !important;
  padding: 10px 14px !important;
  font-family: inherit !important;
  border-radius: 8px !important;
  border: 1.5px solid #d1d5db !important;
  box-sizing: border-box !important;
}

/* Readonly (sequentially locked or non-writer) — light gray, no caret */
#cc-editor-root input[readonly]:not([type="checkbox"]),
#cc-editor-root textarea[readonly] {
  background: #f9fafb !important;
  cursor: default !important;
}

/* Disabled selects (sequential lock / non-writer) */
#cc-editor-root select:disabled {
  background: #f9fafb !important;
  opacity: 1 !important;
  cursor: default !important;
}

/* Mini-panel participant email inputs: compact size, blue border */
#cc-editor-root [id^="cc-mini-panel-"] input:not([type="checkbox"]),
#cc-editor-root [id^="cc-mini-wrap-"] input:not([type="checkbox"]) {
  font-size: 11px !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  border-color: #bfdbfe !important;
}

/* Placeholder text */
#cc-editor-root input::placeholder,
#cc-editor-root textarea::placeholder {
  font-size: 15px;
  color: #9ca3af;
}

/* Extension section date input (narrower width keeps layout intact) */
#cc-editor-root input[type="date"] {
  font-size: 14px !important;
  padding: 8px 10px !important;
}

/* Section header titles (the blue toggle divs) */
#cc-editor-root .card > div:first-child > div:first-child {
  font-size: 18px !important;
}

/* Participant / mini-panel body text */
#cc-editor-root [id^="cc-mini-panel-"] {
  font-size: 13px !important;
}

/* ── Readability: Enhanced Font Sizes ─────────────────────────────────────────
   Applies across: All CC, All Deviations, My Assignments, Analytics, forms.
   Mobile-safe — only increases base sizes proportionally.
───────────────────────────────────────────────────────────────────────────── */

/* Tables — All CC / All Deviations list pages */
.table-container table,
table.data-table,
#cc-table table,
#dev-table table {
  font-size: 14px;
}

/* Table headers */
.table-container th,
table.data-table th,
th {
  font-size: 12px;
}

/* Table cells */
.table-container td,
table.data-table td,
td {
  font-size: 14px;
}

/* Card headers (All CC / All Deviations page headers) */
.card-header h3 { font-size: 16px; }

/* Deviation list items */
.deviation-item .dev-title  { font-size: 15px; }
.deviation-item .dev-meta   { font-size: 13px; }
.deviation-item .dev-id     { font-size: 13px; }

/* Stat cards on dashboard / analytics */
.stat-card .stat-label { font-size: 13px; }

/* My Assignments action button */
.assign-action-btn { font-size: 12px; }

/* Analytics & report text */
.analytics-section p,
.report-text,
#analyticsContent p,
#analyticsContent li,
#analyticsContent td {
  font-size: 14px;
}

/* General page body text */
.main-content p,
.card-body p,
.card-body li {
  font-size: 14px;
  line-height: 1.6;
}

/* Badges / status chips */
.badge, .priority-badge {
  font-size: 12px;
}

/* Placeholder text — global */
input::placeholder,
textarea::placeholder {
  font-size: 14px;
  color: #9ca3af;
}

/* Help/hint text */
.hint-text, .field-hint, small {
  font-size: 13px;
}

/* Section comment panel — list item text */
#scPanelList,
#ccScPanelList {
  font-size: 13px;
}

/* ── Print styles ── */
/* ---- Print styles ---- */
.print-trace-footer {
  display: none;
}
@media (max-width: 900px) {
  .split-screen {
    flex-direction: column;
    align-items: stretch;
    min-height: unset;
  }
  .voice-panel {
    position: static;
    height: auto;
    width: 100%;
    overflow-y: visible;
  }
}

@media print {
  /* Hide all chrome — sidebar, header buttons, workflow bars, toasts */
  .sidebar, .editor-header .btn, #auditBtn, #viewOriginalBtn, #pdfBtn, #printBtn,
  .workflow-buttons, .floating-save-btn, #toast-container,
  .sc-badge-btn, #scPanel, #scPanelBackdrop,
  .nav-item, .nav-section, .sidebar-logo, .sidebar-user { display: none !important; }

  /* Make main content fill page */
  .app-shell { display: block; }
  .main-content { margin: 0; padding: 0; overflow: visible; }
  .editor-panel { box-shadow: none; border: none; border-radius: 0; }
  .editor-body { padding: 12px 0; }
  .form-section-header { background: none !important; }

  /* Traceability footer — always visible when printing */
  .print-trace-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9px;
    color: #6b7280;
    padding: 8px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    font-family: sans-serif;
  }

  /* Add bottom padding so body content doesn't overlap footer */
  body { padding-bottom: 40px; }

  /* Page setup */
  @page { margin: 15mm 12mm 25mm 12mm; }
}

/* Document Upload Styles */
.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.doc-item:hover {
  background: #f9fafb;
  border-color: #cbd5e1;
}

.doc-icon {
  font-size: 20px;
  margin-right: 10px;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-meta {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.doc-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.doc-remove-btn:hover {
  color: #ef4444;
  background: #fef2f2;
}

.analysis-section {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 6px;
}

.analysis-section-title {
  font-weight: 700;
  color: #166534;
  margin-bottom: 8px;
}

.analysis-change {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 12px;
}

/* ---- Profile & Security Page - Rounded Password Inputs ---- */
#page-profile .pwd-wrap input,
#page-profile input[type="password"] {
  border-radius: 40px !important;
  padding: 12px 20px !important;
  border: 1.5px solid var(--gray-200) !important;
  transition: all 0.2s ease;
}

#page-profile .pwd-wrap input:focus,
#page-profile input[type="password"]:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15) !important;
  outline: none !important;
}

/* Also style the eye button to match the rounded inputs */
#page-profile .pwd-wrap {
  position: relative;
}

#page-profile .pwd-eye {
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

#page-profile .pwd-eye:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* ===== FIX: AI buttons grid - 2 columns for better readability ===== */
.ai-action-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 10px !important;
  width: 100% !important;
}

.ai-action-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 10px 8px !important;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px !important;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  transition: all .15s;
  text-align: center !important;
  white-space: normal !important;
  word-break: keep-all;
  line-height: 1.4;
}

.ai-action-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.ai-action-btn:active {
  transform: scale(.97);
}

.ai-action-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* Override any inline styles */
.ai-action-grid[style*="grid-template-columns"] {
  grid-template-columns: repeat(2, 1fr) !important;
}

/* Force all buttons to be equal width */
.ai-action-btn {
  width: 100% !important;
  min-width: 0 !important;
  justify-content: center !important;
  text-align: center !important;
  white-space: nowrap !important;
  padding: 8px 6px !important;
}

/* Override any inline styles that set 2 columns */
.ai-action-grid[style*="grid-template-columns"] {
  grid-template-columns: repeat(4, 1fr) !important;
}

/* Hide duplicate Save/Submit buttons in Change Control that appeared after CSS changes */
#cc-editor-root .btn-primary.btn-sm {
  display: none !important;
}

/* ✅ FIX: Ensure all symbols and emojis render correctly (prevents "�" characters) */
.section-hint,
.info-icon,
.tip-text,
.bullet-point,
.form-section .section-hint,
[class*="hint"],
[class*="tip"] {
  font-family: "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif !important;
}

/* Ensure all text can render emojis and symbols */
body, input, textarea, select, button, .btn, .nav-item, .card, .modal {
  font-family: var(--font);
}

/* Fix for any remaining symbol characters */
[data-i18n]:has(emoji, symbol) {
  font-family: "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", sans-serif;
}

/* All Change Controls table - fit to content */
#all-cc-root table {
  table-layout: auto !important;
  width: 100% !important;
  min-width: auto !important;
}

#all-cc-root th,
#all-cc-root td {
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Title column - allow wrapping */
#all-cc-root th:nth-child(2),
#all-cc-root td:nth-child(2) {
  white-space: normal !important;
  min-width: 200px;
  max-width: 300px;
  word-break: break-word;
}

/* Remove fixed widths */
#all-cc-root th {
  width: auto !important;
  min-width: auto !important;
}