/* ═══════════════════════════════════════════════════════════════
   ALPVIS RMS — Premium Design System
   Phase 1: Design Foundations + Phase 2: Navigation & Layout

   This file layers on top of style.css and style-enterprise.css.
   It does NOT override revenue logic, simulation scores, or
   apply recommendations. Pure visual improvements only.
   ═══════════════════════════════════════════════════════════════ */

/* ─── 1. DESIGN TOKENS ──────────────────────────────────────── */

:root {
  /* Premium color palette */
  --p-bg:           #f8f9fc;
  --p-bg-alt:       #f1f3f8;
  --p-surface:      #ffffff;
  --p-surface-hover:#fafbfe;
  --p-border:       #e5e8ef;
  --p-border-light: #eef0f5;
  --p-text:         #1a1d2b;
  --p-text-secondary:#5b6178;
  --p-text-muted:   #9298ad;
  --p-primary:      #3366ff;
  --p-primary-hover:#2952cc;
  --p-primary-soft: rgba(51, 102, 255, 0.08);
  --p-primary-glow: rgba(51, 102, 255, 0.15);
  --p-success:      #0f9d58;
  --p-success-soft: rgba(15, 157, 88, 0.08);
  --p-warning:      #f0a930;
  --p-warning-soft: rgba(240, 169, 48, 0.08);
  --p-danger:       #e5384f;
  --p-danger-soft:  rgba(229, 56, 79, 0.08);
  --p-info:         #2e9de5;
  --p-info-soft:    rgba(46, 157, 229, 0.08);

  /* Spacing scale */
  --p-space-xs:     4px;
  --p-space-sm:     8px;
  --p-space-md:     16px;
  --p-space-lg:     24px;
  --p-space-xl:     32px;
  --p-space-2xl:    48px;

  /* Typography */
  --p-font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --p-font-mono:    'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --p-text-xs:      11px;
  --p-text-sm:      12.5px;
  --p-text-base:    14px;
  --p-text-lg:      16px;
  --p-text-xl:      20px;
  --p-text-2xl:     28px;
  --p-text-3xl:     36px;

  /* Radius */
  --p-radius-sm:    2px;
  --p-radius-md:    3px;
  --p-radius-lg:    4px;
  --p-radius-xl:    6px;
  --p-radius-full:  3px;

  /* Shadows */
  --p-shadow-xs:    0 1px 2px rgba(0,0,0,0.04);
  --p-shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --p-shadow-md:    0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --p-shadow-lg:    0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --p-shadow-xl:    0 16px 48px rgba(0,0,0,0.10), 0 4px 16px rgba(0,0,0,0.06);

  /* Transitions */
  --p-transition:   0.18s ease;
  --p-transition-slow: 0.3s ease;

  /* Layout */
  --p-content-max:  1440px;
  --p-sidebar-w:    215px;
}

/* Dark theme tokens */
[data-theme="dark"] {
  --p-bg:           #0b0e18;
  --p-bg-alt:       #0f1320;
  --p-surface:      #151928;
  --p-surface-hover:#1a1f30;
  --p-border:       #252a3a;
  --p-border-light: #1e2333;
  --p-text:         #e8eaf0;
  --p-text-secondary:#8b90a5;
  --p-text-muted:   #555a70;
  --p-primary:      #5b8aff;
  --p-primary-hover:#6d98ff;
  --p-primary-soft: rgba(91, 138, 255, 0.12);
  --p-primary-glow: rgba(91, 138, 255, 0.20);
  --p-success:      #34d399;
  --p-success-soft: rgba(52, 211, 153, 0.10);
  --p-warning:      #fbbf24;
  --p-warning-soft: rgba(251, 191, 36, 0.10);
  --p-danger:       #f87171;
  --p-danger-soft:  rgba(248, 113, 113, 0.10);
  --p-info:         #60a5fa;
  --p-info-soft:    rgba(96, 165, 250, 0.10);
}


/* ─── 2. PREMIUM CARD SYSTEM ────────────────────────────────── */

.p-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  padding: var(--p-space-lg);
  box-shadow: var(--p-shadow-sm);
  transition: box-shadow var(--p-transition), border-color var(--p-transition);
}

.p-card:hover {
  box-shadow: var(--p-shadow-md);
}

.p-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--p-space-md);
  padding-bottom: var(--p-space-md);
  border-bottom: 1px solid var(--p-border-light);
}

.p-card-title {
  font-size: var(--p-text-lg);
  font-weight: 600;
  color: var(--p-text);
  letter-spacing: -0.01em;
  margin: 0;
}

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

.p-card-actions {
  display: flex;
  align-items: center;
  gap: var(--p-space-sm);
}

/* Card variants */
.p-card--flat {
  box-shadow: none;
  border-color: var(--p-border-light);
}

.p-card--highlight {
  border-left: 3px solid var(--p-primary);
}

.p-card--success { border-left: 3px solid var(--p-success); }
.p-card--warning { border-left: 3px solid var(--p-warning); }
.p-card--danger  { border-left: 3px solid var(--p-danger); }

/* KPI Card */
.p-kpi {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  padding: var(--p-space-lg);
  box-shadow: var(--p-shadow-xs);
  transition: all var(--p-transition);
  position: relative;
  overflow: hidden;
}

.p-kpi:hover {
  box-shadow: var(--p-shadow-md);
  transform: translateY(-1px);
}

.p-kpi-label {
  font-size: var(--p-text-sm);
  font-weight: 500;
  color: var(--p-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--p-space-sm);
}

.p-kpi-value {
  font-size: var(--p-text-2xl);
  font-weight: 700;
  color: var(--p-text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.p-kpi-value small {
  font-size: var(--p-text-base);
  font-weight: 500;
  color: var(--p-text-secondary);
  margin-left: 2px;
}

.p-kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--p-text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--p-radius-full);
  margin-top: var(--p-space-sm);
}

.p-kpi-change--up {
  color: var(--p-success);
  background: var(--p-success-soft);
}

.p-kpi-change--down {
  color: var(--p-danger);
  background: var(--p-danger-soft);
}

.p-kpi-change--neutral {
  color: var(--p-text-muted);
  background: var(--p-bg-alt);
}

.p-kpi-sub {
  font-size: var(--p-text-xs);
  color: var(--p-text-muted);
  margin-top: var(--p-space-xs);
}

/* KPI grid */
.p-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--p-space-md);
}


/* ─── 3. BUTTON SYSTEM ──────────────────────────────────────── */

.p-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--p-font);
  font-size: var(--p-text-sm);
  font-weight: 600;
  line-height: 1;
  padding: 10px 18px;
  border-radius: var(--p-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--p-transition);
  white-space: nowrap;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}

.p-btn:active {
  transform: scale(0.98);
}

/* Primary */
.p-btn--primary {
  background: var(--p-primary);
  color: #fff;
  border-color: var(--p-primary);
}
.p-btn--primary:hover {
  background: var(--p-primary-hover);
  border-color: var(--p-primary-hover);
  box-shadow: 0 2px 8px var(--p-primary-glow);
}

/* Secondary */
.p-btn--secondary {
  background: var(--p-surface);
  color: var(--p-text);
  border-color: var(--p-border);
}
.p-btn--secondary:hover {
  background: var(--p-surface-hover);
  border-color: var(--p-primary);
  color: var(--p-primary);
}

/* Ghost */
.p-btn--ghost {
  background: transparent;
  color: var(--p-text-secondary);
  border-color: transparent;
}
.p-btn--ghost:hover {
  background: var(--p-primary-soft);
  color: var(--p-primary);
}

/* Danger */
.p-btn--danger {
  background: var(--p-danger);
  color: #fff;
  border-color: var(--p-danger);
}
.p-btn--danger:hover {
  background: #d42d43;
  box-shadow: 0 2px 8px var(--p-danger-soft);
}

/* Success */
.p-btn--success {
  background: var(--p-success);
  color: #fff;
  border-color: var(--p-success);
}
.p-btn--success:hover {
  background: #0d874c;
  box-shadow: 0 2px 8px var(--p-success-soft);
}

/* Sizes */
.p-btn--sm {
  font-size: var(--p-text-xs);
  padding: 6px 12px;
}

.p-btn--lg {
  font-size: var(--p-text-base);
  padding: 14px 28px;
  border-radius: var(--p-radius-md);
}

/* States */
.p-btn:disabled,
.p-btn--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.p-btn--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.p-btn--loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: p-spin 0.6s linear infinite;
}

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


/* ─── 4. BADGE / STATUS SYSTEM ──────────────────────────────── */

.p-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--p-font);
  font-size: var(--p-text-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--p-radius-full);
  line-height: 1.4;
  white-space: nowrap;
}

