/**
 * ANALYX Battery Manufacturing Suite
 * Enterprise Core Design System (v2.0)
 * 
 * High-performance, high-contrast, modern enterprise UI architecture.
 * Designed specifically for battery gigafactory analytics, MES, SCADA, quality engineering & SPC.
 */

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

/* ==========================================================================
   1. DESIGN TOKENS (:root)
   ========================================================================== */
:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Plus Jakarta Sans', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Color Palette - Neutrals & Surfaces */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Zinc Scale */
  --zinc-800:  #27272a;
  --zinc-900:  #18181b;
  --zinc-950:  #09090b;

  /* Primary Brand - Electric Indigo */
  --indigo-50:  #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-200: #c7d2fe;
  --indigo-300: #a5b4fc;
  --indigo-400: #818cf8;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --indigo-800: #3730a3;
  --indigo-900: #312e81;

  /* Accent - Teal / Emerald */
  --teal-50:   #f0fdfa;
  --teal-100:  #ccfbf1;
  --teal-500:  #14b8a6;
  --teal-600:  #0d9488;
  --teal-700:  #0f766e;
  --emerald-500: #10b981;
  --emerald-600: #059669;

  /* Enterprise Semantic Status Tokens */
  /* Success: Within Spec / Completed / Nominal */
  --status-success-bg: #ecfdf5;
  --status-success-border: #a7f3d0;
  --status-success-text: #065f46;
  --status-success-solid: #10b981;
  --status-success-glow: rgba(16, 185, 129, 0.2);

  /* Warning: Near Spec / Warning / Action Required */
  --status-warning-bg: #fffbeb;
  --status-warning-border: #fde68a;
  --status-warning-text: #92400e;
  --status-warning-solid: #f59e0b;
  --status-warning-glow: rgba(245, 158, 11, 0.2);

  /* Danger / Out of Spec / Rejection / Emergency */
  --status-danger-bg: #fef2f2;
  --status-danger-border: #fecaca;
  --status-danger-text: #991b1b;
  --status-danger-solid: #ef4444;
  --status-danger-glow: rgba(239, 68, 68, 0.2);

  /* Info / Active / Telemetry */
  --status-info-bg: #f0f9ff;
  --status-info-border: #bae6fd;
  --status-info-text: #075985;
  --status-info-solid: #0ea5e9;
  --status-info-glow: rgba(14, 165, 233, 0.2);

  /* Surface & Base Layout */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-sidebar: #0f172a;
  --bg-header: rgba(255, 255, 255, 0.85);

  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-on-dark: #f8fafc;

  --border-light: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-strong: #94a3b8;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
  --shadow-glow-indigo: 0 0 20px -3px rgba(99, 102, 241, 0.25);

  /* Rings & Focus */
  --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.25);
  --focus-ring-error: 0 0 0 3px rgba(239, 68, 68, 0.25);

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-indices */
  --z-sticky: 100;
  --z-popover: 200;
  --z-modal-backdrop: 500;
  --z-modal: 600;
  --z-toast: 1000;
}

/* Dark Mode Tokens (Auto or Data-Theme) */
[data-theme="dark"] {
  --bg-app: #09090b;
  --bg-surface: #18181b;
  --bg-surface-elevated: #27272a;
  --bg-surface-subtle: #1e1e24;
  --bg-sidebar: #09090b;
  --bg-header: rgba(24, 24, 27, 0.85);

  --text-main: #f8fafc;
  --text-body: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --border-light: #27272a;
  --border-subtle: #3f3f46;
  --border-medium: #52525b;
  --border-strong: #71717a;

  --status-success-bg: rgba(16, 185, 129, 0.15);
  --status-success-border: rgba(16, 185, 129, 0.3);
  --status-success-text: #34d399;

  --status-warning-bg: rgba(245, 158, 11, 0.15);
  --status-warning-border: rgba(245, 158, 11, 0.3);
  --status-warning-text: #fbbf24;

  --status-danger-bg: rgba(239, 68, 68, 0.15);
  --status-danger-border: rgba(239, 68, 68, 0.3);
  --status-danger-text: #f87171;

  --status-info-bg: rgba(14, 165, 233, 0.15);
  --status-info-border: rgba(14, 165, 233, 0.3);
  --status-info-text: #38bdf8;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}

/* Base Normalization & Typography */
body.enterprise-theme {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-mono { font-family: var(--font-mono) !important; font-feature-settings: 'tnum' on, 'zero' on; }
.font-display { font-family: var(--font-display) !important; }
.font-sans { font-family: var(--font-sans) !important; }

/* ==========================================================================
   2. BUTTONS & INTERACTIVE PRIMITIVES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
  outline: none;
  position: relative;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none !important;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Button Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--indigo-600) 0%, var(--indigo-700) 100%);
  color: #ffffff;
  border-color: var(--indigo-700);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--indigo-500) 0%, var(--indigo-600) 100%);
  box-shadow: var(--shadow-sm), 0 0 12px rgba(99, 102, 241, 0.35);
  transform: translateY(-0.5px);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--slate-700);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background-color: var(--slate-50);
  color: var(--slate-900);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background-color: transparent;
  color: var(--indigo-600);
  border-color: var(--indigo-200);
}
.btn-outline:hover {
  background-color: var(--indigo-50);
  border-color: var(--indigo-400);
  color: var(--indigo-700);
}

.btn-ghost {
  background-color: transparent;
  color: var(--slate-600);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background-color: var(--slate-100);
  color: var(--slate-900);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border-color: #b91c1c;
}
.btn-danger:hover {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  box-shadow: var(--shadow-sm), 0 0 12px rgba(239, 68, 68, 0.35);
}
.btn-danger:focus-visible {
  box-shadow: var(--focus-ring-error);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: #047857;
}
.btn-success:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: var(--shadow-sm), 0 0 12px rgba(16, 185, 129, 0.35);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border-color: #b45309;
}
.btn-warning:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

/* Button Sizes */
.btn-xs {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-xs);
  gap: 0.25rem;
}
.btn-sm {
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  gap: 0.375rem;
}
.btn-md {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}
.btn-lg {
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  gap: 0.625rem;
}

/* Button Loading State */
.btn-loading {
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   3. ENTERPRISE FORM CONTROLS & INPUTS
   ========================================================================== */
.form-group {
  margin-bottom: 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.01em;
}

.form-label .req {
  color: var(--status-danger-solid);
  margin-left: 2px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--status-danger-solid);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.input, .select, .textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-main);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5625rem 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.02);
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-subtle);
}

