/* ==========================================================================
   Call Quality Assurance- Ekant - Core Design System & Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root,
[data-theme="light"] {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Executive Light Palette (Default) */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-hover: #f1f5f9;
  --border-color: #e2e8f0;
  --border-light: rgba(0, 0, 0, 0.06);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-faint: rgba(79, 70, 229, 0.08);
  --primary-glow: rgba(79, 70, 229, 0.18);

  --success: #10b981;
  --success-faint: rgba(16, 185, 129, 0.10);
  --success-border: rgba(16, 185, 129, 0.25);

  --warning: #f59e0b;
  --warning-faint: rgba(245, 158, 11, 0.10);
  --warning-border: rgba(245, 158, 11, 0.25);

  --danger: #ef4444;
  --danger-faint: rgba(239, 68, 68, 0.10);
  --danger-border: rgba(239, 68, 68, 0.25);

  --info: #0284c7;
  --info-faint: rgba(2, 132, 199, 0.10);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 25px rgba(79, 70, 229, 0.15);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-body: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1f2937;
  --bg-surface-hover: #283548;
  --bg-hover: #172033;
  --border-color: #2e3a51;
  --border-light: rgba(255, 255, 255, 0.08);

  --text-main: #f9fafb;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-faint: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.25);

  --success: #10b981;
  --success-faint: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);

  --warning: #f59e0b;
  --warning-faint: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);

  --danger: #ef4444;
  --danger-faint: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.3);

  --info: #06b6d4;
  --info-faint: rgba(6, 182, 212, 0.12);

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

/* Theme Toggle Button Styles */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.theme-icon-sun {
  display: none;
}

.theme-icon-moon {
  display: flex;
}

[data-theme="dark"] .theme-icon-sun {
  display: flex;
}