/* Status badges */
.p-badge--applied,
.p-badge--success {
  color: var(--p-success);
  background: var(--p-success-soft);
}

.p-badge--applying {
  color: var(--p-info);
  background: var(--p-info-soft);
  animation: p-pulse 2s ease-in-out infinite;
}

.p-badge--applied-partial,
.p-badge--warning {
  color: #b07c10;
  background: var(--p-warning-soft);
}

[data-theme="dark"] .p-badge--applied-partial,
[data-theme="dark"] .p-badge--warning {
  color: var(--p-warning);
}

.p-badge--apply-failed,
.p-badge--danger {
  color: var(--p-danger);
  background: var(--p-danger-soft);
}

.p-badge--ready {
  color: var(--p-primary);
  background: var(--p-primary-soft);
}

.p-badge--missing-data {
  color: var(--p-text-muted);
  background: var(--p-bg-alt);
}

.p-badge--high-risk {
  color: var(--p-danger);
  background: var(--p-danger-soft);
}

.p-badge--low-confidence {
  color: #b07c10;
  background: var(--p-warning-soft);
}

[data-theme="dark"] .p-badge--low-confidence {
  color: var(--p-warning);
}

/* Strategy badges */
.p-badge--safe {
  color: var(--p-success);
  background: var(--p-success-soft);
}

.p-badge--balanced {
  color: var(--p-primary);
  background: var(--p-primary-soft);
}

.p-badge--aggressive {
  color: var(--p-danger);
  background: var(--p-danger-soft);
}

/* Size */
.p-badge--lg {
  font-size: var(--p-text-sm);
  padding: 5px 14px;
}

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

/* Dot indicator */
.p-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.p-dot--success { background: var(--p-success); }
.p-dot--warning { background: var(--p-warning); }
.p-dot--danger  { background: var(--p-danger); }
.p-dot--info    { background: var(--p-info); }
.p-dot--muted   { background: var(--p-text-muted); }


/* ─── 5. TABLE SYSTEM ───────────────────────────────────────── */

.p-table-wrap {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  overflow: hidden;
  box-shadow: var(--p-shadow-xs);
}

.p-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--p-text-sm);
}

.p-table thead {
  background: var(--p-bg-alt);
  border-bottom: 1px solid var(--p-border);
}

.p-table th {
  font-size: var(--p-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--p-text-muted);
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}

.p-table td {
  padding: 12px 16px;
  color: var(--p-text);
  border-bottom: 1px solid var(--p-border-light);
  vertical-align: middle;
}

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

.p-table tbody tr {
  transition: background var(--p-transition);
}

.p-table tbody tr:hover {
  background: var(--p-primary-soft);
}

.p-table--striped tbody tr:nth-child(even) {
  background: var(--p-bg-alt);
}

.p-table--striped tbody tr:nth-child(even):hover {
  background: var(--p-primary-soft);
}

/* Sortable header */
.p-table th[data-sortable] {
  cursor: pointer;
  user-select: none;
}

.p-table th[data-sortable]:hover {
  color: var(--p-primary);
}

/* Table empty row */
.p-table-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--p-text-muted);
}

.p-table-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.4;
}

.p-table-empty-text {
  font-size: var(--p-text-sm);
}


/* ─── 6. FORM SYSTEM ────────────────────────────────────────── */

.p-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.p-form-label {
  font-size: var(--p-text-sm);
  font-weight: 500;
  color: var(--p-text-secondary);
}

.p-form-hint {
  font-size: var(--p-text-xs);
  color: var(--p-text-muted);
}

.p-input,
.p-select {
  font-family: var(--p-font);
  font-size: var(--p-text-base);
  padding: 10px 14px;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-sm);
  background: var(--p-surface);
  color: var(--p-text);
  transition: border-color var(--p-transition), box-shadow var(--p-transition);
  outline: none;
  width: 100%;
}

.p-input:focus,
.p-select:focus {
  border-color: var(--p-primary);
  box-shadow: 0 0 0 3px var(--p-primary-soft);
}

.p-input::placeholder {
  color: var(--p-text-muted);
}

.p-input--error {
  border-color: var(--p-danger);
}

.p-input--error:focus {
  box-shadow: 0 0 0 3px var(--p-danger-soft);
}

/* Form grid */
.p-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--p-space-md);
}


/* ─── 7. EMPTY STATES ───────────────────────────────────────── */

.p-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--p-space-2xl) var(--p-space-lg);
  text-align: center;
}

.p-empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: var(--p-space-md);
  opacity: 0.2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--p-text-muted);
}

.p-empty-title {
  font-size: var(--p-text-lg);
  font-weight: 600;
  color: var(--p-text);
  margin-bottom: var(--p-space-sm);
}

.p-empty-text {
  font-size: var(--p-text-sm);
  color: var(--p-text-muted);
  max-width: 360px;
  line-height: 1.6;
}

.p-empty-action {
  margin-top: var(--p-space-lg);
}


/* ─── 8. ERROR STATES ───────────────────────────────────────── */

.p-error {
  display: flex;
  align-items: flex-start;
  gap: var(--p-space-md);
  padding: var(--p-space-md) var(--p-space-lg);
  background: var(--p-danger-soft);
  border: 1px solid rgba(229, 56, 79, 0.15);
  border-radius: var(--p-radius-md);
  color: var(--p-danger);
  font-size: var(--p-text-sm);
  line-height: 1.5;
}

.p-error-icon {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1.3;
}

.p-info-box {
  display: flex;
  align-items: flex-start;
  gap: var(--p-space-md);
  padding: var(--p-space-md) var(--p-space-lg);
  background: var(--p-info-soft);
  border: 1px solid rgba(46, 157, 229, 0.15);
  border-radius: var(--p-radius-md);
  color: var(--p-info);
  font-size: var(--p-text-sm);
  line-height: 1.5;
}

.p-warning-box {
  display: flex;
  align-items: flex-start;
  gap: var(--p-space-md);
  padding: var(--p-space-md) var(--p-space-lg);
  background: var(--p-warning-soft);
  border: 1px solid rgba(240, 169, 48, 0.15);
  border-radius: var(--p-radius-md);
  color: #9a6b0a;
  font-size: var(--p-text-sm);
  line-height: 1.5;
}

[data-theme="dark"] .p-warning-box {
  color: var(--p-warning);
}

.p-success-box {
  display: flex;
  align-items: flex-start;
  gap: var(--p-space-md);
  padding: var(--p-space-md) var(--p-space-lg);
  background: var(--p-success-soft);
  border: 1px solid rgba(15, 157, 88, 0.15);
  border-radius: var(--p-radius-md);
  color: var(--p-success);
  font-size: var(--p-text-sm);
  line-height: 1.5;
}


/* ─── 9. TOAST IMPROVEMENTS ─────────────────────────────────── */

.toast-container {
  z-index: 10000;
}

.toast {
  font-family: var(--p-font);
  font-size: var(--p-text-sm);
  font-weight: 500;
  padding: 14px 20px;
  border-radius: var(--p-radius-md);
  box-shadow: var(--p-shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 440px;
  animation: p-toast-in 0.3s ease forwards;
  border: 1px solid transparent;
}

.toast.success {
  background: var(--p-surface);
  color: var(--p-success);
  border-color: var(--p-success);
}

.toast.error {
  background: var(--p-surface);
  color: var(--p-danger);
  border-color: var(--p-danger);
}

.toast.warn {
  background: var(--p-surface);
  color: #9a6b0a;
  border-color: var(--p-warning);
}

[data-theme="dark"] .toast.warn {
  color: var(--p-warning);
}

.toast.info {
  background: var(--p-surface);
  color: var(--p-info);
  border-color: var(--p-info);
}

@keyframes p-toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ─── 10. PAGE HEADER SYSTEM ────────────────────────────────── */

.p-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--p-space-lg);
  padding-bottom: var(--p-space-lg);
  border-bottom: 1px solid var(--p-border-light);
}

.p-page-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.p-page-title {
  font-size: var(--p-text-2xl);
  font-weight: 700;
  color: var(--p-text);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

.p-page-subtitle {
  font-size: var(--p-text-sm);
  color: var(--p-text-muted);
  line-height: 1.4;
}

.p-page-header-right {
  display: flex;
  align-items: center;
  gap: var(--p-space-sm);
  flex-shrink: 0;
}


/* ─── 11. SIDEBAR PREMIUM REFINEMENTS ───────────────────────── */

/* Light & Enterprise theme sidebar improvements */
[data-theme="light"] .sidebar,
[data-theme="enterprise"] .sidebar {
  background: var(--p-surface);
  border-right: 1px solid var(--p-border);
  box-shadow: var(--p-shadow-sm);
}

[data-theme="light"] .sidebar-brand,
[data-theme="enterprise"] .sidebar-brand {
  padding: 20px 16px 12px;
  border-bottom: none;
}

[data-theme="light"] .nav-label,
[data-theme="enterprise"] .nav-label {
  font-family: var(--p-font);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--p-text-muted);
  padding: 16px 16px 6px;
  margin: 0;
}

