/* === THEME REDSUR GERENCIAL – Sidebar colapsable y paleta corporativa === */

/* ===== PALETA DE COLORES REDSUR ===== */
:root {
  /* Colores principales de marca Redsur */
  --primary: #00a8e1;              /* Celeste Redsur - acciones principales */
  --primary-dark: #0090c4;         /* Hover primary */
  --success: #8bc53f;              /* Verde Redsur - confirmaciones */
  --success-dark: #7ab02f;         /* Hover success */
  
  /* Sidebar profesional */
  --sidebar-bg: #1a2332;           /* Azul oscuro corporativo */
  --sidebar-text: #e2e8f0;         /* Texto principal sidebar */
  --sidebar-text-soft: #94a3b8;    /* Texto secundario/íconos */
  --sidebar-hover: #00a8e1;        /* Hover con color de marca */
  --sidebar-active: rgba(0,168,225,.15); /* Active con transparencia */
  
  /* Colores de estado (alertas/warnings) */
  --warning: #ffa726;              /* Naranja para advertencias */
  --warning-dark: #fb8c00;
  --danger: #ef5350;               /* Rojo para errores */
  --danger-dark: #e53935;
  --info: #42a5f5;                 /* Azul claro para información */
  --info-dark: #1e88e5;
  --secondary: #64748b;            /* Gris para secundarios */
  --secondary-dark: #475569;
  
  /* Bordes y fondos */
  --border-soft: rgba(148,163,184,.15);
  --border-light: #e2e8f0;
  --bg-main: #f8fafc;              /* Fondo principal (más suave) */
  --bg-card: #ffffff;              /* Fondo de tarjetas */
  --bg-hover: #f1f5f9;             /* Hover genérico */
  
  /* Layout */
  --aside-collapsed: 64px;         /* Ancho sidebar colapsado */
}

body {
  background: var(--bg-main);
  color: #1e293b;
  font-size: 13px;
  line-height: 1.5;
}

/* ===== TIPOGRAFÍA PROFESIONAL (tamaños reducidos) ===== */
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
h5 { font-size: 0.9rem; }
h6 { font-size: 0.85rem; }

/* Tablas compactas */
.table {
  font-size: 0.8rem;
}
.table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.5rem 0.6rem;
}
.table td {
  padding: 0.4rem 0.6rem;
  vertical-align: middle;
}
.table-sm th,
.table-sm td {
  padding: 0.3rem 0.5rem;
}

/* Formularios compactos */
.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}
.form-control,
.form-select {
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
}
.form-control-sm,
.form-select-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}
.form-text {
  font-size: 0.7rem;
}
.input-group-text {
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
}

