/* ============================================
   STRATUM PRO — Unified Design System v1.0
   Professional SaaS Financial Dashboard
   ============================================ */

/* ─── 1. CSS CUSTOM PROPERTIES ─── */

:root {
  /* Light mode (default) */
  --sp-bg-app: #F7F9FB;
  --sp-bg-sidebar: #FFFFFF;
  --sp-sidebar-border: #E5E7EB;
  --sp-sidebar-text: #374151;
  --sp-sidebar-text-muted: #6B7280;
  --sp-sidebar-text-heading: #111827;
  --sp-sidebar-hover-bg: rgba(0,0,0,0.04);
  --sp-sidebar-hover-text: #111827;
  --sp-sidebar-active-bg: rgba(79,70,229,0.08);
  --sp-sidebar-active-text: #4F46E5;
  --sp-sidebar-active-bar: #4F46E5;
  --sp-sidebar-icon-opacity: 0.5;
  --sp-bg-card: #FFFFFF;
  --sp-bg-card-hover: #FAFBFC;
  --sp-bg-input: #F3F4F6;
  --sp-bg-input-focus: #FFFFFF;
  --sp-bg-secondary: #E8EAED;

  --sp-text-primary: #111827;
  --sp-text-secondary: #4B5563;
  --sp-text-muted: #6B7280;
  --sp-text-on-dark: #F9FAFB;

  --sp-border: #E5E7EB;
  --sp-border-light: #F3F4F6;
  --sp-border-focus: #6366F1;

  --sp-accent: #4F46E5;
  --sp-accent-hover: #4338CA;
  --sp-accent-light: #EEF2FF;
  --sp-accent-subtle: rgba(79, 70, 229, 0.08);

  --sp-success: #059669;
  --sp-success-light: #ECFDF5;
  --sp-warning: #B45309;
  --sp-warning-light: #FFFBEB;
  --sp-danger: #DC2626;
  --sp-danger-light: #FEF2F2;
  --sp-info: #2563EB;
  --sp-info-light: #EFF6FF;

  --sp-shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --sp-shadow-md: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
  --sp-shadow-lg: 0 4px 18px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.04);
  --sp-shadow-xl: 0 6px 24px rgba(0,0,0,0.10), 0 3px 8px rgba(0,0,0,0.04);
  --sp-shadow-card: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.02);

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

  /* Semantic surface aliases */
  --sp-surface: var(--sp-bg-card);
  --sp-surface-alt: var(--sp-bg-input);
  --sp-bg: var(--sp-bg-app);
  --sp-text: var(--sp-text-primary);

  --sp-sidebar-w: 260px;
  --sp-header-h: 56px;

  --sp-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
}

html.dark {
  --sp-bg-sidebar: #111827;
  --sp-sidebar-border: rgba(255,255,255,0.06);
  --sp-sidebar-text: #D1D5DB;
  --sp-sidebar-text-muted: #6B7280;
  --sp-sidebar-text-heading: #F9FAFB;
  --sp-sidebar-hover-bg: rgba(255,255,255,0.06);
  --sp-sidebar-hover-text: #F9FAFB;
  --sp-sidebar-active-bg: rgba(99,102,241,0.12);
  --sp-sidebar-active-text: #A5B4FC;
  --sp-sidebar-active-bar: #6366F1;
  --sp-sidebar-icon-opacity: 0.6;
  --sp-bg-app: #0F1117;
  --sp-bg-card: #1A1D2E;
  --sp-bg-card-hover: #1E2235;
  --sp-bg-input: #1E2235;
  --sp-bg-input-focus: #252A3A;
  --sp-bg-secondary: #252A3D;

  --sp-surface: var(--sp-bg-card);
  --sp-surface-alt: var(--sp-bg-input);
  --sp-bg: var(--sp-bg-app);
  --sp-text: var(--sp-text-primary);

  --sp-text-primary: #F3F4F6;
  --sp-text-secondary: #9CA3AF;
  --sp-text-muted: #6B7280;

  --sp-border: #2D3346;
  --sp-border-light: #1E2235;
  --sp-border-focus: #7C85D6;

  --sp-accent: #7C85D6;
  --sp-accent-hover: #6366F1;
  --sp-accent-light: rgba(124, 133, 214, 0.10);
  --sp-accent-subtle: rgba(124, 133, 214, 0.06);

  --sp-success: #10B981;
  --sp-success-light: rgba(16, 185, 129, 0.1);
  --sp-warning: #F59E0B;
  --sp-warning-light: rgba(245, 158, 11, 0.08);
  --sp-danger: #EF4444;
  --sp-danger-light: rgba(239, 68, 68, 0.1);
  --sp-info: #3B82F6;
  --sp-info-light: rgba(59, 130, 246, 0.1);

  --sp-shadow-sm: 0 1px 3px rgba(0,0,0,0.20);
  --sp-shadow-md: 0 2px 8px rgba(0,0,0,0.25);
  --sp-shadow-lg: 0 4px 16px rgba(0,0,0,0.35);
  --sp-shadow-xl: 0 6px 24px rgba(0,0,0,0.40), 0 3px 8px rgba(0,0,0,0.20);
  --sp-shadow-card: 0 1px 4px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.12);
}

/* Legacy CSS vars — backward compat for child templates */
:root, html.light {
  --color-primary: #4F46E5;
  --color-secondary: #10B981;
  --color-info: #3B82F6;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --bg-primary: #F7F9FB;
  --bg-secondary: #F1F5F9;
  --bg-tertiary: #E8ECF1;
  --bg-card: #FFFFFF;
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --border-color: #E5E7EB;
  --verde: #10B981;
  --ambar: #F59E0B;
  --rojo: #EF4444;
}

html.dark {
  --color-primary: #818CF8;
  --color-secondary: #34D399;
  --color-info: #60A5FA;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --bg-primary: #0F1117;
  --bg-secondary: #1A1D2E;
  --bg-tertiary: #252A3A;
  --bg-card: #1A1D2E;
  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --border-color: #2D3346;
}

/* ─── 2. RESET & BASE ─── */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: var(--sp-font);
  background: var(--sp-bg-app);
  color: var(--sp-text-primary);
  line-height: 1.5;
  min-height: 100vh;
  margin: 0;
}

a { color: var(--sp-accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--sp-accent-hover); }

img { max-width: 100%; height: auto; }

/* ─── 2b. ACCESSIBILITY UTILITIES ─── */

/* Screen reader only — visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to content link */
.sp-skip-link {
  position: fixed;
  top: -100%;
  left: 16px;
  z-index: 100000;
  padding: 12px 24px;
  background: var(--sp-accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--sp-radius-lg);
  text-decoration: none;
  box-shadow: var(--sp-shadow-lg);
  transition: top 0.15s ease;
}
.sp-skip-link:focus {
  top: 16px;
  color: #fff;
  outline: 3px solid var(--sp-warning);
  outline-offset: 2px;
}

/* Universal focus ring for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 2px;
}
/* Remove outline for mouse clicks */
:focus:not(:focus-visible) {
  outline: none;
}

/* Scroll to top button */
.sp-scroll-top {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 900;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--sp-border);
  background: var(--sp-bg-card);
  color: var(--sp-text-secondary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sp-shadow-md);
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
  opacity: 0;
  transform: translateY(8px);
}
.sp-scroll-top.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
.sp-scroll-top:hover {
  background: var(--sp-accent);
  color: #fff;
  border-color: var(--sp-accent);
}
.sp-scroll-top:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 2px;
}

/* ─── 3. TYPOGRAPHY ─── */

h1, .sp-h1 { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--sp-text-primary); margin: 0 0 8px; }
h2, .sp-h2 { font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: var(--sp-text-primary); margin: 0 0 6px; }
h3, .sp-h3 { font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--sp-text-primary); margin: 0 0 4px; }
h4, .sp-h4 { font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--sp-text-primary); margin: 0; }

