/**
 * portal.css — Sistema visual de BAME (panel de administración, portal del cliente,
 * pantallas de acceso y base de la página pública).
 *
 * Reglas de diseño:
 *   Marca:      azul tinta para la barra lateral y las franjas oscuras, azul BAME para
 *               lo interactivo y un verde menta que solo vive en el logotipo.
 *   Lectura:    títulos en Bricolage Grotesque y todo lo demás en Hanken Grotesk,
 *               cifras tabulares alineadas a la derecha.
 *   Superficie: tarjetas con borde fino y esquinas cortas sobre un gris azulado; las
 *               tablas llevan encabezado con banda, como un programa contable.
 *   Color:      verde y rojo solo para significado (ingreso / error), nunca decoración.
 *   Tacto:      controles de 40 px (44 en pantallas táctiles), foco visible, tema
 *               oscuro opcional, movimiento mínimo.
 *
 * ESTRUCTURA: 1) Tokens  2) Base  3) Shell  4) Página  5) Componentes  6) Formularios
 *             7) Carga de archivos  8) Acceso  9) Ajustes a librerías  10) Portal del cliente
 */

/* =====================================================================
   1) TOKENS
   ===================================================================== */
:root {
  color-scheme: light;

  /* Claro suave: ni el fondo ni las tarjetas son blanco puro, para no deslumbrar */
  --bg: #E3E8EE;
  --surface: #F6F8FA;
  --fill: rgba(15, 37, 66, .07);
  --fill-strong: rgba(15, 37, 66, .13);
  --separator: rgba(15, 37, 66, .15);
  --shadow: 0 1px 2px rgba(15, 37, 66, .06);

  --label: #14213A;
  --label-2: #46536B;
  --label-3: #596680;

  /* Marca */
  --ink: #0F2542;
  --accent: #17B890;
  --tint: #1B56D3;
  --tint-hover: #1648B8;
  --tint-text: #174BBA;
  --tint-soft: rgba(27, 86, 211, .09);
  --focus: rgba(27, 86, 211, .4);

  /* Barra lateral: siempre azul tinta, en claro y en oscuro */
  --side-bg: #0F2542;
  --side-text: #E4EAF3;
  --side-muted: #94A5BF;
  --side-fill: rgba(255, 255, 255, .07);
  --side-fill-strong: rgba(255, 255, 255, .14);
  --side-line: rgba(255, 255, 255, .13);

  --green: #13703F;
  --green-fill: #1E9E5A;
  --green-soft: rgba(30, 158, 90, .13);
  --red: #B8281F;
  --red-fill: #D33A2F;
  --red-soft: rgba(211, 58, 47, .1);
  --orange: #9A4D00;

  /* Series de las gráficas (validadas para daltonismo y contraste en cada modo) */
  --chart-1: #1B56D3;
  --chart-2: #E8590C;

  --radius-s: 4px;
  --radius-m: 6px;
  --radius-l: 10px;

  /* Dos familias: Hanken Grotesk para texto, controles y cifras (tiene cifras tabulares);
     Bricolage Grotesque solo para títulos y el nombre de la marca. */
  --font: 'Hanken Grotesk', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', 'Segoe UI', system-ui, sans-serif;

  /* Bootstrap hereda los mismos tokens (rejilla, utilidades, offcanvas) */
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--label);
  --bs-body-font-family: var(--font);
  --bs-secondary-color: var(--label-2);
  --bs-border-color: var(--separator);
  --bs-link-color-rgb: 23, 75, 186;
  --bs-link-hover-color-rgb: 23, 75, 186;
}

/* Modo oscuro: opcional. Lo elige el usuario en el menú (Claro / Oscuro / Auto);
   el atributo lo pone un script mínimo en el <head> antes de pintar la página. */
@media all {
  :root[data-tema="oscuro"] {
    color-scheme: dark;
    --bg: #0B1420;
    --surface: #142033;
    --fill: rgba(160, 185, 225, .1);
    --fill-strong: rgba(160, 185, 225, .18);
    --separator: rgba(160, 185, 225, .2);
    --shadow: none;

    --label: #EEF2F8;
    --label-2: #A9B6CA;
    --label-3: #8794AB;

    --tint: #2B63DB;
    --tint-hover: #3A70E6;
    --tint-text: #86ACFF;
    --tint-soft: rgba(76, 134, 245, .16);
    --focus: rgba(134, 172, 255, .55);

    --side-bg: #08101B;

    --green: #4CC78C;
    --green-fill: #2FAE6E;
    --green-soft: rgba(47, 174, 110, .16);
    --red: #FF7A70;
    --red-fill: #E5483D;
    --red-soft: rgba(229, 72, 61, .16);
    --orange: #F0A23B;

    --chart-1: #4C86F5;
    --chart-2: #E0702A;

    --bs-link-color-rgb: 134, 172, 255;
    --bs-link-hover-color-rgb: 134, 172, 255;
  }
}