/* Botones compactos */
.btn {
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
}
.btn-sm {
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
}
.btn-lg {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

/* Cards */
.card-header {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
}
.card-body {
  padding: 0.85rem 1rem;
}
.card-title {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.card-text {
  font-size: 0.8rem;
}

/* Badges y pills */
.badge {
  font-size: 0.68rem;
  padding: 0.3em 0.55em;
  font-weight: 500;
}

/* Alerts */
.alert {
  font-size: 0.8rem;
  padding: 0.6rem 0.85rem;
}

/* Modales */
.modal-title {
  font-size: 1rem;
}
.modal-body {
  font-size: 0.85rem;
}

/* Listas */
.list-group-item {
  font-size: 0.8rem;
  padding: 0.55rem 0.85rem;
}

/* Dropdowns */
.dropdown-item {
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
}
.dropdown-header {
  font-size: 0.72rem;
}

/* Paginación */
.pagination {
  font-size: 0.8rem;
}
.page-link {
  padding: 0.35rem 0.65rem;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.78rem;
}

/* Tooltips y Popovers */
.tooltip-inner {
  font-size: 0.72rem;
}
.popover {
  font-size: 0.8rem;
}

/* Tabs y Nav */
.nav-tabs .nav-link,
.nav-pills .nav-link {
  font-size: 0.8rem;
  padding: 0.45rem 0.85rem;
}

/* Progress */
.progress {
  font-size: 0.65rem;
  height: 0.6rem;
}

/* ===== TÍTULO TOPBAR ===== */
.system-title {
  color: #475569;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: normal;
  overflow: visible;
  word-break: normal;
  line-height: 1.3;
  max-width: 100%;
}

@media (max-width:576px) {
  .system-title {
    font-size: 0.7rem;
    padding: 4px 0;
  }
}

/* ===== SIDEBAR (desktop & offcanvas) ===== */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  min-height: 100vh;
  border-right: none;
  transition: flex-basis .2s ease, width .2s ease, max-width .2s ease;
  overflow-x: hidden;
  padding-left: 0;
  padding-right: 0;
}

/* Contenedor del partial */
.sidebar-inner {
  width: 100%;
  background: transparent;
  padding: 0 8px 0 4px;
}

/* Cabecera pequeña dentro del sidebar */
.sidebar-inner small {
  letter-spacing: .05em;
  font-weight: 700;
  color: var(--sidebar-text-soft);
  font-size: 0.7rem;
}

/* Lista raíz del menú */
.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

/* Cada item del menú */
.sidebar-menu .nav-item {
  width: 100%;
  margin-bottom: 2px;
}

/* Enlaces base */
.sidebar-menu .nav-link {
  color: var(--sidebar-text);
  border-radius: 5px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  transition: all .2s ease;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.78rem;
  font-weight: 500;
  position: relative;
}

/* Iconos (Font Awesome / SVG) */
.sidebar-menu .nav-link i {
  color: var(--sidebar-text-soft);
  width: 18px;
  text-align: center;
  font-size: 0.85rem;
  transition: color .2s ease;
}

.sidebar-menu .nav-link svg {
  width: 15px;
  height: 15px;
  vertical-align: -2px;
}

.sidebar-menu .nav-link svg * {
  fill: currentColor !important;
  stroke: currentColor !important;
}

/* Hover - efecto suave con color de marca */
.sidebar-menu .nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  transform: translateX(2px);
}

.sidebar-menu .nav-link:hover i {
  color: var(--primary);
}

/* Activo - fondo con gradiente sutil */
.sidebar .sidebar-menu .mm-active > a.nav-link {
  background: linear-gradient(90deg, rgba(0,168,225,.2) 0%, rgba(139,197,63,.1) 100%);
  color: #fff;
  font-weight: 600;
}

.sidebar .sidebar-menu .mm-active > a.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--success) 100%);
  border-radius: 0 3px 3px 0;
}

.sidebar .sidebar-menu .mm-active > a.nav-link i {
  color: var(--primary);
}

/* ===== Nodos con hijos (cabecera + caret) ===== */
.sidebar-menu .nav-item > a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Texto: se expande y se corta con "..." */
.sidebar-menu .nav-item > a.nav-link .menu-text {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Caret: siempre al final */
.sidebar-menu .nav-item > a.nav-link .caret-wrap {
  flex: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  transition: background .2s ease;
}

.sidebar-menu .nav-item > a.nav-link:hover .caret-wrap {
  background: rgba(255,255,255,.1);
}

/* Animación del caret */
.sidebar-menu .nav-item > a.nav-link .caret-wrap .fa-caret-right {
  transition: transform .25s ease;
  font-size: 0.65rem;
  color: var(--sidebar-text-soft);
}

.sidebar-menu .nav-item.is-open > a.nav-link .caret-wrap .fa-caret-right {
  transform: rotate(90deg);
  color: var(--primary);
}

/* ===== Submenús (niveles) ===== */
.sidebar-menu .collapse {
  padding-left: 0;
}

.sidebar-menu .collapse.show,
.sidebar-menu .collapse {
  transition: none;
}

/* Primer nivel - con línea conectora */
.sidebar-menu .collapse > .nav-item {
  position: relative;
}

.sidebar-menu .collapse > .nav-item::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 50%;
  width: 1px;
  background: rgba(255,255,255,.12);
}

.sidebar-menu .collapse > .nav-item:last-child::before {
  bottom: 50%;
}

.sidebar-menu .collapse > .nav-item > .nav-link {
  padding-left: 32px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--sidebar-text-soft);
}

.sidebar-menu .collapse > .nav-item > .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.05);
}

.sidebar-menu .collapse > .nav-item > .nav-link i {
  font-size: 0.75rem;
}

