/* ============================================================================
   Pipeline EL GRUPO — Estilos
   Identidad oficial (Brandbook EL GRUPO 2026):
   · El Grupo Blue #2D38C5  · Royal Deep #1B22A1  · Play Orange #FF6A13
   · Creative Purple #5141B7 · Ice White #F7F9FC
   · Dark Ink #20253D · Body Gray #5F6880 · Line #DDE4F0
   · Success #2FB67C · Alert #EF4D63
   Tipografía: Poppins (headlines/UI) + Inter (body/data).
   Border radius: 12-20px. Grid base 8px.
   ============================================================================ */

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

:root {
  /* Marca */
  --bl: #2D38C5;        /* El Grupo Blue */
  --bl-d: #1B22A1;      /* Royal Deep */
  --bl-l: #EEF0FB;
  --bl-m: #D5D9F4;
  --or: #FF6A13;        /* Play Orange */
  --or-d: #E55400;
  --or-l: #FFF1E7;
  --pu: #5141B7;        /* Creative Purple */
  --pu-l: #ECEAF8;

  /* Fondos / neutros */
  --bg: #F7F9FC;        /* Ice White */
  --bg2: #EEF2F8;
  --bd: #DDE4F0;        /* Line */
  --bd2: #C5CFE0;

  /* Texto */
  --tx: #20253D;        /* Dark Ink */
  --tx2: #5F6880;       /* Body Gray */
  --tx3: #95A0B5;

  /* Estados */
  --gn: #2FB67C;        /* Success */
  --gn-l: #E2F5EC;
  --rd: #EF4D63;        /* Alert */
  --rd-l: #FDECEE;
  --am: #B86E00;
  --am-l: #FEF1DE;

  /* Geometría */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 20px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(32,37,61,.06);
  --shadow-md: 0 4px 18px rgba(32,37,61,.08);
  --shadow-lg: 0 18px 48px rgba(32,37,61,.14);

  /* Tipografía */
  --font-head: 'Poppins', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body {
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.headline,
.kpi-value,
.modal-title,
.section-title,
.fl-name,
.tab.on {
  font-family: var(--font-head);
  letter-spacing: -0.01em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------------------------------------------------------------------------
   App shell
--------------------------------------------------------------------------- */
.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bl);
  position: sticky;
  top: 0;
  z-index: 100;
}
.top .logo-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.top .logo { height: 30px; display: block; }
.top .tr   { display: flex; align-items: center; gap: 14px; }

.mode-btn {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
.mode-btn.dir { background: var(--or); color: #fff; }
.mode-btn.fl  { background: rgba(255,255,255,.15); color: rgba(255,255,255,.95); border: 1px solid rgba(255,255,255,.3); }
.mode-btn:hover { opacity: .88; }

.year-nav { display: flex; align-items: center; gap: 8px; }
.year-arrow {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  background: transparent;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all .15s;
}
.year-arrow:hover  { background: rgba(255,255,255,.15); color: #fff; }
.year-arrow:disabled { opacity: .3; cursor: not-allowed; }
.year-label { font-size: 15px; font-weight: 700; color: #fff; min-width: 52px; text-align: center; }

.close-year-btn {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--or);
  background: transparent;
  color: var(--or);
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}
.close-year-btn:hover { background: var(--or); color: #fff; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
  color: rgba(255,255,255,.92);
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
}
.user-chip b { color: #fff; font-weight: 600; }
.user-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  color: #fff;
}
.user-chip .logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  cursor: pointer;
}
.user-chip .logout-btn:hover { background: rgba(255,255,255,.15); }

/* ---------------------------------------------------------------------------
   Tabs
--------------------------------------------------------------------------- */
.tabs-wrap { position: relative; }
.tabs {
  display: flex;
  border-bottom: 2px solid var(--bd);
  background: #fff;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { height: 0; display: none; }
.tab {
  font-size: 13px;
  font-weight: 500;
  padding: 12px 18px;
  cursor: pointer;
  color: var(--tx3);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
}
.tab:hover { color: var(--tx); }
.tab.on    { color: var(--bl); border-bottom-color: var(--or); font-weight: 600; }

.view { display: none; }
.view.on { display: block; }

/* Banner archivo histórico */
.archive-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--bl-l);
  border-bottom: 1px solid var(--bl-m);
  font-size: 12px;
  color: var(--bl);
  font-weight: 500;
}

/* ---------------------------------------------------------------------------
   FL header
--------------------------------------------------------------------------- */
.fl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--bd);
  gap: 16px;
  flex-wrap: wrap;
}
.fl-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Toolbar del Resumen (filtro de fechas + Agregar proyecto) */
.summary-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.summary-toolbar-left  { flex: 1 1 auto; min-width: 0; }
.summary-toolbar-right { flex: 0 0 auto; }
@media (max-width: 768px) {
  .summary-toolbar-right { width: 100%; }
  .summary-toolbar-right .btn { width: 100%; }
}

