/* ============================================================
   PLATAFORMA SATELITAL SAAS — Design System v2.0
   ============================================================ */

/* ── Imports ────────────────────────────────────────────────── */
/* Google Fonts eliminado — usando stack de sistema sin conexión a internet */

/* ── CSS Variables — Dark Theme (default) ───────────────────── */
:root {
  /* Brand */
  --brand-50:   #eff6ff;
  --brand-100:  #dbeafe;
  --brand-200:  #bfdbfe;
  --brand-400:  #60a5fa;
  --brand-500:  #3b82f6;
  --brand-600:  #2563eb;
  --brand-700:  #1d4ed8;
  --brand-900:  #1e3a8a;

  --accent-500: #f97316;
  --accent-600: #ea580c;

  --success-400: #34d399;
  --success-500: #10b981;
  --success-600: #059669;

  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  --danger-400:  #f87171;
  --danger-500:  #ef4444;
  --danger-600:  #dc2626;

  --purple-500:  #8b5cf6;
  --teal-500:    #14b8a6;
  --pink-500:    #ec4899;

  /* Background */
  --bg-base:         #0f172a;
  --bg-surface:      #1e293b;
  --bg-elevated:     #263248;
  --bg-card:         #1e293b;
  --bg-input:        #263248;
  --bg-hover:        #2d3f5a;
  --bg-active:       #334155;
  --bg-modal:        #1e293b;
  --bg-overlay:      rgba(0, 0, 0, 0.6);
  --bg-sidebar:      #111827;
  --bg-header:       rgba(15, 23, 42, 0.95);
  --bg-tooltip:      #334155;

  /* Text */
  --text-primary:    #f1f5f9;
  --text-secondary:  #94a3b8;
  --text-muted:      #64748b;
  --text-disabled:   #475569;
  --text-inverse:    #0f172a;
  --text-link:       #60a5fa;

  /* Borders */
  --border:          rgba(148, 163, 184, 0.12);
  --border-focus:    var(--brand-500);
  --border-strong:   rgba(148, 163, 184, 0.25);

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 6px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg:   0 10px 15px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.3);
  --shadow-xl:   0 20px 25px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);

  /* Layout */
  --sidebar-width:          260px;
  --sidebar-collapsed-width: 68px;
  --header-height:          64px;
  --content-max-width:      1400px;

  /* Typography */
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

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

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index */
  --z-dropdown:  100;
  --z-sticky:    200;
  --z-fixed:     300;
  --z-modal-bg:  400;
  --z-modal:     500;
  --z-toast:     600;
  --z-tooltip:   700;
}