.input:hover, .select:hover, .textarea:hover {
  border-color: var(--border-medium);
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--indigo-500);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
  background-color: #ffffff;
}

.input.is-invalid, .select.is-invalid, .textarea.is-invalid {
  border-color: var(--status-danger-solid);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.input.is-valid, .select.is-valid, .textarea.is-valid {
  border-color: var(--status-success-solid);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.input:disabled, .select:disabled, .textarea:disabled {
  background-color: var(--slate-100);
  border-color: var(--border-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Input Icon Group Wrapper */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-icon-prefix {
  position: absolute;
  left: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.95rem;
  z-index: 2;
}

.input-icon-suffix {
  position: absolute;
  right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  z-index: 2;
}

.input-group .input.has-prefix {
  padding-left: 2.375rem;
}
.input-group .input.has-suffix {
  padding-right: 2.375rem;
}

/* Monospace inputs for engineering data / tolerances */
.input-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   4. DATA TABLES (ENTERPRISE GRADE)
   ========================================================================== */
.enterprise-table-container {
  width: 100%;
  overflow-x: auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  position: relative;
}

.enterprise-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
  text-align: left;
  line-height: 1.4;
}

.enterprise-table thead th {
  background-color: var(--slate-50);
  color: var(--slate-700);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
}

.enterprise-table thead th.sortable {
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.enterprise-table thead th.sortable:hover {
  background-color: var(--slate-100);
  color: var(--slate-900);
}

.enterprise-table tbody tr {
  transition: background-color var(--transition-fast);
}

.enterprise-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-body);
  vertical-align: middle;
}

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

/* Row Hover & Selection */
.enterprise-table tbody tr:hover {
  background-color: #f8fafc;
}

.enterprise-table.table-striped tbody tr:nth-child(even) {
  background-color: #fafbfc;
}
.enterprise-table.table-striped tbody tr:nth-child(even):hover {
  background-color: #f1f5f9;
}

.enterprise-table tbody tr.is-selected {
  background-color: var(--indigo-50);
}

/* Numeric & Monospace alignment */
.enterprise-table td.col-mono,
.enterprise-table td.col-number,
.enterprise-table th.col-number {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  text-align: right;
  white-space: nowrap;
}

.enterprise-table td.col-center,
.enterprise-table th.col-center {
  text-align: center;
}

/* Compact Table Density */
.enterprise-table.table-dense thead th {
  padding: 0.5rem 0.75rem;
  font-size: 0.6875rem;
}
.enterprise-table.table-dense tbody td {
  padding: 0.4375rem 0.75rem;
  font-size: 0.75rem;
}

/* ==========================================================================
   5. STATUS BADGES & CHIPS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.71875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background-color: currentColor;
}

.badge-dot-live {
  position: relative;
}
.badge-dot-live::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.75;
  animation: badge-radar 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes badge-radar {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* Semantic Badges */
.badge-success {
  background-color: var(--status-success-bg);
  border-color: var(--status-success-border);
  color: var(--status-success-text);
}

.badge-warning {
  background-color: var(--status-warning-bg);
  border-color: var(--status-warning-border);
  color: var(--status-warning-text);
}

.badge-danger {
  background-color: var(--status-danger-bg);
  border-color: var(--status-danger-border);
  color: var(--status-danger-text);
}

.badge-info {
  background-color: var(--status-info-bg);
  border-color: var(--status-info-border);
  color: var(--status-info-text);
}

.badge-neutral {
  background-color: var(--slate-100);
  border-color: var(--border-subtle);
  color: var(--slate-700);
}

.badge-indigo {
  background-color: var(--indigo-50);
  border-color: var(--indigo-200);
  color: var(--indigo-700);
}

/* ==========================================================================
   6. ENTERPRISE KPI METRIC CARDS
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-medium);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background var(--transition-fast);
}

.kpi-card.kpi-indigo::before { background: var(--indigo-500); }
.kpi-card.kpi-emerald::before { background: var(--emerald-500); }
.kpi-card.kpi-amber::before { background: var(--status-warning-solid); }
.kpi-card.kpi-rose::before { background: var(--status-danger-solid); }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.kpi-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--slate-100);
  color: var(--slate-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.kpi-body {
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.kpi-value.mono {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.75rem;
}

.kpi-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.kpi-trend.positive { color: var(--emerald-600); }
.kpi-trend.negative { color: var(--status-danger-solid); }
.kpi-trend.neutral { color: var(--text-muted); }

.kpi-sparkline {
  height: 36px;
  width: 100%;
  margin-top: 0.5rem;
}

/* ==========================================================================
   7. MODAL DIALOGS (ENTERPRISE GRADE)
   ========================================================================== */
.enterprise-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.enterprise-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.enterprise-modal {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  position: relative;
  transform: scale(0.96) translateY(8px);
  transition: transform var(--transition-normal);
  z-index: var(--z-modal);
  overflow: hidden;
}

.enterprise-modal-backdrop.is-open .enterprise-modal {
  transform: scale(1) translateY(0);
}

.enterprise-modal.modal-lg { max-width: 800px; }
.enterprise-modal.modal-xl { max-width: 1080px; }
.enterprise-modal.modal-full { max-width: calc(100vw - 3rem); height: calc(100vh - 3rem); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.modal-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background-color: var(--slate-100);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  color: var(--text-body);
  font-size: 0.875rem;
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.125rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--slate-50);
}

/* ==========================================================================
   8. TOAST SYSTEM
   ========================================================================== */
.enterprise-toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
  width: calc(100% - 2.5rem);
  pointer-events: none;
}