/* Buscador hint (banner pequeño sobre el input, color amber para indicar atención) */
.fl-search-input-wrap {
  position: relative;
  flex: 1 1 100%;
  min-width: 0;
}
.fl-search-input-wrap input {
  width: 100%;
}
.search-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 12px;
  background: var(--am-l);
  color: var(--am);
  border: 1px solid #FFD5C2;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 500;
}
.search-hint-icon { font-size: 14px; }
.fl-id { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bl);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fl-name { font-size: 14px; font-weight: 600; color: var(--tx); }

.kpis { display: flex; gap: 18px; flex-wrap: wrap; }
.kpi  { font-size: 12px; color: var(--tx3); }
.kpi b { color: var(--tx); font-weight: 600; }

/* Filtro de fechas (compartido Resumen + FL) */
.date-filter {
  padding: 12px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--bd);
}
.summary .date-filter {
  background: transparent;
  padding: 0 0 16px;
  border-bottom: none;
}
.date-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.date-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--bd);
  background: #fff;
  color: var(--tx2);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.date-chip:hover { border-color: var(--bl); color: var(--bl); }
.date-chip.on    { background: var(--bl); color: #fff; border-color: var(--bl); }

.date-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1.5px solid var(--bd);
  border-radius: var(--r);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--tx2);
}
.date-field:focus-within { border-color: var(--bl); }
.date-field span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--tx3);
}
.date-field input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--tx);
  font-family: inherit;
  padding: 4px 0;
  min-width: 120px;
}
.date-clear {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1.5px solid var(--rd-l);
  color: var(--rd);
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}
.date-clear:hover { background: var(--rd-l); }
.date-filter-hint {
  font-size: 11px;
  color: var(--tx3);
  margin-top: 6px;
  font-style: italic;
}

/* Buscador */
.fl-search {
  padding: 12px 20px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--bd);
  background: var(--bg);
}
.fl-search input {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
  border: 1.5px solid var(--bd);
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.fl-search input:focus { border-color: var(--bl); }
.fl-search .filter-chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--bd);
  color: var(--tx2);
  cursor: pointer;
  transition: all .15s;
}
.fl-search .filter-chip:hover { border-color: var(--bl); color: var(--bl); }
.fl-search .filter-chip.on    { background: var(--bl); color: #fff; border-color: var(--bl); }

/* ---------------------------------------------------------------------------
   Tabla de proyectos
--------------------------------------------------------------------------- */
.tw { overflow-x: auto; }
table.projects {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}
table.projects th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--bl);
  white-space: nowrap;
}
table.projects td {
  border-bottom: 1px solid var(--bd);
  vertical-align: middle;
  padding: 8px 12px;
  color: var(--tx);
}
table.projects tbody tr:last-child td { border-bottom: none; }
table.projects tbody tr:hover td      { background: var(--bl-l); }
table.projects tr.closed td           { opacity: .55; }
table.projects tr.empty td            {
  text-align: center; padding: 32px; font-size: 12px; color: var(--tx3); font-style: italic;
}