/* =====================================================================
   2) BASE
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; }

body.bame-app, body.bame-auth {
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font); color: var(--label); }
.bame-title, .bame-auth-title, .bame-auth-show-title, .bame-brand, .bame-section-title { font-family: var(--font-display); }

a { color: var(--tint-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--tint); color: #fff; }
input, textarea { caret-color: var(--tint); }
* { scrollbar-width: thin; scrollbar-color: var(--fill-strong) transparent; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Cifras: siempre tabulares para que las columnas de dinero se alineen */
.bame-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.bame-muted { color: var(--label-2); }
.bame-pos { color: var(--green); }
.bame-neg { color: var(--red); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* =====================================================================
   3) SHELL — barra lateral + contenido
   ===================================================================== */
.bame-shell { display: flex; min-height: 100vh; }

.bame-sidebar {
  --bs-offcanvas-bg: var(--side-bg);
  --bs-offcanvas-width: 280px;
  width: 244px;
  flex-shrink: 0;
  background: var(--side-bg) !important; /* Bootstrap pone transparente el offcanvas-lg en escritorio */
  color: var(--side-text);
  padding: 22px 12px 16px;
  scrollbar-color: var(--side-fill-strong) transparent;
  display: flex;
  flex-direction: column;
}
@media (min-width: 992px) {
  .bame-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}

.bame-sidebar-brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; margin-bottom: 28px;
}
.bame-sidebar .bame-brand, .bame-mobilebar .bame-brand { color: #fff; }
.bame-sidebar .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.bame-brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); font-weight: 800; font-size: 20px; letter-spacing: .01em; line-height: 1;
  font-variation-settings: 'wdth' 88;
}
:root[data-tema="oscuro"] .bame-brand { color: var(--label); }
.bame-brand:hover { text-decoration: none; }
/* Logotipo: una mariposa de un solo trazo y BAME en letras del mismo trazo. Ambos toman
   el color del texto que los rodea; el punto de la mariposa y la barra de la A, que sube
   como una gráfica, van en verde menta. El dibujo vive en views/layout/_marca.php y _logo.php. */
.bame-mark { display: inline-block; flex-shrink: 0; height: 32px; width: auto; color: inherit; }
.bame-word {
  display: inline-block; flex-shrink: 0; height: 22px; width: auto; overflow: visible;
  fill: none; stroke: currentColor; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round;
}

.bame-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.bame-nav-label {
  font-size: 12px; font-weight: 600; color: var(--side-muted);
  padding: 0 10px; margin: 18px 0 6px;
}
.bame-nav-label:first-child { margin-top: 0; }
.bame-nav-link {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 6px 10px; border-radius: var(--radius-s);
  color: var(--side-text); font-size: 14px; font-weight: 500;
  transition: background-color .12s ease;
}
.bame-nav-link i { font-size: 16px; width: 20px; text-align: center; color: var(--side-muted); }
button.bame-nav-link { width: 100%; border: 0; background: transparent; font-family: var(--font); text-align: left; cursor: pointer; }
.bame-nav-link:hover { background: var(--side-fill); text-decoration: none; color: #fff; }
.bame-nav-link.active { background: var(--side-fill-strong); color: #fff; font-weight: 600; }
.bame-nav-link.active i { color: var(--accent); }
.bame-sidebar :focus-visible { outline-color: rgba(255, 255, 255, .7); }
@media (max-width: 991.98px) { .bame-nav-link { min-height: 44px; font-size: 16px; } }

.bame-sidebar-foot { border-top: 1px solid var(--side-line); padding-top: 14px; margin-top: 12px; }
.bame-user { display: flex; align-items: center; gap: 10px; padding: 4px 10px 10px; min-width: 0; }
.bame-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--side-fill-strong); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.bame-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.bame-user-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bame-user-role { font-size: 12px; color: var(--side-muted); }

.bame-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }


/* Barra superior: solo en móvil, para abrir el menú */
.bame-mobilebar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 8px;
  background: var(--side-bg);
}
.bame-mobilebar .bame-iconbtn { color: #fff; }
.bame-mobilebar .bame-iconbtn:hover { background: var(--side-fill); }
.bame-iconbtn {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--tint-text);
  border-radius: var(--radius-m); display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.bame-iconbtn:hover { background: var(--fill); }

.bame-main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 36px 72px; }
.bame-main.is-narrow { max-width: 880px; }
@media (max-width: 767.98px) { .bame-main { padding: 20px 16px 56px; } }

/* =====================================================================
   4) PÁGINA — título grande, subtítulo y acciones
   ===================================================================== */
.bame-back {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; margin-bottom: 8px; min-height: 28px;
}
.bame-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; margin-bottom: 28px;
}
.bame-title {
  font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; margin: 0; color: var(--ink);
}
:root[data-tema="oscuro"] .bame-title { color: var(--label); }
.bame-subtitle { font-size: 15px; color: var(--label-2); margin: 6px 0 0; max-width: 62ch; }
.bame-page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 767.98px) { .bame-title { font-size: 26px; } }

