/* ============================================================
   Central de Producción — Custom Styles
   ============================================================ */

:root {
  /* ── Layout ─────────────────────────────────────────────── */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 56px;

  /* ── Colores marca ──────────────────────────────────────── */
  --color-primary: #164281;        /* alineado con MOVI */
  --color-primary-light: #2451a3;
  --color-accent: #F4831F;
  --color-accent-dark: #d4700f;
  --color-success: #198754;
  --color-danger: #dc3545;
  --color-warning: #b8860b;        /* dorado — centralizado aquí */
  --color-info: #0d6efd;

  /* ── Superficies ────────────────────────────────────────── */
  --color-bg: #f0f2f5;
  --color-card: #ffffff;
  --color-text: #212529;
  --color-text-muted: #5a6370;

  /* ── Bandas (evitar colores hardcoded en templates) ─────── */
  --color-band-gold:   #b8860b;
  --color-band-silver: #6c757d;
  --color-band-bronze: #a05a2c;

  /* ── Tipografía ─────────────────────────────────────────── */
  --font-xs:  0.70rem;
  --font-xxs: 0.65rem;
  --font-weight-normal:   400;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;

  /* ── Motion & Shape ─────────────────────────────────────── */
  --transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --radius-card: 16px;
  --radius-btn: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-card-hover: 0 8px 25px -5px rgba(0,0,0,0.08), 0 4px 10px -3px rgba(0,0,0,0.04);
}

/* ── Reset & Base ──────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  overflow-x: hidden;
}

/* ── Modo embebido (iframe dentro de MOVI) ─────────────────── */
body.embedded #sidebar,
body.embedded #topbar {
  display: none !important;
}
/* La copia flotante de "Última actualización" (fuera del topbar) es al
   revés: oculta en modo normal (ahí ya se ve la del topbar) y visible
   solo embebido, como una píldora fija en la esquina. */
.ult-act-floating {
  display: none;
}
body.embedded .ult-act-floating {
  display: block;
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 1000;
}
body.embedded .ult-act-floating .ult-act-label {
  background: #fff;
  border-color: var(--color-border, #e2e8f0);
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
body.embedded #main-wrapper {
  margin-left: 0 !important;
  padding-top: 0 !important;
}
body.embedded .hscroll-fixed {
  left: 0 !important;
}
body.embedded .messages-container {
  top: 12px;
}
body.embedded #content {
  padding: 12px 16px;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--color-primary);
  transition: width var(--transition);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: var(--topbar-height);
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--color-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 900;
  font-size: .9rem;
}

.sidebar-logo-text { opacity: 1; transition: opacity var(--transition); }
#sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

/* Nav Links */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.sidebar-nav a,
.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .875rem;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
}

.sidebar-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav a.active {
  /* El acento del tema (#2196f3) con texto blanco da 3.1:1; oscurecido 30 % pasa de 4.5:1 */
  background: color-mix(in srgb, var(--color-accent) 70%, #000);
  color: #fff; font-weight: 600;
}

.sidebar-nav a i { font-size: 1.1rem; flex-shrink: 0; min-width: 20px; }

.sidebar-nav-text { transition: opacity var(--transition); }
#sidebar.collapsed .sidebar-nav-text { opacity: 0; width: 0; }

.sidebar-section-header {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.65); /* was .4 → ratio ~2.0:1 insuf.; .65 → ~3.7:1, adecuado para texto decorativo pequeño */
  padding: 16px 18px 4px;
  cursor: default;
}
#sidebar.collapsed .sidebar-section-header { opacity: 0; }

.sidebar-divider {
  border-color: rgba(255,255,255,.1);
  margin: 6px 12px;
}

/* ── Topbar ────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1020;
  transition: left var(--transition);
  gap: 12px;
}

#sidebar.collapsed ~ #main-wrapper #topbar,
#sidebar.collapsed ~ #topbar {
  left: var(--sidebar-collapsed-width);
}

#toggle-sidebar {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
  flex-shrink: 0;
}
#toggle-sidebar:hover { background: var(--color-bg); }

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
}

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

/* ── Main Content ──────────────────────────────────────────── */
#main-wrapper {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  transition: margin-left var(--transition);
}

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

#content {
  padding: 24px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* ── Buttons ─────────────────────────────────────────────────
   Override Bootstrap's default border-radius */
.btn { border-radius: var(--radius-btn) !important; }

.card-header {
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: transparent;
  padding: 16px 20px;
  font-weight: 600;
}