/* ── Light Theme ─────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:         #f8fafc;
  --bg-surface:      #ffffff;
  --bg-elevated:     #f1f5f9;
  --bg-card:         #ffffff;
  --bg-input:        #f8fafc;
  --bg-hover:        #f1f5f9;
  --bg-active:       #e2e8f0;
  --bg-modal:        #ffffff;
  --bg-overlay:      rgba(15, 23, 42, 0.5);
  --bg-sidebar:      #ffffff;
  --bg-header:       rgba(255, 255, 255, 0.95);
  --bg-tooltip:      #1e293b;

  --text-primary:    #0f172a;
  --text-secondary:  #475569;
  --text-muted:      #94a3b8;
  --text-disabled:   #cbd5e1;
  --text-inverse:    #f1f5f9;
  --text-link:       #2563eb;

  --border:          rgba(15, 23, 42, 0.08);
  --border-strong:   rgba(15, 23, 42, 0.16);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family:      var(--font-sans);
  background-color: var(--bg-base);
  color:            var(--text-primary);
  line-height:      1.6;
  overflow-x:       hidden;
  -webkit-font-smoothing: antialiased;
}

img, video, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── App Shell ──────────────────────────────────────────────── */
.app-wrapper {
  display:     flex;
  min-height:  100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position:   fixed;
  top:        0;
  left:       0;
  width:      var(--sidebar-width);
  height:     100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display:    flex;
  flex-direction: column;
  z-index:    var(--z-fixed);
  transition: width var(--transition-slow);
  overflow:   hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-logo {
  display:     flex;
  align-items: center;
  gap:         12px;
  padding:     20px 18px;
  height:      var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width:  32px;
  height: 32px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: var(--radius-md);
  display:      flex;
  align-items:  center;
  justify-content: center;
  color:        white;
  font-size:    16px;
  font-weight:  700;
}

.sidebar-logo-text {
  display:    flex;
  flex-direction: column;
  overflow:   hidden;
  white-space: nowrap;
  transition: opacity var(--transition-slow);
}

.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

.sidebar-logo-name {
  font-size:   14px;
  font-weight: 700;
  color:       var(--text-primary);
  letter-spacing: 0.02em;
}

.sidebar-logo-version {
  font-size: 10px;
  color:     var(--text-muted);
  font-weight: 500;
}

.sidebar-nav {
  flex:       1;
  overflow-y: auto;
  padding:    12px 8px;
  display:    flex;
  flex-direction: column;
  gap:        2px;
}

.sidebar-section {
  padding:    16px 10px 4px;
  font-size:  10px;
  font-weight: 600;
  color:      var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow:   hidden;
  transition: opacity var(--transition-slow);
}

.sidebar.collapsed .sidebar-section { opacity: 0; }

.nav-item {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     9px 10px;
  border-radius: var(--radius-md);
  color:       var(--text-secondary);
  cursor:      pointer;
  transition:  background var(--transition-fast), color var(--transition-fast);
  position:    relative;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color:      var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color:      var(--brand-400);
}

.nav-item.active::before {
  content:  '';
  position: absolute;
  left:     0;
  top:      6px;
  bottom:   6px;
  width:    3px;
  background: var(--brand-500);
  border-radius: 0 3px 3px 0;
}

.nav-item-icon {
  width:      20px;
  height:     20px;
  flex-shrink: 0;
  display:    flex;
  align-items: center;
  justify-content: center;
  font-size:  16px;
}

.nav-item-label {
  font-size:   13px;
  font-weight: 500;
  overflow:    hidden;
  transition:  opacity var(--transition-slow), width var(--transition-slow);
}

.sidebar.collapsed .nav-item-label { opacity: 0; width: 0; }

.nav-item-badge {
  margin-left: auto;
  background:  var(--danger-500);
  color:       white;
  font-size:   10px;
  font-weight: 700;
  padding:     2px 6px;
  border-radius: var(--radius-full);
  min-width:   18px;
  text-align:  center;
  transition:  opacity var(--transition-slow);
}

.sidebar.collapsed .nav-item-badge { opacity: 0; }

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

.sidebar-user {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     8px 10px;
  border-radius: var(--radius-md);
  cursor:      pointer;
  transition:  background var(--transition-fast);
}

.sidebar-user:hover { background: var(--bg-hover); }

.sidebar-user-avatar {
  width:        32px;
  height:       32px;
  border-radius: var(--radius-full);
  background:   linear-gradient(135deg, var(--brand-500), var(--purple-500));
  display:      flex;
  align-items:  center;
  justify-content: center;
  color:        white;
  font-size:    12px;
  font-weight:  700;
  flex-shrink:  0;
}

.sidebar-user-info {
  overflow: hidden;
  transition: opacity var(--transition-slow);
}

.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }

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

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

/* ── Header ──────────────────────────────────────────────────── */
.header {
  position:    fixed;
  top:         0;
  left:        var(--sidebar-width);
  right:       0;
  height:      var(--header-height);
  background:  var(--bg-header);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display:     flex;
  align-items: center;
  padding:     0 24px;
  gap:         16px;
  z-index:     var(--z-sticky);
  transition:  left var(--transition-slow);
}

.sidebar.collapsed ~ .main-content .header {
  left: var(--sidebar-collapsed-width);
}