.bame-section-title { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin: 32px 0 12px; }

/* =====================================================================
   5) COMPONENTES
   ===================================================================== */

/* ---------- Tarjeta: superficie clara con borde fino ---------- */
.bame-card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  padding: 20px;
}
.bame-card + .bame-card { margin-top: 16px; }
.bame-card.is-flush { padding: 0; overflow: hidden; }
.bame-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.bame-card.is-flush > .bame-card-head { padding: 16px 20px 0; margin-bottom: 12px; }
.bame-card.is-flush > .bame-card-body { padding: 0 20px 12px; }
.bame-card.is-flush > .bame-card-body:empty { display: none; }
.bame-card-title { font-size: 16px; font-weight: 700; letter-spacing: 0; margin: 0; }
.bame-card-note { font-size: 13px; color: var(--label-2); margin: 2px 0 0; }

/* ---------- Cifras resumen: una sola tarjeta dividida por líneas ---------- */
.bame-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); padding: 0; overflow: hidden; }
.bame-stat { padding: 18px 20px; border-left: 1px solid var(--separator); min-width: 0; }
.bame-stat:first-child { border-left: 0; }
.bame-stat-label { display: block; font-size: 13px; font-weight: 500; color: var(--label-2); }
.bame-stat-value {
  display: block; font-size: 27px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere;
}
.bame-stat-foot { display: block; font-size: 13px; color: var(--label-2); margin-top: 4px; }

/* Proporción egresos / ingresos: una línea bajo las cifras del periodo */
@media (min-width: 768px) { .bame-stats.is-3 { grid-template-columns: repeat(3, 1fr); } }
/* Cuatro cifras: 2 × 2 en pantallas medianas, en una fila en las grandes */
@media (min-width: 768px) {
  .bame-stats.is-4 { grid-template-columns: repeat(2, 1fr); }
  .bame-stats.is-4 .bame-stat:nth-child(3) { border-left: 0; }
  .bame-stats.is-4 .bame-stat:nth-child(n+3):nth-child(-n+4) { border-top: 1px solid var(--separator); }
}
@media (min-width: 1200px) {
  .bame-stats.is-4 { grid-template-columns: repeat(4, 1fr); }
  .bame-stats.is-4 .bame-stat:nth-child(3) { border-left: 1px solid var(--separator); }
  .bame-stats.is-4 .bame-stat:nth-child(n+3):nth-child(-n+4) { border-top: 0; }
  .bame-stats.is-4 .bame-stat-value { font-size: 24px; }
}
/* Cinco cifras: 3 + 2 en pantallas medianas, en una fila en las grandes */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .bame-stats.is-5 { grid-template-columns: repeat(3, 1fr); }
  .bame-stats.is-5 .bame-stat:nth-child(4) { border-left: 0; }
  .bame-stats.is-5 .bame-stat:nth-child(n+4):nth-child(-n+5) { border-top: 1px solid var(--separator); }
}
@media (min-width: 1200px) {
  .bame-stats.is-5 { grid-template-columns: repeat(5, 1fr); }
  .bame-stats.is-5 .bame-stat { padding: 18px 16px; }
  .bame-stats.is-5 .bame-stat-value { font-size: 22px; }
}
.bame-ratio { grid-column: 1 / -1; padding: 14px 20px 16px; border-top: 1px solid var(--separator); }
.bame-ratio-bar { display: flex; gap: 2px; height: 8px; border-radius: 2px; overflow: hidden; background: var(--fill); }
.bame-ratio-bar > span { display: block; height: 100%; min-width: 2px; }
.bame-ratio-text { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--label-2); margin-top: 8px; }
.bame-ratio-text span { display: inline-flex; align-items: center; gap: 6px; }
.bame-ratio-text i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
@media (max-width: 767.98px) {
  .bame-stats { grid-template-columns: 1fr; }
  .bame-stat { border-left: 0; border-top: 1px solid var(--separator); padding: 14px 16px; }
  .bame-stat:first-child { border-top: 0; }
  .bame-stat-value { font-size: 24px; }
}