/* Segundo nivel anidado */
.sidebar-menu .collapse .collapse > .nav-item > .nav-link {
  padding-left: 44px;
  font-size: 0.72rem;
}

/* Tercer nivel anidado */
.sidebar-menu .collapse .collapse .collapse > .nav-item > .nav-link {
  padding-left: 56px;
}

/* Estado ACTIVO en submenús */
.sidebar .sidebar-menu .collapse .mm-active > a.nav-link {
  color: #fff;
  background: rgba(0,168,225,.15);
}

.sidebar .sidebar-menu .collapse .mm-active > a.nav-link::before {
  display: none;
}

/* ===== OFFCANVAS (móvil) ===== */
.offcanvas.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.offcanvas.sidebar .offcanvas-header {
  border-bottom: 1px solid var(--border-soft);
}

.offcanvas.sidebar .btn-close {
  filter: invert(1) grayscale(100%);
}

/* ===== TOPBAR ===== */
.navbar.sticky-top {
  box-shadow: 0 1px 0 var(--border-soft);
}

/* Logo en cabecera */
.logo-header {
  display: flex;
  align-items: center;
}

.logo-header img {
  height: 42px;
  width: auto;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.12));
}

/* ===== PERFIL DE USUARIO EN TOPBAR ===== */

/* Avatar de usuario con iniciales */
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

/* Contenedor clickeable del usuario */
.user-dropdown {
  padding: 6px 10px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.user-dropdown:hover {
  background-color: #f1f5f9;
}

/* Nombre del usuario en topbar */
.user-dropdown .fw-semibold {
  font-size: 0.8rem;
}

/* Rol del usuario en topbar */
.user-dropdown .small {
  font-size: 0.7rem;
}

/* ===== DROPDOWN MENU DEL USUARIO ===== */
.dropdown-menu.dropdown-menu-end {
  min-width: 190px;
  padding: 6px 0;
  margin-top: 6px !important;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

/* Items del dropdown */
.dropdown-menu .dropdown-item {
  padding: 7px 14px;
  font-size: 0.78rem;
  color: #334155;
  transition: all 0.15s ease;
  border-radius: 0;
  margin: 0;
  width: 100%;
}

.dropdown-menu .dropdown-item:hover {
  background-color: #f1f5f9;
  color: var(--primary);
}

.dropdown-menu .dropdown-item:active {
  background-color: #e2e8f0;
}

.dropdown-menu .dropdown-item i {
  width: 20px;
  text-align: center;
}

/* Item de cerrar sesión */
.dropdown-menu .dropdown-item.text-danger:hover {
  background-color: #fef2f2;
  color: #dc2626;
}

/* Divisor */
.dropdown-menu .dropdown-divider {
  margin: 8px 0;
  border-color: #e2e8f0;
}

/* Info del usuario en móvil */
.dropdown-menu .border-bottom {
  border-color: #e2e8f0 !important;
  background-color: #f8fafc;
}

/* ===== SISTEMA DE BOTONES REDSUR ===== */

/* Primary - Celeste Redsur */
.btn-redsur-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
  transition: all .2s ease;
}

.btn-redsur-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
}

.btn-redsur-primary:focus,
.btn-redsur-primary:active {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 0.2rem rgba(0,168,225,.25);
}

/* Success - Verde Redsur */
.btn-redsur-success {
  background-color: var(--success);
  border-color: var(--success);
  color: white;
  transition: all .2s ease;
}

.btn-redsur-success:hover {
  background-color: var(--success-dark);
  border-color: var(--success-dark);
  color: white;
}

.btn-redsur-success:focus,
.btn-redsur-success:active {
  background-color: var(--success-dark);
  border-color: var(--success-dark);
  box-shadow: 0 0 0 0.2rem rgba(139,197,63,.25);
}

/* Warning - Naranja */
.btn-redsur-warning {
  background-color: var(--warning);
  border-color: var(--warning);
  color: white;
  transition: all .2s ease;
}

.btn-redsur-warning:hover {
  background-color: var(--warning-dark);
  border-color: var(--warning-dark);
  color: white;
}

.btn-redsur-warning:focus,
.btn-redsur-warning:active {
  background-color: var(--warning-dark);
  border-color: var(--warning-dark);
  box-shadow: 0 0 0 0.2rem rgba(255,167,38,.25);
}