.sp-subtitle { font-size: 14px; color: var(--sp-text-secondary); margin: 0; }
.sp-caption { font-size: 11px; color: var(--sp-text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* ─── 4. LAYOUT ─── */

.sp-app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar — theme-aware */
.sp-sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sp-sidebar-w);
  background: var(--sp-bg-sidebar);
  border-right: 1px solid var(--sp-sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sp-sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sp-sidebar-border);
  flex-shrink: 0;
}

.sp-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sp-sidebar-logo-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sp-sidebar-logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--sp-sidebar-text-heading);
  letter-spacing: -0.02em;
}

.sp-sidebar-logo-sub {
  font-size: 11px;
  color: var(--sp-sidebar-text-muted);
  font-weight: 400;
}

.sp-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
}

.sp-nav-section {
  margin-bottom: 4px;
}

.sp-nav-section-label {
  padding: 16px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-sidebar-text-muted);
}

.sp-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sp-sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  text-decoration: none;
  position: relative;
  margin-bottom: 2px;
}

.sp-nav-link:hover {
  background: var(--sp-sidebar-hover-bg);
  color: var(--sp-sidebar-hover-text);
}

.sp-nav-link.active {
  background: var(--sp-sidebar-active-bg);
  color: var(--sp-sidebar-active-text);
}

.sp-nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sp-sidebar-active-bar);
}

.sp-nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: var(--sp-sidebar-icon-opacity);
}

.sp-nav-link:hover .sp-nav-icon,
.sp-nav-link.active .sp-nav-icon {
  opacity: 1;
}

.sp-nav-label { flex: 1; }

.sp-nav-hint {
  font-size: 11px;
  color: #6B7280;
  margin-left: auto;
}

.sp-sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--sp-sidebar-border);
  flex-shrink: 0;
}

.sp-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.sp-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #A78BFA);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

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

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

.sp-user-role {
  font-size: 11px;
  color: var(--sp-sidebar-text-muted);
}

/* Main Content Area */
.sp-main {
  margin-left: var(--sp-sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Header */
.sp-header {
  height: var(--sp-header-h);
  border-bottom: 1px solid var(--sp-border);
  background: var(--sp-bg-card);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--sp-shadow-sm);
}

.sp-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--sp-text-primary);
}

.sp-header-breadcrumb {
  font-size: 13px;
  color: var(--sp-text-muted);
}

.sp-header-sep {
  color: var(--sp-text-muted);
  font-size: 13px;
  margin: 0 2px;
}

.sp-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Content Container */
.sp-content {
  flex: 1;
  padding: 24px 32px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* Footer */
.sp-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--sp-border);
  text-align: center;
  font-size: 12px;
  color: var(--sp-text-muted);
  flex-shrink: 0;
}

.sp-footer a {
  color: var(--sp-text-muted);
  margin: 0 8px;
  transition: color 0.15s;
}

.sp-footer a:hover { color: var(--sp-text-secondary); }

/* ─── 5. CARDS ─── */

.sp-card {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--sp-shadow-card);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.sp-card-interactive:hover {
  border-color: var(--sp-border-focus);
  box-shadow: var(--sp-shadow-md);
}

.sp-card-header {
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--sp-border);
}

.sp-card-flush {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-lg);
  box-shadow: var(--sp-shadow-card);
  overflow: hidden;
}

/* ─── 6. BUTTONS ─── */

.sp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--sp-radius-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.4;
  font-family: var(--sp-font);
  white-space: nowrap;
}

.sp-btn-primary {
  background: var(--sp-accent);
  color: white;
}

.sp-btn-primary:hover {
  background: var(--sp-accent-hover);
  color: white;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.18);
}
.sp-btn-primary:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 2px;
}

.sp-btn-secondary {
  background: transparent;
  color: var(--sp-text-primary);
  border: 1px solid var(--sp-border);
}

.sp-btn-secondary:hover {
  border-color: var(--sp-border-focus);
  color: var(--sp-accent);
  background: var(--sp-accent-subtle);
}
.sp-btn-secondary:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 2px;
}

.sp-btn-ghost {
  background: transparent;
  color: var(--sp-text-secondary);
  padding: 9px 14px;
}

.sp-btn-ghost:hover {
  background: var(--sp-accent-subtle);
  color: var(--sp-accent);
}

.sp-btn-danger {
  background: var(--sp-danger);
  color: white;
}

.sp-btn-danger:hover {
  background: #B91C1C;
  color: white;
}

.sp-btn-sm { padding: 5px 12px; font-size: 13px; }
.sp-btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--sp-radius-lg); }
.sp-btn-block { width: 100%; }

.sp-btn:disabled, .sp-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─── 7. FORMS ─── */

.sp-form-group {
  margin-bottom: var(--sp-6);
}

.sp-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--sp-text-primary);
  margin-bottom: 6px;
}

.sp-label-hint {
  font-weight: 400;
  font-size: 12px;
  color: var(--sp-text-muted);
  margin-left: 4px;
}

/* Global input styling */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
select,
textarea {
  padding: 10px 14px;
  background: var(--sp-bg-input);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-md);
  color: var(--sp-text-primary);
  font-size: 14px;
  font-family: var(--sp-font);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--sp-border-focus);
  background: var(--sp-bg-input-focus);
  box-shadow: 0 0 0 3px var(--sp-accent-subtle);
}

input::placeholder,
textarea::placeholder {
  color: var(--sp-text-muted);
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--sp-text-primary);
  margin-bottom: 6px;
}

input[type="file"] {
  padding: 8px;
  background: var(--sp-bg-input);
  border: 2px dashed var(--sp-border);
  border-radius: var(--sp-radius-md);
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: var(--sp-accent);
  background: var(--sp-accent-subtle);
}

/* ─── 8. BADGES ─── */

.sp-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.sp-badge-success { background: var(--sp-success-light); color: var(--sp-success); border: 1px solid rgba(5,150,105,0.15); }
.sp-badge-warning { background: var(--sp-warning-light); color: var(--sp-warning); border: 1px solid rgba(217,119,6,0.15); }
.sp-badge-danger { background: var(--sp-danger-light); color: var(--sp-danger); border: 1px solid rgba(220,38,38,0.15); }
.sp-badge-info { background: var(--sp-info-light); color: var(--sp-info); border: 1px solid rgba(37,99,235,0.15); }
.sp-badge-neutral { background: var(--sp-bg-input); color: var(--sp-text-secondary); border: 1px solid var(--sp-border); }

/* ─── 9. ALERTS & FLASH MESSAGES ─── */

.sp-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--sp-radius-md);
  font-size: 14px;
  margin-bottom: 12px;
  border-left: 3px solid;
}

.sp-alert-success { background: var(--sp-success-light); border-color: var(--sp-success); }
.sp-alert-warning { background: var(--sp-warning-light); border-color: var(--sp-warning); }
.sp-alert-danger { background: var(--sp-danger-light); border-color: var(--sp-danger); }
.sp-alert-info { background: var(--sp-info-light); border-color: var(--sp-info); }

.sp-alert-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.sp-alert-text { flex: 1; color: var(--sp-text-primary); font-size: 14px; line-height: 1.5; }
.sp-alert-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sp-text-muted);
  padding: 0;
  display: flex;
}
.sp-alert-close:hover { color: var(--sp-text-primary); }

/* Auto-dismiss animation for success alerts */
.sp-alert-autodismiss {
  animation: sp-alert-fadeout 0.4s ease forwards;
  animation-delay: 4.6s;
}
@keyframes sp-alert-fadeout {
  0% { opacity: 1; max-height: 100px; margin-bottom: 12px; }
  70% { opacity: 0; max-height: 100px; margin-bottom: 12px; }
  100% { opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; overflow: hidden; }
}

/* Legacy alert compat */
.cfo-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--sp-radius-md);
  font-size: 14px;
  margin-bottom: 12px;
  border-left: 3px solid;
}