/* Celda editable */
.editable {
  cursor: text;
  border-radius: 5px;
  padding: 3px 6px;
  margin: -3px -6px;
  display: inline-block;
  min-width: 32px;
}
.editable:hover    { background: var(--bl-l); }
.editable.locked   { cursor: not-allowed; color: var(--tx3) !important; }
.editable.locked:hover { background: transparent; }
.editable.empty    { color: var(--tx3) !important; font-style: italic; }

.edit-input {
  font-size: 13px;
  color: var(--tx);
  border: 1.5px solid var(--bl);
  border-radius: 6px;
  padding: 4px 8px;
  outline: none;
  background: #fff;
  font-family: inherit;
}

/* Selectores inline */
.inline-select {
  font-size: 12px;
  color: var(--tx2);
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  padding: 4px 22px 4px 6px;
  border-radius: 5px;
  max-width: 180px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%232D38C5' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: all .15s;
}
.inline-select:hover { background-color: var(--bl-l); color: var(--tx); }
.inline-select:focus { background-color: #fff; border-color: var(--bl); color: var(--tx); }
.inline-select.has-value { color: var(--tx); }

/* Estado píldora */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  border: none;
  transition: transform .12s;
}
.status-pill:hover { transform: scale(1.04); box-shadow: var(--shadow-sm); }

.status-dropdown {
  position: relative;
  display: inline-block;
}
.status-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 5px;
  min-width: 180px;
  box-shadow: var(--shadow-md);
}
.status-menu.on { display: block; }
.status-option {
  padding: 6px 11px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  color: var(--tx2);
}
.status-option:hover { background: var(--bl-l); color: var(--bl); }

/* Indicador de alerta */
.row-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* Paginador */
.paginator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--bd);
  background: var(--bg);
  font-size: 12px;
  color: var(--tx2);
  flex-wrap: wrap;
}
.paginator .pag-left,
.paginator .pag-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.paginator .pag-label {
  font-size: 11px;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  margin-right: 4px;
}
.paginator .pag-size {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1.5px solid var(--bd);
  background: #fff;
  color: var(--tx2);
  cursor: pointer;
  transition: all .15s;
}
.paginator .pag-size:hover { border-color: var(--bl); color: var(--bl); }
.paginator .pag-size.on    { background: var(--bl); color: #fff; border-color: var(--bl); }
.paginator .pag-info       { font-size: 12px; color: var(--tx2); }
.paginator .pag-nav {
  width: 28px; height: 28px;
  border-radius: 999px;
  border: 1.5px solid var(--bd);
  background: #fff;
  color: var(--tx);
  cursor: pointer;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.paginator .pag-nav:hover:not(:disabled) { background: var(--bl); color: #fff; border-color: var(--bl); }
.paginator .pag-nav:disabled { opacity: .4; cursor: not-allowed; }
.paginator .pag-current { font-size: 12px; color: var(--tx); font-weight: 500; padding: 0 6px; }

@media (max-width: 768px) {
  .paginator { padding: 10px 12px; }
  .paginator .pag-info { width: 100%; order: -1; text-align: center; }
}

/* Audit log */
.audit-body {
  font-size: 13px;
  max-height: 65vh;
  overflow-y: auto;
  border: 1px solid var(--bd);
  border-radius: var(--r);
  background: #fff;
}
.audit-body > .paginator {
  border-top: 1px solid var(--bd);
  border-radius: 0 0 var(--r) var(--r);
  position: sticky;
  bottom: 0;
}
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}
.audit-table thead { position: sticky; top: 0; z-index: 5; }
.audit-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bl);
  color: #fff;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  white-space: nowrap;
}
/* Anchos sugeridos por columna */
.audit-table th:nth-child(1), .audit-table td:nth-child(1) { width: 110px; }
.audit-table th:nth-child(2), .audit-table td:nth-child(2) { width: 140px; }
.audit-table th:nth-child(3), .audit-table td:nth-child(3) { width: 80px;  }
.audit-table th:nth-child(4), .audit-table td:nth-child(4) { width: 110px; }
.audit-table th:nth-child(5), .audit-table td:nth-child(5) { width: auto;  }