/* Danger - Rojo */
.btn-redsur-danger {
  background-color: var(--danger);
  border-color: var(--danger);
  color: white;
  transition: all .2s ease;
}

.btn-redsur-danger:hover {
  background-color: var(--danger-dark);
  border-color: var(--danger-dark);
  color: white;
}

.btn-redsur-danger:focus,
.btn-redsur-danger:active {
  background-color: var(--danger-dark);
  border-color: var(--danger-dark);
  box-shadow: 0 0 0 0.2rem rgba(239,83,80,.25);
}

/* Info - Azul claro */
.btn-redsur-info {
  background-color: var(--info);
  border-color: var(--info);
  color: white;
  transition: all .2s ease;
}

.btn-redsur-info:hover {
  background-color: var(--info-dark);
  border-color: var(--info-dark);
  color: white;
}

.btn-redsur-info:focus,
.btn-redsur-info:active {
  background-color: var(--info-dark);
  border-color: var(--info-dark);
  box-shadow: 0 0 0 0.2rem rgba(66,165,245,.25);
}

/* Secondary - Gris */
.btn-redsur-secondary {
  background-color: var(--secondary);
  border-color: var(--secondary);
  color: white;
  transition: all .2s ease;
}

.btn-redsur-secondary:hover {
  background-color: var(--secondary-dark);
  border-color: var(--secondary-dark);
  color: white;
}

.btn-redsur-secondary:focus,
.btn-redsur-secondary:active {
  background-color: var(--secondary-dark);
  border-color: var(--secondary-dark);
  box-shadow: 0 0 0 0.2rem rgba(100,116,139,.25);
}

/* ===== VARIANTES OUTLINE ===== */
.btn-outline-redsur-primary {
  border-color: var(--primary);
  color: var(--primary);
  background-color: transparent;
}

.btn-outline-redsur-primary:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-outline-redsur-success {
  border-color: var(--success);
  color: var(--success);
  background-color: transparent;
}

.btn-outline-redsur-success:hover {
  background-color: var(--success);
  border-color: var(--success);
  color: white;
}

/* ===== UTILIDADES ===== */
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 100%;
  margin-right: 6px;
}

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== POPOVER DE CONTACTOS ===== */
a[bs-popover] { 
  cursor: pointer; 
  text-decoration: none; 
}

.popover-contact a { 
  text-decoration: none; 
}

.popover-contact a:hover { 
  text-decoration: underline; 
}

.popover-contact .fa-envelope,
.popover-contact .fa-phone { 
  opacity: .75; 
}

.popover-contact .text-muted {
  font-size: .68rem;
}

.popover-contact .fw-semibold {
  font-size: .78rem;
}

.popover-contact .section-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  margin-bottom: .35rem;
}

.popover-contact .info-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .35rem;
}

.popover-contact .info-row .label { 
  min-width: 135px; 
}

.popover-contact .btn.btn-xs {
  font-size: .72rem;
}

/* ===== COLAPSO SIDEBAR (Desktop) ===== */
@media (min-width: 992px) {
  /* Sidebar a 64px */
  .sidebar-collapsed aside.sidebar {
    flex: 0 0 var(--aside-collapsed) !important;
    max-width: var(--aside-collapsed) !important;
    width: var(--aside-collapsed) !important;
    overflow: hidden;
  }
  
  /* Main se expande */
  .sidebar-collapsed main {
    flex: 1 1 auto !important;
    max-width: none !important;
  }
}

/* Ocultar textos en colapso, mantener íconos */
.sidebar-collapsed aside.sidebar .sidebar-inner .menu-text,
.sidebar-collapsed aside.sidebar .sidebar-inner .px-3.small,
.sidebar-collapsed aside.sidebar .sidebar-inner small.text-uppercase,
.sidebar-collapsed aside.sidebar .sidebar-inner .nav .nav-link span,
.sidebar-collapsed aside.sidebar .sidebar-inner .nav .nav-item .label {
  display: none !important;
}