.header-toggle {
  width:  36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color:  var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.header-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.header-breadcrumb {
  display:     flex;
  align-items: center;
  gap:         6px;
  font-size:   14px;
  color:       var(--text-secondary);
  flex:        1;
  min-width:   0;
}

.header-breadcrumb .current { color: var(--text-primary); font-weight: 600; }
.header-breadcrumb .sep     { color: var(--text-muted); }

.header-search {
  position: relative;
  flex-shrink: 0;
}

.header-search input {
  background:   var(--bg-elevated);
  border:       1px solid var(--border);
  border-radius: var(--radius-full);
  padding:      7px 14px 7px 36px;
  font-size:    13px;
  color:        var(--text-primary);
  width:        220px;
  outline:      none;
  transition:   border-color var(--transition-fast), width var(--transition-base);
}

.header-search input:focus {
  border-color: var(--brand-500);
  width:        280px;
}

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

.header-search-icon {
  position:  absolute;
  left:      12px;
  top:       50%;
  transform: translateY(-50%);
  color:     var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.header-actions {
  display:     flex;
  align-items: center;
  gap:         4px;
  flex-shrink: 0;
}

.header-btn {
  width:  36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color:  var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.header-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.header-btn .badge {
  position:  absolute;
  top:       5px;
  right:     5px;
  width:     8px;
  height:    8px;
  background: var(--danger-500);
  border-radius: var(--radius-full);
  border:    2px solid var(--bg-header);
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height:  100vh;
  display:     flex;
  flex-direction: column;
  transition:  margin-left var(--transition-slow);
}

.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-width); }

.page-content {
  margin-top: var(--header-height);
  padding:    28px 32px;
  flex:       1;
  max-width:  var(--content-max-width);
  width:      100%;
  margin-left-auto: auto;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display:     flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap:         16px;
}

.page-title {
  font-size:   24px;
  font-weight: 700;
  color:       var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size:  14px;
  color:      var(--text-secondary);
  margin-top: 4px;
}

.page-actions {
  display:  flex;
  gap:      10px;
  align-items: center;
  flex-shrink: 0;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background:   var(--bg-card);
  border:       1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:      20px;
  box-shadow:   var(--shadow-sm);
}

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

.card-title {
  font-size:   15px;
  font-weight: 600;
  color:       var(--text-primary);
  display:     flex;
  align-items: center;
  gap:         8px;
}

.card-title-icon {
  color: var(--brand-500);
}

/* ── KPI Cards ──────────────────────────────────────────────── */
.kpi-grid {
  display:   grid;
  grid-template-columns: repeat(5, 1fr);
  gap:       16px;
  margin-bottom: 28px;
}

.kpi-card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       20px;
  box-shadow:    var(--shadow-sm);
  position:      relative;
  overflow:      hidden;
  transition:    transform var(--transition-base), box-shadow var(--transition-base);
}

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

.kpi-card::after {
  content:  '';
  position: absolute;
  top:      0;
  left:     0;
  right:    0;
  height:   3px;
  background: var(--kpi-color, var(--brand-500));
}

.kpi-card.blue   { --kpi-color: var(--brand-500); }
.kpi-card.green  { --kpi-color: var(--success-500); }
.kpi-card.yellow { --kpi-color: var(--warning-500); }
.kpi-card.red    { --kpi-color: var(--danger-500); }
.kpi-card.purple { --kpi-color: var(--purple-500); }
.kpi-card.teal   { --kpi-color: var(--teal-500); }
.kpi-card.orange { --kpi-color: var(--accent-500); }