.audit-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--bd);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.audit-table tr:hover td { background: var(--bl-l); }
.audit-action {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.audit-action.create  { background: var(--gn-l); color: var(--gn); }
.audit-action.update  { background: var(--bl-l); color: var(--bl); }
.audit-action.delete  { background: var(--rd-l); color: var(--rd); }
.audit-action.close   { background: var(--am-l); color: var(--am); }
.audit-action.other   { background: var(--bg2); color: var(--tx2); }
.audit-diff {
  font-size: 12px;
  color: var(--tx2);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.audit-diff .row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.audit-diff .lab { font-size: 10px; color: var(--tx3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; min-width: 38px; }
.audit-diff .val { word-break: break-word; }
.audit-diff .old { color: var(--rd); text-decoration: line-through; opacity: .75; }
.audit-diff .new { color: var(--gn); font-weight: 600; }
.audit-diff .single { color: var(--tx); }
.audit-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--tx3);
  font-size: 12px;
}

@media (max-width: 768px) {
  .audit-table { table-layout: auto; font-size: 11px; }
  .audit-table th, .audit-table td { padding: 8px 10px; }
  .audit-table th:nth-child(1), .audit-table td:nth-child(1) { width: auto; }
  .audit-table th:nth-child(2), .audit-table td:nth-child(2) { width: auto; }
}

/* Edit inline en config (cuando un item se vuelve editable) */
.config-item.editing {
  background: var(--bl-l) !important;
  border-color: var(--bl) !important;
}
.config-item .item-input {
  flex: 1;
  font-size: 13px;
  padding: 4px 8px;
  border: 1.5px solid var(--bl);
  border-radius: 6px;
  background: #fff;
  outline: none;
  margin-right: 8px;
}
.config-item .item-name {
  flex: 1;
  font-size: 13px;
  color: var(--tx);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.config-item .item-name:hover {
  background: var(--bg);
  color: var(--bl);
}
.config-item .item-actions {
  display: flex;
  gap: 4px;
}

/* Botones de aprobado */
.ap-group { display: inline-flex; gap: 4px; }
.ap-btn {
  font-size: 11px;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
  border: 1.5px solid var(--bd2);
  background: #fff;
  color: var(--tx2);
}
.ap-btn:hover { border-color: var(--bl); }
.ap-btn.on-yes { background: var(--gn); color: #fff; border-color: var(--gn); font-weight: 600; }
.ap-btn.on-no  { background: var(--rd); color: #fff; border-color: var(--rd); font-weight: 600; }

/* Acciones de fila */
.row-action {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--tx3);
  transition: all .15s;
}
.row-action:hover           { background: var(--bg2); color: var(--tx); }
.row-action.danger:hover    { background: var(--rd-l); color: var(--rd); }

/* Botón agregar proyecto */
.add-project {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--or);
  padding: 12px 18px;
  cursor: pointer;
  border-top: 1px solid var(--bd);
  transition: background .15s;
}
.add-project:hover { background: var(--or-l); }

/* ---------------------------------------------------------------------------
   Resumen
--------------------------------------------------------------------------- */
.summary { padding: 20px 24px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.kpi-card {
  border-radius: var(--r);
  padding: 16px 18px;
  border: 1.5px solid var(--bd);
  transition: transform .15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.kpi-card.blue   { background: var(--bl); border-color: transparent; }
.kpi-card.orange { background: var(--or); border-color: transparent; }
.kpi-card.neutral{ background: var(--bg); }
.kpi-card.warn   { background: var(--am-l); border-color: #FFD5C2; }

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.kpi-card.blue .kpi-label,
.kpi-card.orange .kpi-label { color: rgba(255,255,255,.78); }
.kpi-card.neutral .kpi-label,
.kpi-card.warn .kpi-label   { color: var(--tx3); }

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.kpi-card.blue .kpi-value,
.kpi-card.orange .kpi-value { color: #fff; }
.kpi-card.neutral .kpi-value{ color: var(--tx); }
.kpi-card.warn .kpi-value   { color: var(--am); }

.kpi-sub {
  font-size: 11px;
  margin-top: 4px;
}
.kpi-card.blue .kpi-sub,
.kpi-card.orange .kpi-sub { color: rgba(255,255,255,.7); }
.kpi-card.neutral .kpi-sub,
.kpi-card.warn .kpi-sub   { color: var(--tx3); }

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--tx3);
  margin: 20px 0 10px;
}

table.summary-tbl {
  width: 100%;
  border-collapse: collapse;
  border: 1.5px solid var(--bd);
  border-radius: var(--r);
  overflow: hidden;
}
table.summary-tbl th {
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #fff;
  background: var(--bl);
  text-align: left;
}
table.summary-tbl td {
  padding: 11px 14px;
  border-top: 1px solid var(--bd);
  font-size: 13px;
  color: var(--tx);
}

/* Gráficas dentro de la vista de Fan Líder */
.fl-charts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--bd);
}
@media (max-width: 1024px) {
  .fl-charts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .fl-charts { grid-template-columns: 1fr; padding: 12px 14px; gap: 12px; }
}

/* ---------------------------------------------------------------------------
   Gráficas del Resumen
--------------------------------------------------------------------------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 12px;
}
.chart-card {
  background: #fff;
  border: 1.5px solid var(--bd);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chart-card:hover { box-shadow: var(--shadow-sm); }
.chart-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--tx);
  letter-spacing: -.01em;
}
.chart-note {
  font-size: 11px;
  color: var(--tx3);
  line-height: 1.4;
}
.chart-canvas-wrap {
  position: relative;
  height: 220px;
  margin: 8px 0 4px;
}
.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg);
}
.chart-legend-item:hover { background: var(--bl-l); }
.chart-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.chart-legend-label {
  flex: 1;
  color: var(--tx);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-legend-value {
  color: var(--tx2);
  font-size: 11px;
  white-space: nowrap;
}
.chart-legend-value b { color: var(--tx); font-weight: 700; }
.chart-legend-total {
  display: flex;
  justify-content: space-between;
  padding: 8px 8px 2px;
  margin-top: 4px;
  border-top: 1px solid var(--bd);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--tx3);
}

@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-canvas-wrap { height: 240px; }
}

.bar-bg {
  background: var(--bd);
  border-radius: 999px;
  height: 5px;
  width: 80px;
  display: inline-block;
  overflow: hidden;
}
.bar-fill { height: 5px; border-radius: 999px; background: var(--or); }

/* ---------------------------------------------------------------------------
   Configuración
--------------------------------------------------------------------------- */
.config { padding: 20px 24px; }
.config-section { margin-bottom: 24px; }
.config-title {
  font-size: 13px; font-weight: 700; color: var(--tx); margin-bottom: 4px;
}
.config-note {
  font-size: 12px; color: var(--tx3); margin-bottom: 12px; line-height: 1.5;
}
.config-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 280px; overflow-y: auto;
  margin-bottom: 12px;
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 8px;
  background: var(--bg);
}
.config-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: var(--r);
}
.config-add {
  display: flex; gap: 8px; align-items: center;
}
.config-add input {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
  border: 1.5px solid var(--bd);
  border-radius: var(--r);
  background: #fff;
  outline: none;
}
.config-add input:focus { border-color: var(--bl); }