.cfo-alert.low { background: var(--sp-success-light); border-color: var(--sp-success); }
.cfo-alert.high { background: var(--sp-danger-light); border-color: var(--sp-danger); }
.cfo-alert.medium { background: var(--sp-warning-light); border-color: var(--sp-warning); }
.cfo-alert-message { font-size: 14px; color: var(--sp-text-primary); }

/* ─── 10. TABLES ─── */

.sp-table {
  width: 100%;
  border-collapse: collapse;
}

.sp-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sp-text-muted);
  border-bottom: 2px solid var(--sp-border);
}

.sp-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--sp-text-secondary);
  border-bottom: 1px solid var(--sp-border-light);
}

.sp-table tr:hover td {
  background: var(--sp-accent-subtle);
}

/* ─── 11. LOADING OVERLAY (base — full styles in section 20) ─── */

/* ─── 12. KPI METRIC CARDS ─── */

.sp-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--sp-text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sp-kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--sp-text-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.sp-kpi-value-sm {
  font-size: 18px;
  font-weight: 600;
  color: var(--sp-text-primary);
  line-height: 1.2;
}

.sp-kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.sp-kpi-change.up { color: var(--sp-success); }
.sp-kpi-change.down { color: var(--sp-danger); }
.sp-kpi-change.neutral { color: var(--sp-text-muted); }

/* ─── 13. SCORE RING ─── */

.sp-score-ring {
  position: relative;
  width: 88px;
  height: 88px;
}

.sp-score-ring svg {
  width: 88px;
  height: 88px;
  transform: rotate(-90deg);
}

.sp-score-ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sp-score-number {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.sp-score-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ─── 14. MODULE INDICATOR BAR ─── */

.sp-module-bar {
  width: 4px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: stretch;
}

.sp-module-bar-success { background: var(--sp-success); }
.sp-module-bar-warning { background: var(--sp-warning); }
.sp-module-bar-danger { background: var(--sp-danger); }
.sp-module-bar-info { background: var(--sp-accent); }

/* ─── 15. PRIORITY LIST ─── */

.sp-priority-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--sp-radius-md);
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  margin-bottom: 8px;
}

.sp-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.sp-priority-dot-critical { background: var(--sp-danger); box-shadow: 0 0 6px rgba(220, 38, 38, 0.4); }
.sp-priority-dot-high { background: var(--sp-warning); box-shadow: 0 0 6px rgba(217, 119, 6, 0.3); }
.sp-priority-dot-medium { background: var(--sp-info); }
.sp-priority-dot-low { background: var(--sp-text-muted); }

/* ─── 16. ACTION CARD ─── */

.sp-action-card {
  background: var(--sp-accent-light);
  border: 1px solid var(--sp-accent);
  border-radius: var(--sp-radius-lg);
  padding: var(--sp-6);
}

html.dark .sp-action-card {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.3);
}

/* ─── 17. THEME TOGGLE (sidebar) ─── */

.sp-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--sp-sidebar-hover-bg);
  border: 1px solid var(--sp-sidebar-border);
  cursor: pointer;
  color: var(--sp-sidebar-text-muted);
  font-size: 13px;
  transition: all 0.15s;
  width: 100%;
}

.sp-theme-toggle:hover {
  background: var(--sp-sidebar-active-bg);
}

/* ─── 18. HAMBURGER ─── */

.sp-hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: var(--sp-radius-md);
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--sp-shadow-md);
  color: var(--sp-text-primary);
}

/* ─── 19. DEMO BANNER ─── */

.sp-demo-banner {
  background: linear-gradient(90deg, #D97706, #B45309);
  color: white;
  padding: 6px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  letter-spacing: 0.3px;
}

body.has-demo .sp-sidebar { top: 32px; height: calc(100vh - 32px); }
body.has-demo .sp-main { padding-top: 32px; }
body.has-demo .sp-hamburger { top: 44px; }

/* ─── 20. LOADING OVERLAY ─── */

/* Backdrop */
.sp-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Glass card */
.sp-loading-card {
  background: rgba(12, 16, 32, 0.96);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: 24px;
  padding: 40px 44px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: 380px;
  box-shadow:
    0 0 0 1px rgba(99, 102, 241, 0.08),
    0 32px 80px rgba(0, 0, 0, 0.65),
    0 0 80px rgba(99, 102, 241, 0.10);
  animation: sp-card-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

@keyframes sp-card-in {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ── Icon area with pulsing rings ── */
.sp-loading-icon-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-loading-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(99, 102, 241, 0.45);
  animation: sp-ring-pulse 2.4s ease-out infinite;
}
.sp-loading-ring-2 { animation-delay: 0.7s; }
.sp-loading-ring-3 { animation-delay: 1.4s; }

@keyframes sp-ring-pulse {
  0%   { transform: scale(0.7);  opacity: 0.8; }
  100% { transform: scale(1.55); opacity: 0; }
}

.sp-loading-icon-center {
  position: relative;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.10);
  border: 1.5px solid rgba(99, 102, 241, 0.30);
  border-radius: 50%;
  z-index: 2;
}

/* Rotating arc spinner */
@keyframes sp-spin { to { transform: rotate(360deg); } }

.sp-loading-orb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid rgba(99, 102, 241, 0.18);
  border-top-color: #818cf8;
  border-right-color: rgba(129, 140, 248, 0.5);
  animation: sp-spin 0.75s linear infinite;
}

/* Check on complete */
.sp-loading-checkwrap {
  color: #34d399;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sp-pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sp-pop-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Text ── */
.sp-loading-texts {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-loading-text {
  color: #f1f5f9;
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  min-height: 1.5em;
  transition: opacity 0.25s ease;
  letter-spacing: -0.01em;
}

.sp-loading-subtext {
  font-size: 12px;
  color: #4b5563;
  margin: 0;
  letter-spacing: 0.01em;
}

/* ── Step indicators ── */
.sp-loading-steps {
  display: flex;
  align-items: flex-start;
  width: 100%;
  gap: 0;
}

.sp-lstep {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.sp-lstep span {
  font-size: 10px;
  color: #374151;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  transition: color 0.35s ease;
}

.sp-lstep-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
  flex-shrink: 0;
}

.sp-lstep-connector {
  flex: 1;
  height: 1.5px;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 3px; /* align with dot center */
  transition: background 0.5s ease;
}

/* Active step */
.sp-lstep-active .sp-lstep-dot {
  background: #6366f1;
  border-color: #818cf8;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.7);
}
.sp-lstep-active span { color: #c7d2fe; }

/* Done step */
.sp-lstep-done .sp-lstep-dot {
  background: #34d399;
  border-color: #34d399;
  box-shadow: none;
}
.sp-lstep-done span { color: #6ee7b7; }

.sp-lstep-connector-done {
  background: rgba(52, 211, 153, 0.30);
}

/* ── Progress bar ── */
.sp-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.sp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #818cf8 60%, #a5b4fc 100%);
  border-radius: 3px;
  transition: width 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.55);
  position: relative;
  overflow: hidden;
}

.sp-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60px;
  width: 60px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: sp-shimmer 1.8s ease-in-out infinite;
}

@keyframes sp-shimmer {
  from { transform: translateX(0); }
  to   { transform: translateX(500px); }
}

/* ── Time hint ── */
.sp-loading-hint {
  font-size: 11px;
  color: #1f2937;
  margin: 0;
  text-align: center;
  letter-spacing: 0.01em;
}

/* ─── 21. COOKIE CONSENT ─── */

.sp-cookie-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 99999;
  background: var(--sp-bg-card);
  border-top: 1px solid var(--sp-border);
  padding: 14px 24px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
}