/* Centrar ítems al colapso */
.sidebar-collapsed aside.sidebar .sidebar-inner .nav .nav-link,
.sidebar-collapsed aside.sidebar .sidebar-inner .px-3.mb-2 {
  justify-content: center;
  padding-left: .5rem;
  padding-right: .5rem;
}

/* ===== ACCESIBILIDAD ===== */
.sidebar-menu .nav-link:focus {
  outline: 2px solid rgba(0,168,225,.5);
  outline-offset: 2px;
}

/* Scrollbar discreto en sidebar (webkit) */
.sidebar ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.sidebar ::-webkit-scrollbar-thumb {
  background: rgba(226,232,240,.2);
  border-radius: 8px;
}

.sidebar ::-webkit-scrollbar-thumb:hover {
  background: rgba(226,232,240,.3);
}

/* Prefiere menor movimiento */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-menu .nav-link,
  .sidebar-menu .fa-caret-right {
    transition: none !important;
  }
}

/* ===== DASHBOARD CARDS (estilo PowerBI compacto) ===== */
.dashboard-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  border: 1px solid var(--border-light);
  transition: transform .15s ease, box-shadow .15s ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.dashboard-card .card-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.dashboard-card .card-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: .2rem;
}

.dashboard-card .card-sub {
  font-size: .68rem;
  color: #64748b;
}

/* Espaciado entre cards */
.dashboard-grid {
  display: grid;
  gap: 1rem;
}

/* Layout adaptable */
@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

/* Badges compactos */
.card-badge {
  display: inline-block;
  background: var(--bg-hover);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: .6rem;
  color: #64748b;
}

/* Tendencias con colores de marca */
.dashboard-card .trend-up {
  color: var(--success);
  font-weight: 600;
  font-size: 0.82rem;
}

.dashboard-card .trend-down {
  color: var(--danger);
  font-weight: 600;
  font-size: 0.82rem;
}

/* ===== CONTENEDOR CON SCROLL (informes de terreno) ===== */
.pdf-list-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: 0.375rem;
  padding: 0;
  background: var(--bg-card);
}

/* Personalizar scrollbar */
.pdf-list-container::-webkit-scrollbar {
  width: 8px;
}

.pdf-list-container::-webkit-scrollbar-track {
  background: var(--bg-hover);
  border-radius: 4px;
}

.pdf-list-container::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

.pdf-list-container::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Mejorar el aspecto de los items */
.pdf-list-container .list-group-item {
  border-left: none;
  border-right: none;
  border-radius: 0;
}

.pdf-list-container .list-group-item:first-child {
  border-top: none;
  border-top-left-radius: 0.375rem;
  border-top-right-radius: 0.375rem;
}

.pdf-list-container .list-group-item:last-child {
  border-bottom: none;
  border-bottom-left-radius: 0.375rem;
  border-bottom-right-radius: 0.375rem;
}

/* Tooltip de error */
.error-tooltip {
  position: relative;
  cursor: help;
}

.error-message {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.25rem;
}

/* ===== BADGES Y ALERTAS CON COLORES REDSUR ===== */
.badge-redsur-primary {
  background-color: var(--primary);
  color: white;
}

.badge-redsur-success {
  background-color: var(--success);
  color: white;
}

.badge-redsur-warning {
  background-color: var(--warning);
  color: white;
}

.badge-redsur-danger {
  background-color: var(--danger);
  color: white;
}

.badge-redsur-info {
  background-color: var(--info);
  color: white;
}

/* Alertas */
.alert-redsur-primary {
  background-color: rgba(0,168,225,.1);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.alert-redsur-success {
  background-color: rgba(139,197,63,.1);
  border-color: var(--success);
  color: var(--success-dark);
}

.alert-redsur-warning {
  background-color: rgba(255,167,38,.1);
  border-color: var(--warning);
  color: var(--warning-dark);
}

.alert-redsur-danger {
  background-color: rgba(239,83,80,.1);
  border-color: var(--danger);
  color: var(--danger-dark);
}

/* ===== PÁGINA DE LOGIN ===== */
html, body {
  overflow-x: hidden;
}

.login-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('../img/background.png') center center / cover no-repeat;
  overflow: hidden;
  z-index: 9999;
}

