/* ==========================================================================
   ADA JAÉN - INFRAESTRUCTURAS RCJA
   Design System & Modern Responsive Stylesheet
   ========================================================================== */

:root {
  --primary: #006847;
  --primary-dark: #004d34;
  --primary-light: #0d9488;
  --primary-subtle: #ecfdf5;
  --accent: #2563eb;
  --accent-light: #3b82f6;
  --dark-bg: #0f172a;
  --sidebar-bg: #0f1f1a;
  --sidebar-text: #e2e8f0;
  --sidebar-hover: #1e3a32;
  --sidebar-active: #059669;
  
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #0d9488;
  
  --status-abierta: #ef4444;
  --status-abierta-bg: #fef2f2;
  --status-cerrada: #10b981;
  --status-cerrada-bg: #ecfdf5;
  --status-pendiente: #f59e0b;
  --status-pendiente-bg: #fffbeb;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.12), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --sidebar-width: 270px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

/* ==========================================================================
   LAYOUT: SIDEBAR + MAIN CONTENT
   ========================================================================== */

.app-wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar a la izquierda */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s ease, width 0.3s ease;
  overflow-y: auto;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
}

.brand-info span {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
  display: block;
}

.sidebar-menu {
  list-style: none;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.menu-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 12px 12px 6px;
  font-weight: 700;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: #cbd5e1;
  font-size: 0.92rem;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar-menu a:hover {
  background-color: var(--sidebar-hover);
  color: #ffffff;
  transform: translateX(3px);
}

.sidebar-menu a.active {
  background: linear-gradient(90deg, var(--sidebar-active) 0%, #047857 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.sidebar-menu a svg,
.sidebar-menu a .menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  color: #94a3b8;
  background-color: rgba(0, 0, 0, 0.2);
}

.db-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 6px;
}

.db-pill.sqlite {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.db-pill.mysql {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(8px);
}

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

.mobile-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  color: var(--text-main);
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */

.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
  transition: var(--transition);
}

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

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #ffffff;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-body {
  padding: 24px;
}

/* Grid system */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

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

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

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.3;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 104, 71, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #047857 0%, #064e3b 100%);
  color: #ffffff;
  box-shadow: 0 4px 8px rgba(0, 104, 71, 0.3);
}

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

.btn-secondary:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

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

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #dc2626;
  color: #ffffff;
}

.btn-success {
  background-color: #10b981;
  color: #ffffff;
}

.btn-success:hover {
  background-color: #059669;
  color: #ffffff;
}

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

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

.form-control {
  width: 100%;
  padding: 9px 14px;
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* ==========================================================================
   BADGES & STATUS
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

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

.badge-danger {
  background-color: var(--status-abierta-bg);
  color: var(--status-abierta);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-success {
  background-color: var(--status-cerrada-bg);
  color: var(--status-cerrada);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
  background-color: var(--status-pendiente-bg);
  color: var(--status-pendiente);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-secondary {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.badge-primary {
  background-color: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid rgba(0, 104, 71, 0.2);
}

/* ==========================================================================
   TABLES & DATA LISTS & HORIZONTAL SCROLLBARS
   ========================================================================== */

/* Estilos de barra de desplazamiento siempre visible y destacada */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) #e2e8f0;
}

.table-responsive::-webkit-scrollbar,
.top-scrollbar-wrap::-webkit-scrollbar {
  height: 12px;
}

.table-responsive::-webkit-scrollbar-track,
.top-scrollbar-wrap::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.table-responsive::-webkit-scrollbar-thumb,
.top-scrollbar-wrap::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #0f766e 0%, #004d34 100%);
  border-radius: 6px;
  border: 2px solid #f1f5f9;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.top-scrollbar-wrap::-webkit-scrollbar-thumb:hover {
  background: #047857;
}

/* Barra de desplazamiento superior sincronizada */
.top-scrollbar-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  height: 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-scrollbar-inner {
  height: 16px;
}

/* Tarjeta de Anotaciones */
.anotacion-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-light);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 14px;
  transition: var(--transition);
}

.anotacion-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: #cbd5e1;
}

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

.anotacion-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text-main);
}

.anotacion-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.anotacion-text {
  font-size: 0.92rem;
  color: #334155;
  line-height: 1.55;
  white-space: pre-wrap;
}

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

.data-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

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

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

.data-table tbody tr:hover {
  background-color: #f1f5f9;
}

.code-badge {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  background-color: #f1f5f9;
  color: var(--primary-dark);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}

/* ==========================================================================
   STAT CARDS
   ========================================================================== */

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

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

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

.stat-icon.green {
  background-color: #ecfdf5;
  color: #059669;
}

.stat-icon.blue {
  background-color: #eff6ff;
  color: #2563eb;
}

.stat-icon.amber {
  background-color: #fffbeb;
  color: #d97706;
}