/* ─── 22. CHATBOT ─── */
.sp-chatbot-fab {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 8000;
  width: 44px; height: 44px;
  border-radius: 6px;
  background: var(--sp-bg-sidebar);
  border: 1px solid var(--sp-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
  color: var(--sp-text-secondary);
  box-shadow: none;
}

.sp-chatbot-fab:hover {
  border-color: var(--sp-text-muted);
  background: var(--sp-bg-secondary);
  box-shadow: none;
}

.sp-chatbot-window {
  display: none;
  position: fixed;
  bottom: 76px; right: 24px;
  width: 340px;
  max-height: 480px;
  background: var(--sp-bg-sidebar);
  border-radius: 4px;
  border: 1px solid var(--sp-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 8000;
  overflow: hidden;
  flex-direction: column;
}

.sp-chatbot-window.active { display: flex; }

.sp-chatbot-header {
  background: var(--sp-bg-sidebar);
  color: var(--sp-text-primary);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--sp-border);
}

.sp-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--sp-bg-sidebar);
  max-height: 320px;
}

.sp-chatbot-bubble {
  background: transparent;
  padding: 0 0 10px;
  max-width: 100%;
  margin-bottom: 2px;
  font-size: 0.8125rem;
  line-height: 1.55;
  border: none;
  color: var(--sp-text-secondary);
}

.sp-chatbot-bubble.user {
  background: var(--sp-bg-secondary);
  color: var(--sp-text-primary);
  margin-left: auto;
  max-width: 82%;
  padding: 7px 10px;
  border: 1px solid var(--sp-border);
  border-radius: 2px;
}

.sp-chatbot-input-area {
  padding: 8px 10px;
  border-top: 1px solid var(--sp-border);
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  background: var(--sp-bg-sidebar);
}

.sp-chatbot-input-area textarea {
  flex: 1;
  border: 1px solid var(--sp-border);
  border-radius: 2px;
  padding: 6px 10px;
  resize: none;
  font-family: var(--sp-font);
  font-size: 0.8125rem;
  background: var(--sp-bg-app);
  color: var(--sp-text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.sp-chatbot-input-area textarea:focus {
  border-color: var(--sp-accent);
}

.sp-chatbot-input-area textarea::placeholder {
  color: var(--sp-text-muted);
}

.sp-chatbot-send {
  padding: 6px 12px;
  border-radius: 2px;
  background: var(--sp-accent);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--sp-font);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.sp-chatbot-send:hover { opacity: 0.85; }
.sp-chatbot-send:disabled { opacity: 0.35; cursor: not-allowed; }

/* ─── 23. INACTIVITY BANNER ─── */

.sp-inactivity-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: linear-gradient(90deg, var(--sp-warning), var(--sp-danger));
  color: white;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

.sp-inactivity-banner a {
  color: white;
  text-decoration: underline;
  margin-left: 8px;
}

/* ─── 24. SIDEBAR CLOSE BTN ─── */

.sp-sidebar-close {
  display: none;
  position: absolute;
  top: 16px;
  right: 12px;
  z-index: 41;
  background: none;
  border: none;
  color: var(--sp-sidebar-text-muted);
  cursor: pointer;
  padding: 4px;
}

.sp-sidebar-close:hover { color: var(--sp-sidebar-text-heading); }

/* ─── 25. LOGOUT BUTTON ─── */

.sp-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--sp-sidebar-hover-bg);
  border: 1px solid var(--sp-sidebar-border);
  color: var(--sp-sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.sp-logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--sp-danger);
}

/* ─── 26. SCROLLBAR ─── */

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

/* Sidebar scrollbar */
.sp-sidebar ::-webkit-scrollbar-track { background: transparent; }
.sp-sidebar ::-webkit-scrollbar-thumb { background: var(--sp-sidebar-border); }

/* ─── 27. LEGACY CLASS COMPAT ─── */

/* Old classes from the previous design that child templates may use */
.cfo-glass { background: var(--sp-bg-card); }
.cfo-card { background: var(--sp-bg-card); border: 1px solid var(--sp-border); border-radius: var(--sp-radius-md); padding: 12px; }
.cfo-text-gradient { background: linear-gradient(135deg, #818CF8, #A78BFA); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.cfo-mesh-bg { background: var(--sp-bg-app); }
.cfo-fade-in { animation: sp-fade-in 0.3s ease; }
@keyframes sp-fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.cfo-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--sp-radius-md); font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; text-decoration: none; border: none; }
.cfo-btn-secondary { background: rgba(255,255,255,0.06); color: #D1D5DB; border: 1px solid rgba(255,255,255,0.1); border-radius: var(--sp-radius-md); }
.cfo-btn-secondary:hover { background: rgba(255,255,255,0.1); color: white; }
html.light .cfo-btn-secondary { background: var(--sp-bg-input); color: var(--sp-text-secondary); border-color: var(--sp-border); }
html.light .cfo-btn-secondary:hover { background: var(--sp-bg-card-hover); color: var(--sp-text-primary); }

/* sidebar-link compat */
.sidebar-link { position: relative; overflow: hidden; }
.sidebar-link::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 3px;
  background: var(--sp-accent);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}
.sidebar-link:hover::before,
.sidebar-link.active::before { transform: scaleY(1); }

/* ─── EXEC-* VARIABLE ALIASES ─── */
/* Maps --exec-* variables (used in form templates) to --sp-* design tokens */

:root {
  /* Backgrounds */
  --exec-bg-primary: var(--sp-bg-app);
  --exec-bg-secondary: var(--sp-bg-card);
  --exec-bg-tertiary: var(--sp-bg-input);
  --exec-bg-elevated: var(--sp-bg-card-hover);
  --exec-bg-subtle: var(--sp-bg-input);

  /* Text */
  --exec-text-primary: var(--sp-text-primary);
  --exec-text-secondary: var(--sp-text-secondary);
  --exec-text-tertiary: var(--sp-text-muted);
  --exec-text-disabled: #D1D5DB;
  --exec-text-muted: var(--sp-text-muted);

  /* Borders */
  --exec-border-subtle: var(--sp-border-light);
  --exec-border-default: var(--sp-border);
  --exec-border-strong: #D1D5DB;

  /* Brand / Status */
  --exec-brand-primary: var(--sp-accent);
  --exec-success: var(--sp-success);
  --exec-warning: var(--sp-warning);
  --exec-danger: var(--sp-danger);
  --exec-info: var(--sp-info);
  --exec-accent: var(--sp-accent);

  /* Spacing */
  --exec-space-1: var(--sp-1);
  --exec-space-2: var(--sp-2);
  --exec-space-3: var(--sp-3);
  --exec-space-4: var(--sp-4);
  --exec-space-5: var(--sp-5);
  --exec-space-6: var(--sp-6);
  --exec-space-8: var(--sp-8);
  --exec-space-10: var(--sp-10);
  --exec-space-12: var(--sp-12);
  --exec-space-16: var(--sp-16);

  /* Border Radius */
  --exec-radius-sm: var(--sp-radius-sm);
  --exec-radius-md: var(--sp-radius-md);
  --exec-radius-lg: var(--sp-radius-lg);
  --exec-radius-xl: var(--sp-radius-xl);
  --exec-radius-2xl: 24px;

  /* Typography Sizes */
  --exec-text-xs: 0.75rem;
  --exec-text-sm: 0.875rem;
  --exec-text-base: 1rem;
  --exec-text-lg: 1.125rem;
  --exec-text-xl: 1.25rem;
  --exec-text-2xl: 1.5rem;
  --exec-text-3xl: 1.875rem;
  --exec-text-4xl: 2.25rem;

  /* Shadows */
  --exec-shadow-sm: var(--sp-shadow-sm);
  --exec-shadow-md: var(--sp-shadow-md);
  --exec-shadow-lg: var(--sp-shadow-lg);

  /* Transition */
  --exec-transition: all 0.12s ease;
}