.login-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  margin: 16px;
  background: rgba(255,255,255,0.95);
  border-radius: 12px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.25);
  padding: 32px 28px;
  backdrop-filter: blur(10px);
}

.login-logo {
  height: 48px;
  width: auto;
}

.login-title {
  color: var(--sidebar-bg);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
  text-align: center;
}

.login-subtitle {
  color: #64748b;
  font-size: 0.8rem;
  text-align: center;
  margin-bottom: 20px;
}

.login-card .form-label {
  font-weight: 600;
  color: #334155;
  font-size: 0.78rem;
}

.login-card .input-group-text {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: var(--primary);
  font-size: 0.85rem;
  padding: 8px 12px;
}

.login-card .form-control {
  border-color: #e2e8f0;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.login-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,168,225,0.15);
}

.btn-login {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-login:hover {
  background: var(--primary-dark);
  color: #fff;
}

.btn-login:active {
  background: #007bb5;
}

/* ===== FILE UPLOAD ROWS (modal de carga brechas) ===== */
.file-upload-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  margin-bottom: 0.35rem;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--bg-card);
}

.file-upload-row:hover {
  background: var(--bg-hover);
}

.file-upload-row.is-selected {
  border-left: 3px solid var(--success);
  background: rgba(139,197,63,0.04);
}

.file-upload-row__status {
  flex: 0 0 18px;
  font-size: 0.85rem;
  line-height: 1;
}

.file-upload-row.is-selected .file-upload-row__status {
  color: var(--success);
}

.file-upload-row:not(.is-selected) .file-upload-row__status {
  color: #cbd5e1;
}

.file-upload-row__label {
  flex: 0 0 auto;
  font-weight: 600;
  font-size: 0.75rem;
  color: #334155;
  white-space: nowrap;
}

.file-upload-row__file {
  flex: 1 1 auto;
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  padding: 0 0.25rem;
}

.file-upload-row.is-selected .file-upload-row__file {
  color: var(--success-dark);
  font-weight: 500;
}

.file-upload-row__actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.2rem;
}

.file-upload-row__actions .btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  border-radius: 4px;
}

/* ===== PANEL ESTADO CARGAS (CSC) ===== */
.csc-panel {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
}

.csc-panel--loading .csc-body {
  opacity: 0.45;
  pointer-events: none;
}

.csc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  background: #1e293b;
  color: #e2e8f0;
  gap: 0.5rem;
}

.csc-header__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #cbd5e1;
  white-space: nowrap;
}

.csc-header__period {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #94a3b8;
  font-size: 0.72rem;
}

.csc-btn-historial {
  font-size: 0.65rem;
  padding: 0.15rem 0.55rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: #cbd5e1;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.csc-btn-historial:hover {
  background: rgba(255,255,255,0.13);
  color: #fff;
}

.csc-body {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
}

.csc-col {
  padding: 0.5rem 0.8rem;
  border-right: 1px solid var(--border-light);
}

.csc-col:last-child {
  border-right: none;
  min-width: 155px;
}

