@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* FlowBack Primary Palette */
  --cobalto: #1F6FB2;
  --cobalto-rgb: 31, 111, 178;
  --cobalto-dark: #144A77;
  --cobalto-light: #4A8BCA;
  --cobalto-bg: #E8F0FA;

  --amatista: #848AC4;
  --amatista-rgb: 132, 138, 196;
  --amatista-dark: #5E6283;
  --amatista-light: #B0B4D9;
  --amatista-bg: #F0F0FA;

  --naranja-energia: #E07B27;
  --naranja-rgb: 224, 123, 39;
  --naranja-dark: #B35E14;
  --naranja-light: #F2A15C;

  /* Neutrals */
  --negro-profundo: #2A292A;
  --gris-oscuro: #545656;
  --gris-medio: #DADADA;
  --gris-claro: #EDEDED;

  /* Semantic aliases */
  --primary-color: var(--cobalto);
  --primary-dark: var(--cobalto-dark);
  --secondary-color: var(--amatista);
  --accent-color: var(--naranja-energia);
  --sidebar-bg: var(--cobalto);
  --header-bg: #f8f9fa;
  --transition-speed: 0.3s;

  /* Bootstrap overrides */
  --bs-primary: #1F6FB2;
  --bs-primary-rgb: 31, 111, 178;
  --bs-primary-bg-subtle: #E8F0FA;
  --bs-primary-text-emphasis: #144A77;
  --bs-secondary: var(--amatista);
  --bs-secondary-rgb: 132, 138, 196;
}

/* =============================================
   BASE / TYPOGRAPHY
   ============================================= */

body {
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f0f2f5;
}

* {
  transition: background-color var(--transition-speed),
    border-color var(--transition-speed),
    color var(--transition-speed),
    box-shadow var(--transition-speed);
}

/* =============================================
   UTILITY CLASSES
   ============================================= */
.bg-cobalto { background-color: var(--cobalto) !important; }
.bg-cobalto-light { background-color: var(--cobalto-bg) !important; }
.bg-amatista { background-color: var(--amatista) !important; }
.bg-naranja { background-color: var(--naranja-energia) !important; }

.text-cobalto { color: var(--cobalto) !important; }
.text-amatista { color: var(--amatista) !important; }
.text-naranja { color: var(--naranja-energia) !important; }

.border-cobalto { border-color: var(--cobalto) !important; }
.border-amatista { border-color: var(--amatista) !important; }