html.dark {
  --exec-bg-primary: #0F1117;
  --exec-bg-secondary: var(--sp-bg-card);
  --exec-bg-tertiary: var(--sp-bg-input);
  --exec-bg-elevated: var(--sp-bg-card-hover);
  --exec-bg-subtle: var(--sp-bg-input);

  --exec-text-primary: var(--sp-text-primary);
  --exec-text-secondary: var(--sp-text-secondary);
  --exec-text-tertiary: var(--sp-text-muted);
  --exec-text-disabled: #4B5563;
  --exec-text-muted: var(--sp-text-muted);

  --exec-border-subtle: var(--sp-border-light);
  --exec-border-default: var(--sp-border);
  --exec-border-strong: #3D4458;

  --exec-brand-primary: var(--sp-accent);
  --exec-success: var(--sp-success);
  --exec-warning: var(--sp-warning);
  --exec-danger: var(--sp-danger);
  --exec-info: var(--sp-info);
  --exec-accent: var(--sp-accent);
}

/* ─── EXEC-* CLASS COMPAT ─── */
/* Cards */
.exec-card {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--sp-shadow-card);
}
.exec-card:hover { border-color: var(--sp-border-focus); }
.exec-card-static {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--sp-shadow-card);
}

/* Buttons */
.exec-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--sp-radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  border: none;
}
.exec-btn-primary {
  background: var(--sp-accent);
  color: white;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}
.exec-btn-primary:hover {
  background: var(--sp-accent-hover);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.22);
}
.exec-btn-secondary {
  background: var(--sp-bg-input);
  color: var(--sp-text-primary);
  border: 1px solid var(--sp-border);
}
.exec-btn-secondary:hover {
  border-color: var(--sp-border-focus);
  background: var(--sp-bg-card);
}

/* Badges */
.exec-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.exec-badge-success { background: var(--sp-success-light); color: var(--sp-success); }
.exec-badge-warning { background: var(--sp-warning-light); color: var(--sp-warning); }
.exec-badge-danger { background: var(--sp-danger-light); color: var(--sp-danger); }
.exec-badge-info { background: var(--sp-info-light); color: var(--sp-info); }
.exec-badge-neutral { background: var(--sp-bg-input); color: var(--sp-text-muted); }

/* Form Elements */
.exec-form-group {
  margin-bottom: 0;
}

.exec-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--sp-text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.exec-input,
.exec-textarea,
.exec-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--sp-bg-input);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-md);
  color: var(--sp-text-primary);
  font-size: 14px;
  font-family: var(--sp-font);
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.5;
}

.exec-input:focus,
.exec-textarea:focus,
.exec-select:focus {
  outline: none;
  border-color: var(--sp-accent);
  background: var(--sp-bg-input-focus);
  box-shadow: 0 0 0 3px var(--sp-accent-subtle);
}

.exec-input::placeholder,
.exec-textarea::placeholder {
  color: var(--sp-text-muted);
}

.exec-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Divider */
.exec-divider { height: 1px; background: var(--sp-border); margin: var(--sp-6) 0; }
.exec-text-muted { color: var(--sp-text-muted); }

/* Alerts */
.exec-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--sp-radius-md);
  font-size: 14px;
  margin-bottom: 16px;
  border-left: 3px solid;
  line-height: 1.5;
}
.exec-alert svg { flex-shrink: 0; margin-top: 1px; }
.exec-alert-success { background: var(--sp-success-light); border-color: var(--sp-success); color: var(--sp-text-primary); }
.exec-alert-warning { background: var(--sp-warning-light); border-color: var(--sp-warning); color: var(--sp-text-primary); }
.exec-alert-danger { background: var(--sp-danger-light); border-color: var(--sp-danger); color: var(--sp-text-primary); }
.exec-alert-info { background: var(--sp-info-light); border-color: var(--sp-info); color: var(--sp-text-primary); }

/* File Upload Zone */
.exec-file-upload {
  cursor: pointer;
  border: 2px dashed var(--sp-border);
  border-radius: var(--sp-radius-lg);
  padding: var(--sp-8);
  text-align: center;
  transition: all 0.2s ease;
  background: var(--sp-bg-input);
}
.exec-file-upload:hover {
  border-color: var(--sp-accent);
  background: var(--sp-accent-subtle);
}

/* Details/Summary polish for Holded sections */
.exec-card-static[open] > summary svg:last-child {
  transform: rotate(180deg);
}
.exec-card-static summary::-webkit-details-marker { display: none; }
.exec-card-static summary { list-style: none; }

/* ─── 28. RESPONSIVE ─── */

@media (max-width: 768px) {
  .sp-sidebar {
    transform: translateX(-100%);
  }

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

  .sp-main {
    margin-left: 0;
  }

  .sp-hamburger {
    display: flex;
  }

  .sp-sidebar-close {
    display: block;
  }

  .sp-content {
    padding: 16px;
  }

  .sp-header {
    padding: 0 16px 0 56px;
  }
}

@media (max-width: 430px) {
  .sp-content {
    padding: 12px;
  }

  h1, .sp-h1 { font-size: 22px; }
  h2, .sp-h2 { font-size: 18px; }

  .sp-kpi-value { font-size: 22px; }
}

/* ─── 29. RESULTS PAGE COMPONENTS ─── */

/* Executive Summary Block */
.sp-exec-summary {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.sp-exec-summary::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--sp-accent);
}