[data-theme="light"] .nav-item,
[data-theme="enterprise"] .nav-item {
  font-family: var(--p-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--p-text-secondary);
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: var(--p-radius-sm);
  transition: all var(--p-transition);
  border-left: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

[data-theme="light"] .nav-item:hover,
[data-theme="enterprise"] .nav-item:hover {
  background: var(--p-primary-soft);
  color: var(--p-primary);
}

[data-theme="light"] .nav-item.active,
[data-theme="enterprise"] .nav-item.active {
  background: var(--p-primary-soft);
  color: var(--p-primary);
  font-weight: 600;
  border-left-color: var(--p-primary);
}

[data-theme="light"] .nav-item.active::before,
[data-theme="enterprise"] .nav-item.active::before {
  display: none;
}

/* Nav item icon refinement */
[data-theme="light"] .nav-item .ni,
[data-theme="enterprise"] .nav-item .ni {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}

[data-theme="light"] .nav-item.active .ni,
[data-theme="enterprise"] .nav-item.active .ni {
  opacity: 1;
}

/* Sidebar user area */
[data-theme="light"] .sidebar-user,
[data-theme="enterprise"] .sidebar-user {
  border-top: 1px solid var(--p-border-light);
  padding: 12px 16px;
  background: var(--p-bg-alt);
}

[data-theme="light"] .su-name,
[data-theme="enterprise"] .su-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--p-text);
}

[data-theme="light"] .su-role,
[data-theme="enterprise"] .su-role {
  font-size: 11px;
  color: var(--p-text-muted);
}

/* Sidebar live area */
[data-theme="light"] .sidebar-live,
[data-theme="enterprise"] .sidebar-live {
  border-top: 1px solid var(--p-border-light);
  padding: 10px 16px;
  background: var(--p-bg-alt);
}

/* Nav section separator */
[data-theme="light"] .nav-section + .nav-section,
[data-theme="enterprise"] .nav-section + .nav-section {
  margin-top: 4px;
}

/* Dark theme sidebar refinements */
[data-theme="dark"] .nav-item {
  font-family: var(--p-font);
  font-size: 13px;
  font-weight: 500;
  margin: 1px 8px;
  border-radius: var(--p-radius-sm);
  padding: 8px 16px;
  border-left: 2px solid transparent;
  transition: all var(--p-transition);
}

[data-theme="dark"] .nav-item:hover {
  background: var(--p-primary-soft);
}

[data-theme="dark"] .nav-item.active {
  background: var(--p-primary-soft);
  color: var(--p-primary);
  border-left-color: var(--p-primary);
}

[data-theme="dark"] .nav-label {
  font-family: var(--p-font);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 16px 6px;
}


/* ─── 12. TOPBAR / HEADER REFINEMENTS ───────────────────────── */

[data-theme="light"] .topbar,
[data-theme="enterprise"] .topbar {
  background: var(--p-surface);
  border-bottom: 1px solid var(--p-border);
  padding: 14px 28px;
  box-shadow: var(--p-shadow-xs);
}

[data-theme="light"] .topbar h1,
[data-theme="enterprise"] .topbar h1 {
  font-family: var(--p-font);
  font-size: var(--p-text-xl);
  font-weight: 700;
  color: var(--p-text);
  letter-spacing: -0.02em;
}

[data-theme="light"] .topbar-date,
[data-theme="enterprise"] .topbar-date {
  font-family: var(--p-font);
  font-size: var(--p-text-sm);
  color: var(--p-text-muted);
}

[data-theme="dark"] .topbar h1 {
  font-family: var(--p-font);
  font-size: var(--p-text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}


/* ─── 13. CONTENT CONTAINER ─────────────────────────────────── */

.page {
  padding: 90px 32px 32px;
  width: 100%;
  box-sizing: border-box;
}

/* Ensure main area uses premium font */
.main {
  font-family: var(--p-font);
}


/* ─── 14. GLOBAL TYPOGRAPHY ─────────────────────────────────── */

body {
  font-family: var(--p-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Card glass improvements for light/enterprise */
[data-theme="light"] .card.glass,
[data-theme="enterprise"] .card.glass {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-sm);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

[data-theme="light"] .card-header,
[data-theme="enterprise"] .card-header {
  border-bottom: 1px solid var(--p-border-light);
}

[data-theme="light"] .card-header h3,
[data-theme="enterprise"] .card-header h3 {
  font-family: var(--p-font);
  font-size: var(--p-text-lg);
  font-weight: 600;
  color: var(--p-text);
  letter-spacing: -0.01em;
}


/* ─── 15. MODAL IMPROVEMENTS ────────────────────────────────── */

.modal-overlay.show .modal {
  border-radius: var(--p-radius-xl);
  box-shadow: var(--p-shadow-xl);
}

[data-theme="light"] .modal-overlay.show .modal,
[data-theme="enterprise"] .modal-overlay.show .modal {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
}

[data-theme="light"] .modal-header,
[data-theme="enterprise"] .modal-header {
  border-bottom: 1px solid var(--p-border-light);
}

[data-theme="light"] .modal-header h3,
[data-theme="enterprise"] .modal-header h3 {
  font-family: var(--p-font);
  font-weight: 600;
  color: var(--p-text);
}


/* ─── 16. PILL TABS ─────────────────────────────────────────── */

[data-theme="light"] .pill-tabs,
[data-theme="enterprise"] .pill-tabs {
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-md);
  padding: 3px;
}

[data-theme="light"] .pill,
[data-theme="enterprise"] .pill {
  font-family: var(--p-font);
  font-size: var(--p-text-sm);
  font-weight: 500;
  color: var(--p-text-secondary);
  border-radius: var(--p-radius-sm);
  padding: 6px 14px;
  transition: all var(--p-transition);
}

[data-theme="light"] .pill.active,
[data-theme="enterprise"] .pill.active {
  background: var(--p-surface);
  color: var(--p-primary);
  font-weight: 600;
  box-shadow: var(--p-shadow-sm);
}

[data-theme="light"] .pill:hover:not(.active),
[data-theme="enterprise"] .pill:hover:not(.active) {
  color: var(--p-text);
  background: rgba(255,255,255,0.5);
}


/* ─── 17. OVERVIEW PAGE IMPROVEMENTS ────────────────────────── */

/* RateBoard cards */
[data-theme="light"] .rb-card,
[data-theme="enterprise"] .rb-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-xs);
  transition: all var(--p-transition);
}

[data-theme="light"] .rb-card:hover,
[data-theme="enterprise"] .rb-card:hover {
  box-shadow: var(--p-shadow-md);
}

[data-theme="light"] .rb-label,
[data-theme="enterprise"] .rb-label {
  font-family: var(--p-font);
  font-size: var(--p-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--p-text-muted);
}

[data-theme="light"] .rb-value,
[data-theme="enterprise"] .rb-value {
  font-family: var(--p-font);
  font-weight: 700;
  color: var(--p-text);
  letter-spacing: -0.02em;
}

[data-theme="light"] .rb-value small,
[data-theme="enterprise"] .rb-value small {
  color: var(--p-text-muted);
  font-weight: 500;
}

[data-theme="light"] .rb-sub,
[data-theme="enterprise"] .rb-sub {
  font-size: var(--p-text-xs);
  color: var(--p-text-muted);
}

/* Sidebar panel */
[data-theme="light"] .rb-sidebar.glass,
[data-theme="enterprise"] .rb-sidebar.glass {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-xs);
  backdrop-filter: none;
}

[data-theme="light"] .rb-side-title,
[data-theme="enterprise"] .rb-side-title {
  font-family: var(--p-font);
  font-weight: 700;
  color: var(--p-text);
}

[data-theme="light"] .rb-side-label,
[data-theme="enterprise"] .rb-side-label {
  color: var(--p-text-muted);
  font-size: var(--p-text-xs);
}

[data-theme="light"] .rb-side-value,
[data-theme="enterprise"] .rb-side-value {
  color: var(--p-text);
  font-weight: 600;
}

/* Card border accent colors */
[data-theme="light"] .rb-card-border.red,
[data-theme="enterprise"] .rb-card-border.red {
  background: var(--p-primary);
}