.csc-col--gen      { border-top: 2px solid #E55302; }
.csc-col--regen    { border-top: 2px solid #0098AA; }
.csc-col--especial { border-top: 2px solid var(--primary); }

.csc-col__title {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-light);
}

.csc-col--gen .csc-col__title      { color: #E55302; }
.csc-col--regen .csc-col__title    { color: #0098AA; }
.csc-col--especial .csc-col__title { color: var(--primary); }

.csc-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.17rem 0;
  font-size: 0.72rem;
  line-height: 1.3;
}

.csc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.csc-dot--ok       { background: var(--success); }
.csc-dot--huerfano { background: var(--warning); }
.csc-dot--sin      { background: transparent; border: 1.5px solid #cbd5e1; }

.csc-item__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.csc-item--ok .csc-item__label       { color: #334155; }
.csc-item--huerfano .csc-item__label { color: #475569; }
.csc-item--sin .csc-item__label      { color: #94a3b8; }

.csc-item__val {
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.csc-item--ok .csc-item__val  { color: var(--success-dark); }
.csc-item--sin .csc-item__val { color: #cbd5e1; }

.csc-badge-vacio {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.08em 0.4em;
  border-radius: 3px;
  background: rgba(255,167,38,0.12);
  color: var(--warning-dark);
  border: 1px solid rgba(255,167,38,0.25);
  text-transform: uppercase;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .csc-body {
    grid-template-columns: 1fr 1fr;
  }
  .csc-col--especial {
    grid-column: 1 / -1;
    border-right: none;
    border-top: 1px solid var(--border-light);
  }
}

/* ===== PANEL KPI TERRENO CUATRIMESTRAL (TSC) ===== */
.tsc-panel {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
}

.tsc-panel--loading .tsc-body {
  opacity: 0.45;
  pointer-events: none;
}

.tsc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  background: #1e293b;
  color: #e2e8f0;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tsc-header__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #cbd5e1;
  white-space: nowrap;
}

.tsc-header__selectors {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tsc-select {
  font-size: 0.68rem;
  padding: 0.18rem 1.4rem 0.18rem 0.45rem;
  background: #2d3f55;
  border: 1px solid rgba(255,255,255,0.18);
  color: #e2e8f0;
  border-radius: 3px;
  cursor: pointer;
  appearance: auto;
}

.tsc-select:focus {
  outline: none;
  border-color: var(--primary);
}

.tsc-body {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
}

.tsc-col {
  padding: 0.5rem 0.8rem;
  border-right: 1px solid var(--border-light);
}

.tsc-col:last-child {
  border-right: none;
  min-width: 150px;
}

.tsc-col--periodica { border-top: 2px solid #10637F; }
.tsc-col--spot      { border-top: 2px solid #E97131; }
.tsc-col--resumen   { border-top: 2px solid var(--primary); }

.tsc-col__title {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-light);
}

.tsc-col--periodica .tsc-col__title { color: #10637F; }
.tsc-col--spot .tsc-col__title      { color: #E97131; }
.tsc-col--resumen .tsc-col__title   { color: var(--primary); }

/* Filas de mes */
.tsc-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.17rem 0;
  font-size: 0.72rem;
  line-height: 1.3;
}

.tsc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tsc-dot--ok       { background: var(--success); }
.tsc-dot--warning  { background: var(--warning); }
.tsc-dot--sin      { background: transparent; border: 1.5px solid #cbd5e1; }

.tsc-item__label {
  flex: 1;
  color: #334155;
  white-space: nowrap;
}

.tsc-item__val {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #475569;
}

.tsc-item__val--zero { color: #cbd5e1; }

/* Separador entre meses y filas especiales */
.tsc-separator {
  border-top: 1px solid var(--border-light);
  margin: 0.3rem 0;
}

/* Filas especiales: por_fiscalizar, total */
.tsc-item--special {
  font-size: 0.7rem;
}

.tsc-item--special .tsc-item__label {
  color: #64748b;
  font-weight: 500;
}

.tsc-item--warning .tsc-item__val  { color: var(--warning-dark); font-weight: 700; }
.tsc-item--success .tsc-item__val  { color: var(--success-dark); font-weight: 700; }
.tsc-item--total .tsc-item__label  { color: #334155; font-weight: 600; }
.tsc-item--total .tsc-item__val    { color: #1e293b; font-weight: 700; }

/* Columna resumen */
.tsc-resumen-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.22rem 0;
  font-size: 0.72rem;
  border-bottom: 1px solid #f1f5f9;
}

.tsc-resumen-item:last-child {
  border-bottom: none;
}

.tsc-resumen__label {
  color: #64748b;
  flex: 1;
}

.tsc-resumen__val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: #1e293b;
  min-width: 30px;
  text-align: right;
}

.tsc-resumen__val--success { color: var(--success-dark); }
.tsc-resumen__val--warning { color: var(--warning-dark); }
.tsc-resumen__val--muted   { color: #94a3b8; }

/* Badge sin programación cargada */
.tsc-no-data {
  text-align: center;
  padding: 0.6rem 0.5rem;
  font-size: 0.7rem;
  color: #94a3b8;
}

@media (max-width: 768px) {
  .tsc-body {
    grid-template-columns: 1fr 1fr;
  }
  .tsc-col--resumen {
    grid-column: 1 / -1;
    border-right: none;
    border-top: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }
  .tsc-col--resumen .tsc-col__title {
    grid-column: 1 / -1;
  }
}