.sp-exec-summary.health-critical::before { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.sp-exec-summary.health-risk::before { background: linear-gradient(90deg, #f97316, #c2410c); }
.sp-exec-summary.health-stable::before { background: linear-gradient(90deg, #eab308, #a16207); }
.sp-exec-summary.health-solid::before { background: linear-gradient(90deg, #22c55e, #15803d); }
.sp-exec-summary.health-excellent::before { background: linear-gradient(90deg, #10b981, #047857); }

.sp-exec-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.sp-exec-score {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.sp-exec-score svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}

.sp-exec-score-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--sp-text);
  line-height: 1;
  z-index: 1;
}

.sp-exec-score-label {
  font-size: 11px;
  color: var(--sp-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  z-index: 1;
  margin-top: 2px;
}

.sp-exec-info { flex: 1; }

.sp-exec-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--sp-text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.sp-exec-diagnosis {
  font-size: 15px;
  color: var(--sp-text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
  max-width: 640px;
}

.sp-exec-risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sp-exec-risk-badge.risk-low { background: rgba(16,185,129,0.12); color: #10b981; }
.sp-exec-risk-badge.risk-medium { background: rgba(234,179,8,0.12); color: #eab308; }
.sp-exec-risk-badge.risk-high { background: rgba(239,68,68,0.12); color: #ef4444; }

.sp-exec-action {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(79,70,229,0.06);
  border: 1px solid rgba(79,70,229,0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dark .sp-exec-action {
  background: rgba(129,140,248,0.08);
  border-color: rgba(129,140,248,0.2);
}

.sp-exec-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--sp-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sp-exec-action-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--sp-text);
}

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

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

.sp-kpi-card {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sp-kpi-card:hover {
  border-color: var(--sp-accent);
  box-shadow: 0 4px 12px rgba(79,70,229,0.08);
}

.sp-kpi-card-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
}

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

.sp-kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--sp-text);
  line-height: 1.2;
}

.sp-kpi-sub {
  font-size: 13px;
  color: var(--sp-text-secondary);
  margin-top: 4px;
}

.sp-kpi-hint {
  font-size: 11px;
  color: var(--sp-text-muted);
  margin-top: 6px;
  font-style: italic;
}

.sp-kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}

.sp-kpi-trend.positive { color: #10b981; }
.sp-kpi-trend.negative { color: #ef4444; }
.sp-kpi-trend.neutral { color: #eab308; }

/* Structured Analysis Block */
.sp-analysis-section {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: 16px;
  margin-bottom: 32px;
  overflow: hidden;
}

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

.sp-analysis-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--sp-text);
  margin: 0;
}

.sp-analysis-header .sp-subtitle {
  font-size: 13px;
  color: var(--sp-text-muted);
  margin: 0;
}

.sp-analysis-body {
  padding: 24px;
}

/* Structured content sections */
.sp-section-block {
  padding: 20px 0;
  border-bottom: 1px solid var(--sp-border);
}

.sp-section-block:last-child { border-bottom: none; }

.sp-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--sp-accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}

.sp-section-content {
  font-size: 15px;
  color: var(--sp-text-secondary);
  line-height: 1.7;
}

.sp-section-content strong {
  color: var(--sp-text);
  font-weight: 600;
}

/* IA Report Content */
.sp-report-prose {
  font-size: 15px;
  color: var(--sp-text-secondary);
  line-height: 1.8;
}

.sp-report-prose h1,
.sp-report-prose h2,
.sp-report-prose h3 {
  color: var(--sp-text);
  font-weight: 700;
  margin: 28px 0 12px;
  line-height: 1.3;
}

.sp-report-prose h1 { font-size: 22px; }
.sp-report-prose h2 { font-size: 18px; }
.sp-report-prose h3 {
  font-size: 16px;
  color: var(--sp-accent);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--sp-border);
}

.sp-report-prose p {
  margin: 12px 0;
}

.sp-report-prose ul,
.sp-report-prose ol {
  padding-left: 20px;
  margin: 12px 0;
}

.sp-report-prose li {
  margin: 8px 0;
  line-height: 1.7;
}

.sp-report-prose li::marker {
  color: var(--sp-accent);
}

.sp-report-prose strong {
  color: var(--sp-text);
  font-weight: 600;
}

.sp-report-prose em {
  color: var(--sp-accent);
}

/* Action Plan Block */
.sp-action-plan {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 32px;
}

.sp-action-plan-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--sp-text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sp-action-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--sp-border);
  border-radius: 10px;
  margin-bottom: 12px;
  transition: border-color 0.2s, background 0.2s;
}

.sp-action-item:last-child { margin-bottom: 0; }

.sp-action-item:hover {
  border-color: var(--sp-accent);
  background: rgba(79,70,229,0.03);
}

.dark .sp-action-item:hover {
  background: rgba(129,140,248,0.05);
}

.sp-action-number {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sp-action-number.priority-alta {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}

.sp-action-number.priority-media {
  background: rgba(234,179,8,0.12);
  color: #eab308;
}

.sp-action-number.priority-baja {
  background: rgba(79,70,229,0.12);
  color: var(--sp-accent);
}

.sp-action-body { flex: 1; }

.sp-action-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--sp-text);
  margin-bottom: 4px;
}

.sp-action-detail {
  font-size: 13px;
  color: var(--sp-text-secondary);
  line-height: 1.5;
}

.sp-action-impact {
  font-size: 12px;
  color: var(--sp-text-muted);
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(79,70,229,0.04);
  border-radius: 6px;
  display: inline-block;
}

.dark .sp-action-impact {
  background: rgba(129,140,248,0.06);
}

/* Tabs */
.sp-tabs {
  display: flex;
  border-bottom: 1px solid var(--sp-border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sp-tabs::-webkit-scrollbar { display: none; }

.sp-tab-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--sp-text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-tab-btn:hover {
  color: var(--sp-text);
}

.sp-tab-btn.active {
  color: var(--sp-accent);
  border-bottom-color: var(--sp-accent);
  font-weight: 600;
}

.sp-tab-panel {
  padding: 24px;
}

/* Results Table */
.sp-results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.sp-results-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--sp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--sp-border);
  position: sticky;
  top: 0;
  background: var(--sp-bg-card);
}

.sp-results-table thead th.text-right {
  text-align: right;
}

.sp-results-table tbody td {
  padding: 10px 14px;
  color: var(--sp-text-secondary);
  border-bottom: 1px solid var(--sp-border);
}

.sp-results-table tbody tr:hover td {
  background: rgba(79,70,229,0.03);
}

.dark .sp-results-table tbody tr:hover td {
  background: rgba(129,140,248,0.04);
}

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

.sp-results-table .col-positive { color: #10b981; }
.sp-results-table .col-negative { color: #ef4444; }
.sp-results-table .col-neutral { color: #eab308; }
.sp-results-table .font-mono { font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; }
.sp-results-table .font-bold { font-weight: 700; }
.sp-results-table .font-medium { font-weight: 500; color: var(--sp-text); }

/* Download Cards */
.sp-download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.sp-download-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  background: var(--sp-bg-card);
  text-decoration: none;
  color: var(--sp-text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.sp-download-card:hover {
  border-color: var(--sp-accent);
  box-shadow: 0 2px 8px rgba(79,70,229,0.08);
}

.sp-download-card svg {
  width: 32px;
  height: 32px;
  color: var(--sp-text-muted);
}

.sp-download-card:hover svg { color: var(--sp-accent); }

.sp-download-name {
  font-size: 14px;
  font-weight: 600;
}

.sp-download-hint {
  font-size: 12px;
  color: var(--sp-text-muted);
}

/* Confidence Badge */
.sp-confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.sp-confidence-badge.high {
  background: rgba(16,185,129,0.1);
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.25);
}

.sp-confidence-badge.medium {
  background: rgba(79,70,229,0.1);
  color: var(--sp-accent);
  border: 1px solid rgba(79,70,229,0.25);
}

.sp-confidence-badge.low {
  background: rgba(234,179,8,0.1);
  color: #eab308;
  border: 1px solid rgba(234,179,8,0.25);
}

/* Results header actions */
.sp-results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Alert cards */
.sp-alert-card {
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--sp-border);
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sp-alert-card:last-child { margin-bottom: 0; }

.sp-alert-card.severity-high {
  border-left: 3px solid #ef4444;
  background: rgba(239,68,68,0.04);
}

.sp-alert-card.severity-medium {
  border-left: 3px solid #eab308;
  background: rgba(234,179,8,0.04);
}

.sp-alert-card.severity-low {
  border-left: 3px solid #3b82f6;
  background: rgba(59,130,246,0.04);
}

.dark .sp-alert-card.severity-high { background: rgba(239,68,68,0.08); }
.dark .sp-alert-card.severity-medium { background: rgba(234,179,8,0.08); }
.dark .sp-alert-card.severity-low { background: rgba(59,130,246,0.08); }

.sp-alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.sp-alert-card.severity-high .sp-alert-dot { background: #ef4444; }
.sp-alert-card.severity-medium .sp-alert-dot { background: #eab308; }
.sp-alert-card.severity-low .sp-alert-dot { background: #3b82f6; }

.sp-alert-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--sp-text);
  margin-bottom: 2px;
}

.sp-alert-msg {
  font-size: 13px;
  color: var(--sp-text-secondary);
  line-height: 1.5;
}

.sp-alert-action {
  margin-top: 8px;
  font-size: 12px;
  color: var(--sp-accent);
  font-weight: 500;
}

/* Quick mode confirmation */
.sp-quick-confirm {
  background: rgba(79,70,229,0.04);
  border: 1px solid rgba(79,70,229,0.15);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.dark .sp-quick-confirm {
  background: rgba(129,140,248,0.06);
  border-color: rgba(129,140,248,0.2);
}

/* No data state */
.sp-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--sp-text-muted);
}

.sp-empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--sp-text-muted);
  opacity: 0.5;
}

/* 30. RESULTS RESPONSIVE */

@media (max-width: 768px) {
  .sp-exec-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .sp-exec-diagnosis { max-width: none; }

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

  .sp-download-grid {
    grid-template-columns: 1fr 1fr;
  }

  .sp-results-actions {
    justify-content: center;
  }

  .sp-exec-score {
    width: 80px;
    height: 80px;
  }

  .sp-exec-score-value { font-size: 24px; }
}

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

  .sp-exec-summary { padding: 20px; }
  .sp-analysis-body { padding: 16px; }
  .sp-action-plan { padding: 16px; }
}

/* ─── 31. PRINT ─── */

@media print {
  .sp-sidebar,
  .sp-hamburger,
  .sp-header,
  .sp-footer,
  .sp-demo-banner { display: none !important; }

  .sp-main { margin-left: 0; }
  .sp-content { padding: 0; max-width: 100%; }

  body { background: white; color: black; }
}

/* ─── 32. LIGHT-MODE TAILWIND COMPATIBILITY ─── */
/* Overrides for legal/legacy pages that use raw Tailwind dark-only classes */

html.light .text-white { color: var(--sp-text-primary) !important; }
html.light .text-gray-300 { color: var(--sp-text-secondary) !important; }
html.light .text-gray-400 { color: var(--sp-text-muted) !important; }
html.light .text-gray-600 { color: var(--sp-text-muted) !important; }
html.light .text-indigo-300,
html.light .text-indigo-400 { color: var(--sp-accent) !important; }
html.light .text-blue-300 { color: var(--sp-info) !important; }
html.light .text-yellow-400 { color: var(--sp-warning) !important; }
html.light .text-amber-200 { color: var(--sp-warning) !important; }
html.light .border-gray-700,
html.light .border-gray-800 { border-color: var(--sp-border) !important; }
html.light .font-mono { color: var(--sp-accent) !important; }

/* ── Info tooltips ──────────────────────────────── */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #9ca3af;
  background: transparent;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 5px;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.info-btn:hover {
  border-color: #6b7280;
  color: #d1d5db;
}
.info-btn::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #f9fafb;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  padding: 7px 11px;
  border-radius: 7px;
  width: max-content;
  max-width: 240px;
  white-space: normal;
  text-align: left;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.info-btn::before {
  content: '';
  display: none;
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
  z-index: 9999;
  pointer-events: none;
}
.info-btn:hover::after,
.info-btn:hover::before { display: block; }
.info-btn.tip-down::after {
  bottom: auto;
  top: calc(100% + 7px);
}
.info-btn.tip-down::before {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: #1f2937;
}

/* -- Info tooltips ---------------------------------- */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #9ca3af;
  background: transparent;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 5px;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.info-btn:hover {
  border-color: #6b7280;
  color: #d1d5db;
}
.info-btn::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #f9fafb;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  padding: 7px 11px;
  border-radius: 7px;
  width: max-content;
  max-width: 240px;
  white-space: normal;
  text-align: left;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.info-btn::before {
  content: '';
  display: none;
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
  z-index: 9999;
  pointer-events: none;
}
.info-btn:hover::after,
.info-btn:hover::before { display: block; }
.info-btn.tip-down::after {
  bottom: auto;
  top: calc(100% + 7px);
}
.info-btn.tip-down::before {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: #1f2937;
}

/* -- Collapsible sector briefing ------------------------- */
.briefing-card { transition: padding 0.2s ease; }
.briefing-card.is-collapsed { padding-top: 12px !important; padding-bottom: 12px !important; }

.briefing-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  width: 100%;
}
.briefing-toggle-row:hover .briefing-toggle-btn { color: #d1d5db; }

.briefing-subtitle { transition: opacity 0.15s; }
.is-collapsed .briefing-subtitle { display: none; }
.is-collapsed .briefing-toggle-row { margin-bottom: 0 !important; }

.briefing-body {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  opacity: 1;
}
.is-collapsed .briefing-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.briefing-toggle-btn {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}
.briefing-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  line-height: 1;
}

/* ── Topbar ─────────────────────────────────────────── */
.app-topbar {
  position: fixed;
  top: 0;
  left: var(--sp-sidebar-w);
  right: 0;
  height: 48px;
  background: var(--sp-bg-sidebar);
  border-bottom: 1px solid var(--sp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}
.app-topbar__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--sp-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.topbar-icon-btn {
  position: relative;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--sp-text-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.topbar-icon-btn:hover {
  color: var(--sp-text-primary);
  background: var(--sp-bg-input);
}
.topbar-notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: #dc2626;
  border-radius: 50%;
  pointer-events: none;
}
.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #A78BFA);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  flex-shrink: 0;
  user-select: none;
}
/* Theme toggle icons — controlled by updateThemeIcons() JS */
.topbar-icon-btn .theme-icon-dark,
.topbar-icon-btn .theme-icon-light { display: none; }

/* Content top offset for fixed topbar */
.sp-content { padding-top: 48px; }

/* ── Sidebar nav restructure ─────────────────────────── */
.nav-section-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sp-sidebar-text-muted);
  font-weight: 500;
  padding: 16px 12px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-section-label.collapsible {
  cursor: pointer;
  user-select: none;
}
.nav-section-label.collapsible:hover {
  color: var(--sp-sidebar-text);
}
.nav-section-chevron {
  display: block;
  flex-shrink: 0;
  transition: transform 0.25s ease-in-out;
  color: var(--sp-sidebar-text);
  opacity: 0.8;
}
.nav-section-label.open .nav-section-chevron {
  transform: rotate(90deg);
}
/* HERRAMIENTAS collapsible toggle */
.nav-tools-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
  text-align: left;
  transition: color 0.15s;
}
.nav-tools-toggle:hover {
  color: var(--sp-sidebar-text);
}
.nav-tools-chevron {
  display: block;
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.7;
  transition: transform 0.25s ease-in-out;
}
.nav-tools-toggle[aria-expanded="true"] .nav-tools-chevron {
  transform: rotate(180deg);
}
.nav-tools-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
  opacity: 0;
}
.nav-tools-items.open {
  max-height: 400px;
  opacity: 1;
}
.nav-bottom {
  border-top: 1px solid var(--sp-sidebar-border);
  padding: 10px 0 4px;
}
.nav-bottom-item {
  display: block;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--sp-sidebar-text-muted);
  text-decoration: none;
  transition: color 0.12s;
}
.nav-bottom-item:hover { color: var(--sp-sidebar-text-heading); }