[data-theme="light"] .rb-card-border.olive,
[data-theme="enterprise"] .rb-card-border.olive {
  background: var(--p-success);
}

/* Week at a glance */
[data-theme="light"] .week-day,
[data-theme="enterprise"] .week-day {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  transition: all var(--p-transition);
}

[data-theme="light"] .week-day:hover,
[data-theme="enterprise"] .week-day:hover {
  box-shadow: var(--p-shadow-sm);
  border-color: var(--p-primary);
}

[data-theme="light"] .week-day.today,
[data-theme="enterprise"] .week-day.today {
  border-color: var(--p-primary);
  box-shadow: 0 0 0 3px var(--p-primary-soft);
}

/* Insights panel */
[data-theme="light"] .insight,
[data-theme="enterprise"] .insight {
  background: var(--p-bg-alt);
  border: 1px solid var(--p-border-light);
  border-radius: var(--p-radius-md);
  padding: 10px 14px;
}

/* Category cards */
[data-theme="light"] .cat-card,
[data-theme="enterprise"] .cat-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-xs);
  transition: all var(--p-transition);
}

[data-theme="light"] .cat-card:hover,
[data-theme="enterprise"] .cat-card:hover {
  box-shadow: var(--p-shadow-md);
  transform: translateY(-1px);
}


/* ─── 18. SIMULATION PAGE IMPROVEMENTS ──────────────────────── */

/* Sim form card */
[data-theme="light"] #page-simulation .card.glass,
[data-theme="enterprise"] #page-simulation .card.glass {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-sm);
}

/* Sim price recommendation cards */
[data-theme="light"] .sim-price-card,
[data-theme="enterprise"] .sim-price-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  padding: var(--p-space-lg);
  box-shadow: var(--p-shadow-xs);
  transition: all var(--p-transition);
}

[data-theme="light"] .sim-price-card:hover,
[data-theme="enterprise"] .sim-price-card:hover {
  box-shadow: var(--p-shadow-md);
  transform: translateY(-2px);
}

/* Score cards */
[data-theme="light"] .sim-score-card,
[data-theme="enterprise"] .sim-score-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  padding: var(--p-space-lg);
  box-shadow: var(--p-shadow-xs);
}

/* Agent result cards */
[data-theme="light"] .sim-agent-card,
[data-theme="enterprise"] .sim-agent-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  padding: var(--p-space-md);
  transition: all var(--p-transition);
}

[data-theme="light"] .sim-agent-card:hover,
[data-theme="enterprise"] .sim-agent-card:hover {
  box-shadow: var(--p-shadow-sm);
}

/* Graph explanation */
[data-theme="light"] .sim-graph-col,
[data-theme="enterprise"] .sim-graph-col {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-xs);
}

/* Graph nodes */
[data-theme="light"] .graph-node,
[data-theme="enterprise"] .graph-node {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--p-transition);
}

[data-theme="light"] .graph-node:hover,
[data-theme="enterprise"] .graph-node:hover {
  border-color: var(--p-primary);
  box-shadow: 0 0 0 3px var(--p-primary-soft);
}

/* Graph node detail panel */
[data-theme="light"] .graph-detail,
[data-theme="enterprise"] .graph-detail {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-lg);
  padding: var(--p-space-lg);
}


/* ─── 19. SETTINGS PAGE ─────────────────────────────────────── */

[data-theme="light"] .settings-input,
[data-theme="enterprise"] .settings-input {
  font-family: var(--p-font);
  font-size: var(--p-text-base);
  padding: 10px 14px;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-sm);
  background: var(--p-surface);
  color: var(--p-text);
  transition: border-color var(--p-transition), box-shadow var(--p-transition);
}

[data-theme="light"] .settings-input:focus,
[data-theme="enterprise"] .settings-input:focus {
  border-color: var(--p-primary);
  box-shadow: 0 0 0 3px var(--p-primary-soft);
  outline: none;
}

[data-theme="light"] .settings-tabs-bar,
[data-theme="enterprise"] .settings-tabs-bar {
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-md);
  padding: 4px;
}

[data-theme="light"] .settings-tab,
[data-theme="enterprise"] .settings-tab {
  font-family: var(--p-font);
  font-size: var(--p-text-sm);
  font-weight: 500;
  color: var(--p-text-secondary);
  border-radius: var(--p-radius-sm);
  transition: all var(--p-transition);
}

[data-theme="light"] .settings-tab.active,
[data-theme="enterprise"] .settings-tab.active {
  background: var(--p-surface);
  color: var(--p-primary);
  font-weight: 600;
  box-shadow: var(--p-shadow-sm);
}


/* ─── 20. ENTERPRISE TOPNAV IMPROVEMENTS ────────────────────── */

[data-theme="enterprise"] .enterprise-topnav {
  background: var(--p-surface);
  border-bottom: 1px solid var(--p-border);
  box-shadow: var(--p-shadow-xs);
}

[data-theme="enterprise"] .ent-logo {
  font-family: var(--p-font);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--p-text);
}

[data-theme="enterprise"] .ent-logo-sub {
  font-family: var(--p-font);
  color: var(--p-text-muted);
}

[data-theme="enterprise"] .ent-tab {
  font-family: var(--p-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--p-text-secondary);
  padding: 8px 14px;
  border-radius: var(--p-radius-sm);
  transition: all var(--p-transition);
}

[data-theme="enterprise"] .ent-tab:hover {
  color: var(--p-primary);
  background: var(--p-primary-soft);
}

[data-theme="enterprise"] .ent-tab.active {
  color: var(--p-primary);
  font-weight: 600;
  background: var(--p-primary-soft);
}

[data-theme="enterprise"] .ent-dropdown {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  box-shadow: var(--p-shadow-lg);
}

[data-theme="enterprise"] .ent-dropdown a {
  font-family: var(--p-font);
  font-size: 13px;
  color: var(--p-text-secondary);
  padding: 8px 16px;
  transition: all var(--p-transition);
}

[data-theme="enterprise"] .ent-dropdown a:hover {
  background: var(--p-primary-soft);
  color: var(--p-primary);
}


/* ─── 21. SCROLLBAR ─────────────────────────────────────────── */

[data-theme="light"] .sidebar-scroll::-webkit-scrollbar,
[data-theme="enterprise"] .sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-track,
[data-theme="enterprise"] .sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-thumb,
[data-theme="enterprise"] .sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--p-border);
  border-radius: 4px;
}

[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-thumb:hover,
[data-theme="enterprise"] .sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--p-text-muted);
}


/* ─── 22. COMMAND PALETTE ───────────────────────────────────── */

[data-theme="light"] .cmd-box,
[data-theme="enterprise"] .cmd-box {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-xl);
  box-shadow: var(--p-shadow-xl);
}

[data-theme="light"] .cmd-input,
[data-theme="enterprise"] .cmd-input {
  font-family: var(--p-font);
  color: var(--p-text);
}

[data-theme="light"] .cmd-results .cmd-item.active,
[data-theme="enterprise"] .cmd-results .cmd-item.active {
  background: var(--p-primary-soft);
  color: var(--p-primary);
}


/* ─── 23. NOTIFICATION DROPDOWN ─────────────────────────────── */

[data-theme="light"] .notif-dropdown,
[data-theme="enterprise"] .notif-dropdown {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-lg);
}

[data-theme="light"] .notif-head,
[data-theme="enterprise"] .notif-head {
  font-family: var(--p-font);
  font-weight: 600;
  color: var(--p-text);
  border-bottom: 1px solid var(--p-border-light);
}

[data-theme="light"] .notif-badge,
[data-theme="enterprise"] .notif-badge {
  background: var(--p-danger);
  color: #fff;
  font-family: var(--p-font);
  font-weight: 700;
}


/* ─── 24. RESPONSIVE ────────────────────────────────────────── */

@media (max-width: 1200px) {
  :root {
    --p-content-max: 100%;
  }
  .p-kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (max-width: 768px) {
  .page {
    padding: var(--p-space-md);
  }

  .p-page-header {
    flex-direction: column;
    gap: var(--p-space-md);
  }

  .p-page-header-right {
    width: 100%;
    justify-content: flex-start;
  }

  .p-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--p-space-sm);
  }

  .p-form-grid {
    grid-template-columns: 1fr;
  }

  .p-card {
    padding: var(--p-space-md);
  }

  .p-page-title {
    font-size: var(--p-text-xl);
  }
}

@media (max-width: 480px) {
  .p-kpi-grid {
    grid-template-columns: 1fr;
  }

  .p-btn--lg {
    width: 100%;
  }
}


/* ─── 25. UTILITY CLASSES ───────────────────────────────────── */