/* ---------- Lista agrupada (filas con separador) ---------- */
.bame-list { list-style: none; margin: 0; padding: 0; }
.bame-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 20px; color: var(--label);
  position: relative;
}
.bame-list > li + li > .bame-row::before, .bame-list > .bame-row + .bame-row::before {
  content: ''; position: absolute; top: 0; left: 20px; right: 0; height: 1px; background: var(--separator);
}
a.bame-row:hover { background: var(--fill); text-decoration: none; }
.bame-row-icon { font-size: 20px; width: 24px; text-align: center; color: var(--tint-text); flex-shrink: 0; }
.bame-row-main { flex: 1; min-width: 0; }
.bame-row-title { display: block; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.bame-row-sub { display: block; font-size: 13px; color: var(--label-2); }
.bame-row-trail { display: flex; align-items: center; gap: 8px; color: var(--label-2); font-size: 14px; flex-shrink: 0; }
.bame-chevron { color: var(--label-3); font-size: 13px; }

/* Pares etiqueta / valor (datos bancarios, montos) */
.bame-kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 6px 0; border-top: 1px solid var(--separator); }
.bame-kv:first-child { border-top: 0; }
.bame-kv-label { color: var(--label-2); font-size: 14px; flex-shrink: 0; }
.bame-kv-value { font-size: 15px; font-weight: 500; text-align: right; overflow-wrap: anywhere; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Botones ---------- */
.bame-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border: 1px solid var(--separator); border-radius: var(--radius-m);
  font-family: var(--font); font-size: 15px; font-weight: 600; line-height: 1;
  background: var(--surface); color: var(--label); cursor: pointer; white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, transform .08s ease;
}
.bame-btn:hover { background: var(--fill); border-color: var(--label-3); text-decoration: none; color: var(--label); }
.bame-btn:active { transform: translateY(1px); }
.bame-btn.is-primary { background: var(--tint); border-color: var(--tint); color: #fff; }
.bame-btn.is-primary:hover { background: var(--tint-hover); border-color: var(--tint-hover); color: #fff; }
.bame-btn.is-plain { background: transparent; border-color: transparent; color: var(--tint-text); padding: 0 10px; }
.bame-btn.is-plain:hover { background: var(--fill); border-color: transparent; color: var(--tint-text); }
.bame-btn.is-danger { color: var(--red); }
.bame-btn.is-sm { min-height: 32px; padding: 0 12px; font-size: 14px; border-radius: var(--radius-s); }
@media (pointer: coarse) { .bame-btn { min-height: 44px; } }
.bame-btn.is-block { width: 100%; }
.bame-btn:disabled, .bame-btn[aria-disabled="true"] { opacity: .4; cursor: default; pointer-events: none; }
/* En pantallas táctiles los botones pequeños conservan el objetivo de 44 px */
@media (pointer: coarse) { .bame-btn.is-sm { min-height: 44px; } }

/* ---------- Control segmentado ---------- */
.bame-segmented { display: inline-flex; border: 1px solid var(--separator); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.bame-segmented button {
  border: 0; border-left: 1px solid var(--separator); background: transparent; color: var(--label-2); font-family: var(--font);
  font-size: 13px; font-weight: 600; min-height: 32px; padding: 0 14px; cursor: pointer;
}
.bame-segmented button:first-child { border-left: 0; }
.bame-segmented button:hover { background: var(--fill); color: var(--label); }
.bame-segmented button[aria-pressed="true"] { background: var(--tint-soft); color: var(--tint-text); }
.bame-segmented button:focus-visible { outline-offset: -3px; }
@media (pointer: coarse) { .bame-segmented button { min-height: 40px; } }

/* ---------- Estado: punto + texto (nunca solo color) ---------- */
.bame-status {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; line-height: 1; color: var(--label-2);
  background: var(--fill); border-radius: var(--radius-s); padding: 5px 8px;
}
.bame-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--label-3); flex-shrink: 0; }
.bame-status.is-ok { color: var(--green); background: var(--green-soft); }
.bame-status.is-ok::before { background: var(--green-fill); }
.bame-status.is-off::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--label-3); }
.bame-status.is-warn { color: var(--orange); background: rgba(232, 89, 12, .1); }
.bame-status.is-warn::before { background: var(--orange); }

/* Pagos de servicios BAME: saldo en el portal y estado del pago en el detalle del periodo */
.bame-saldo { font-size: 20px; font-weight: 700; }
.bame-kv.is-sub { min-height: 32px; padding: 2px 0 2px 12px; border-top: 0; }
.bame-kv.is-sub .bame-kv-label, .bame-kv.is-sub .bame-kv-value { font-size: 13px; color: var(--label-2); font-weight: 400; }
.bame-pago {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--separator);
}
.bame-pago-texto { display: flex; flex-direction: column; min-width: 0; flex: 1 1 240px; }
.bame-pago .bame-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Avisos ---------- */
.bame-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius-m); margin-bottom: 16px;
  background: var(--fill); color: var(--label); font-size: 14px;
}
.bame-alert > i { font-size: 17px; line-height: 1.3; flex-shrink: 0; color: var(--label-2); }
.bame-alert.is-success { background: var(--green-soft); }
.bame-alert.is-success > i { color: var(--green); }
.bame-alert.is-error { background: var(--red-soft); }
.bame-alert.is-error > i { color: var(--red); }
.bame-alert ul { margin: 4px 0 0; padding-left: 18px; }
.bame-alert strong { font-weight: 600; }