@media (max-width: 768px) {
  .app-topbar { display: none; }
  .sp-content { padding-top: 24px; }
}

/* ─── LIGHT MODE OVERRIDES ─────────────────────────────────── */

/* FIX: Loading card — light mode */
html.light .sp-loading-card {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-lg);
  color: var(--sp-text-primary);
}
html.light .sp-loading-card .sp-loading-title,
html.light .sp-loading-card .sp-loading-subtitle,
html.light .sp-loading-card p,
html.light .sp-loading-card span {
  color: var(--sp-text-primary);
}

/* FIX: info-btn tooltip — light mode */
html.light .info-btn::after {
  background: var(--sp-bg-card);
  color: var(--sp-text-primary);
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-md);
}
html.light .info-btn::before {
  border-top-color: var(--sp-border);
}
html.light .info-btn.tip-down::before {
  border-bottom-color: var(--sp-border, #e5e7eb) !important;
  border-top-color: transparent !important;
}

/* FIX: info-btn with child <span class="info-tooltip"> — span-based tooltip pattern.
   Hides the span by default and shows it on hover. Also suppresses the empty ::after
   bubble that fires when data-tip is absent. */
.info-btn .info-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #f9fafb;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  padding: 7px 11px;
  border-radius: 7px;
  width: max-content;
  max-width: 240px;
  white-space: normal;
  text-align: left;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  transition: opacity 0.15s ease;
}
.info-btn:hover .info-tooltip {
  visibility: visible;
  opacity: 1;
}
/* Suppress the empty ::after / ::before pseudo-element on buttons that use the span pattern */
.info-btn:has(.info-tooltip)::after,
.info-btn:has(.info-tooltip)::before {
  display: none !important;
}
/* Light mode override for span-based tooltips */
html.light .info-btn .info-tooltip {
  background: var(--sp-bg-card);
  color: var(--sp-text-primary);
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-md);
}

/* === GESTORIA DYNAMIC ISLAND === */
.gestoria-island {
  position: fixed;
  top: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
  transition: none;
}

.gestoria-island-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px 7px 12px;
  background: rgba(15, 15, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  transition: color 0.15s;
  transform: none;
}

.gestoria-island-btn:hover {
  color: #fff;
  transform: none;
}