.p-mt-xs  { margin-top: var(--p-space-xs); }
.p-mt-sm  { margin-top: var(--p-space-sm); }
.p-mt-md  { margin-top: var(--p-space-md); }
.p-mt-lg  { margin-top: var(--p-space-lg); }
.p-mt-xl  { margin-top: var(--p-space-xl); }

.p-mb-xs  { margin-bottom: var(--p-space-xs); }
.p-mb-sm  { margin-bottom: var(--p-space-sm); }
.p-mb-md  { margin-bottom: var(--p-space-md); }
.p-mb-lg  { margin-bottom: var(--p-space-lg); }
.p-mb-xl  { margin-bottom: var(--p-space-xl); }

.p-gap-sm { gap: var(--p-space-sm); }
.p-gap-md { gap: var(--p-space-md); }
.p-gap-lg { gap: var(--p-space-lg); }

.p-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--p-space-md); }
.p-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--p-space-md); }
.p-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--p-space-md); }

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

.p-flex    { display: flex; }
.p-flex-center { display: flex; align-items: center; }
.p-flex-between { display: flex; align-items: center; justify-content: space-between; }
.p-flex-col { display: flex; flex-direction: column; }

.p-text-muted   { color: var(--p-text-muted); }
.p-text-success { color: var(--p-success); }
.p-text-warning { color: var(--p-warning); }
.p-text-danger  { color: var(--p-danger); }
.p-text-primary { color: var(--p-primary); }

.p-font-mono { font-family: var(--p-font-mono); }
.p-font-bold { font-weight: 700; }
.p-font-semi { font-weight: 600; }

.p-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Divider */
.p-divider {
  height: 1px;
  background: var(--p-border-light);
  margin: var(--p-space-md) 0;
  border: none;
}

/* Section heading */
.p-section-title {
  font-size: var(--p-text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--p-text-muted);
  margin-bottom: var(--p-space-md);
}


/* ─── 26. LOADING SKELETON ──────────────────────────────────── */

.p-skeleton {
  background: linear-gradient(90deg, var(--p-bg-alt) 25%, var(--p-border-light) 50%, var(--p-bg-alt) 75%);
  background-size: 200% 100%;
  animation: p-shimmer 1.5s infinite;
  border-radius: var(--p-radius-sm);
}

.p-skeleton--text {
  height: 14px;
  width: 60%;
  margin-bottom: 8px;
}

.p-skeleton--title {
  height: 24px;
  width: 40%;
  margin-bottom: 12px;
}

.p-skeleton--card {
  height: 120px;
  border-radius: var(--p-radius-lg);
}

@keyframes p-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}


/* ─── 27. SIMULATION PAGE ───────────────────────────────────── */

.sim-form-card {
  margin-bottom: var(--p-space-lg);
}

/* Price recommendation grid */
.sim-prices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--p-space-md);
  margin-bottom: var(--p-space-lg);
}

.sim-price-card {
  text-align: center;
  cursor: pointer;
  position: relative;
  border-top: 3px solid var(--p-border);
  transition: all var(--p-transition);
}

.sim-price-card--safe   { border-top-color: var(--p-success); }
.sim-price-card--balanced { border-top-color: var(--p-primary); }
.sim-price-card--aggressive { border-top-color: var(--p-danger); }

.sim-price-card.selected {
  box-shadow: 0 0 0 2px var(--p-primary);
}
.sim-price-card--safe.selected    { box-shadow: 0 0 0 2px var(--p-success); }
.sim-price-card--aggressive.selected { box-shadow: 0 0 0 2px var(--p-danger); }

.sim-price-label {
  font-size: var(--p-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--p-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--p-space-sm);
}

.sim-price-value {
  font-size: var(--p-text-3xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--p-space-xs);
}

.sim-price-card--safe .sim-price-value     { color: var(--p-success); }
.sim-price-card--balanced .sim-price-value  { color: var(--p-primary); }
.sim-price-card--aggressive .sim-price-value { color: var(--p-danger); }

.sim-price-delta {
  font-size: var(--p-text-sm);
  font-weight: 600;
  margin-bottom: var(--p-space-sm);
}

.sim-price-desc {
  font-size: var(--p-text-xs);
  color: var(--p-text-muted);
  line-height: 1.4;
}

/* Score cards grid */
.sim-scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--p-space-sm);
  margin-bottom: var(--p-space-md);
}

.sim-score-item {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  padding: var(--p-space-md);
  text-align: center;
  transition: all var(--p-transition);
}

.sim-score-item:hover {
  box-shadow: var(--p-shadow-sm);
}

.sim-score-value {
  font-size: var(--p-text-xl);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.sim-score-label {
  font-size: var(--p-text-xs);
  font-weight: 500;
  color: var(--p-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Agent cards */
.sim-agent-item {
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  padding: var(--p-space-md);
  margin-bottom: var(--p-space-sm);
  transition: all var(--p-transition);
  border-left: 3px solid var(--p-border);
}

.sim-agent-item:hover {
  box-shadow: var(--p-shadow-sm);
  background: var(--p-surface-hover);
}

.sim-agent-item--positive { border-left-color: var(--p-success); }
.sim-agent-item--negative { border-left-color: var(--p-danger); }
.sim-agent-item--neutral  { border-left-color: var(--p-text-muted); }

.sim-agent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sim-agent-name {
  font-size: var(--p-text-base);
  font-weight: 600;
  color: var(--p-text);
}

.sim-agent-impacts {
  display: flex;
  gap: var(--p-space-sm);
}

.sim-agent-impact {
  font-size: var(--p-text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--p-radius-full);
}

.sim-agent-recommendation {
  font-size: var(--p-text-sm);
  color: var(--p-text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.sim-agent-codes {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sim-agent-code {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--p-radius-full);
  background: var(--p-primary-soft);
  color: var(--p-primary);
}

.sim-agent-warning {
  font-size: var(--p-text-xs);
  color: var(--p-warning);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sim-agent-missing {
  font-size: var(--p-text-xs);
  color: var(--p-text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* Factor impact bars */
.sim-factor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sim-factor-label {
  min-width: 130px;
  font-size: var(--p-text-sm);
  color: var(--p-text-secondary);
  text-align: right;
}

.sim-factor-bar-wrap {
  flex: 1;
  height: 22px;
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-sm);
  overflow: hidden;
}

.sim-factor-bar {
  height: 100%;
  border-radius: var(--p-radius-sm);
  transition: width 0.4s ease;
}

.sim-factor-bar--positive { background: var(--p-success); }
.sim-factor-bar--negative { background: var(--p-danger); }

.sim-factor-value {
  min-width: 45px;
  font-size: var(--p-text-xs);
  font-weight: 700;
  text-align: right;
}

/* Apply section */
.sim-apply-section {
  margin-top: var(--p-space-lg);
  padding: var(--p-space-lg);
  text-align: center;
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-lg);
  border: 1px solid var(--p-border-light);
}

.sim-apply-info {
  font-size: var(--p-text-xs);
  color: var(--p-text-muted);
  margin-top: var(--p-space-sm);
  line-height: 1.5;
}

/* Graph improvements */
.sim-graph-col-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--p-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--p-border);
}

.sim-graph-node {
  border-left: 3px solid var(--p-border);
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--p-transition);
}

.sim-graph-node:hover {
  box-shadow: var(--p-shadow-sm);
  border-color: var(--p-primary);
}

.sim-graph-node--positive { border-left: 3px solid var(--p-success); }
.sim-graph-node--negative { border-left: 3px solid var(--p-danger); }
.sim-graph-node--missing  { border-left: 3px solid var(--p-warning); }
.sim-graph-node--neutral  { border-left: 3px solid var(--p-text-muted); }

.sim-graph-chains {
  margin-top: var(--p-space-lg);
  padding: var(--p-space-md);
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-md);
  border: 1px solid var(--p-border-light);
}

.sim-graph-detail {
  margin-top: var(--p-space-md);
  padding: var(--p-space-lg);
  background: var(--p-surface);
  border: 1px solid var(--p-primary);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-md);
}

/* Responsive sim */
@media (max-width: 768px) {
  .sim-prices-grid {
    grid-template-columns: 1fr;
  }
  .sim-scores-grid {
    grid-template-columns: 1fr 1fr;
  }
  .sim-factor-label {
    min-width: 80px;
    font-size: var(--p-text-xs);
  }
}


/* ─── 28. COCKPIT / OVERVIEW IMPROVEMENTS ───────────────────── */

/* Quick Actions */
.cockpit-quick-actions {
  display: flex;
  gap: var(--p-space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--p-space-lg);
}

.cockpit-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  font-family: var(--p-font);
  font-size: var(--p-text-sm);
  font-weight: 500;
  color: var(--p-text-secondary);
  cursor: pointer;
  transition: all var(--p-transition);
}