.hover-bg-light:hover { background-color: #f0f0f0; }
.tracking-wide { letter-spacing: 0.05em; }
.cursor-pointer { cursor: pointer; }

/* =============================================
   LAYOUT
   ============================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: linear-gradient(180deg, #1F6FB2 0%, #144A77 100%);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
}

.sidebar .brand {
  padding: 0.9rem 1rem 0.5rem;
  text-align: center;
}

.sidebar .brand .logo-img {
  max-width: 195px;
  height: auto;
  margin-bottom: 0;
}

.sidebar .brand .brand-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff;
}

.sidebar .brand .brand-sub {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.15rem;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.8);
  padding: 0.42rem 1.25rem;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border-left-color: var(--naranja-energia);
}

.sidebar .nav-link i {
  margin-right: 10px;
  width: 20px;
  text-align: center;
}

.sidebar .sidebar-heading {
  padding: 0.85rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 600;
}

.main-content {
  margin-left: 250px;
  flex: 1;
  padding: 16px;
  height: 100vh;
  overflow-y: auto;
}

/* =============================================
   PAGE HEADER
   ============================================= */
.page-header {
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

[data-bs-theme="light"] .page-header,
:root:not([data-bs-theme="dark"]) .page-header {
  background: linear-gradient(135deg, #E8F0FA 0%, #F0F0FA 100%);
  border: 1px solid #D0D8E8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* =============================================
   CARDS
   ============================================= */
.card {
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  margin-bottom: 0.75rem;
  border: 1px solid #D0D8E8 !important;
}

[data-bs-theme="light"] .card,
:root:not([data-bs-theme="dark"]) .card {
  --bs-card-bg: #F8F9FD;
  background-color: #F8F9FD !important;
}

[data-bs-theme="dark"] .card {
  border: 1px solid #3a3f4a !important;
  --bs-card-bg: #2a2d35;
}

.card-header {
  background: white;
  border-bottom: 2px solid #e0e4ea;
  border-radius: 10px 10px 0 0 !important;
  padding: 0.7rem 1rem;
  font-weight: 600;
}

[data-bs-theme="dark"] .card-header {
  background: #2a2d35 !important;
  border-bottom-color: #3a3f4a !important;
}

/* =============================================
   STAT CARDS
   ============================================= */
.stat-card {
  border-radius: 8px;
  padding: 0.6rem 0.5rem;
  color: white;
  border: none !important;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.stat-card .stat-icon {
  font-size: 1.4rem;
  opacity: 0.25;
}

.stat-card .stat-number {
  font-size: 1.3rem;
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 0.65rem;
  opacity: 0.9;
  font-weight: 500;
}

/* Stat card color variants */
.stat-card.bg-cobalto-stat { background: linear-gradient(135deg, #1F6FB2, #4A8BCA) !important; }
.stat-card.bg-amatista-stat { background: linear-gradient(135deg, #5E6283, #848AC4) !important; }
.stat-card.bg-naranja-stat { background: linear-gradient(135deg, #B35E14, #E07B27) !important; }
.stat-card.bg-success-stat { background: linear-gradient(135deg, #2E7D32, #66BB6A) !important; }
.stat-card.bg-danger-stat { background: linear-gradient(135deg, #C62828, #EF5350) !important; }
.stat-card.bg-info-stat { background: linear-gradient(135deg, #1565C0, #42A5F5) !important; }

.stat-card.bg-proveedor-stat { background: linear-gradient(135deg, #455A64, #78909C) !important; }

/* =============================================
   TABLES
   ============================================= */
.table-container {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  border: 1px solid #D0D8E8;
}

[data-bs-theme="dark"] .table-container {
  background: #2a2d35;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border-color: #3a3f4a;
}

.table th {
  border-top: none;
  color: var(--cobalto);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

[data-bs-theme="dark"] .table th {
  color: var(--amatista-light);
}

.table td {
  vertical-align: middle;
  font-size: 0.85rem;
}

.table > :not(caption) > * > * {
  border-bottom-color: #D0D8E8;
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
  border-bottom-color: #3a3f4a;
}

.table-hover > tbody > tr:hover > * {
  background-color: rgba(31, 111, 178, 0.06);
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: rgba(132, 138, 196, 0.1);
}

.table-secondary {
  --bs-table-bg: #E8F0FA;
  --bs-table-color: #000;
}

[data-bs-theme="dark"] .table-secondary {
  --bs-table-bg: #2a2d35;
  --bs-table-color: #dee2e6;
}

/* =============================================
   FILTER PANEL
   ============================================= */
.filter-panel {
  background: linear-gradient(135deg, #E8F0FA, #F0F0FA);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid #D0D8E8;
}

[data-bs-theme="dark"] .filter-panel {
  background: #1a2744;
  border-color: #2d4a6a;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
  background: var(--cobalto);
  border-color: var(--cobalto);
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--cobalto-dark);
  border-color: var(--cobalto-dark);
}

.btn-primary:active,
.btn-primary:focus {
  background: var(--cobalto-dark) !important;
  border-color: var(--cobalto-dark) !important;
}

.btn-outline-primary {
  color: var(--cobalto);
  border-color: var(--cobalto);
}

.btn-outline-primary:hover {
  background: var(--cobalto);
  border-color: var(--cobalto);
  color: white;
}

.btn-accent {
  background: var(--naranja-energia);
  border-color: var(--naranja-energia);
  color: white;
  font-weight: 500;
}

.btn-accent:hover {
  background: var(--naranja-dark);
  border-color: var(--naranja-dark);
  color: white;
}

.btn-outline-accent {
  color: var(--naranja-energia);
  border-color: var(--naranja-energia);
}

.btn-outline-accent:hover {
  background: var(--naranja-energia);
  border-color: var(--naranja-energia);
  color: white;
}

/* =============================================
   THEME TOGGLE BUTTON
   ============================================= */
.theme-toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.theme-toggle-btn i {
  font-size: 1.1rem;
}

/* =============================================
   STATUS BADGES
   ============================================= */
.badge-estado {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 50px;
}

.estado-badge {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
}

/* Fondo celeste: texto oscuro para legibilidad en cualquier modo */
.bg-info {
  color: #212529 !important;
}

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
  background: linear-gradient(135deg, #1F6FB2 0%, #848AC4 50%, #5E6283 100%);
  min-height: 100vh;
}

.login-card {
  border-radius: 15px;
  border: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.login-card .card-body {
  padding: 2.5rem;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.75rem;
}

.login-logo img {
  max-width: 92%;
  height: auto;
}

[data-bs-theme="dark"] .login-page {
  background: linear-gradient(135deg, #144A77 0%, #5E6283 50%, #2A292A 100%);
}

/* =============================================
   ALERTS
   ============================================= */
.alert {
  border: none;
  border-radius: 10px;
}

/* =============================================
   PAGINATION
   ============================================= */
.pagination {
  margin-bottom: 0;
}

.page-link {
  color: var(--cobalto);
  border-radius: 8px !important;
  margin: 0 2px;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.page-item.active .page-link {
  background: var(--cobalto);
  border-color: var(--cobalto);
}

[data-bs-theme="dark"] .page-link {
  color: var(--amatista-light);
}

[data-bs-theme="dark"] .page-item.active .page-link {
  background: var(--cobalto-dark);
  border-color: var(--cobalto-dark);
  color: white;
}

/* =============================================
   FORMS
   ============================================= */
[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
  border-color: #B9C4D4;
  background-color: #FBFCFE;
}

[data-bs-theme="light"] .form-control:hover:not(:focus),
[data-bs-theme="light"] .form-select:hover:not(:focus) {
  border-color: #93A1B8;
}

[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
  border-color: var(--cobalto);
  background-color: #fff;
  box-shadow: 0 0 0 0.2rem rgba(31, 111, 178, 0.15);
}

[data-bs-theme="light"] .form-control:disabled,
[data-bs-theme="light"] .form-select:disabled {
  background-color: #EDEDED;
  border-color: #D0D8E8;
}

[data-bs-theme="light"] .form-check-input {
  border-color: #B9C4D4;
}

[data-bs-theme="light"] .input-group-text {
  border-color: #B9C4D4;
  background-color: #E8F0FA;
  color: var(--cobalto-dark);
}

[data-bs-theme="light"] .form-label {
  color: #3D4753;
  font-weight: 500;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #23262d;
  border-color: #4A5260;
  color: #dee2e6;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #2a2d35;
  border-color: var(--amatista-light);
  box-shadow: 0 0 0 0.2rem rgba(132, 138, 196, 0.2);
}

[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .form-check-label {
  color: #E9EDF3 !important;
  font-weight: 400 !important;
}

/* =============================================
   OBSERVATIONS
   ============================================= */
.obs-item {
  background-color: #f8f9fa;
}
.obs-text {
  color: #212529;
}
.obs-meta {
  color: #6c757d;
}
.obs-badge {
  background-color: #0dcaf0;
  color: #000;
  font-size: 0.75rem;
}
[data-bs-theme="dark"] .obs-item {
  background-color: #2a2d35 !important;
}
[data-bs-theme="dark"] .obs-text {
  color: #dee2e6;
}
[data-bs-theme="dark"] .obs-meta {
  color: #adb5bd;
}
[data-bs-theme="dark"] .obs-badge {
  background-color: #0b6e7a !important;
  color: #dee2e6;
}

.obs-table td {
  border: none;
  padding: 0.25rem 0;
}
[data-bs-theme="dark"] .obs-table {
  color: #dee2e6;
}
[data-bs-theme="dark"] .obs-table .obs-badge {
  background-color: #0b6e7a !important;
  color: #dee2e6;
}

/* =============================================
   TIMELINE
   ============================================= */
.timeline .rounded-circle {
  flex-shrink: 0;
}

.timeline-item {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--cobalto);
  background-color: #f8f9fa;
  border-radius: 4px;
}

[data-bs-theme="dark"] .timeline-item {
  background-color: #2a2d35;
}

/* =============================================
   STATUS BADGES (máquina de estados)
   ============================================= */
.status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-autorizado_pendiente_or { background-color: #6f42c1 !important; color: #fff !important; }
.status-or_generada_pendiente_despacho { background-color: #0dcaf0 !important; color: #000 !important; }
.status-no_viaja { background-color: #dc3545 !important; color: #fff !important; }
.status-en_transito { background-color: #ffc107 !important; color: #000 !important; }
.status-ingresado_cd { background-color: #fd7e14 !important; color: #fff !important; }
.status-recepcionado_postventa { background-color: #198754 !important; color: #fff !important; }
.status-gestion_proveedor { background-color: #6c757d !important; color: #fff !important; }

/* =============================================
   DETAIL TABLE
   ============================================= */
.detail-table th {
  width: 40%;
  color: #6c757d;
  font-weight: 500;
  font-size: 0.85rem;
}

[data-bs-theme="dark"] .detail-table {
  color: #dee2e6;
}

[data-bs-theme="dark"] .detail-table th {
  color: #adb5bd;
}

/* =============================================
   DARK MODE OVERRIDES
   ============================================= */
[data-bs-theme="dark"] body {
  background-color: #1a1d21;
}

[data-bs-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #144A77 0%, #0A2A4A 100%);
}

[data-bs-theme="dark"] .sidebar .theme-toggle-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .sidebar .theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

[data-bs-theme="dark"] .main-content {
  background-color: #1a1d21;
}

[data-bs-theme="dark"] .page-header {
  background: #2a2d35 !important;
  border: 1px solid #3a3f4a !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .filter-panel {
  background: #1a2744;
  border-color: #2d4a6a;
}

[data-bs-theme="dark"] .stat-card.bg-cobalto-stat { background: linear-gradient(135deg, #144A77, #1F6FB2) !important; }
[data-bs-theme="dark"] .stat-card.bg-amatista-stat { background: linear-gradient(135deg, #3A3D5E, #5E6283) !important; }
[data-bs-theme="dark"] .stat-card.bg-naranja-stat { background: linear-gradient(135deg, #8A2D00, #B35E14) !important; }
[data-bs-theme="dark"] .stat-card.bg-success-stat { background: linear-gradient(135deg, #1B5E20, #2E7D32) !important; }
[data-bs-theme="dark"] .stat-card.bg-danger-stat { background: linear-gradient(135deg, #7F1D1D, #C62828) !important; }
[data-bs-theme="dark"] .stat-card.bg-info-stat { background: linear-gradient(135deg, #0D47A1, #1565C0) !important; }

[data-bs-theme="dark"] .stat-card.bg-proveedor-stat { background: linear-gradient(135deg, #37474F, #455A64) !important; }

/* =============================================
   NAV TABS
   ============================================= */
.nav-tabs .nav-link {
  border: 1px solid var(--bs-border-color);
  border-bottom: none;
  background: var(--cobalto-bg);
  color: var(--cobalto);
  margin-right: 2px;
  border-radius: 6px 6px 0 0;
  font-weight: 500;
  padding: 0.5rem 1rem;
}

.nav-tabs .nav-link:hover {
  background: #D0E0F0;
  border-color: var(--bs-border-color);
}

.nav-tabs .nav-link.active {
  background: var(--cobalto);
  border-color: var(--cobalto) var(--cobalto) transparent;
  color: #fff;
  font-weight: 600;
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
  border-color: #444;
  background: #1a2744;
  color: var(--amatista-light);
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
  background: #2a3a5e;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  background: var(--cobalto-dark);
  border-color: var(--cobalto-dark) var(--cobalto-dark) transparent;
  color: #fff;
}

/* =============================================
   PRINT STYLES
   ============================================= */
@media print {
  .sidebar,
  .no-print {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
  }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .main-content {
    margin-left: 0;
  }
}

/* =============================================
   MISC
   ============================================= */
.bg-entrenamiento {
  background-color: #E67E22 !important;
  color: #fff !important;
}

/* =============================================
   LAYOUT A MEDIDA (diseño nuevo: azul marino)
   Se activa cuando <body data-layout="a-medida">
   ============================================= */
body[data-layout="a-medida"] {
  background-color: #E9Eef4;
}

/* Header superior full-width */
.medida-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(90deg, #0E2E53 0%, #14406B 55%, #0E2E53 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  z-index: 1200;
  box-shadow: 0 2px 10px rgba(4, 14, 28, 0.45);
}

.medida-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 250px;
}

.medida-brand img {
  height: 42px;
  width: auto;
}

.medida-brand-text {
  line-height: 1.15;
}

.medida-brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
}

.medida-brand-sub {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

/* Búsqueda central */
.medida-search {
  flex: 1;
  max-width: 520px;
  margin: 0 3.5rem 0 auto;
}

.medida-search form {
  position: relative;
  display: flex;
  align-items: center;
}

.medida-search input {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1rem 0.45rem 2.5rem;
  background: #fff;
  color: #14324f;
  font-size: 0.85rem;
  box-shadow: 0 2px 4px rgba(4, 14, 28, 0.18);
}

.medida-search input::placeholder {
  color: #7d93a8;
}

.medida-search input:focus {
  outline: 2px solid #ffd400;
  outline-offset: 1px;
}

.medida-search .medida-search-icon {
  position: absolute;
  left: 0.9rem;
  color: #42668c;
  font-size: 0.9rem;
  pointer-events: none;
}

/* Botón de notificaciones (campanita amarilla) */
.medida-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.medida-bell {
  position: relative;
  background: transparent;
  border: none;
  color: #ffd400;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.medida-bell:hover {
  transform: scale(1.08);
}

.medida-bell:hover {
  color: #ffe75e;
}

.medida-bell-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff3b30;
  border: 1.5px solid #0E2E53;
}

/* Bloque de usuario */
.medida-user {
  text-align: left;
  line-height: 1.15;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  padding-left: 1rem;
}

.medida-user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #40c8ff;
}

.medida-user-rol {
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.78);
}

/* Sidebar y contenido: arrancan por debajo del header */
body[data-layout="a-medida"] .app-layout {
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}

body[data-layout="a-medida"] .sidebar {
  top: 60px;
  height: calc(100vh - 60px);
  background: linear-gradient(180deg, #0E2E53 0%, #081C33 100%);
}

body[data-layout="a-medida"] .sidebar .nav-link.active {
  background: #0d6efd;
  border-left-color: #0d6efd;
  color: #fff;
}

body[data-layout="a-medida"] .sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: #ffd400;
}

body[data-layout="a-medida"] .main-content {
  margin-left: 250px;
  height: calc(100vh - 60px);
}

body[data-layout="a-medida"] .main-content:has(.screen-fit) {
  overflow: hidden;
}

body[data-layout="a-medida"] .main-content .screen-fit {
  height: calc(100vh - 60px - 32px);
  overflow: hidden;
}

/* Dropdown de notificaciones sobre el header */
.medida-bell + .dropdown-menu {
  box-shadow: 0 8px 24px rgba(4, 14, 28, 0.25);
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
}

@media (max-width: 992px) {
  body[data-layout="a-medida"] .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    top: 0;
  }
  body[data-layout="a-medida"] .app-layout {
    margin-top: 60px;
    display: block;
  }
  body[data-layout="a-medida"] .main-content {
    margin-left: 0;
    height: auto;
  }
  .medida-search {
    display: none;
  }
}

@media (max-width: 576px) {
  .medida-user {
    display: none;
  }
}

/* =============================================
   DASHBOARD NUEVO — cards blancas (3 arriba / 3 abajo)
   ============================================= */
.dash-card {
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(20, 40, 70, 0.06);
  padding: 1rem 1.1rem;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dash-card-val {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--cobalto);
}

.dash-card-val.val-cobalto { color: #1F6FB2; }
.dash-card-val.val-verde { color: #1e9e50; }
.dash-card-val.val-naranja { color: #E07B27; }
.dash-card-val.val-violeta { color: #6f74c9; }
.dash-card-val.val-rojo { color: #d93b3b; }

.dash-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #33475c;
  margin-top: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard-nota {
  font-size: 0.72rem;
  color: #7c8b99;
  font-style: italic;
  margin: 0 0 0.5rem;
}

.dash-card-delta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.dash-card-delta .tri-up {
  font-size: 1rem;
  line-height: 1;
}

.dash-card-delta .tri-down {
  font-size: 0.65rem;
  line-height: 1;
}

.dash-card-delta.up {
  color: #1e9e50;
}

.dash-card-delta.down {
  color: #d93b3b;
}

/* Card del gráfico de evolución */
.dash-chart-card {
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(20, 40, 70, 0.06);
  padding: 1rem 1.1rem 1.1rem;
}

.dash-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.dash-chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: #14324f;
  margin: 0;
}

.dash-chart-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #33475c;
}

.dash-chart-legend span {
  display: inline-flex;
  align-items: center;
}

.dash-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 0.35rem;
}

.dash-dot-dark {
  background: #144A77;
}

.dash-dot-light {
  background: #6FB0E6;
}

.dash-chart-body {
  position: relative;
  height: 300px;
}

/* =============================================
   DARK MODE — layout a medida + dashboard nuevo
   ============================================= */
[data-bs-theme="dark"] body[data-layout="a-medida"] {
  background-color: #1a1d21;
}

[data-bs-theme="dark"] body[data-layout="a-medida"] .main-content {
  background-color: #1a1d21;
}

[data-bs-theme="dark"] .dash-card,
[data-bs-theme="dark"] .dash-chart-card {
  background: #2a2d35;
  border-color: #3a3f4a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .dash-card-label,
[data-bs-theme="dark"] .dash-chart-legend,
[data-bs-theme="dark"] .dash-card-delta {
  color: #c6d0dc;
}

[data-bs-theme="dark"] .dash-chart-title {
  color: #eef3f9;
}

[data-bs-theme="dark"] .dashboard-nota {
  color: #9aa7b5;
}

/* =============================================
   PANTALLA COMPLETA SIN SCROLL (bandejas)
   ============================================= */
.screen-fit {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.screen-fit .table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid #D0D8E8;
  border-radius: 10px;
  background: var(--bs-body-bg);
}
.screen-fit .table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.screen-fit .sticky-footer {
  border-top: 1px solid #D0D8E8;
  padding-top: 0.6rem;
}
.screen-fit .filter-label {
  height: 20px;
  line-height: 20px;
  font-size: 0.72rem;
  color: var(--bs-secondary-color, #6c757d);
  white-space: nowrap;
  overflow: hidden;
}
[data-bs-theme="dark"] .screen-fit .table-scroll {
  border-color: #3a3f4a;
}
[data-bs-theme="dark"] .screen-fit .sticky-footer {
  border-top-color: #3a3f4a;
}
[data-bs-theme="dark"] .screen-fit .filter-label {
  color: #9aa7b5;
}

/* =============================================
   ETIQUETADO - vista previa y formatos
   ============================================= */
.preview-etiqueta {
  width: 100%;
  max-width: 320px;
  transition: width 0.2s ease;
}
.preview-etiqueta.reducida {
  width: 62%;
}
.preview-etiqueta.barras {
  width: 48%;
}
.etq-seccion-titulo {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--bs-secondary-color, #6c757d);
  margin-bottom: 0.45rem;
}
.preview-lamina svg {
  display: block;
}
[data-bs-theme="dark"] .preview-lamina {
  background: #fff !important;
}

/* =============================================
   INGRESO CDR
   ============================================= */
.cdr-scan {
  background: linear-gradient(135deg, #E8F0FA, #F0F0FA);
  border: 1px dashed #1F6FB2;
  border-radius: 12px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem 1.4rem;
}
[data-bs-theme="dark"] .cdr-scan {
  background: #1a2744;
  border-color: #2d6ca8;
}
.cdr-scan-icon {
  width: 64px;
  height: 64px;
  background: rgba(31, 111, 178, 0.12);
  color: #1F6FB2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 0.7rem;
}
.cdr-scan-titulo {
  color: #0d4f8a;
  font-weight: 800;
  font-size: 1.1rem;
}
[data-bs-theme="dark"] .cdr-scan-titulo {
  color: #9cc6ee;
}
.cdr-scan-sub {
  color: #7c8b99;
  font-size: 0.82rem;
}
.cdr-scan-input {
  max-width: 300px;
}
.cdr-kpi {
  min-height: 0;
  height: 200px;
  padding: 1rem 0.9rem;
  flex: 1;
  justify-content: center;
}
.cdr-kpi .dash-card-val {
  font-size: 2.4rem;
}
.cdr-kpi .dash-card-label {
  font-size: 0.9rem;
  margin-top: 0.2rem;
}
.cdr-kpi .dash-card-delta {
  font-size: 0.95rem;
}
.cdr-kpi-sub {
  color: #1F6FB2;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

/* Pie fijo con las 3 cards (escaneo + KPIs) */
[data-pantalla-ingreso-cdr] {
  position: relative;
}
.cdr-contenido {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 232px;
}
.cdr-pie-fijo {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: #ffffff;
  border-top: 1px solid #d8dee8;
  z-index: 5;
}
[data-bs-theme="dark"] .cdr-pie-fijo {
  background: #1a1d21;
  border-top-color: #3a3f4a;
}
.cdr-pie-fijo .cdr-scan,
.cdr-pie-fijo .cdr-pie-minis {
  flex: 1;
}
.cdr-pie-minis {
  display: flex;
  gap: 0.6rem;
}

/* =============================================
   GESTIÓN PROVEEDOR — bloques de tabla screen-fit
   ============================================= */
.gp-bloque {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.gp-bloque + .gp-bloque {
  margin-top: 0.6rem;
}
.gp-bloque .table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.tabla-titulo {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--bs-secondary-color, #6c757d);
  margin-bottom: 0.4rem;
}

/* =============================================
   REPORTES — cards de informes estándar
   ============================================= */
.repo-card,
.cfg-card {
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(20, 40, 70, 0.06);
  padding: 1rem 1.1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 170px;
}
[data-bs-theme="dark"] .repo-card,
[data-bs-theme="dark"] .cfg-card {
  background: #2a2d35;
  border-color: #3a3f4a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.repo-card-titulo {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--bs-heading-color, #1d2733);
}
[data-bs-theme="dark"] .repo-card-titulo {
  color: #eef3f9;
}
.repo-card-sub {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7c8b99;
  margin-top: 0.25rem;
}
[data-bs-theme="dark"] .repo-card-sub {
  color: #9aa7b5;
}
.repo-card-cuerpo {
  margin-top: auto;
  padding-top: 0.9rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
}
.repo-card-icono {
  width: 84px;
  height: 64px;
  color: #1F6FB2;
}
.repo-card-icono svg {
  width: 100%;
  height: 100%;
}

/* Configuración — contenido de pestañas */
.cfg-contenido {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.repo-titulo-seccion {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--bs-heading-color, #1d2733);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0.6rem 0 0.5rem;
}
.repo-grafico-card {
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(20, 40, 70, 0.06);
  padding: 0.9rem 1rem;
  height: 100%;
}
[data-bs-theme="dark"] .repo-grafico-card {
  background: #2a2d35;
  border-color: #3a3f4a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.repo-grafico-card .repo-card-titulo {
  margin-bottom: 0.5rem;
}
.repo-chart-wrap {
  position: relative;
  height: 240px;
}

/* Versión compacta: todo en una pantalla, sin scroll */
/* Pestaña de gráficos e indicadores: flujo normal con scroll y gráficos de buen tamaño */
.reporte-graficos-fit .filter-panel {
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
}
.reporte-graficos-fit .repo-titulo-seccion {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.9rem;
}
.reporte-graficos-fit .repo-indicadores {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.3rem;
}
.reporte-graficos-fit .repo-indicadores .stat-card {
  padding: 0.4rem 0.2rem;
}
.reporte-graficos-fit .repo-indicadores .stat-card .stat-number {
  font-size: 1.05rem;
}
.reporte-graficos-fit .repo-indicadores .stat-card .stat-label {
  font-size: 0.58rem;
}
.reporte-graficos-fit .repo-graficos-charts {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.25rem;
}
.reporte-graficos-fit .repo-grafico-card {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
}
.reporte-graficos-fit .repo-grafico-card .repo-card-titulo {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.reporte-graficos-fit .repo-chart-wrap {
  position: relative;
}
.reporte-graficos-fit .repo-graficos-fila-grande .repo-chart-wrap {
  height: 320px;
}
.reporte-graficos-fit .repo-graficos-fila-chica .repo-chart-wrap {
  height: 280px;
}
.reporte-graficos-fit .repo-chart-wrap canvas {
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.18));
}
@media (max-width: 1199.98px) {
  .reporte-graficos-fit .repo-indicadores {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* ===== Botón de chat (Mensajería interna) ===== */
.medida-chat {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: 50%;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.medida-chat:hover {
  transform: scale(1.08);
}
.medida-chat-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--bs-body-bg);
  pointer-events: none;
}

/* ===== Pantalla de Mensajería ===== */
.chat-pantalla {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 1rem;
}
.chat-lista {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 12px;
  overflow: hidden;
}
.chat-buscador {
  position: relative;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.chat-buscador input {
  width: 100%;
  padding-left: 1.8rem;
}
.chat-buscador-icon {
  position: absolute;
  left: 1.05rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}
.chat-listado {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.chat-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--bs-border-color);
  text-decoration: none;
  color: var(--bs-body-color);
  background: transparent;
  transition: background 0.12s ease;
}
.chat-item:last-child {
  border-bottom: none;
}
.chat-item:hover {
  background: rgba(var(--bs-primary-rgb, 31, 111, 178), 0.07);
}
.chat-item.active {
  background: rgba(var(--bs-primary-rgb, 31, 111, 178), 0.18);
}
.chat-item.active:hover {
  background: rgba(var(--bs-primary-rgb, 31, 111, 178), 0.24);
}
.chat-item-cuerpo {
  flex: 1;
  min-width: 0;
  line-height: 1.28;
}
.chat-item-nombre {
  font-weight: 600;
}
.chat-item-rol {
  font-size: 0.76rem;
  color: var(--bs-secondary-color);
}
.chat-item-ultimo {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.chat-item-ultimo.no-leido {
  color: var(--bs-primary);
  font-weight: 600;
}
.chat-item-fecha {
  font-size: 0.72rem;
  color: var(--bs-secondary-color);
  white-space: nowrap;
}
.chat-badge-sm {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  pointer-events: none;
}
.chat-thread {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 12px;
  overflow: hidden;
}
.chat-thread-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.chat-mensajes {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.chat-fecha-sep {
  align-self: center;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  background: var(--bs-body-bg);
  padding: 0.25rem 0.75rem;
  border-radius: 10px;
  margin: 0.5rem 0;
}
.burbuja {
  max-width: 75%;
  padding: 0.5rem 0.8rem;
  border-radius: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.burbuja.propia {
  align-self: flex-end;
  background: linear-gradient(135deg, #1f6fb2 0%, #195a90 100%);
  color: #f1f3f5;
  border-bottom-right-radius: 4px;
}
.burbuja.ajena {
  align-self: flex-start;
  background: var(--bs-secondary-bg, #e9ecef);
  color: var(--bs-body-color);
  border-bottom-left-radius: 4px;
}
.burbuja-texto {
  margin-bottom: 0.2rem;
}
.burbuja-hora {
  font-size: 0.68rem;
  opacity: 0.7;
  text-align: right;
}
.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 0.8rem;
  border-top: 1px solid var(--bs-border-color);
  align-items: flex-end;
}
.chat-input textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
}
.btn-chat-enviar {
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chat-vacio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--bs-secondary-color);
}

/* ===== Modal "Nuevo mensaje" (posicionado más abajo y centrado) ===== */
#modal-nuevo-chat .modal-dialog {
  max-width: 460px;
  margin-top: 14vh;
  margin-left: auto;
  margin-right: auto;
}
#modal-nuevo-chat .modal-content {
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}
#modal-nuevo-chat .modal-title i {
  color: #25d366;
}

/* Impresión del informe de gráficos e indicadores */
@media print {
  body * {
    visibility: hidden;
  }
  #reporte-print,
  #reporte-print * {
    visibility: visible;
  }
  #reporte-print {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 0;
  }
  .filter-panel,
  .repo-grafico-card,
  .stat-card {
    break-inside: avoid;
  }
}