/* Badges de estado en Config */
.inactive-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.usage-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bl-l);
  color: var(--bl);
  white-space: nowrap;
}
.fl-card.inactive,
.config-item.inactive {
  opacity: .65;
  background: var(--bg);
}
.fl-card.inactive .fl-card-head { background: var(--bg); }
.config-item.inactive .item-name { color: var(--tx3); cursor: default; }
.config-item.inactive .item-name:hover { background: transparent; color: var(--tx3); }

/* Tarjetas Fan Líder en Config */
.fl-card {
  border: 1.5px solid var(--bd);
  border-radius: var(--r);
  margin-bottom: 8px;
  background: #fff;
  overflow: hidden;
}
.fl-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.fl-card-edit {
  border-top: 1px solid var(--bd);
  padding: 12px 16px;
  background: var(--bg);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.fl-card-delete {
  border-top: 1px solid #FDECEC;
  padding: 12px 16px;
  background: #FFF8F8;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Botones genéricos
--------------------------------------------------------------------------- */
.btn {
  font-size: 13px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--r);
  border: 1.5px solid var(--bd);
  background: transparent;
  color: var(--tx);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.btn:hover { background: var(--bg2); }
.btn-primary  { background: var(--or)!important; color: #fff!important; border-color: transparent!important; }
.btn-primary:hover { background: var(--or-d)!important; }
.btn-secondary{ background: var(--bl)!important; color: #fff!important; border-color: transparent!important; }
.btn-secondary:hover { background: var(--bl-d)!important; }
.btn-danger   { color: var(--rd); border-color: var(--rd-l); }
.btn-danger:hover { background: var(--rd-l); }
.btn-small {
  font-size: 12px; padding: 5px 12px; border-radius: 6px;
}

/* ---------------------------------------------------------------------------
   Modales
--------------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 25, 23, 0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.on { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--r-lg);
  padding: 24px;
  width: 540px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal.modal-sm { width: 380px; }
.modal.modal-lg { width: 820px; max-width: 95%; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--tx); }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg2);
  color: var(--tx2);
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--bd); color: var(--tx); }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 12px; }
.form-row    { margin-top: 12px; }
.form-field  { display: flex; flex-direction: column; gap: 4px; }
.form-field label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--tx3);
}
.form-field .full-col { grid-column: span 2; }
.form-input {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--r);
  border: 1.5px solid var(--bd);
  background: var(--bg);
  color: var(--tx);
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--bl); background: #fff; }
select.form-input {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%232D38C5' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px;
}

/* Resumen de cierre de año */
.rollover-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: var(--r); margin-bottom: 10px;
}
.rollover-row.closed { background: var(--gn-l); border: 1px solid #C5E8D5; }
.rollover-row.open   { background: var(--bl-l); border: 1px solid var(--bl-m); }
.rollover-n {
  font-size: 22px; font-weight: 700;
}
.rollover-row.closed .rollover-n { color: var(--gn); }
.rollover-row.open .rollover-n   { color: var(--bl); }
.rollover-list {
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--bd);
  border-radius: var(--r);
}
.rollover-list-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--bd);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}
.rollover-list-item:last-child { border-bottom: none; }

/* PIN modal */
.pin-input {
  letter-spacing: .35em;
  text-align: center;
  font-size: 22px;
}
.pin-error {
  font-size: 12px;
  color: var(--rd);
  text-align: center;
  margin-top: 8px;
  min-height: 16px;
}

/* ---------------------------------------------------------------------------
   Toast
--------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--tx);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in .25s ease;
  max-width: 320px;
}
.toast.ok    { background: var(--gn); }
.toast.error { background: var(--rd); }
.toast.fade  { animation: toast-out .25s ease forwards; }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateY(20px); opacity: 0; }
}

/* ---------------------------------------------------------------------------
   Loader
--------------------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--bl-m);
  border-top-color: var(--bl);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.full-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  flex-direction: column;
  gap: 12px;
  color: var(--tx3);
  font-size: 13px;
}
.full-loader .spinner { width: 28px; height: 28px; border-width: 3px; }

/* ---------------------------------------------------------------------------
   Responsive — tablet
--------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .app-shell { box-shadow: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------------------
   Responsive — móvil vertical
--------------------------------------------------------------------------- */
@media (max-width: 768px) {
  body { font-size: 13px; }

  /* Topbar más compacto, dos filas si hace falta */
  .top {
    padding: 8px 14px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .top .logo { height: 28px; }
  .top .tr   { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .user-chip {
    padding: 4px 10px;
    font-size: 11px;
  }
  .user-chip b { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mode-btn { font-size: 11px; padding: 5px 10px; }
  .year-arrow { width: 26px; height: 26px; font-size: 13px; }
  .year-label { font-size: 13px; min-width: 44px; }
  .close-year-btn { font-size: 11px; padding: 5px 10px; }

  /* Tabs con scroll horizontal real */
  .tabs { padding: 0 8px; }
  .tab  { padding: 10px 12px; font-size: 12px; }
  .tabs::-webkit-scrollbar { display: none; }

  /* Header de FL apilado */
  .fl-header {
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .kpis { gap: 14px; }

  /* Filtro de fechas: stacks */
  .date-filter      { padding: 10px 14px; }
  .summary .date-filter { padding: 0 0 14px; }
  .date-filter-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .date-chip { flex: 0 0 auto; }
  .date-field {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 4px 8px;
  }
  .date-field input { min-width: 0; width: 100%; font-size: 12px; }
  .date-clear { flex: 0 0 100%; text-align: center; }

  /* Buscador apilado */
  .fl-search {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .fl-search input {
    flex: 1 1 100%;
    min-width: 0;
    order: -1;
  }
  .fl-search .filter-chip {
    font-size: 11px;
    padding: 5px 10px;
  }

  /* KPI cards: 2 columnas */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 18px; }

  /* Resumen + config: padding reducido */
  .summary, .config { padding: 14px; }

  /* Tabla por Fan Líder: cabeceras más compactas, scroll horizontal */
  table.summary-tbl th { padding: 8px 10px; font-size: 9px; }
  table.summary-tbl td { padding: 8px 10px; font-size: 12px; }

  /* Tabla de proyectos sigue con scroll horizontal (es lo correcto) */
  table.projects { min-width: 980px; }

  /* Formularios y modales 1 columna */
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; gap: 10px; }
  .form-field .full-col { grid-column: span 1; }
  .modal {
    padding: 18px;
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    align-self: flex-end;
  }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-title { font-size: 15px; }

  /* Config Fan Líder card: acciones envuelven */
  .fl-card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .fl-card-head > div:last-child { width: 100%; }

  /* Items del catálogo: apilado vertical */
  .config-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }
  .config-item .item-name { width: 100%; }
  .config-item .item-actions { width: 100%; justify-content: flex-end; }
  .config-add { flex-wrap: wrap; }
  .config-add input { flex: 1 1 100%; }

  /* Audit log table: solo scroll horizontal cuando hace falta */
  .audit-table { font-size: 11px; }
  .audit-table th, .audit-table td { padding: 6px 8px; }

  /* Toast adaptado al borde inferior del modal sheet */
  .toast-container { bottom: 14px; right: 14px; left: 14px; }
  .toast { max-width: none; }

  /* Píldoras y botones inline más compactos */
  .status-pill { font-size: 10px; padding: 3px 9px; }
  .ap-btn      { font-size: 10px; padding: 4px 9px; }
  .row-action  { font-size: 14px; padding: 4px 7px; }
}

/* ---------------------------------------------------------------------------
   Responsive — móvil pequeño
--------------------------------------------------------------------------- */
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .top .logo { height: 24px; }
  .user-chip { display: none; }
  .top .tr { gap: 4px; }
}