.cockpit-quick-btn:hover {
  border-color: var(--p-primary);
  color: var(--p-primary);
  background: var(--p-primary-soft);
  box-shadow: var(--p-shadow-sm);
}

.cockpit-quick-btn-icon {
  font-size: 16px;
}

/* Alerts section */
.cockpit-alerts {
  display: flex;
  flex-direction: column;
  gap: var(--p-space-sm);
  margin-bottom: var(--p-space-lg);
}

.cockpit-alert-item {
  display: flex;
  align-items: center;
  gap: var(--p-space-md);
  padding: 12px var(--p-space-md);
  border-radius: var(--p-radius-md);
  font-size: var(--p-text-sm);
  line-height: 1.4;
}

.cockpit-alert-item--danger {
  background: var(--p-danger-soft);
  border: 1px solid rgba(229,56,79,0.12);
  color: var(--p-danger);
}

.cockpit-alert-item--warning {
  background: var(--p-warning-soft);
  border: 1px solid rgba(240,169,48,0.12);
  color: #9a6b0a;
}

[data-theme="dark"] .cockpit-alert-item--warning {
  color: var(--p-warning);
}

.cockpit-alert-item--info {
  background: var(--p-info-soft);
  border: 1px solid rgba(46,157,229,0.12);
  color: var(--p-info);
}

.cockpit-alert-item--success {
  background: var(--p-success-soft);
  border: 1px solid rgba(15,157,88,0.12);
  color: var(--p-success);
}

.cockpit-alert-icon {
  font-size: 16px;
  flex-shrink: 0;
}


/* ─── 29. TOAST IMPROVEMENTS ────────────────────────────────── */

.toast {
  position: relative;
  overflow: hidden;
}

.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  animation: p-toast-dismiss 4s linear forwards;
}

.toast.success::after { background: var(--p-success); }
.toast.error::after   { background: var(--p-danger); }
.toast.warn::after    { background: var(--p-warning); }
.toast.info::after    { background: var(--p-info); }

@keyframes p-toast-dismiss {
  from { width: 100%; }
  to   { width: 0%; }
}


/* ─── 30. FOCUS & ACCESSIBILITY ─────────────────────────────── */

/* Focus visible for keyboard nav */
.p-btn:focus-visible,
.p-input:focus-visible,
.p-select:focus-visible,
.nav-item:focus-visible,
.ent-tab:focus-visible,
button:focus-visible {
  outline: 2px solid var(--p-primary);
  outline-offset: 2px;
}

/* Better contrast for muted text on hover */
.p-card:hover .p-card-subtitle {
  color: var(--p-text-secondary);
}

/* Skip to content (hidden, keyboard accessible) */
.p-skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 10001;
  padding: 8px 16px;
  background: var(--p-primary);
  color: #fff;
  border-radius: var(--p-radius-sm);
  font-size: var(--p-text-sm);
  font-weight: 600;
  text-decoration: none;
}

.p-skip-link:focus {
  top: 16px;
}

/* Close buttons - consistent */
.modal-close:focus-visible {
  outline: 2px solid var(--p-primary);
  outline-offset: 2px;
}


/* ─── 31. RESPONSIVE DEEP ───────────────────────────────────── */

/* Tablet (768-1024) */
@media (max-width: 1024px) {
  .p-page-header {
    flex-direction: column;
    gap: var(--p-space-md);
    align-items: flex-start;
  }

  .p-page-header-right {
    width: 100%;
    flex-wrap: wrap;
  }

  /* Overview layout */
  .rb-layout {
    grid-template-columns: 1fr;
  }

  .rb-sidebar.glass {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--p-space-sm);
  }

  .rb-sidebar .rb-side-title {
    grid-column: 1 / -1;
  }

  .rb-main {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Charts */
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  /* Cockpit alerts */
  .cockpit-quick-actions {
    flex-wrap: wrap;
  }
}

/* Mobile (max 768) */
@media (max-width: 768px) {
  /* Main layout */
  .main {
    margin-left: 0;
  }

  .page {
    padding: var(--p-space-md) var(--p-space-sm);
  }

  .p-page-title {
    font-size: var(--p-text-xl);
  }

  .p-page-subtitle {
    font-size: var(--p-text-xs);
  }

  /* Buttons stack */
  .p-page-header-right {
    flex-direction: column;
    align-items: stretch;
  }

  .p-page-header-right .p-btn {
    width: 100%;
    justify-content: center;
  }

  /* RB cards single column */
  .rb-main {
    grid-template-columns: 1fr;
  }

  .rb-sidebar.glass {
    grid-template-columns: 1fr 1fr;
  }

  .rb-card.rb-wide,
  .rb-card.rb-chart-card {
    grid-column: 1;
  }

  /* Top row */
  .top-row {
    flex-direction: column;
  }

  /* Week glance scroll */
  .week-glance {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: var(--p-space-sm);
  }

  .week-day {
    min-width: 100px;
    flex-shrink: 0;
  }

  /* Category cards */
  .cat-cards {
    grid-template-columns: 1fr 1fr;
  }

  /* Simulation */
  .sim-prices-grid {
    grid-template-columns: 1fr;
    gap: var(--p-space-sm);
  }

  .sim-scores-grid {
    grid-template-columns: 1fr 1fr;
  }

  .sim-agent-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .sim-agent-impacts {
    flex-wrap: wrap;
  }

  .sim-factor-label {
    min-width: 70px;
    font-size: 10px;
  }

  .sim-apply-section {
    padding: var(--p-space-md);
  }

  /* Tables */
  .p-table-wrap,
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .p-table {
    min-width: 600px;
  }

  .data-table {
    min-width: 600px;
  }

  /* Modals */
  .modal {
    margin: var(--p-space-sm);
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-overlay.show .modal {
    width: calc(100vw - 24px);
    max-width: none;
  }

  /* Calendar */
  .cal-layout {
    grid-template-columns: 1fr;
  }

  .cal-sidebar {
    order: -1;
  }

  /* Inbox */
  .inbox-layout {
    grid-template-columns: 1fr;
  }

  .inbox-detail-pane {
    display: none;
  }

  /* Pipeline */
  .kanban-board {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Alerts */
  .cockpit-alert-item {
    font-size: var(--p-text-xs);
    padding: 10px var(--p-space-sm);
  }

  /* Quick actions */
  .cockpit-quick-btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }
}

/* Small mobile (max 480) */
@media (max-width: 480px) {
  .p-page-title {
    font-size: 18px;
  }

  .rb-sidebar.glass {
    grid-template-columns: 1fr;
  }

  .cat-cards {
    grid-template-columns: 1fr;
  }

  .sim-scores-grid {
    grid-template-columns: 1fr;
  }

  .p-kpi-grid {
    grid-template-columns: 1fr;
  }

  .p-form-grid {
    grid-template-columns: 1fr;
  }

  .sim-graph-grid {
    grid-template-columns: 1fr;
  }
}


/* ─── 32. PAGE-SPECIFIC POLISH ──────────────────────────────── */

/* Pricing page */
[data-theme="light"] #page-pricing .card.glass,
[data-theme="enterprise"] #page-pricing .card.glass {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-sm);
}

/* Rate Shop page */
[data-theme="light"] .rs-kpis,
[data-theme="enterprise"] .rs-kpis {
  gap: var(--p-space-md);
}

[data-theme="light"] .rs-kpis .card.glass,
[data-theme="enterprise"] .rs-kpis .card.glass {
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-xs);
}

/* Forecast page */
[data-theme="light"] .grid-3-kpi .card.glass,
[data-theme="enterprise"] .grid-3-kpi .card.glass {
  border-radius: var(--p-radius-lg);
}

/* Events page */
[data-theme="light"] .ev-toolbar,
[data-theme="enterprise"] .ev-toolbar {
  gap: var(--p-space-md);
}

[data-theme="light"] .ev-form-card,
[data-theme="enterprise"] .ev-form-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-sm);
}

/* Calendar */
[data-theme="light"] .cal-toolbar,
[data-theme="enterprise"] .cal-toolbar {
  gap: var(--p-space-md);
}

[data-theme="light"] .cal-cell,
[data-theme="enterprise"] .cal-cell {
  border-radius: var(--p-radius-sm);
  transition: all var(--p-transition);
}

[data-theme="light"] .cal-cell:hover,
[data-theme="enterprise"] .cal-cell:hover {
  box-shadow: var(--p-shadow-sm);
}

