:root {
  --primary-color: #002B49;
  --primary-hover: #001f35;
  --secondary-color: #0072CE;
  --accent-gold: #D4AF37;
  --bg-main: #f4f6fb;
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --sidebar-width: 260px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-elevated: 0 10px 30px rgba(0, 43, 73, 0.12);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* App Wrapper Layout */
#app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-color);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
  overflow-x: hidden;
}

/* Sidebar Colapsada */
.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 50%;
  background: #ffffff;
  padding: 3px;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
  letter-spacing: -0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  transform: translateX(4px);
}

.nav-link.active {
  background: var(--secondary-color);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 114, 206, 0.35);
}

.nav-icon {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

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

.main-content.expanded {
  margin-left: 0;
  width: 100%;
}

/* Navbar Header */
.top-header {
  height: 62px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Botón Toggle de la Barra Lateral Siempre Disponible */
.btn-toggle-sidebar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(0, 43, 73, 0.06);
  border: 1px solid var(--border-color);
  font-size: 1.15rem;
  color: var(--primary-color);
  cursor: pointer;
  transition: var(--transition);
}

.btn-toggle-sidebar:hover {
  background: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 43, 73, 0.2);
}

.page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
}

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

.scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 43, 73, 0.06);
  border: 1px solid rgba(0, 43, 73, 0.12);
  padding: 5px 12px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-color);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Page Body Container */
.content-body {
  padding: 20px;
  flex: 1;
}

/* Card System */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  box-shadow: var(--shadow-subtle);
  margin-bottom: 16px;
  transition: var(--transition);
}

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

.card-header-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Grid KPI Layout Compacto */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

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

.kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-color);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 0.72rem;
  color: #10b981;
  font-weight: 600;
}

/* Custom Table Styles */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.custom-table th {
  background: rgba(0, 43, 73, 0.04);
  color: var(--primary-color);
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.82rem;
  border-bottom: 2px solid var(--border-color);
}

.custom-table td {
  padding: 10px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-dark);
}

.custom-table tr:hover {
  background: rgba(0, 114, 206, 0.03);
}

/* Badges & Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(0, 43, 73, 0.3);
}

.btn-secondary {
  background: var(--secondary-color);
  color: #ffffff;
}

.btn-secondary:hover {
  filter: brightness(0.9);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #e0f2fe; color: #075985; }

/* Forms */
.form-group {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
}

.form-control {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(0, 114, 206, 0.15);
}

/* Leaflet Container */
#map-canvas {
  height: 520px;
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  z-index: 1;
}

/* Leaflet Permanent Tooltip Label para Ciudades */
.ciudad-map-label {
  background: rgba(0, 43, 73, 0.88) !important;
  border: 1px solid #0072CE !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: 0.76rem !important;
  padding: 3px 8px !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
  white-space: nowrap !important;
}

.ciudad-map-label::before {
  border-top-color: rgba(0, 43, 73, 0.88) !important;
}

/* Responsive Rules */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    width: 100%;
  }
}