[data-theme="dark"] .theme-icon-moon {
  display: none;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

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

.sidebar {
  width: 270px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-badge {
  font-size: 10px;
  padding: 2px 6px;
  background-color: var(--primary-faint);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--primary-faint);
  color: var(--primary);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-elevated);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.user-role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--primary-faint);
  color: var(--primary);
  text-transform: uppercase;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.page-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.content-container {
  padding: 32px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Flash Messages */
.flash-alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flash-success {
  background-color: var(--success-faint);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.flash-error {
  background-color: var(--danger-faint);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* Card System */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stat Metrics Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.primary {
  background: var(--primary-faint);
  color: var(--primary);
}

.stat-icon.success {
  background: var(--success-faint);
  color: var(--success);
}

.stat-icon.warning {
  background: var(--warning-faint);
  color: var(--warning);
}

.stat-icon.danger {
  background: var(--danger-faint);
  color: var(--danger);
}

.stat-icon.info {
  background: var(--info-faint);
  color: var(--info);
}

.stat-meta {
  flex: 1;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 4px;
  line-height: 1.1;
}

.stat-subtext {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-align: center;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

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

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background-color: var(--danger-faint);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn-danger:hover {
  background-color: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}

.data-table th {
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background-color: var(--bg-surface-elevated);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.badge-success {
  background: var(--success-faint);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-faint);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-faint);
  color: var(--danger);
}

.badge-primary {
  background: var(--primary-faint);
  color: var(--primary);
}

.badge-neutral {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
}

/* Score Gauge & Pill */
.score-pill {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  display: inline-block;
}

.score-pass {
  background: var(--success-faint);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.score-warning {
  background: var(--warning-faint);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.score-fail {
  background: var(--danger-faint);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* Evaluation Dynamic Form UI */
.eval-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1024px) {
  .eval-form-grid {
    grid-template-columns: 1fr;
  }
}

.eval-sidebar-sticky {
  position: sticky;
  top: 76px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 960px) {
  .form-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  transition: border-color var(--transition-fast);
}

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

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* Category Scoring Card */
.category-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  transition: border-color var(--transition-fast);
}

.category-card:hover {
  border-color: var(--border-color);
}

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

.category-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.category-weight {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--primary-faint);
  color: var(--primary);
  font-family: var(--font-mono);
}

/* Radio Group options (Met, Partially Met, Not Met, N/A) */
.score-options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 580px) {
  .score-options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.score-radio-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  text-align: center;
}

.score-radio-label input {
  display: none;
}

.score-radio-label:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.score-radio-label.checked-met {
  background-color: var(--success-faint);
  border-color: var(--success);
  color: var(--success);
}

.score-radio-label.checked-partial {
  background-color: var(--warning-faint);
  border-color: var(--warning);
  color: var(--warning);
}

.score-radio-label.checked-not {
  background-color: var(--danger-faint);
  border-color: var(--danger);
  color: var(--danger);
}

.score-radio-label.checked-na {
  background-color: var(--bg-surface-hover);
  border-color: var(--text-faint);
  color: var(--text-muted);
}

/* Compact Card & Form Layout Tokens */
.compact-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.compact-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.compact-card-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

/* Compact Critical Error Alert Strip */
.compact-critical-strip {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.04));
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-critical-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.compact-critical-title {
  color: var(--danger);
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.compact-critical-desc {
  font-size: 11.5px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .compact-critical-desc {
    display: none;
  }
}

/* Compact Audio Recording Bar */
.compact-audio-bar {
  background: var(--bg-surface-elevated);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Compact Category Evaluation Table & Segmented Pills */
.compact-category-list {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
}

.compact-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
  transition: background var(--transition-fast);
}

.compact-category-row:last-child {
  border-bottom: none;
}

.compact-category-row:hover {
  background: var(--bg-surface-elevated);
}

.compact-cat-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.compact-cat-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-faint);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.compact-cat-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-cat-weight {
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--primary);
  background: var(--primary-faint);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.compact-cat-desc-hint {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

@media (max-width: 1200px) {
  .compact-cat-desc-hint {
    display: none;
  }
}

/* Horizontal Segmented Score Pills */
.compact-score-pills {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.compact-score-pills .score-radio-label {
  flex-direction: row;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  min-width: unset;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.compact-score-pills .score-radio-label:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.compact-score-pills .score-radio-label.checked-met {
  background-color: var(--success);
  color: #ffffff !important;
  border-color: var(--success);
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.35);
}

.compact-score-pills .score-radio-label.checked-partial {
  background-color: var(--warning);
  color: #ffffff !important;
  border-color: var(--warning);
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.35);
}

.compact-score-pills .score-radio-label.checked-not {
  background-color: var(--danger);
  color: #ffffff !important;
  border-color: var(--danger);
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.35);
}

.compact-score-pills .score-radio-label.checked-na {
  background-color: var(--text-muted);
  color: #ffffff !important;
  border-color: var(--text-muted);
}

/* Critical Error Switch UI (Legacy fallback) */
.critical-error-box {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.critical-error-meta {
  flex: 1;
}

.critical-error-title {
  color: var(--danger);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.critical-error-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: .3s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--danger);
  border-color: var(--danger);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

/* Mini Switch */
.switch.switch-sm {
  width: 34px;
  height: 18px;
}

.switch.switch-sm .slider:before {
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
}

.switch.switch-sm input:checked+.slider:before {
  transform: translateX(16px);
}

#coaching_required:checked+.slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* Real-time Score Gauge */
.score-summary-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.score-display-number {
  font-size: 38px;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
  margin: 8px 0 4px;
  transition: color var(--transition-normal);
}

.score-status-text {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  margin: 10px 0;
  overflow: hidden;
}

.score-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease, background-color 0.3s ease;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Online indicator dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
  background-color: var(--text-faint);
}

/* Mobile Sidebar Toggle */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: inline-flex;
  }
}

/* ==========================================================================
   Team Hierarchy Tree & Agent Directory Styling
   ========================================================================== */
.dir-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.dir-search-wrap {
  position: relative;
  min-width: 280px;
  flex: 1;
}

.dir-search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.dir-search-wrap input {
  padding-left: 36px;
}

.dir-filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.dir-filter-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dir-filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--primary);
}

.dir-filter-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Tree Structure */
.team-tree-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.team-tree-node {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.team-tree-node:hover {
  border-color: rgba(79, 70, 229, 0.4);
  box-shadow: var(--shadow-sm);
}

.team-tree-header {
  padding: 14px 18px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.team-tree-header:hover {
  background: var(--bg-hover);
}

.team-tree-node.open .team-tree-header {
  border-bottom-color: var(--border-color);
}

.team-tree-chevron {
  transition: transform 0.2s ease;
  color: var(--text-faint);
  margin-right: 10px;
}

.team-tree-node.open .team-tree-chevron {
  transform: rotate(90deg);
}

.team-tree-body {
  padding: 16px 20px 20px 32px;
  position: relative;
  display: none;
}

.team-tree-node.open .team-tree-body {
  display: block;
}

/* Visual Tree Branches */
.team-tree-stem {
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 24px;
  width: 2px;
  background: var(--border-color);
}

.agent-tree-row {
  position: relative;
  margin-bottom: 12px;
  padding-left: 24px;
}

.agent-tree-row:last-child {
  margin-bottom: 0;
}

.agent-tree-branch {
  position: absolute;
  left: 0;
  top: 50%;
  width: 24px;
  height: 2px;
  background: var(--border-color);
}

.agent-tree-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.agent-tree-card:hover {
  transform: translateX(3px);
  border-color: var(--primary);
  background: var(--bg-surface);
}

.dir-view-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 4px;
  gap: 4px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.dir-view-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.dir-view-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.dir-view-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

.agent-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.12) 0%, rgba(99, 102, 241, 0.22) 100%);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(79, 70, 229, 0.2);
}