/* Audit page */
[data-theme="light"] #page-audit .card.glass,
[data-theme="enterprise"] #page-audit .card.glass {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-sm);
}

/* IBELSA page */
[data-theme="light"] .ib-kpi-bar .kpi,
[data-theme="enterprise"] .ib-kpi-bar .kpi {
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-xs);
}

/* Analytics tabs */
[data-theme="light"] .an-tabs,
[data-theme="enterprise"] .an-tabs {
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-md);
  padding: 3px;
}

[data-theme="light"] .an-tab,
[data-theme="enterprise"] .an-tab {
  font-family: var(--p-font);
  border-radius: var(--p-radius-sm);
  transition: all var(--p-transition);
}

[data-theme="light"] .an-tab.active,
[data-theme="enterprise"] .an-tab.active {
  background: var(--p-surface);
  color: var(--p-primary);
  box-shadow: var(--p-shadow-sm);
}

/* Algo tabs */
[data-theme="light"] .algo-tabs,
[data-theme="enterprise"] .algo-tabs {
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-md);
  padding: 3px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}

/* Ensure algo-tabs are always scrollable */
.algo-tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.algo-tabs::-webkit-scrollbar { height: 3px; }
.algo-tabs::-webkit-scrollbar-thumb { background: var(--p-border); border-radius: 3px; }

.algo-tab { white-space: nowrap; flex-shrink: 0; }

[data-theme="light"] .algo-tab,
[data-theme="enterprise"] .algo-tab {
  font-family: var(--p-font);
  border-radius: var(--p-radius-sm);
  transition: all var(--p-transition);
}

[data-theme="light"] .algo-tab.active,
[data-theme="enterprise"] .algo-tab.active {
  background: var(--p-surface);
  color: var(--p-primary);
  box-shadow: var(--p-shadow-sm);
}


/* ─── 33. STUNNING VISUAL COMPONENTS (VX) ────────────────────── */

/* === ANIMATIONS === */
@keyframes vx-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes vx-fadein {
  to { opacity: 1; }
}

@keyframes vx-slideup {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes vx-scalein {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes vx-glow-pulse {
  0%, 100% { opacity: 0.15; }
  50%      { opacity: 0.35; }
}

/* Reveal animation for results */
.vx-reveal > * {
  animation: vx-slideup 0.5s ease both;
}
.vx-reveal > *:nth-child(1) { animation-delay: 0s; }
.vx-reveal > *:nth-child(2) { animation-delay: 0.08s; }
.vx-reveal > *:nth-child(3) { animation-delay: 0.16s; }
.vx-reveal > *:nth-child(4) { animation-delay: 0.24s; }
.vx-reveal > *:nth-child(5) { animation-delay: 0.32s; }
.vx-reveal > *:nth-child(6) { animation-delay: 0.4s; }
.vx-reveal > *:nth-child(7) { animation-delay: 0.48s; }
.vx-reveal > *:nth-child(8) { animation-delay: 0.56s; }

/* === SCORE RINGS === */
.vx-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: vx-scalein 0.6s ease both;
}

.vx-ring-arc {
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Score grid override */
.sim-scores-grid {
  display: flex;
  justify-content: center;
  gap: var(--p-space-lg);
  flex-wrap: wrap;
  padding: var(--p-space-lg) 0;
}

/* === AGENT BOARD === */
.vx-agents {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--p-space-md);
}

.vx-agent {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  padding: 18px;
  transition: all 0.25s ease;
  animation: vx-slideup 0.5s ease both;
  position: relative;
  overflow: hidden;
}

.vx-agent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--agent-color, #3366ff), transparent);
  opacity: 0.6;
}

.vx-agent:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  transform: translateY(-3px);
  border-color: var(--agent-color, var(--p-primary));
}

.vx-agent-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.vx-agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--p-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

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

.vx-agent-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--p-text);
  margin-bottom: 3px;
}

.vx-agent-rec {
  font-size: 12px;
  color: var(--p-text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vx-agent-scores {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.vx-score-pill {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-sm);
}

.vx-score-label {
  display: block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-bottom: 2px;
}

.vx-score-num {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* Agent bar */
.vx-agent-bar-wrap {
  height: 5px;
  background: var(--p-bg-alt);
  border-radius: 3px;
  position: relative;
  margin-bottom: 10px;
}

.vx-agent-bar-center {
  position: absolute;
  left: 50%;
  top: -2px;
  width: 1px;
  height: 9px;
  background: var(--p-border);
}

.vx-agent-bar {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* Chips */
.vx-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--p-radius-full);
  background: var(--p-primary-soft);
  color: var(--p-primary);
  letter-spacing: 0.02em;
}

.vx-agent-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.vx-agent-warn {
  font-size: 11px;
  color: var(--p-warning);
  margin-top: 4px;
}

.vx-agent-miss {
  font-size: 11px;
  color: var(--p-text-muted);
  font-style: italic;
  margin-top: 3px;
}

/* === SVG FLOW GRAPH === */
.vx-flow {
  position: relative;
  background: linear-gradient(135deg, var(--p-bg-alt) 0%, var(--p-surface) 100%);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-xl);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.vx-flow-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.vx-col-label {
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--p-text-muted);
  white-space: nowrap;
}

/* Graph Nodes */
.vx-node {
  position: absolute;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
  animation: vx-scalein 0.4s ease both;
  overflow: hidden;
  z-index: 1;
}

.vx-node:hover {
  border-color: var(--nc, var(--p-primary));
  box-shadow: 0 0 20px color-mix(in srgb, var(--nc, var(--p-primary)) 25%, transparent);
  z-index: 5;
  transform: scale(1.04);
}

.vx-node--active {
  border-color: var(--nc, var(--p-primary));
  box-shadow: 0 0 25px color-mix(in srgb, var(--nc, var(--p-primary)) 30%, transparent);
  z-index: 5;
}

.vx-node-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  animation: vx-glow-pulse 3s ease-in-out infinite;
}

.vx-node-content {
  padding: 8px 12px 8px 14px;
  position: relative;
}

.vx-node-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--p-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vx-node-price {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.vx-node-score {
  font-size: 17px;
  font-weight: 700;
}

.vx-node-score small {
  font-size: 10px;
  color: var(--p-text-muted);
  font-weight: 500;
}

.vx-node-impacts {
  font-size: 10px;
  font-weight: 600;
  margin-top: 1px;
}

.vx-node-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
}

/* Edge transitions */
.vx-edge {
  transition: opacity 0.25s ease, stroke-width 0.25s ease;
}

/* Legend */
.vx-legend {
  position: absolute;
  bottom: 12px;
  left: 30px;
  display: flex;
  gap: 18px;
  z-index: 2;
}

.vx-legend-i {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--p-text-muted);
  font-weight: 500;
}

.vx-legend-dot {
  width: 10px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

/* Factor bars (animated) */
.vx-factors {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vx-factor {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: vx-slideup 0.4s ease both;
}

.vx-factor-name {
  min-width: 130px;
  font-size: 13px;
  color: var(--p-text-secondary);
  text-align: right;
  font-weight: 500;
}

.vx-factor-track {
  flex: 1;
  height: 22px;
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-sm);
  overflow: hidden;
}

.vx-factor-bar {
  height: 100%;
  border-radius: var(--p-radius-sm);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.vx-factor-val {
  min-width: 45px;
  text-align: right;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Price cards glow on selection */
.sim-price-card.selected {
  border-color: transparent;
}

.sim-price-card--safe.selected {
  box-shadow: 0 0 0 2px #34d399, 0 0 20px rgba(52,211,153,0.15);
}

.sim-price-card--balanced.selected {
  box-shadow: 0 0 0 2px #3366ff, 0 0 20px rgba(51,102,255,0.15);
}

.sim-price-card--aggressive.selected {
  box-shadow: 0 0 0 2px #f87171, 0 0 20px rgba(248,113,113,0.15);
}

/* Responsive */
@media (max-width: 768px) {
  .vx-agents {
    grid-template-columns: 1fr;
  }

  .vx-flow {
    min-height: auto;
  }

  .sim-scores-grid {
    gap: var(--p-space-sm);
  }

  .vx-factor-name {
    min-width: 80px;
    font-size: 11px;
  }
}


/* ─── 34. AI COCKPIT PREMIUM ─────────────────────────────────── */

/* KPI Cards */
#page-ai .ai-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--p-space-md);
  margin-bottom: var(--p-space-md);
}

#page-ai .ai-kpi-card {
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  border-top: 3px solid var(--kpi-accent, var(--p-primary));
}

#page-ai .ai-kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

#page-ai .ai-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--p-text-muted);
  margin-bottom: 8px;
}