.stat-icon.purple {
  background-color: #faf5ff;
  color: #7e22ce;
}

.stat-val {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
}

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

/* ==========================================================================
   FICHA DE SEDE DETAIL
   ========================================================================== */

.sede-header-card {
  background: linear-gradient(135deg, #004d34 0%, #0f766e 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}

.sede-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.sede-code-chip {
  background-color: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.sede-header-title {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 8px;
}

.sede-header-subtitle {
  font-size: 0.95rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  position: relative;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--primary);
  background-color: #f1f5f9;
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 700;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--primary);
  border-radius: 3px 3px 0 0;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Data Key-Value Display */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.prop-item {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  border-radius: var(--radius-md);
}

.prop-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.prop-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

/* Network VLAN card */
.vlan-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: #ffffff;
  position: relative;
  border-left: 5px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.vlan-card.vlan21 { border-left-color: #2563eb; } /* VOS */
.vlan-card.vlan20 { border-left-color: #059669; } /* DATOS */
.vlan-card.vlan30 { border-left-color: #ea580c; } /* INTERNET */
.vlan-card.vlan60 { border-left-color: #7c3aed; } /* WIFI */

.vlan-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Network calc result pill */
.calc-result-box {
  background: #f8fafc;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 0.82rem;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #f1f5f9;
}

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

/* Incident timeline */
.incident-timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.incident-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  background: #ffffff;
  transition: var(--transition);
}

.incident-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.incident-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.incident-num {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  font-family: monospace;
}

.incident-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.incident-desc {
  font-size: 0.9rem;
  color: #334155;
  white-space: pre-wrap;
  margin-bottom: 8px;
}

.incident-res {
  background: #f0fdf4;
  border-left: 3px solid #10b981;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #065f46;
  margin-top: 8px;
}

/* Photo gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.gallery-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
  aspect-ratio: 4/3;
  background: #000;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.gallery-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gallery-item:hover .gallery-actions {
  opacity: 1;
}

/* Attachments list */
.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: #ffffff;
}

.attachment-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.attachment-icon {
  font-size: 24px;
  color: #ef4444;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-container {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: modalFadeIn 0.2s ease;
}

.modal-container.large {
  max-width: 1100px;
  height: 90vh;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-container form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

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

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

/* Alerts / Flash */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 500;
}

.alert-success {
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-error {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
}

.page-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

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

/* ==========================================================================
   TARJETAS DE DISPOSITIVO / ELECTRÓNICA & SERVIDORES (INVENTARIO)
   ========================================================================== */
.device-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: all 0.2s ease;
  position: relative;
}

.device-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}

.device-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.device-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.device-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.device-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.device-badges-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.badge-crija {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-family: monospace;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-sn {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-family: monospace;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.badge-operativo-ok {
  background: #dcfce7;
  color: #15803d;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.badge-operativo-maint {
  background: #fef9c3;
  color: #a16207;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.badge-operativo-down {
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.badge-operativo-reserva {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px 18px;
}

.device-prop {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-prop-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.device-prop-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-all;
}

.device-prop-val code {
  font-family: monospace;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.83rem;
  color: #0f172a;
}

.copy-mini-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  font-size: 0.8rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.copy-mini-btn:hover {
  opacity: 1;
}

.device-obs-box {
  margin-top: 14px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 6px;
  border-left: 3px solid #047857;
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ==========================================================================
   MARCADORES PERSONALIZADOS PARA MAPAS LEAFLET (POR ORGANISMO)
   ========================================================================== */
.custom-map-pin {
  background: transparent !important;
  border: none !important;
}

.pin-marker {
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  border: 2px solid #ffffff;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.pin-marker:hover {
  transform: rotate(-45deg) scale(1.22);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  z-index: 1000 !important;
}

.pin-icon {
  transform: rotate(45deg);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

/* Leyenda interactiva de organismos en el mapa */
.map-legend-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-top: 16px;
}

.map-legend-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 14px;
  margin-top: 12px;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #334155;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.map-legend-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.map-legend-item.active {
  background: #eff6ff;
  border-color: #3b82f6;
  font-weight: 700;
  color: #1e40af;
}

.map-legend-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ==========================================================================
   NOTIFICACIONES TOAST (FLOTANTES)
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  border-left: 4px solid var(--primary);
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.2s ease;
}

.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error { border-left-color: #ef4444; }
.toast.toast-info { border-left-color: #3b82f6; }
.toast.toast-warning { border-left-color: #f59e0b; }

.toast.toast-hiding {
  opacity: 0;
  transform: translateX(30px);
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   BUSCADOR UNIVERSAL SPOTLIGHT (CTRL + K)
   ========================================================================== */
.spotlight-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  color: #64748b;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}

.spotlight-trigger-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
  border-color: #cbd5e1;
}

.spotlight-trigger-btn kbd {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.72rem;
  font-family: monospace;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.spotlight-overlay {
  align-items: flex-start !important;
  padding-top: 10vh !important;
}

.spotlight-container {
  max-width: 650px;
  width: 100%;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  border: 1px solid var(--border-color);
  animation: modalFadeIn 0.15s ease-out;
}

.spotlight-search-bar {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  gap: 12px;
}

.spotlight-search-input {
  flex: 1;
  border: none;
  font-size: 1.1rem;
  outline: none;
  color: var(--text-main);
  background: transparent;
}

.spotlight-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px 0;
}

.spotlight-section-title {
  padding: 8px 20px 4px 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

.spotlight-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
  transition: background 0.15s;
  cursor: pointer;
}

.spotlight-item:hover, .spotlight-item.selected {
  background: #f1f5f9;
}

.spotlight-footer {
  padding: 10px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   TOPOLOGÍA LÓGICA DE RED DE SEDE
   ========================================================================== */
.topology-container {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  margin-top: 24px;
}

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

.topology-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
}

.topology-node {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px 24px;
  min-width: 260px;
  text-align: center;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
  transition: all 0.2s;
  position: relative;
}

.topology-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.topology-node.node-wan {
  border-color: #0284c7;
  background: #f0f9ff;
}

.topology-node.node-fw {
  border-color: #ef4444;
  background: #fef2f2;
}

.topology-node.node-sw {
  border-color: #10b981;
  background: #ecfdf5;
}

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

.topology-vlan-leaf {
  background: #ffffff;
  border-radius: 10px;
  padding: 12px 14px;
  border-left: 4px solid #64748b;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  border-top: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.topology-connector {
  width: 2px;
  height: 20px;
  background: #94a3b8;
  position: relative;
}

.topology-connector::after {
  content: '▼';
  font-size: 8px;
  color: #94a3b8;
  position: absolute;
  bottom: -6px;
  left: -3px;
}

/* ==========================================================================
   ARMARIO RACK 42U ELEVATION
   ========================================================================== */
.rack-cabinet {
  max-width: 680px;
  margin: 0 auto;
  background: #1e293b;
  border: 10px solid #0f172a;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  padding: 10px 14px;
  font-family: monospace;
}

.rack-header-badge {
  text-align: center;
  color: #94a3b8;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  padding-bottom: 10px;
  border-bottom: 1px solid #334155;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rack-units-scroll {
  max-height: 680px;
  overflow-y: auto;
  padding-right: 4px;
}

.rack-unit-slot {
  display: flex;
  align-items: center;
  height: 29px;
  border-bottom: 1px solid #334155;
  color: #cbd5e1;
  font-size: 0.75rem;
  position: relative;
  transition: background 0.15s;
}

.rack-unit-num {
  width: 36px;
  color: #64748b;
  font-weight: 700;
  font-size: 0.72rem;
  text-align: center;
  border-right: 1px solid #334155;
  user-select: none;
}

.rack-unit-body {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 10px;
}

.rack-unit-occupied {
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 3px;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.rack-unit-occupied:hover {
  border-color: #94a3b8;
  background: #1e293b;
}

.rack-unit-occupied.type-switch {
  border-left: 4px solid #10b981;
}

.rack-unit-occupied.type-router {
  border-left: 4px solid #ef4444;
}

.rack-unit-occupied.type-server {
  border-left: 4px solid #3b82f6;
}

.rack-unit-occupied.type-ups {
  border-left: 4px solid #f59e0b;
}

.rack-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 4px #10b981;
}

/* ==========================================================================
   ESTILOS DE IMPRESIÓN / FICHA DE CAMPO (@media print)
   ========================================================================== */
.print-only {
  display: none !important;
}

@media print {
  .sidebar, .topbar, .tabs-nav, .spotlight-trigger-btn, .btn, form,
  .toast-container, .modal-overlay, #topScrollbarWrap, .copy-mini-btn,
  .sede-header-card .btn, .card-header .btn {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  
  .content-container {
    padding: 0 !important;
  }
  
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt !important;
  }
  
  .print-only {
    display: block !important;
  }
  
  .card, .device-card, .anotacion-card, .vlan-card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 12px !important;
  }
  
  .tab-pane {
    display: block !important;
  }
  
  .tab-pane:not(#tab-general):not(#tab-contactos):not(#tab-red):not(#tab-inventario):not(#tab-anotaciones) {
    display: none !important;
  }
  
  .print-header {
    display: block !important;
    border-bottom: 3px solid #004d34;
    padding-bottom: 12px;
    margin-bottom: 18px;
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN (PC / TABLET / MOBILE)
   ========================================================================== */

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-toggle {
    display: inline-flex;
  }
  .content-container {
    padding: 16px;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 10px 16px;
  }
  .sede-header-card {
    padding: 20px;
  }
  .sede-header-title {
    font-size: 1.3rem;
  }
  .data-table th, .data-table td {
    padding: 10px 12px;
  }
}