/* ==========================================================================
   Compact Operations Ribbon & Org Hierarchy Tree Chart
   ========================================================================== */
.compact-ribbon {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 18px;
}

.compact-ribbon-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-right: 1px solid var(--border-color);
}

.compact-ribbon-item:last-child {
  border-right: none;
}

.compact-ribbon-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.compact-ribbon-icon.primary { background: rgba(79, 70, 229, 0.12); color: var(--primary); }
.compact-ribbon-icon.success { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.compact-ribbon-icon.warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.compact-ribbon-icon.danger { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.compact-ribbon-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.compact-ribbon-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

/* Org Chart Container & Canvas */
.org-chart-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 36px 24px 48px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-height: 480px;
  display: flex;
  justify-content: flex-start; /* CRITICAL: Never center an overflow container with justify-content: center (clips left content into negative scroll) */
  position: relative;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.org-chart-wrap.is-dragging {
  cursor: grabbing !important;
  user-select: none;
}

.org-tree-canvas {
  margin: 0 auto; /* Perfectly centers if canvas width <= container; aligns to left edge with padding if width > container */
  padding: 0 100px; /* Generous 100px safety margin on left and right so no cards are cut off or touch borders */
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: top center;
  flex-shrink: 0;
  min-width: max-content;
}

/* Maximize / Expanded Canvas Mode */
.card.expanded-org-canvas {
  position: fixed !important;
  top: 16px !important;
  left: 16px !important;
  right: 16px !important;
  bottom: 16px !important;
  z-index: 9999 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5) !important;
  background: var(--bg-surface) !important;
}

.card.expanded-org-canvas #orgChartView {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card.expanded-org-canvas .org-chart-wrap {
  flex: 1;
  min-height: 0;
  height: 100%;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Semantic Tree Structure with Connector Lines */
.org-tree, .org-tree ul {
  display: flex;
  justify-content: center;
  position: relative;
  padding: 24px 0 0 0;
  margin: 0;
  list-style-type: none;
}

/* Vertical line from parent node down to child bar */
.org-tree ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid var(--border-color);
  width: 0;
  height: 24px;
  transform: translateX(-50%);
}

.org-tree li {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 24px 10px 0 10px;
  list-style-type: none;
}

/* Horizontal connectors above siblings */
.org-tree li::before, .org-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid var(--border-color);
  width: 50%;
  height: 24px;
}

.org-tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--border-color);
}

.org-tree li:only-child::after, .org-tree li:only-child::before {
  display: none;
}

.org-tree li:only-child {
  padding-top: 0;
}

.org-tree li:first-child::before, .org-tree li:last-child::after {
  border: 0 none;
}

.org-tree li:last-child::before {
  border-right: 2px solid var(--border-color);
  border-radius: 0 8px 0 0;
}

.org-tree li:first-child::after {
  border-radius: 8px 0 0 0;
}

/* Org Card Styling */
.org-card {
  width: 216px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 2;
  text-align: left;
}

.org-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.org-card.is-me {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2), 0 4px 12px rgba(79, 70, 229, 0.15);
}

.org-card.highlight-match {
  outline: 3px solid #f59e0b;
  animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
}

.org-card-header {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.02em;
}

.org-card-header.role-admin { background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%); color: #fff; }
.org-card-header.role-manager { background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%); color: #fff; }
.org-card-header.role-tl { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); color: #fff; }
.org-card-header.role-auditor { background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%); color: #fff; }
.org-card-header.role-employee { background: linear-gradient(135deg, #059669 0%, #047857 100%); color: #fff; }

.org-card-body {
  padding: 10px 12px 12px;
}

.org-card-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.org-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.org-user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.org-user-empid {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.org-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.org-toggle-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.org-toggle-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg-hover);
}

.org-tree li.collapsed > ul {
  display: none !important;
}

.org-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.org-zoom-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.org-zoom-btn {
  background: transparent;
  border: none;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.org-zoom-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}