#page-ai .ai-kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--p-text);
  line-height: 1;
  margin-bottom: 6px;
}

#page-ai .ai-kpi-value.ai-kpi-up { color: #0f9d58; }
#page-ai .ai-kpi-value.ai-kpi-down { color: #e5384f; }
#page-ai .ai-kpi-value.ai-kpi-warn { color: #f0a930; }

#page-ai .ai-kpi-sub {
  font-size: 11px;
  color: var(--p-text-muted);
}

/* Insights */
#page-ai .ai-insights-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#page-ai .ai-insight-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-md);
  font-size: 13px;
  color: var(--p-text);
  line-height: 1.5;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

#page-ai .ai-insight-item:hover {
  background: var(--p-primary-soft);
  border-left-color: var(--p-primary);
}

#page-ai .ai-insight-warn {
  border-left-color: var(--p-warning);
  background: var(--p-warning-soft);
}

#page-ai .ai-insight-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Channel Mix */
#page-ai .ai-channel-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#page-ai .ai-channel-row {
  display: grid;
  grid-template-columns: 100px 1fr 60px 60px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

#page-ai .ai-channel-name {
  font-weight: 600;
  color: var(--p-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#page-ai .ai-channel-bar-bg {
  height: 8px;
  background: var(--p-bg-alt);
  border-radius: 4px;
  overflow: hidden;
}

#page-ai .ai-channel-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
}

#page-ai .ai-channel-stats {
  font-weight: 600;
  color: var(--p-text);
  text-align: right;
  font-size: 12px;
}

#page-ai .ai-channel-pct {
  color: var(--p-text-muted);
  font-weight: 400;
}

#page-ai .ai-channel-adr {
  font-weight: 600;
  color: var(--p-text-secondary);
  text-align: right;
  font-size: 12px;
}

/* Category Performance */
#page-ai .ai-category-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#page-ai .ai-cat-row {
  display: grid;
  grid-template-columns: 50px 1fr 80px 80px 80px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--p-border-light);
}

#page-ai .ai-cat-row:last-child {
  border-bottom: none;
}

#page-ai .ai-cat-name {
  font-weight: 700;
  font-size: 14px;
}

#page-ai .ai-cat-bar-bg {
  height: 8px;
  background: var(--p-bg-alt);
  border-radius: 4px;
  overflow: hidden;
}

#page-ai .ai-cat-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
}

#page-ai .ai-cat-bookings,
#page-ai .ai-cat-adr,
#page-ai .ai-cat-rev {
  text-align: right;
  font-size: 12px;
  font-weight: 500;
  color: var(--p-text-secondary);
}

#page-ai .ai-cat-rev {
  font-weight: 700;
  color: var(--p-text);
}

/* Weights */
#page-ai .ai-weights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#page-ai .ai-weight-row {
  display: grid;
  grid-template-columns: 90px 1fr 40px 60px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

#page-ai .ai-weight-name {
  font-weight: 600;
  color: var(--p-text);
}

#page-ai .ai-weight-bar-bg {
  height: 6px;
  background: var(--p-bg-alt);
  border-radius: 3px;
  overflow: hidden;
}

#page-ai .ai-weight-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3366ff, #7c3aed);
  transition: width 0.6s ease;
}

#page-ai .ai-weight-val {
  font-weight: 700;
  color: var(--p-text);
  text-align: right;
}

#page-ai .ai-weight-change {
  font-size: 11px;
  color: var(--p-text-muted);
  text-align: right;
}

#page-ai .ai-weight-change.positive { color: #0f9d58; }
#page-ai .ai-weight-change.negative { color: #e5384f; }

/* Patterns */
#page-ai .ai-patterns-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#page-ai .ai-pattern-item {
  padding: 10px 14px;
  background: var(--p-bg-alt);
  border-radius: var(--p-radius-md);
  font-size: 13px;
  color: var(--p-text);
  line-height: 1.5;
  border-left: 3px solid var(--p-primary);
  transition: all 0.2s ease;
}

#page-ai .ai-pattern-item:hover {
  background: var(--p-primary-soft);
}

#page-ai .ai-pattern-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--p-radius-full);
  background: var(--p-primary-soft);
  color: var(--p-primary);
  margin-right: 8px;
}

/* YoY Toggles */
#page-ai .ai-yoy-toggles .pill {
  font-size: 12px;
  padding: 5px 12px;
}

/* Responsive */
@media (max-width: 1024px) {
  #page-ai .ai-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .ai-charts-row {
    grid-template-columns: 1fr !important;
  }
  .ai-bottom-row {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  #page-ai .ai-kpi-row {
    grid-template-columns: 1fr;
  }
  #page-ai .ai-cat-row {
    grid-template-columns: 50px 1fr 60px;
  }
  #page-ai .ai-cat-adr,
  #page-ai .ai-cat-bookings {
    display: none;
  }
}


/* ─── 35. ALGORITHM SETTINGS UI ──────────────────────────────── */

.as-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: var(--p-space-lg);
  background: var(--p-bg-alt);
  padding: 4px;
  border-radius: var(--p-radius-md);
}

.as-tab {
  font-family: var(--p-font);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--p-text-secondary);
  border-radius: var(--p-radius-sm);
  cursor: pointer;
  transition: all var(--p-transition);
}

.as-tab:hover { color: var(--p-primary); background: rgba(255,255,255,0.5); }
.as-tab.active { background: var(--p-surface); color: var(--p-primary); font-weight: 600; box-shadow: var(--p-shadow-sm); }

/* Mode cards */
.as-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--p-space-md);
}

.as-mode-card {
  padding: var(--p-space-md);
  border: 2px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.as-mode-card:hover { border-color: var(--p-primary); box-shadow: var(--p-shadow-sm); }
.as-mode-card--selected { border-color: var(--p-primary); background: var(--p-primary-soft); }

.as-mode-name { font-size: 15px; font-weight: 700; color: var(--p-text); margin-bottom: 6px; }
.as-mode-desc { font-size: 12px; color: var(--p-text-muted); line-height: 1.5; }

/* Template grid */
.as-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--p-space-md);
}

.as-template-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  padding: var(--p-space-md);
  transition: all 0.2s ease;
}

.as-template-card:hover { box-shadow: var(--p-shadow-md); transform: translateY(-2px); }
.as-template-card--active { border-color: var(--p-success); border-width: 2px; }

.as-template-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.as-template-name { font-size: 15px; font-weight: 700; color: var(--p-text); }
.as-template-desc { font-size: 12px; color: var(--p-text-muted); line-height: 1.5; margin-bottom: 10px; }
.as-template-stats { display: flex; gap: 12px; font-size: 11px; color: var(--p-text-secondary); }

/* Factor rows */
.as-factors { display: flex; flex-direction: column; gap: 6px; }

.as-factor-row {
  display: grid;
  grid-template-columns: 36px 1fr 180px 90px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--p-surface);
  border: 1px solid var(--p-border-light);
  border-radius: var(--p-radius-md);
  transition: background 0.15s;
}

.as-factor-row:hover { background: var(--p-surface-hover); }

.as-factor-toggle { display: flex; align-items: center; justify-content: center; }
.as-factor-toggle input { width: 16px; height: 16px; cursor: pointer; }

.as-factor-name { font-size: 13px; font-weight: 600; color: var(--p-text); }
.as-factor-explain { font-size: 11px; color: var(--p-text-muted); line-height: 1.4; }

.as-factor-slider { display: flex; align-items: center; gap: 8px; }

.as-slider {
  width: 120px;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 3px;
  background: var(--p-bg-alt);
  outline: none;
}

.as-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--p-primary);
  cursor: pointer;
  border: 2px solid var(--p-surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.as-slider:disabled { opacity: 0.3; }
.as-slider-val { font-size: 13px; font-weight: 700; color: var(--p-text); min-width: 28px; text-align: right; }
.as-factor-dir { font-size: 11px; font-weight: 600; text-align: right; }

/* Responsive */
@media (max-width: 768px) {
  .as-mode-grid { grid-template-columns: 1fr; }
  .as-template-grid { grid-template-columns: 1fr; }
  .as-factor-row { grid-template-columns: 30px 1fr; }
  .as-factor-slider, .as-factor-dir { display: none; }
}


/* ─── 36. PRINT STYLES ──────────────────────────────────────── */

@media print {
  .sidebar,
  .enterprise-topnav,
  .topbar,
  .toast-container,
  .cmd-overlay,
  .sidebar-live,
  .sidebar-user {
    display: none !important;
  }

  .main {
    margin-left: 0 !important;
  }

  .page {
    max-width: 100%;
    padding: 0;
  }

  .p-card, .card.glass, .rb-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