.enterprise-toast {
  pointer-events: auto;
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--indigo-500);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: toast-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
  overflow: hidden;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(110%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.enterprise-toast.is-leaving {
  animation: toast-slide-out 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toast-slide-out {
  to {
    transform: translateX(110%);
    opacity: 0;
  }
}

.toast-icon {
  font-size: 1.125rem;
  margin-top: 0.125rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.3;
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 0.25rem;
  margin: -0.25rem -0.25rem 0 0;
  border-radius: var(--radius-xs);
  transition: color var(--transition-fast);
}
.toast-close:hover {
  color: var(--text-main);
}

/* Toast Color Variants */
.enterprise-toast.toast-success {
  border-left-color: var(--status-success-solid);
}
.enterprise-toast.toast-success .toast-icon {
  color: var(--status-success-solid);
}

.enterprise-toast.toast-warning {
  border-left-color: var(--status-warning-solid);
}
.enterprise-toast.toast-warning .toast-icon {
  color: var(--status-warning-solid);
}

.enterprise-toast.toast-error {
  border-left-color: var(--status-danger-solid);
}
.enterprise-toast.toast-error .toast-icon {
  color: var(--status-danger-solid);
}

.enterprise-toast.toast-info {
  border-left-color: var(--status-info-solid);
}
.enterprise-toast.toast-info .toast-icon {
  color: var(--status-info-solid);
}

/* ==========================================================================
   9. MODERN TAB SWITCHERS & SEGMENTED CONTROLS
   ========================================================================== */
.nav-tabs-enterprise {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem;
  background-color: var(--slate-100);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  width: fit-content;
  user-select: none;
}

.nav-tabs-enterprise .tab-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.875rem;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-tabs-enterprise .tab-item:hover {
  color: var(--text-main);
}

.nav-tabs-enterprise .tab-item.active {
  background-color: #ffffff;
  color: var(--indigo-700);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* Underline variant for secondary dashboards */
.nav-tabs-line {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
}

.nav-tabs-line .tab-item {
  padding: 0.75rem 0.25rem;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

.nav-tabs-line .tab-item:hover {
  color: var(--text-main);
}

.nav-tabs-line .tab-item.active {
  color: var(--indigo-600);
  font-weight: 700;
}

.nav-tabs-line .tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--indigo-600);
  border-radius: 2px 2px 0 0;
}

/* ==========================================================================
   10. BATTERY MANUFACTURING DOMAIN-SPECIFIC UTILITIES
   ========================================================================== */
.spec-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}

.spec-in-spec {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.spec-near-spec {
  background-color: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.spec-out-of-spec {
  background-color: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.cell-grade-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-xs);
}
.grade-a { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.grade-b { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }
.grade-c { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* Custom Scrollbar for Enterprise Tables and Modals */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}