/* ---------- Tablas ---------- */
.bame-table-wrap { overflow-x: auto; }
.bame-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.bame-table th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--label-2);
  padding: 9px 12px; background: var(--fill); white-space: nowrap;
  border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator);
}
.bame-table tbody tr:hover td { background: var(--fill); }
.bame-table td { padding: 12px; border-bottom: 1px solid var(--separator); vertical-align: middle; }
.bame-table tbody tr:last-child td { border-bottom: 0; }
.bame-table th:first-child, .bame-table td:first-child { padding-left: 20px; }
.bame-table th:last-child, .bame-table td:last-child { padding-right: 20px; }
.bame-table .is-end { text-align: right; }
.bame-table tfoot td { border-top: 2px solid var(--label-3); border-bottom: 0; font-weight: 700; }
/* Varios renglones de totales: solo el primero visible lleva la línea gruesa. */
.bame-table tfoot tr:not([hidden]) ~ tr td { border-top: 1px solid var(--separator); }
.bame-table-date { color: var(--label-2); white-space: nowrap; width: 1%; }
.bame-table-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }

.bame-empty { padding: 36px 20px; text-align: center; color: var(--label-2); }
.bame-empty-title { display: block; color: var(--label); font-size: 17px; font-weight: 600; margin-bottom: 4px; }

/* ---------- Progreso ---------- */
.bame-progress { height: 6px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.bame-progress > span { display: block; height: 100%; border-radius: 2px; background: var(--tint); }
.bame-progress.is-done > span { background: var(--green-fill); }

/* ---------- Gráficas ---------- */
.bame-chart { position: relative; height: 240px; }
.bame-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--label-2); }
.bame-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bame-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* =====================================================================
   6) FORMULARIOS
   ===================================================================== */
.bame-field { margin-bottom: 18px; }
.bame-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--label); }
.bame-label small { font-weight: 400; color: var(--label-2); font-size: 13px; }
.bame-hint { font-size: 13px; color: var(--label-2); margin-top: 6px; }

.bame-input {
  display: block; width: 100%; min-height: 42px; padding: 8px 12px;
  font-family: var(--font); font-size: 16px; line-height: 1.4; color: var(--label);
  background: var(--surface); border: 1px solid var(--label-3); border-radius: var(--radius-m);
  box-shadow: inset 0 0 0 1px transparent;
  transition: border-color .12s ease, box-shadow .12s ease;
  appearance: none; -webkit-appearance: none;
}
:root:not([data-tema="oscuro"]) .bame-input { background-color: #FCFDFE; }
:root[data-tema="oscuro"] .bame-input { background-color: var(--bg); }
@media (pointer: coarse) { .bame-input { min-height: 44px; } }
.bame-input::placeholder { color: var(--label-3); }
.bame-input:focus { outline: 0; border-color: var(--tint); box-shadow: 0 0 0 3px var(--focus); }
.bame-input.is-invalid { border-color: var(--red-fill); }
select.bame-input {
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23596680' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.bame-input.is-code { text-align: center; font-size: 24px; letter-spacing: .3em; font-variant-numeric: tabular-nums; padding-left: calc(12px + .3em); }

/* Campo de dinero: prefijo "$" dentro del campo, cifra alineada a la derecha */
.bame-money { position: relative; }
.bame-money > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--label-2); font-size: 16px; pointer-events: none; }
.bame-money .bame-input { padding-left: 28px; text-align: right; font-variant-numeric: tabular-nums; }

/* Selector de meses (honorarios): una caja dividida por líneas de 1 px, cada mes es una casilla */
fieldset.bame-field { border: 0; padding: 0; min-width: 0; }
.bame-meses-atajos { display: inline-flex; gap: 2px; margin-right: -10px; }
.bame-mesesel {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; margin-top: 8px;
  background: var(--separator); border: 1px solid var(--label-3); border-radius: var(--radius-m); overflow: hidden;
}
@media (max-width: 575.98px) { .bame-mesesel { grid-template-columns: repeat(4, 1fr); } }
.bame-mesesel label { position: relative; margin: 0; cursor: pointer; }
.bame-mesesel input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.bame-mesesel span {
  display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px;
  background: var(--surface); color: var(--label-2); font-size: 14px; font-weight: 500;
  transition: background-color .12s ease, color .12s ease;
}
.bame-mesesel abbr { text-decoration: none; cursor: inherit; }
.bame-mesesel label:hover span { background: var(--fill); color: var(--label); }
.bame-mesesel input:checked + span { background: linear-gradient(var(--tint-soft), var(--tint-soft)), var(--surface); color: var(--tint-text); font-weight: 600; }
.bame-mesesel input:checked + span::before { content: '\2713'; font-size: 12px; }
.bame-mesesel input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
@media (pointer: coarse) { .bame-mesesel span { min-height: 44px; } }

/* Campo con botón dentro (mostrar contraseña, limpiar) */
.bame-input-wrap { position: relative; }
.bame-input-wrap .bame-input { padding-right: 46px; }
.bame-input-btn {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; background: transparent; color: var(--label-2);
  border-radius: var(--radius-s); display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.bame-input-btn:hover { color: var(--label); }

/* Buscador con lupa */
.bame-search { position: relative; }
.bame-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--label-3); pointer-events: none; }
.bame-search .bame-input { padding-left: 36px; }
.bame-search.is-compact .bame-input { min-height: 36px; padding-top: 5px; padding-bottom: 5px; font-size: 15px; }
@media (pointer: coarse) { .bame-search.is-compact .bame-input { min-height: 44px; font-size: 16px; } }