.kpi-label {
  font-size:   12px;
  font-weight: 500;
  color:       var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.kpi-value {
  font-size:   28px;
  font-weight: 800;
  color:       var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
}

.kpi-change {
  font-size:   12px;
  font-weight: 500;
  display:     flex;
  align-items: center;
  gap:         4px;
}

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

.kpi-icon {
  position:  absolute;
  right:     16px;
  top:       50%;
  transform: translateY(-50%);
  font-size: 36px;
  opacity:   0.12;
}

/* ── Grid Layouts ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display:     inline-flex;
  align-items: center;
  justify-content: center;
  gap:         7px;
  padding:     9px 18px;
  border-radius: var(--radius-md);
  border:      1px solid transparent;
  font-size:   13px;
  font-weight: 600;
  cursor:      pointer;
  white-space: nowrap;
  transition:  background var(--transition-fast), box-shadow var(--transition-fast),
               transform var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
  line-height: 1;
}

.btn:active   { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-600);
  color:      white;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.4);
}
.btn-primary:hover { background: var(--brand-700); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4); }

.btn-secondary {
  background: var(--bg-elevated);
  color:      var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-success {
  background: var(--success-600);
  color:      white;
}
.btn-success:hover { background: var(--success-500); }

.btn-danger {
  background: var(--danger-600);
  color:      white;
}
.btn-danger:hover { background: var(--danger-500); }

.btn-warning {
  background: var(--warning-600);
  color:      white;
}
.btn-warning:hover { background: var(--warning-500); }

.btn-ghost {
  background:  transparent;
  color:       var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-outline {
  background:  transparent;
  color:       var(--brand-400);
  border-color: var(--brand-500);
}
.btn-outline:hover { background: rgba(59, 130, 246, 0.1); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 9px; }
.btn-sm.btn-icon { padding: 6px; }

/* ── Badges / Status Pills ──────────────────────────────────── */
.badge {
  display:     inline-flex;
  align-items: center;
  gap:         5px;
  padding:     3px 9px;
  border-radius: var(--radius-full);
  font-size:   11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-dot {
  width:  6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.badge-success  { background: rgba(16, 185, 129, 0.15); color: var(--success-400); }
.badge-warning  { background: rgba(245, 158, 11, 0.15); color: var(--warning-400); }
.badge-danger   { background: rgba(239, 68, 68,  0.15); color: var(--danger-400); }
.badge-info     { background: rgba(59, 130, 246, 0.15); color: var(--brand-400); }
.badge-purple   { background: rgba(139, 92, 246, 0.15); color: var(--purple-500); }
.badge-muted    { background: var(--bg-elevated);       color: var(--text-secondary); }
.badge-orange   { background: rgba(249, 115, 22, 0.15); color: var(--accent-500); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group {
  display:       flex;
  flex-direction: column;
  gap:           6px;
  margin-bottom: 16px;
}

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

.form-label.required::after {
  content: ' *';
  color:   var(--danger-500);
}

.form-control {
  background:   var(--bg-input);
  border:       1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding:      9px 13px;
  font-size:    13px;
  color:        var(--text-primary);
  width:        100%;
  outline:      none;
  transition:   border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--brand-500);
  box-shadow:   0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled     { opacity: 0.6; cursor: not-allowed; }

.form-control-icon-wrapper { position: relative; }
.form-control-icon-wrapper .form-control { padding-left: 36px; }
.form-control-icon-wrapper .icon {
  position:  absolute;
  left:      11px;
  top:       50%;
  transform: translateY(-50%);
  color:     var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger-500); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap:     16px;
}

select.form-control {
  cursor:     pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat:   no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width:           100%;
  border-collapse: collapse;
  font-size:       13px;
}

thead th {
  background:    var(--bg-elevated);
  padding:       11px 14px;
  text-align:    left;
  font-size:     11px;
  font-weight:   600;
  color:         var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space:   nowrap;
  border-bottom: 1px solid var(--border);
}

thead th:first-child { border-radius: var(--radius-md) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-md) 0 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition:    background var(--transition-fast);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover      { background: var(--bg-hover); }

tbody td {
  padding: 12px 14px;
  color:   var(--text-primary);
  vertical-align: middle;
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position:   fixed;
  inset:      0;
  background: var(--bg-overlay);
  z-index:    var(--z-modal-bg);
  display:    flex;
  align-items: center;
  justify-content: center;
  padding:    20px;
  backdrop-filter: blur(4px);
  opacity:    0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.open {
  opacity:        1;
  pointer-events: all;
}

.modal {
  background:    var(--bg-modal);
  border:        1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow:    var(--shadow-xl);
  width:         100%;
  max-width:     580px;
  max-height:    90vh;
  overflow:      hidden;
  display:       flex;
  flex-direction: column;
  transform:     scale(0.95) translateY(20px);
  transition:    transform var(--transition-base);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-size:   17px;
  font-weight: 700;
  color:       var(--text-primary);
}

.modal-close {
  width:  32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background var(--transition-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
  padding:    24px;
  overflow-y: auto;
  flex:       1;
}

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

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  top:      20px;
  right:    20px;
  z-index:  var(--z-toast);
  display:  flex;
  flex-direction: column;
  gap:      10px;
  pointer-events: none;
}

.toast {
  background:    var(--bg-elevated);
  border:        1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding:       14px 18px;
  box-shadow:    var(--shadow-lg);
  display:       flex;
  align-items:   flex-start;
  gap:           12px;
  min-width:     300px;
  max-width:     420px;
  pointer-events: all;
  transform:     translateX(100%);
  opacity:       0;
  transition:    transform var(--transition-base), opacity var(--transition-base);
  border-left:   4px solid var(--border);
}

.toast.show {
  transform: translateX(0);
  opacity:   1;
}

.toast.success { border-left-color: var(--success-500); }
.toast.error   { border-left-color: var(--danger-500); }
.toast.warning { border-left-color: var(--warning-500); }
.toast.info    { border-left-color: var(--brand-500); }

.toast-icon   { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-body   { flex: 1; }
.toast-title  { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.toast-msg    { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display:       flex;
  gap:           2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding:     9px 16px;
  background:  transparent;
  border:      none;
  border-bottom: 2px solid transparent;
  font-size:   13px;
  font-weight: 500;
  color:       var(--text-secondary);
  cursor:      pointer;
  transition:  color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab-btn:hover  { color: var(--text-primary); }
.tab-btn.active { color: var(--brand-400); border-bottom-color: var(--brand-500); }

.tab-panel      { display: none; }
.tab-panel.active { display: block; }

/* ── Search & Filters Bar ───────────────────────────────────── */
.filter-bar {
  display:  flex;
  gap:      10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .form-control {
  flex: 1;
  min-width: 200px;
}

.filter-bar select.form-control {
  flex: 0;
  min-width: 140px;
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display:     flex;
  align-items: center;
  justify-content: space-between;
  padding:     12px 0;
  font-size:   13px;
  color:       var(--text-secondary);
  flex-wrap:   wrap;
  gap:         10px;
}

.pagination-pages {
  display: flex;
  gap:     4px;
}

.page-btn {
  width:  32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color:  var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition-fast);
}

.page-btn:hover  { background: var(--bg-hover); }
.page-btn.active { background: var(--brand-600); color: white; border-color: var(--brand-600); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Charts ──────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width:    100%;
}

.chart-legend {
  display:  flex;
  gap:      16px;
  flex-wrap: wrap;
  margin-top: 12px;
  justify-content: center;
}

.legend-item {
  display:     flex;
  align-items: center;
  gap:         6px;
  font-size:   12px;
  color:       var(--text-secondary);
}

.legend-dot {
  width:  10px;
  height: 10px;
  border-radius: var(--radius-full);
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding:    60px 20px;
  color:      var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-text  { font-size: 14px; margin-bottom: 20px; }

/* ── Loading Spinner ─────────────────────────────────────────── */
.spinner {
  width:  20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand-500);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width:  40px;
  height: 40px;
  border-width: 3px;
}

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

.loading-overlay {
  position: absolute;
  inset:    0;
  background: var(--bg-overlay);
  display:  flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index:  10;
}

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display:  inline-block;
}

.dropdown-menu {
  position:      absolute;
  top:           calc(100% + 6px);
  right:         0;
  background:    var(--bg-modal);
  border:        1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow:    var(--shadow-lg);
  z-index:       var(--z-dropdown);
  min-width:     160px;
  overflow:      hidden;
  opacity:       0;
  pointer-events: none;
  transform:     translateY(-8px);
  transition:    opacity var(--transition-fast), transform var(--transition-fast);
}

.dropdown-menu.open {
  opacity:        1;
  pointer-events: all;
  transform:      translateY(0);
}

.dropdown-item {
  display:     flex;
  align-items: center;
  gap:         8px;
  padding:     9px 14px;
  font-size:   13px;
  color:       var(--text-primary);
  cursor:      pointer;
  transition:  background var(--transition-fast);
}

.dropdown-item:hover         { background: var(--bg-hover); }
.dropdown-item.danger        { color: var(--danger-500); }
.dropdown-item.danger:hover  { background: rgba(239,68,68,0.1); }

.dropdown-divider {
  height:     1px;
  background: var(--border);
  margin:     4px 0;
}

/* ── Alert Banner ────────────────────────────────────────────── */
.alert-banner {
  display:       flex;
  align-items:   flex-start;
  gap:           12px;
  padding:       14px 18px;
  border-radius: var(--radius-lg);
  border:        1px solid;
  margin-bottom: 20px;
  font-size:     13px;
}

.alert-banner.success { background: rgba(16,185,129,0.1); border-color: var(--success-500); color: var(--success-400); }
.alert-banner.warning { background: rgba(245,158,11,0.1); border-color: var(--warning-500); color: var(--warning-400); }
.alert-banner.error   { background: rgba(239,68,68,0.1);  border-color: var(--danger-500);  color: var(--danger-400); }
.alert-banner.info    { background: rgba(59,130,246,0.1); border-color: var(--brand-500);   color: var(--brand-400); }

/* ── Progress Bars ───────────────────────────────────────────── */
.progress-bar-wrapper {
  background:    var(--bg-elevated);
  border-radius: var(--radius-full);
  height:        6px;
  overflow:      hidden;
}

.progress-bar {
  height:        100%;
  border-radius: var(--radius-full);
  transition:    width 0.5s ease;
  background:    var(--brand-500);
}

.progress-bar.green  { background: var(--success-500); }
.progress-bar.yellow { background: var(--warning-500); }
.progress-bar.red    { background: var(--danger-500); }

/* ── Tooltip ─────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::before {
  content:       attr(data-tooltip);
  position:      absolute;
  bottom:        calc(100% + 6px);
  left:          50%;
  transform:     translateX(-50%);
  background:    var(--bg-tooltip);
  color:         var(--text-primary);
  font-size:     11px;
  font-weight:   500;
  padding:       5px 9px;
  border-radius: var(--radius-sm);
  white-space:   nowrap;
  opacity:       0;
  pointer-events: none;
  transition:    opacity var(--transition-fast);
  z-index:       var(--z-tooltip);
}

[data-tooltip]:hover::before { opacity: 1; }

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height:      100vh;
  display:         flex;
  align-items:     center;
  justify-content: center;
  background:      var(--bg-base);
  padding:         20px;
  position:        relative;
  overflow:        hidden;
}

.login-bg-gradient {
  position:  absolute;
  inset:     0;
  background: radial-gradient(ellipse at 30% 20%, rgba(59,130,246,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(139,92,246,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.login-card {
  background:    var(--bg-card);
  border:        1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  box-shadow:    var(--shadow-xl);
  width:         100%;
  max-width:     420px;
  padding:       40px;
  position:      relative;
  z-index:       1;
}

.login-logo {
  text-align:    center;
  margin-bottom: 28px;
}

.login-logo-icon {
  width:  56px;
  height: 56px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: var(--radius-xl);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(59,130,246,0.4);
}

.login-title {
  font-size:   20px;
  font-weight: 700;
  color:       var(--text-primary);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color:     var(--text-muted);
}

/* ── Sidebar Tooltip (collapsed mode) ───────────────────────── */
.sidebar.collapsed .nav-item {
  position: relative;
}

.sidebar.collapsed .nav-item::after {
  content:   attr(data-label);
  position:  absolute;
  left:      calc(100% + 8px);
  top:       50%;
  transform: translateY(-50%);
  background:    var(--bg-tooltip);
  color:         var(--text-primary);
  font-size:     12px;
  font-weight:   500;
  padding:       5px 10px;
  border-radius: var(--radius-md);
  white-space:   nowrap;
  opacity:       0;
  pointer-events: none;
  transition:    opacity var(--transition-fast);
  box-shadow:    var(--shadow-md);
  border:        1px solid var(--border-strong);
  z-index:       var(--z-tooltip);
}

.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* ── Utilities ───────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-1        { gap: 4px; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.gap-6        { gap: 24px; }
.mt-1         { margin-top: 4px; }
.mt-2         { margin-top: 8px; }
.mt-4         { margin-top: 16px; }
.mt-6         { margin-top: 24px; }
.mb-4         { margin-bottom: 16px; }
.mb-6         { margin-bottom: 24px; }
.w-full       { width: 100%; }
.text-sm      { font-size: 13px; }
.text-xs      { font-size: 11px; }
.text-muted   { color: var(--text-muted); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-bold    { font-weight: 700; }
.font-semibold { font-weight: 600; }
.hidden       { display: none !important; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .page-content { padding: 20px; }
  .kpi-grid     { grid-template-columns: repeat(5, 1fr); }
}

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

@media (max-width: 768px) {
  .sidebar       { transform: translateX(-100%); transition: transform var(--transition-slow); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content  { margin-left: 0 !important; }
  .header        { left: 0 !important; }
  .page-content  { padding: 16px; }
  .page-header   { flex-direction: column; align-items: flex-start; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .header-search input { width: 160px; }
  .kpi-grid      { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .kpi-grid      { grid-template-columns: 1fr; }
  .filter-bar    { flex-direction: column; }
  .filter-bar .form-control { min-width: unset; }
  .modal         { border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; max-height: 85vh; }
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.animate-fade-in { animation: fadeIn 0.3s ease both; }
.animate-slide-in { animation: slideIn 0.3s ease both; }
.animate-pulse    { animation: pulse 2s infinite; }

/* ── Severity colors ─────────────────────────────────────────── */
.severity-emergency { color: var(--danger-500); }
.severity-critical  { color: var(--danger-400); }
.severity-warning   { color: var(--warning-400); }
.severity-info      { color: var(--brand-400); }