.gestoria-island-btn svg {
  opacity: 0.75;
  flex-shrink: 0;
}

.gestoria-island-sep {
  opacity: 0.3;
  font-weight: 300;
}

.gestoria-island-empresa {
  opacity: 0.55;
  font-weight: 400;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.light .gestoria-island-btn {
  background: rgba(250, 250, 252, 0.88);
  border-color: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.85);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

html.light .gestoria-island-btn:hover {
  background: rgba(240, 240, 245, 0.96);
  border-color: rgba(0, 0, 0, 0.15);
  color: #000;
  transform: none;
}

html.light .gestoria-island-sep {
  opacity: 0.25;
}

html.light .gestoria-island-empresa {
  opacity: 0.45;
}
/* === FIN GESTORIA DYNAMIC ISLAND === */

/* ═══════════════════════════════════════════════════════════════════
   UPGRADE MODAL GESTORÍAS + BOTONES LOCKED + LIMITE AVISO
   ═══════════════════════════════════════════════════════════════════ */

/* ── Modal de upgrade gestorías ── */
.upgrade-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.upgrade-modal-inner {
  background: var(--sp-bg-card);
  border: 1px solid var(--sp-border);
  border-radius: 14px;
  padding: 32px 28px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  position: relative;
}
.upgrade-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--sp-text-muted);
  cursor: pointer;
  line-height: 1;
}
.upgrade-modal-icon {
  margin-bottom: 16px;
  color: var(--sp-text-muted);
}
.upgrade-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--sp-text-primary);
  margin-bottom: 10px;
}
.upgrade-modal-desc {
  font-size: 13px;
  color: var(--sp-text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}
.upgrade-modal-cta {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 10px 20px;
  border-radius: 8px;
  background: var(--sp-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}
.upgrade-modal-cta:hover { opacity: 0.85; }

/* ── Botones locked ── */
.btn-locked {
  opacity: 0.65;
  cursor: pointer;
}
.btn-locked:hover { opacity: 0.85; }

.plan-badge-required {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border-radius: 99px;
  font-weight: 600;
  margin-left: 4px;
}

/* ── Aviso de límite mensual (dashboard) ── */
.limite-aviso {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--sp-text-secondary);
}
.limite-aviso-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  flex-shrink: 0;
}
.limite-aviso-dot--danger {
  background: #ef4444;
}
.limite-aviso-text strong {
  color: var(--sp-text-primary);
  font-weight: 500;
}
.limite-aviso-link {
  margin-left: auto;
  color: #f59e0b;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.limite-aviso-link:hover {
  color: var(--sp-text-primary);
}

/* ═══════════════════════════════════════════════════════════════════
   FIN UPGRADE MODAL / LOCKED / LIMITE AVISO
   ═══════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
   FIX: alert bars visibles — .sp-content no queda tapado por
   .app-topbar (position: fixed; top: 0; height: 48px)
   !important necesario para ganar a mobile-responsive.css (cargado
   después con padding shorthand que resetea padding-top a 16px).
   ═══════════════════════════════════════════════════════════════════ */
.sp-content { padding-top: 56px !important; } /* 48px topbar + 8px gap */

@media (max-width: 768px) {
  /* Topbar oculto en móvil — restaurar padding normal */
  .sp-content { padding-top: 16px !important; }
}

/* ══════════════════════════════════════════════════
   Alert bars — layout limpio, una línea profesional
   ══════════════════════════════════════════════════ */

/* Parent wrappers: no height clipping */
.dp-wrap,
.dp-anim,
[class*="alert-container"],
[class*="alert-wrapper"],
[class*="alert-stack"] {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  transform: none !important;
}

/* Alert row */
.alert-panel {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 14px !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  margin-bottom: 2px !important;
  border-radius: 0 !important;
}

/* Icono — pequeño, sin deformarse */
.alert-panel .alert-panel__icon {
  flex-shrink: 0 !important;
  width: 14px !important;
  height: 14px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.alert-panel .alert-panel__icon svg {
  width: 14px !important;
  height: 14px !important;
  flex-shrink: 0 !important;
}

/* Cuerpo — tag + texto en fila */
.alert-panel .alert-panel__body {
  flex: 1 !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: baseline !important;
  gap: 6px !important;
  min-width: 0 !important;
  overflow: hidden !important;
}

/* Label — fijo, mayúsculas pequeñas */
.alert-panel .alert-panel__tag {
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* Mensaje — una línea, truncar si desborda */
.alert-panel .alert-panel__text {
  font-size: 12px !important;
  line-height: 1.3 !important;
  margin: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  min-width: 0 !important;
}

/* CTA — pegado a la derecha */
.alert-panel .alert-panel__cta {
  flex-shrink: 0 !important;
  margin-left: auto !important;
  display: flex !important;
  align-items: center !important;
}

/* Botón CTA discreto */
.alert-panel .alert-panel__btn {
  flex-shrink: 0 !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  padding: 3px 8px !important;
  border-radius: 3px !important;
  white-space: nowrap !important;
  border: 1px solid currentColor !important;
  background: transparent !important;
  color: inherit !important;
  text-decoration: none !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center !important;
}

/* ═══════════════════════════════════════════════════════════════════
   FIX: botón flotante chatbot — más presencia, color de acento
   (el botón de sidebar "¿Qué le falta?" NO está aquí — es flow normal)
   ═══════════════════════════════════════════════════════════════════ */
.chat-fab,
[class*="chat-fab"],
[class*="help-fab"] {
  width: 44px !important;
  height: 44px !important;
  background: var(--sp-bg-card) !important;
  border: 1.5px solid var(--sp-text-secondary) !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2) !important;
  color: var(--sp-text-primary) !important;
  opacity: 1 !important;
  transition: border-color 0.15s, box-shadow 0.15s !important;
}

/* Hover: borde más marcado */
.chat-fab:hover {
  border-color: var(--sp-text-primary) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25) !important;
}

/* SVG dentro del botón — tamaño correcto */
.chat-fab svg {
  width: 20px !important;
  height: 20px !important;
  stroke-width: 1.5 !important;
}

/* Light mode: borde más visible */
html.light .chat-fab {
  border-color: #9ca3af !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
}

/* ═══════════════════════════════════════════════════════════════
   Fix: dp-hero margin-top no solapa alert-panels en el dashboard
   (no aplica a gestoria/panel que usa .dp-wrap.dp-anim)
   ═══════════════════════════════════════════════════════════════ */
.dp-wrap:not(.dp-anim) .dp-hero {
  margin-top: 0 !important;
}

/* ══════════════════════════════════════════════════
   Fix: sin transform en hover — botón feedback + sidebar
   ══════════════════════════════════════════════════ */
button[onclick*="openGlobalFeedback"]:hover,
button[onclick*="openGlobalFeedback"]:focus,
a[onclick*="openGlobalFeedback"]:hover,
.chat-fab:hover,
.sidebar-link:hover,
[class*="sidebar"] a:hover,
[class*="sidebar"] button:hover {
  transform: none !important;
  transition: background-color 0.15s, border-color 0.15s !important;
}

/* ══════════════════════════════════════════════════
   Botones "Descargar plantilla" en formularios de upload
   ══════════════════════════════════════════════════ */
.btn-download-template {
  display: inline-block;
  font-size: 11px;
  color: var(--sp-accent, #4f8ef7);
  text-decoration: none;
  border: 1px solid var(--sp-accent, #4f8ef7);
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  transition: background 0.15s;
}
.btn-download-template:hover {
  background: rgba(79, 142, 247, 0.08);
  text-decoration: none;
}
.template-hint {
  font-size: 11px;
  color: var(--sp-text-muted, #888);
  margin-left: 8px;
}
.btn-clear-file {
  display: none;
  font-size: 11px;
  color: var(--sp-text-muted, #888);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  margin-top: 4px;
  text-decoration: underline;
}
.btn-clear-file:hover {
  color: var(--sp-danger, #e05252);
}