.bame-form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 24px; }

/* Lista de resultados del buscador de cliente */
.bame-combo { position: relative; }
.bame-combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--separator); border-radius: var(--radius-m);
  box-shadow: 0 10px 28px rgba(15, 37, 66, .16); padding: 4px; max-height: 300px; overflow-y: auto;
  list-style: none; margin: 0;
}
.bame-combo-list:empty { display: none; }
.bame-combo-option { padding: 10px 12px; border-radius: var(--radius-s); cursor: pointer; font-size: 15px; display: flex; justify-content: space-between; gap: 12px; }
.bame-combo-option small { color: var(--label-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.bame-combo-option[aria-selected="true"] { background: var(--tint); color: #fff; }
.bame-combo-option[aria-selected="true"] small { color: rgba(255, 255, 255, .85); }
.bame-combo-empty { padding: 10px 12px; color: var(--label-2); font-size: 14px; }

/* =====================================================================
   7) CARGA DE ARCHIVOS — pasos del periodo
   ===================================================================== */
.bame-step-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.bame-step-check { font-size: 22px; line-height: 1.15; color: var(--label-3); flex-shrink: 0; }
.bame-step.is-done .bame-step-check { color: var(--green-fill); }
.bame-step-text { flex: 1; min-width: 0; }
.bame-step-body { padding-left: 34px; }
@media (max-width: 575.98px) { .bame-step-body { padding-left: 0; } }

.bame-drop {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 72px; padding: 14px 16px; cursor: pointer;
  border: 1.5px dashed var(--label-3); border-radius: var(--radius-m);
  transition: border-color .12s ease, background-color .12s ease;
}
.bame-drop:hover, .bame-drop.is-over { border-color: var(--tint); background: var(--tint-soft); }
.bame-drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.bame-drop.has-file { border-style: solid; border-color: var(--tint); }
.bame-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.bame-drop-icon { font-size: 24px; color: var(--tint-text); flex-shrink: 0; }
.bame-drop-text { flex: 1; min-width: 0; }
.bame-drop-title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bame-drop-sub { display: block; font-size: 13px; color: var(--label-2); }

/* Archivo ya cargado */
.bame-file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--fill); border-radius: var(--radius-m); margin-bottom: 12px; }
.bame-file > i { font-size: 22px; color: var(--label-2); }
.bame-file-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Documentos de un periodo: un renglón por archivo con sus acciones (admin y portal) */
.bame-subhead { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 600; margin: 24px 0 8px; padding-top: 16px; border-top: 1px solid var(--separator); }
.bame-subhead .bame-muted { font-weight: 400; font-size: 13px; }
.bame-docs { border: 1px solid var(--separator); border-radius: var(--radius-m); overflow: hidden; }
.bame-doc { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--separator); min-height: 56px; }
.bame-doc:first-child { border-top: 0; }
.bame-doc-icon { font-size: 20px; color: var(--label-3); flex-shrink: 0; }
.bame-doc.is-listo .bame-doc-icon { color: var(--green-fill); }
.bame-doc-main { flex: 1; min-width: 0; }
.bame-doc-title { display: block; font-size: 15px; font-weight: 500; }
.bame-doc-sub { display: block; font-size: 13px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bame-doc-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.bame-doc-actions form { margin: 0; }
.bame-doc-subir { cursor: pointer; }
.bame-doc-subir:focus-within { outline: 2px solid var(--tint); outline-offset: 2px; }
.bame-doc-subir.is-cargando { opacity: .6; pointer-events: none; }
@media (max-width: 575.98px) {
  .bame-doc { flex-wrap: wrap; }
  .bame-doc-actions { width: 100%; padding-left: 32px; }
}

/* Formato esperado del Excel, mostrado como la hoja misma */
.bame-sheet { border: 1px solid var(--separator); border-radius: var(--radius-s); overflow: hidden; font-size: 13px; margin-top: 8px; }
.bame-sheet table { width: 100%; border-collapse: collapse; }
.bame-sheet th { background: var(--fill); font-weight: 600; text-align: left; }
.bame-sheet th, .bame-sheet td { padding: 6px 10px; border-left: 1px solid var(--separator); white-space: nowrap; }
.bame-sheet th:first-child, .bame-sheet td:first-child { border-left: 0; }
.bame-sheet td { border-top: 1px solid var(--separator); color: var(--label-2); font-variant-numeric: tabular-nums; }

details.bame-disclosure > summary {
  list-style: none; cursor: pointer; color: var(--tint-text); font-size: 14px;
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px;
}
details.bame-disclosure > summary::-webkit-details-marker { display: none; }
details.bame-disclosure > summary::before { content: '\203A'; display: inline-block; transition: transform .15s ease; font-size: 16px; }
details.bame-disclosure[open] > summary::before { transform: rotate(90deg); }

/* =====================================================================
   8) ACCESO — a la izquierda, el producto (una muestra de lo que el cliente verá
      al entrar); a la derecha, el formulario. En móvil solo queda el formulario.
   ===================================================================== */
body.bame-auth { min-height: 100vh; background: var(--surface); }
.bame-auth-split { display: flex; min-height: 100vh; }
.bame-auth-pane { flex: 1; min-width: 0; display: flex; background: var(--surface); }
.bame-auth-wrap { flex: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; }
.bame-auth-card { width: 100%; max-width: 360px; }
.bame-auth-head { margin-bottom: 28px; }
.bame-auth-head .bame-mark { display: block; height: 44px; margin-bottom: 20px; color: var(--ink); }
:root[data-tema="oscuro"] .bame-auth-head .bame-mark { color: var(--label); }
@media (min-width: 992px) { .bame-auth-head .bame-mark { display: none; } }

.bame-auth-show {
  display: none; flex: 1.15; min-width: 0; flex-direction: column;
  background: var(--side-bg); color: var(--side-text); padding: 40px 64px 0; overflow: hidden; height: 100vh; position: sticky; top: 0;
  align-items: center;
}
.bame-auth-show .bame-brand { color: #fff; }
.bame-auth-show .bame-auth-show-title { color: #fff; }
.bame-auth-show .bame-auth-show-text { color: var(--side-muted); }
@media (min-width: 992px) { .bame-auth-show { display: flex; } }
.bame-auth-show-title {
  font-size: clamp(34px, 3.2vw, 50px); line-height: 1.08; font-weight: 700; letter-spacing: -0.02em;
  margin: 0; padding-top: clamp(48px, 14vh, 160px);
}
.bame-auth-show-text { font-size: 19px; line-height: 1.4; color: var(--label-2); margin: 16px 0 48px; }
.bame-auth-show > * { width: 100%; max-width: 600px; }
.bame-auth-show-title, .bame-auth-show-text { text-wrap: balance; }

/* Muestra del portal: misma tarjeta y mismas filas que la pantalla real */
.bame-auth-preview {
  background: var(--surface); color: var(--label); border: 1px solid var(--separator); border-radius: 12px; padding: 22px 0 8px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(8, 20, 38, .22); margin-bottom: 0; flex-shrink: 0;
}
.bame-auth-preview-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 24px 16px; }
.bame-auth-preview-head strong { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
:root[data-tema="oscuro"] .bame-auth-preview-head strong { color: var(--label); }
.bame-auth-preview .bame-table tbody tr:hover td { background: transparent; }
.bame-auth-preview-head span { font-size: 13px; color: var(--label-3); }
.bame-auth-preview .bame-stats { border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); border-radius: 0; grid-template-columns: repeat(3, 1fr); }
.bame-auth-preview .bame-ratio { padding-left: 24px; padding-right: 24px; }
.bame-auth-preview .bame-stat { padding: 14px 16px 14px 24px; }
.bame-auth-preview .bame-stat-value { font-size: 20px; }
.bame-auth-preview .bame-table td { padding-top: 11px; padding-bottom: 11px; }
.bame-auth-preview .bame-table th:first-child, .bame-auth-preview .bame-table td:first-child { padding-left: 24px; }
.bame-auth-preview .bame-table td:last-child { padding-right: 24px; }
.bame-auth-title { font-size: 28px; font-weight: 700; letter-spacing: -0.015em; margin: 0; color: var(--ink); }
:root[data-tema="oscuro"] .bame-auth-title { color: var(--label); }
.bame-auth-sub { color: var(--label-2); font-size: 15px; margin: 6px 0 0; }
.bame-auth-links { margin-top: 20px; font-size: 14px; }
.bame-auth-foot { width: 100%; max-width: 360px; margin: 40px 0 0; font-size: 12px; color: var(--label-3); }

/* Selector de apariencia en la barra lateral */
.bame-tema { display: flex; margin: 0 10px 12px; }
.bame-tema button { flex: 1; padding: 0 6px; min-height: 30px; }
.bame-sidebar .bame-segmented { background: transparent; border-color: var(--side-line); }
.bame-sidebar .bame-segmented button { color: var(--side-muted); border-color: var(--side-line); }
.bame-sidebar .bame-segmented button:hover { background: var(--side-fill); color: #fff; }
.bame-sidebar .bame-segmented button[aria-pressed="true"] { background: var(--side-fill-strong); color: #fff; }

.bame-qr { width: 206px; height: 206px; padding: 8px; background: #fff; border-radius: var(--radius-m); margin: 0 auto 12px; }
.bame-secret { font-family: var(--font); font-variant-numeric: tabular-nums; font-size: 14px; letter-spacing: .04em; word-break: break-all; }

/* =====================================================================
   9) AJUSTES A LIBRERÍAS
   ===================================================================== */
.btn-close { opacity: .6; }
:root[data-tema="oscuro"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

.swal2-popup { font-family: var(--font); background: var(--surface) !important; color: var(--label) !important; border-radius: var(--radius-l) !important; }
.swal2-title { font-size: 19px !important; font-weight: 600 !important; color: var(--label) !important; }
.swal2-html-container { font-size: 15px !important; color: var(--label-2) !important; }
.swal2-styled { border-radius: var(--radius-m) !important; font-size: 15px !important; font-weight: 500 !important; box-shadow: none !important; }
.swal2-styled.swal2-cancel { background: var(--fill) !important; color: var(--label) !important; }

/* =====================================================================
   10) PORTAL DEL CLIENTE — distribución
   Columna principal (resumen, movimientos, gráfica + periodos) y un riel fijo
   a la derecha (pagos, cuenta, documentos). Aprovecha pantallas anchas sin
   estirar las líneas de texto.
   ===================================================================== */
.bame-main.is-wide { max-width: 1600px; }
.bame-portal-grid { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 26vw, 440px); gap: 16px; align-items: start; }
.bame-portal-main, .bame-portal-rail { min-width: 0; }
.bame-portal-par { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.bame-portal-par > .bame-card { margin-top: 0; }
.bame-portal-par > .bame-card:only-child { grid-column: 1 / -1; }
.bame-historial { max-height: 300px; overflow-y: auto; }
.bame-table tr.is-actual td { background: var(--tint-soft); }
.bame-table tr.is-actual td:first-child { font-weight: 600; }
@media (min-width: 992px) { .bame-portal-rail { position: sticky; top: 24px; } }
@media (max-width: 1299.98px) { .bame-portal-par { grid-template-columns: 1fr; } }
@media (max-width: 991.98px) { .bame-portal-grid { grid-template-columns: 1fr; } }

/* En monitores muy anchos el texto y las cifras crecen un punto para no verse perdidos */
@media (min-width: 1800px) {
  .bame-main.is-wide { padding-left: 56px; padding-right: 56px; }
  .bame-main.is-wide .bame-table, .bame-main.is-wide .bame-kv-value { font-size: 16px; }
  .bame-main.is-wide .bame-stat-value { font-size: 34px; }
  .bame-main.is-wide .bame-stat { padding: 22px 24px; }
  .bame-main.is-wide .bame-table td { padding-top: 14px; padding-bottom: 14px; }
  .bame-main.is-wide .bame-chart { height: 300px; }
  .bame-main.is-wide .bame-historial { max-height: 360px; }
}

/* ---------- Selector de periodo: año + "Todo el año" + 12 meses ---------- */
.bame-periodos { display: flex; align-items: center; gap: 12px; margin: -8px 0 20px; flex-wrap: wrap; }
.bame-periodos select.bame-input { width: auto; min-width: 104px; font-weight: 600; background-color: var(--surface); }
.bame-meses { display: flex; background: var(--surface); border: 1px solid var(--separator); border-radius: var(--radius-m); box-shadow: var(--shadow); overflow-x: auto; max-width: 100%; }
.bame-mes {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  min-height: 40px; min-width: 54px; padding: 0 12px; border-left: 1px solid var(--separator);
  font-size: 14px; font-weight: 600; color: var(--label); white-space: nowrap;
}
.bame-mes:first-child { border-left: 0; }
a.bame-mes:hover { background: var(--fill); text-decoration: none; color: var(--label); }
a.bame-mes:focus-visible { outline-offset: -3px; }
.bame-mes.is-on, a.bame-mes.is-on:hover { background: var(--tint); color: #fff; }
.bame-mes.is-off { color: var(--label-3); font-weight: 400; cursor: default; }
.bame-mes.is-anual { padding: 0 16px; }
@media (pointer: coarse) { .bame-mes { min-height: 44px; } }

/* ---------- Nota del contador ---------- */
.bame-nota { display: flex; gap: 14px; align-items: flex-start; background: color-mix(in srgb, var(--tint) 7%, var(--surface)); border-color: color-mix(in srgb, var(--tint) 30%, transparent); }
.bame-nota > i { font-size: 20px; color: var(--tint-text); line-height: 1.2; flex-shrink: 0; }
.bame-nota p { margin: 4px 0 0; max-width: 78ch; }

/* ---------- Fecha límite de pago ---------- */
.bame-limite { flex-direction: column; align-items: flex-end; gap: 0; }
.bame-limite small { font-size: 13px; font-weight: 400; color: var(--label-2); }
.bame-limite.is-cerca small { color: var(--orange); font-weight: 600; }

/* ---------- Vista anual ---------- */
.bame-table tr.is-vacio td { color: var(--label-3); }
.bame-doc-links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
textarea.bame-input { min-height: 104px; resize: vertical; line-height: 1.5; }