/* KPI Cards */
.kpi-card {
  border-radius: var(--radius-card);
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.kpi-card .kpi-icon {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 2.6rem;
  opacity: .12;      /* marca de agua: no debe competir con el monto */
  z-index: 0;
  pointer-events: none;
}
.kpi-card .kpi-label, .kpi-card .kpi-value, .kpi-card .kpi-yoy { position: relative; z-index: 1; }
.kpi-card .kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}
.kpi-card .kpi-label {
  font-size: .8rem;
  color: rgba(255,255,255,.95); /* was opacity:.85 — on lighter grads (#6c757d,#495057) that could fail 4.5:1 */
  text-transform: uppercase;
  letter-spacing: .06em;
}
.kpi-yoy {
  font-size: .72rem;
  font-weight: 600;
  margin-top: .3rem;
}
/* Bright enough to pass on all KPI card gradients including kpi-secondary (#6c757d→#495057) */
.kpi-yoy-up   { color: #c8fce0; } /* was #a8f0c6 — brighter for sufficient contrast on mid-gray bg */
.kpi-yoy-down { color: #ffd0d0; } /* was #ffb3b3 — brighter for sufficient contrast on mid-gray bg */
.kpi-yoy-label {
  font-weight: 400;
  color: rgba(255,255,255,.88); /* was opacity:.75 — fails on lighter gradient backgrounds */
  margin-left: .15rem;
}

.kpi-blue      { background: linear-gradient(135deg, #164281, #2451a3); }
.kpi-orange    { background: linear-gradient(135deg, #F4831F, #e06000); }
.kpi-green     { background: linear-gradient(135deg, #198754, #0f5c38); }
.kpi-teal      { background: linear-gradient(135deg, #0d6efd, #0a58ca); }
.kpi-secondary { background: linear-gradient(135deg, #6c757d, #495057); }

/* ── Tables ────────────────────────────────────────────────── */
.table-responsive-fixed {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 280px);
}

/* Scrollbar horizontal fija al fondo de la ventana */
.hscroll-fixed {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 12px;
  background: #e9ecef;
  z-index: 1010;
  overflow-x: auto;
  overflow-y: hidden;
  transition: left var(--transition);
}
#sidebar.collapsed ~ #main-wrapper .hscroll-fixed,
#sidebar.collapsed ~ .hscroll-fixed {
  left: var(--sidebar-collapsed-width);
}
.hscroll-inner { height: 1px; }

.table { font-size: .83rem; }
.table thead th {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
  padding: 10px 12px;
}
.table tbody tr:hover { background: rgba(22,66,129,.04); }
.table td { vertical-align: middle; padding: 8px 12px; }

/* ── Badges / Tags ─────────────────────────────────────────── */
.badge-convenio    { background: #d4edda; color: #155724; }
.badge-no-convenio { background: #f8d7da; color: #721c24; }

/* ── Catalog Cards (home) ──────────────────────────────────── */
.catalog-card {
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  border-radius: 12px;
  border: 1px solid #e9ecef;
}
.catalog-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.catalog-card .catalog-icon {
  width: 48px; height: 48px;
  background: rgba(22,66,129,.08);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  color: var(--color-primary);
}

/* ── Progress Bars ─────────────────────────────────────────── */
.progress {
  height: 8px;
  border-radius: 4px;
}
.progress-bar-custom {
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

/* ── Filters Bar ───────────────────────────────────────────── */
.filters-bar {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: 20px;
  position: sticky;
  top: var(--topbar-height);
  z-index: 100;
}
.filters-bar .form-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #4A546A; /* darkened from #6c757d for WCAG AA at small uppercase text */
  margin-bottom: 4px;
}
.filters-bar .form-select, .filters-bar .form-control {
  font-size: .83rem;
}

/* ── Page Title ────────────────────────────────────────────── */
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 20px;
}
.page-title .breadcrumb {
  font-size: .8rem;
  font-weight: 400;
  color: #4b5563;  /* 7:1 sobre el fondo gris claro (antes 4.3:1) */
}

/* ── Button colors ─────────────────────────────────────────── */
.btn-primary   { background: var(--color-primary); border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-light); border-color: var(--color-primary-light); }
.btn-accent    { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-dark); color: #fff; }

/* ── Login Page ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-primary) 0%, #2451a3 50%, #1a2a4a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
  padding: 40px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--color-accent);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  font-weight: 900;
  margin: 0 auto 20px;
}

/* ── Alerts & Messages ─────────────────────────────────────── */
.messages-container {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 20px;
  z-index: 1050;
  min-width: 300px;
  max-width: 420px;
}

/* ── TomSelect en barra de filtros ────────────────────────── */
.ts-wrap .ts-control {
  font-size: .83rem !important;
  min-height: 31px !important;
  padding: 2px 6px !important;
  border-radius: 6px !important;
  border-color: #dee2e6 !important;
}
.ts-wrap .ts-control input { font-size: .83rem !important; }
.ts-wrap .ts-control .item {
  font-size: .75rem;
  padding: 1px 4px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 4px;
  margin: 1px 2px 1px 0;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ts-wrap .ts-control .item .remove {
  color: rgba(255,255,255,.8) !important;
  border-left: 1px solid rgba(255,255,255,.3) !important;
  margin-left: 3px !important;
  padding-left: 3px !important;
}
.ts-dropdown { font-size: .83rem !important; z-index: 1060 !important; }
.form-label-xs {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #4A546A; /* darkened from #6c757d for WCAG AA compliance at small font size */
  margin-bottom: 2px;
  display: block;
}
.ts-dropdown .option { padding: 5px 10px; }
.ts-dropdown .option.active { background: rgba(22,66,129,.1); color: var(--color-primary); }
.ts-dropdown .option.selected { background: var(--color-primary); color: #fff; }

/* ── Excel-style filter dropdown ──────────────────────────── */
.ef-wrap { position: relative; display: inline-block; }

.ef-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 4px 26px 4px 10px;
  cursor: pointer;
  min-width: 96px;
  max-width: 165px;
  position: relative;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.3;
}
.ef-btn:hover { border-color: #adb5bd; }
.ef-btn.active { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(22,66,129,.15); }
.ef-btn.ef-locked { background: #f8f9fa; border-color: #dee2e6; cursor: not-allowed; opacity: .75; }
.ef-btn.ef-locked .ef-btn-value { color: #4A546A; }
.ef-btn.ef-locked .ef-btn-arrow { display: none; }

.ef-btn-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #4A546A; /* darkened from #6c757d for WCAG AA compliance at small font size */
  white-space: nowrap;
  pointer-events: none;
}
.ef-btn-value {
  font-size: .78rem;
  color: #495057;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  pointer-events: none;
}
.ef-btn-value.has-selection { color: var(--color-primary); font-weight: 600; }
.ef-btn-arrow {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .6rem;
  color: #4A546A;
  pointer-events: none;
}

.ef-panel {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 1070;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  box-shadow: 0 6px 28px rgba(0,0,0,.18);
  min-width: 230px;
  max-width: 300px;
}
.ef-panel-header {
  padding: 8px 12px 6px;
  border-bottom: 1px solid #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ef-panel-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--color-primary);
}
.ef-panel-count { font-size: .72rem; color: #4A546A; } /* darkened from #6c757d for WCAG AA at small size */

.ef-search {
  display: block;
  width: 100%;
  border: none;
  border-bottom: 1px solid #f0f2f5;
  padding: 7px 12px;
  font-size: .82rem;
  outline: none;
  background: #fafbfc;
}
.ef-search::placeholder { color: #4A546A; font-style: italic; }

/* Sel. todo / Ninguno actions bar */
.ef-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-bottom: 1px solid #f0f2f5;
  background: #fafbfc;
}
.ef-action-btn {
  font-size: .70rem;
  color: var(--color-primary);
  background: none;
  border: 1px solid #d0d8e8;
  border-radius: 4px;
  padding: 2px 9px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.5;
  transition: background .12s;
}
.ef-action-btn:hover { background: rgba(22,66,129,.09); }

.ef-items-wrap { max-height: 260px; overflow-y: auto; }
.ef-items-wrap::-webkit-scrollbar { width: 5px; }
.ef-items-wrap::-webkit-scrollbar-thumb { background: #dee2e6; border-radius: 3px; }

.ef-item {
  display: flex;
  align-items: center;
  padding: 4px 10px 4px 12px;
  gap: 8px;
  font-size: .82rem;
  user-select: none;
}
.ef-item:hover { background: rgba(22,66,129,.05); }
.ef-item input[type=checkbox] {
  width: 14px; height: 14px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--color-primary);
}
/* label wrapping text + amount */
.ef-item-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  overflow: hidden;
  margin: 0;
  font-size: .82rem;
}
.ef-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ef-item-amt {
  font-size: .72rem;
  color: #4A546A; /* darkened from #6c757d for WCAG AA at small font size */
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* "Solo" button — visible only on row hover */
.ef-item-only {
  display: none;
  font-size: .66rem;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(22,66,129,.08);
  border: 1px solid rgba(22,66,129,.18);
  border-radius: 3px;
  padding: 1px 7px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.5;
  transition: background .1s;
}
.ef-item:hover .ef-item-only { display: block; }
.ef-item-only:hover { background: rgba(22,66,129,.18); }

/* ── Preset panel ──────────────────────────────────────────── */
.preset-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 1080;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  width: 280px;
  padding: 10px;
}
.preset-item {
  border-radius: 5px;
  padding: 5px 6px;
}
.preset-item:hover { background: #f0f4ff; }
.preset-item-name { font-size: .82rem; }

/* ── Tabulator custom theme ────────────────────────────────── */
.tabulator { border-radius: 0 0 12px 12px; }
.tabulator .tabulator-header {
  background: var(--color-primary) !important;
}
.tabulator .tabulator-header .tabulator-col {
  background: var(--color-primary) !important;
  color: #fff !important;
  font-weight: 600;
  font-size: .8rem;
}
.tabulator .tabulator-row:hover { background: rgba(22,66,129,.04) !important; }

/* ── Contrast fixes ───────────────────────────────────────── */

/* Bootstrap text-warning (#ffc107) on white has ~1.07:1 ratio — unusable.
   Override to a dark amber that meets WCAG AA 4.5:1 on white backgrounds.
   Applies inside cards, tables, and content areas (not inside dark KPI cards). */
.card .text-warning,
.table .text-warning,
.modal .text-warning,
.alert .text-warning {
  color: #a06000 !important; /* dark amber — ratio ~5.6:1 on white ✓ */
}

/* Bootstrap's text-muted (#6c757d on white = ratio ~4.49:1) is borderline.
   Override to our darker --color-text-muted (#5a6370, ratio ~5.0:1) everywhere. */
.text-muted {
  color: var(--color-text-muted) !important; /* #5a6370, ratio ~5.0:1 on white ✓ */
}

/* ══════════════════════════════════════════════════════════════
   CLASES UTILITARIAS REUTILIZABLES
   (Reemplazan inline styles repetidos en múltiples templates)
   ══════════════════════════════════════════════════════════════ */

/* ── Encabezado de tabla ─────────────────────────────────────── */
.table-header {
  background: var(--color-primary);
  color: #fff;
  font-weight: var(--font-weight-semibold);
  padding: 10px 12px;
}
.table-header-sm {
  background: var(--color-primary);
  color: #fff;
  font-weight: var(--font-weight-semibold);
  padding: 7px 10px;
  font-size: var(--font-xs);
}

/* ── Etiquetas de sección y formulario ─────────────────────────── */
.label-section {
  font-size: var(--font-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #4A546A;
}
.label-xs {
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.label-xxs {
  font-size: var(--font-xxs);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}

/* ── Contenedor scrollable con altura dinámica ─────────────────── */
.scroll-container {
  overflow-y: auto;
  overflow-x: hidden;
}
.scroll-container-sm  { max-height: 260px; }
.scroll-container-md  { max-height: 400px; }
.scroll-container-lg  { max-height: 600px; }

/* ── KPI card dorado (variante faltante) ───────────────────────── */
.kpi-gold {
  background: linear-gradient(135deg, var(--color-warning) 0%, #8b6914 100%);
  color: #fff;
}
.kpi-gold .kpi-icon  { background: rgba(0,0,0,.20); color: #fff; }
.kpi-gold .kpi-label { color: rgba(255,255,255,.85); }
.kpi-gold .kpi-value { color: #fff; }
.kpi-gold:hover { box-shadow: 0 14px 36px rgba(184,134,11,.45); }

/* ── Badge de nivel de banda ────────────────────────────────────── */
.badge-band-gold   { background: var(--color-warning); color: #fff; }
.badge-band-silver { background: var(--color-band-silver); color: #fff; }

/* ── Accesibilidad: estado con ícono (no solo color) ──────────── */
.status-up   { color: var(--color-success); }
.status-down { color: var(--color-danger); }
.status-up::before   { content: '▲ '; font-size: .75em; }
.status-down::before { content: '▼ '; font-size: .75em; }

/* ── Sidebar: sección header con contraste WCAG AA ────────────── */
.sidebar-section-header {
  /* Aumentado de rgba(255,255,255,.65) a .85 para cumplir WCAG AA */
  color: rgba(255,255,255,.88) !important;
}

/* ── Touch targets mínimos 44px (WCAG 2.1 SC 2.5.5) ──────────── */
.btn-touch {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Empty state genérico ──────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: #4A546A;
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.empty-state p { font-size: .85rem; margin: 0; }

/* ── Responsive ────────────────────────────────────────────── */
/* ── Hamburger button (solo visible en mobile) ─────────────── */
#btn-hamburger {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1100;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* ── Overlay oscuro cuando el sidebar está abierto en mobile ── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
}
#sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  /* En mobile el sidebar arranca oculto (off-canvas) */
  #sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--transition);
    z-index: 1000;
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }
  /* Cuando está colapsado mantenemos el mismo comportamiento */
  #sidebar.collapsed { width: var(--sidebar-width); transform: translateX(-100%); }
  #main-wrapper { margin-left: 0; }
  #sidebar.collapsed ~ #main-wrapper { margin-left: 0; }
  #topbar { left: 0; }
  #sidebar ~ #topbar { left: 0; }
  #btn-hamburger { display: flex; }
  #toggle-sidebar { display: none; }  /* Ocultar el botón de colapso desktop */
  #content { padding: 12px; }
  /* KPI cards: max 2 columnas en mobile */
  .kpi-card { min-width: 0; }
  /* Home banner: stack vertical en mobile */
  .home-banner { flex-direction: column; text-align: center; }
  .hb-right { text-align: center; }
  /* Filtros: wrap en mobile */
  .filters-bar .d-flex { flex-wrap: wrap; }
}

@media (min-width: 769px) {
  #btn-hamburger { display: none !important; }
  #sidebar-overlay { display: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   UX ENHANCEMENTS — animaciones, micro-interacciones, gamificación
   ══════════════════════════════════════════════════════════════ */

/* ── 1. KPI card hover lift + glow ──────────────────────────── */
.kpi-card {
  transition: transform .22s ease, box-shadow .22s ease;
  cursor: default;
}
.kpi-card:hover { transform: translateY(-6px) scale(1.015); }
.kpi-blue:hover     { box-shadow: 0 14px 36px rgba(22,66,129,.45); }
.kpi-orange:hover   { box-shadow: 0 14px 36px rgba(244,131,31,.45); }
.kpi-green:hover    { box-shadow: 0 14px 36px rgba(25,135,84,.42); }
.kpi-teal:hover     { box-shadow: 0 14px 36px rgba(13,110,253,.42); }
.kpi-secondary:hover{ box-shadow: 0 14px 36px rgba(73,80,87,.35); }
.kpi-card .kpi-icon { transition: opacity .22s ease, transform .22s ease; }
.kpi-card:hover .kpi-icon { opacity:.35; transform:translateY(-50%) scale(1.2); }

/* ── 2. Skeleton shimmer para KPIs durante carga AJAX ───────── */
@keyframes shimmer {
  0%   { background-position:-600px 0; }
  100% { background-position: 600px 0; }
}
.kpi-skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,.10) 25%,
    rgba(255,255,255,.38) 50%,
    rgba(255,255,255,.10) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
  display: inline-block;
  color: transparent !important;
  min-width: 130px;
  height: 1.5em;
  vertical-align: middle;
  pointer-events: none;
}

/* ── 3. Slide-up fade-in de entrada ─────────────────────────── */
@keyframes slideUpFadeIn {
  from { opacity:0; transform:translateY(22px); }
  to   { opacity:1; transform:translateY(0); }
}
.anim-entry {
  opacity: 0;
  animation: slideUpFadeIn .48s ease forwards;
}

/* ── 4. Podio visual top 3 en tablas de ranking ─────────────── */
.ranking-pos-1 {
  background: linear-gradient(90deg,rgba(255,215,0,.14) 0%,transparent 65%) !important;
  border-left: 3px solid #FFD700;
}
.ranking-pos-2 {
  background: linear-gradient(90deg,rgba(192,192,192,.14) 0%,transparent 65%) !important;
  border-left: 3px solid #C0C0C0;
}
.ranking-pos-3 {
  background: linear-gradient(90deg,rgba(205,127,50,.14) 0%,transparent 65%) !important;
  border-left: 3px solid #CD7F32;
}
.ranking-pos-1 td:first-child { font-size:1.3rem !important; line-height:1; }
.ranking-pos-2 td:first-child { font-size:1.12rem !important; line-height:1; }
.ranking-pos-3 td:first-child { font-size:1rem !important; line-height:1; }
.ranking-pos-1:hover { background:linear-gradient(90deg,rgba(255,215,0,.24) 0%,rgba(255,215,0,.04) 65%) !important; }
.ranking-pos-2:hover { background:linear-gradient(90deg,rgba(192,192,192,.24) 0%,rgba(192,192,192,.04) 65%) !important; }
.ranking-pos-3:hover { background:linear-gradient(90deg,rgba(205,127,50,.24) 0%,rgba(205,127,50,.04) 65%) !important; }

/* ── 5. Barra de progreso con transición animada (Metas) ─────── */
.progress-bar-anim {
  transition: width 1.2s cubic-bezier(.25,.46,.45,.94);
}

/* ── 6. Badge "En línea" home ────────────────────────────────── */
@keyframes pulse-dot {
  0%, 100% { opacity:1; }
  50%       { opacity:.35; }
}
.online-dot { animation: pulse-dot 2s ease-in-out infinite; }

/* ══ Layout Controls (Sortable / Edge-Resize / Minimize) ════════════════ */

/* Each sortable card needs position:relative for the resize handle */
.layout-card { position: relative; }

/* Strip for home.html cards (above the partial) */
.lc-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 2px 3px 0;
  margin-bottom: 4px;
  font-size: .72rem;
  color: #4A546A;
  user-select: none;
}
.lc-card-label {
  flex: 1;
  font-weight: 600;
  color: #4A546A;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .72rem;
}

/* Lectura (con mouse): la etiqueta repite el título de la tarjeta → se oculta y el botón
   minimizar flota en la esquina al pasar el mouse. Tarjetas minimizadas o sin información
   conservan la etiqueta. */
@media (hover: hover) and (min-width: 992px) {
  .lc-snap-grid:not(.lc-editando) > .layout-card[data-minimized="0"]:not(:has(.lc-sin-info)) > .lc-strip {
    position: absolute; top: 4px; right: 4px; z-index: 4; margin: 0; padding: 0;
    opacity: 0; transition: opacity .15s; }
  .lc-snap-grid:not(.lc-editando) > .layout-card[data-minimized="0"]:not(:has(.lc-sin-info)) > .lc-strip .lc-card-label { display: none; }
  .lc-snap-grid:not(.lc-editando) > .layout-card[data-minimized="0"]:not(:has(.lc-sin-info)) > .lc-strip .lc-min-btn {
    background: #fff; box-shadow: 0 1px 3px rgba(15,23,42,.18); color: #475569; }
  .lc-snap-grid:not(.lc-editando) > .layout-card:hover > .lc-strip,
  .lc-snap-grid:not(.lc-editando) > .layout-card > .lc-strip:focus-within { opacity: 1; }
}

/* Controls inside dashboard card-headers */
.lc-controls {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

/* Shared button style */
.lc-btn {
  background: none;
  border: none;
  padding: 2px 5px;
  cursor: pointer;
  color: #4A546A;
  border-radius: 4px;
  font-size: .8rem;
  line-height: 1.4;
  transition: background .12s, color .12s;
}
.lc-btn:hover { background: #f1f5f9; color: #374151; }

/* Drag handle cursor */
.lc-drag-handle { cursor: grab; }
.lc-drag-handle:active { cursor: grabbing; }

/* ── Edge resize handle ───────────────────────────────────────────────── */
.lc-resize-handle {
  position: absolute;
  top: 0;
  right: 0;             /* flush with card right edge — stays inside card */
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* permanent subtle dots — always visible, communicates draggability */
.lc-resize-handle::before {
  content: '';
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-primary, #164281);
  opacity: .18;
  box-shadow:
    0 -7px 0 0 var(--color-primary, #164281),
    0  7px 0 0 var(--color-primary, #164281);
  transition: opacity .18s, box-shadow .18s;
}
/* brighter on card hover */
.layout-card:hover .lc-resize-handle::before { opacity: .35; }
/* accent + larger dots on handle hover */
.lc-resize-handle:hover::before {
  opacity: .75 !important;
  box-shadow:
    0 -8px 0 0 var(--color-accent, #F4831F),
    0  8px 0 0 var(--color-accent, #F4831F);
  background: var(--color-accent, #F4831F);
}
/* accent + tall line while actively resizing */
.lc-resize-handle.resizing::before {
  opacity: 1 !important;
  width: 3px;
  height: 40px;
  border-radius: 2px;
  background: var(--color-accent, #F4831F);
  box-shadow: none;
}
/* freeze cursor + selection during drag */
body.lc-resizing {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: col-resize !important;
}

/* ── Vertical (height) resize handle ─────────────────────────────────── */
.lc-body { position: relative; }

.lc-resize-handle-y {
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 100%;
  height: 12px;
  cursor: row-resize;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* horizontal dots — permanent, subtle */
.lc-resize-handle-y::before {
  content: '';
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-primary, #164281);
  opacity: .18;
  box-shadow:
    -8px 0 0 0 var(--color-primary, #164281),
     8px 0 0 0 var(--color-primary, #164281);
  transition: opacity .18s, box-shadow .18s, background .18s;
}
.layout-card:hover .lc-resize-handle-y::before { opacity: .35; }
.lc-resize-handle-y:hover::before {
  opacity: .75 !important;
  background: var(--color-accent, #F4831F);
  box-shadow:
    -10px 0 0 0 var(--color-accent, #F4831F),
     10px 0 0 0 var(--color-accent, #F4831F);
}
.lc-resize-handle-y.resizing::before {
  opacity: 1 !important;
  width: 50px;
  height: 3px;
  border-radius: 2px;
  background: var(--color-accent, #F4831F);
  box-shadow: none;
}
body.lc-resizing-y {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: row-resize !important;
}

/* Sortable ghost / chosen feedback */
.layout-card.sortable-ghost   { opacity: .35; }
.layout-card.sortable-chosen  {
  box-shadow: 0 0 0 2px var(--color-primary, #164281);
  border-radius: var(--radius-card, 14px);
  z-index: 10;
}

/* KPI block minimize strip */
.kpi-block-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 6px;
}

/* ── Scrollbar horizontal siempre visible en tablas ──────────────────── */
/* Tabulator */
.tabulator .tabulator-tableHolder {
  overflow-x: scroll !important;
}
/* Bootstrap table-responsive (Renovaciones) */
.table-responsive {
  overflow-x: scroll !important;
}
/* Scrollbar visible en webkit (Chrome, Safari, Edge) */
.tabulator .tabulator-tableHolder::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
  height: 8px;
}
.tabulator .tabulator-tableHolder::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.tabulator .tabulator-tableHolder::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.tabulator .tabulator-tableHolder::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Última Actualización (topbar badge + popup) ────────────────────────── */
.ult-act-wrap {
  position: relative;
  flex-shrink: 0;
}

.ult-act-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .74rem;
  color: var(--color-text-muted, #64748b);
  cursor: default;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
  user-select: none;
}

.ult-act-wrap:hover .ult-act-label {
  background: var(--color-bg, #f8f9fb);
  color: var(--color-primary, #5B5E7C);
  border-color: var(--color-border, #e2e8f0);
}

.ult-act-popup {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.13);
  padding: 14px 18px;
  min-width: 270px;
  z-index: 2100;
  transition: opacity .15s, visibility .15s;
}

/* Arrow pointing up */
.ult-act-popup::before {
  content: '';
  position: absolute;
  top: -7px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  border-left: 1px solid #e2e8f0;
  transform: rotate(45deg);
}

.ult-act-wrap:hover .ult-act-popup {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.ult-act-title {
  font-size: .7rem;
  font-weight: 700;
  color: #5B5E7C;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid #f1f5f9;
}

.ult-act-table {
  width: 100%;
  border-collapse: collapse;
}

.ult-act-table tr + tr td {
  padding-top: 5px;
}

.ult-act-key {
  font-size: .78rem;
  color: #4A546A;
  padding-right: 16px;
  white-space: nowrap;
}

.ult-act-val {
  font-size: .78rem;
  font-weight: 600;
  color: #1e293b;
  text-align: right;
  white-space: nowrap;
}


/* ── Sección de datos de prueba (QA) en catálogos ─────────────────────────── */
.badge-qa {
  display: inline-block; margin-left: .35rem; padding: .1rem .4rem; border-radius: .25rem;
  font-size: .65rem; font-weight: 700; letter-spacing: .06em; vertical-align: middle;
  color: #fff; background: #6d28d9;
}
tr.fila-qa > td {
  background: repeating-linear-gradient(135deg, #f5f3ff 0 10px, #ede9fe 10px 20px) !important;
  color: #4c1d95;
}
tr.fila-qa-sep > td {
  background: #6d28d9 !important; color: #fff; font-size: .78rem; padding: .35rem .75rem;
  border-top: 3px solid #4c1d95;
}

/* ── Legibilidad (hallazgos del bot QA, 2026-11) ─────────────────────────── */
/* Etiquetas amarillas/celestes con texto blanco no se leen (1.6:1 / 1.9:1) */
.badge.bg-warning { color: #1f2937 !important; }
.badge.bg-info    { color: #082f49 !important; }
/* Botones amarillos de contorno sobre blanco */
.btn-outline-warning { color: #92400e; border-color: #d97706; }
.btn-outline-warning:hover, .btn-outline-warning.active, .btn-check:checked + .btn-outline-warning {
  color: #fff; background: #b45309; border-color: #b45309;
}
/* Tablas (Tabulator): encabezados en dos renglones en vez de recortarse */
.tabulator .tabulator-col .tabulator-col-title { white-space: normal; text-overflow: clip; line-height: 1.2; }

/* ── Mi Convención: barra única con marcas por nivel ─────────────────────── */
.conv-barra { padding: 4px 0 2px; }
.conv-barra-pista { position: relative; height: 10px; border-radius: 5px; background: #e0f2fe; }
.conv-barra-relleno { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px;
  background: linear-gradient(90deg, #0369a1, #38bdf8); transition: width .8s ease; }
.conv-barra-marca { position: absolute; top: -3px; width: 3px; height: 16px; margin-left: -1.5px;
  border-radius: 2px; background: #94a3b8; }
.conv-barra-marca.ok { background: #16a34a; }
.conv-barra-etiquetas { position: relative; height: 34px; margin-top: 4px; }
.conv-barra-etq { position: absolute; transform: translateX(-50%); font-size: .7rem; font-weight: 600;
  color: #475569; white-space: nowrap; line-height: 1.15; text-align: center; max-width: 110px;
  white-space: normal; }
.conv-barra-etq.ok { color: #2E7D32; }
.conv-barra-etq.ultima { transform: translateX(-100%); text-align: right; white-space: nowrap; }

/* ── Comunicado minimizable (Inicio) ──────────────────────────────────────── */
.comunicado-mini { display: flex; align-items: center; gap: .6rem; padding: .5rem .9rem;
  background: #fff; border: 1px solid #e2e8f0; border-left: 4px solid var(--color-primary);
  border-radius: .5rem; font-size: .82rem; color: #374151; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.comunicado-mini.d-none { display: none !important; }
.comunicado-mini .bi { color: var(--color-primary); }
.comunicado-min-btn { position: absolute; top: .6rem; right: .6rem; font-size: .75rem; color: #475569; }

/* ── Diseño de tarjetas: modo lectura vs. Personalizar (layout-controls.js) ── */
/* En lectura no hay controles en los bordes ni manija de arrastre */
.layout-card .lc-resize-handle, .layout-card .lc-resize-handle-y,
.layout-card .lc-drag-handle, .layout-card .lc-mover { display: none !important; }
.lc-editando > .layout-card .lc-resize-handle,
.lc-editando > .layout-card .lc-resize-handle-y { display: flex !important; }
.lc-editando > .layout-card .lc-drag-handle { display: inline-flex !important; }
.lc-editando > .layout-card .lc-mover { display: inline-flex !important; gap: 2px; margin-left: 4px; }
.lc-editando > .layout-card .lc-mover .lc-btn { min-width: 30px; min-height: 30px; }

/* Cuadrícula visible y tarjetas con contorno al personalizar */
.lc-snap-grid.lc-editando {
  background-image: repeating-linear-gradient(90deg,
    rgba(37,99,235,.06) 0, rgba(37,99,235,.06) calc((100% - 11rem) / 12),
    transparent calc((100% - 11rem) / 12), transparent calc((100% - 11rem) / 12 + 1rem));
  border-radius: 10px; outline: 2px dashed rgba(37,99,235,.25); outline-offset: 6px;
}
.lc-editando > .layout-card { outline: 2px dashed #93c5fd; outline-offset: 2px; border-radius: 10px; }
.lc-editando > .layout-card .lc-strip,
.lc-editando > .layout-card > .card > .card-header { cursor: grab; }
.lc-editando > .layout-card .lc-strip:active,
.lc-editando > .layout-card > .card > .card-header:active { cursor: grabbing; }
.lc-ghost   { opacity: .35; outline: 2px dashed #2563eb !important; background: #eff6ff; }
.lc-chosen  { box-shadow: 0 12px 30px rgba(15,23,42,.18); }
.lc-dragging { opacity: .95 !important; transform: rotate(.6deg); }

/* Vista previa del ancho */
.lc-preview { position: fixed; z-index: 2000; pointer-events: none; border: 2px dashed #2563eb;
  background: rgba(37,99,235,.08); border-radius: 10px; transition: width .08s, left .08s, top .08s;
  display: flex; align-items: flex-start; justify-content: flex-end; }
.lc-preview-label { margin: 8px; padding: 2px 8px; border-radius: 999px; background: #2563eb; color: #fff;
  font-size: .75rem; font-weight: 700; white-space: nowrap; }

/* "Ver todos" en lugar de scroll interno */
.lc-recortado { position: relative; }
.lc-recortado:not(.lc-expandido)::after { content: ''; position: sticky; display: block; left: 0; right: 0; bottom: 0;
  height: 36px; margin-top: -36px; background: linear-gradient(rgba(255,255,255,0), #fff); pointer-events: none; }
.lc-ver-todos { display: block; width: 100%; border: 0; border-top: 1px solid #e5e7eb; background: #f8fafc;
  color: #164281; font-size: .78rem; font-weight: 600; padding: 6px 0; }
.lc-ver-todos:hover { background: #eff6ff; }

/* Carga progresiva: esqueleto por tarjeta */
.layout-card.lc-cargando .lc-body { position: relative; }
.layout-card.lc-cargando .lc-body::before { content: ''; position: absolute; inset: 0; z-index: 5; border-radius: 10px;
  background: linear-gradient(100deg, rgba(241,245,249,.85) 30%, rgba(226,232,240,.95) 50%, rgba(241,245,249,.85) 70%);
  background-size: 300% 100%; animation: lc-shimmer 1.2s linear infinite; }
@keyframes lc-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .layout-card.lc-cargando .lc-body::before { animation: none; } }

/* Mensaje de tarjeta sin información */
.lc-sin-info { padding: 1.5rem 1rem; text-align: center; color: #4A546A; font-size: .85rem;
  background: #fff; border-radius: 10px; border: 1px dashed #cbd5e1; }
.lc-ayuda-edicion, .lc-solo-edicion { display: none !important; }
body.lc-modo-edicion .lc-ayuda-edicion { display: inline !important; }
body.lc-modo-edicion .lc-solo-edicion { display: inline-block !important; }
@media (max-width: 991px) { body.lc-modo-edicion .lc-ayuda-edicion { display: none !important; } }
