@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700;12..96,800&family=Hanken+Grotesk:wght@400;500;600;700;800&display=swap');

/* ============================================================================
   BIOCEÁNICA ERP · app.css  v3  —  Tema claro premium
   Deploy: ASSETS_V 118 · 29/07/2026
   ----------------------------------------------------------------------------
   Reemplaza por completo el app.css v2 (marino oscuro).

   NOTA DE COMPATIBILIDAD — leer antes de tocar los tokens:
   views.js tiene 429 atributos style="" inline y la mayoría usan var(--*)
   con los nombres VIEJOS (--card, --border, --accent, --text2, --muted2,
   --card-bg, --text-muted, --danger...). Si esos nombres desaparecen, se
   rompen 429 puntos del sistema de una sola vez.

   Por eso el bloque §2 mapea TODOS los nombres viejos sobre la paleta nueva.
   No borrar §2 hasta que views.js esté normalizado.
   ============================================================================ */


/* ═══ §1 · TOKENS — tema claro premium (default) ═══════════════════════════ */
:root {
  /* Superficies */
  --canvas:       #f4f5f8;
  --panel:        #ffffff;
  --panel-2:      #fafbfd;
  --panel-3:      #f7f8fa;
  --panel-dark:   #181a24;

  /* Rail lateral oscuro */
  --rail-a:       #15171f;
  --rail-b:       #0f1017;

  /* Tinta */
  --ink:          #14161d;
  --ink-2:        #4a4f5c;
  --ink-3:        #868c99;
  --ink-4:        #a8aeba;

  /* Hairlines — bordes suaves, nunca duros */
  --hairline:     #eaecf1;
  --hairline-2:   #eef0f3;
  --hairline-3:   #f2f4f7;

  /* Primary */
  --brand:        #4f46e5;
  --brand-dark:   #2a1fb0;
  --brand-tint:   rgba(79, 70, 229, .10);
  --brand-tint-2: rgba(79, 70, 229, .05);

  /* Marca — oro (logo, acento PRO) */
  --gold-a:       #e0a83a;
  --gold-b:       #c47f1c;
  --gold-grad:    linear-gradient(135deg, var(--gold-a), var(--gold-b));

  /* Semánticos */
  --ok:           #0f9d6a;   --ok-tint:     #e6f6ef;
  --bad:          #e5484d;   --bad-tint:    #fdeceb;
  --warn:         #d9922b;   --warn-tint:   #fbf1dd;
  --violet:       #7c3aed;   --violet-tint: #f2ecfe;
  --cyan:         #0891b2;   --cyan-tint:   #e2f4f8;

  /* Tipografía */
  --font:         'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', system-ui, sans-serif;
  --font-num:     var(--font-display);

  /* Radios */
  --r-panel:      20px;
  --r:            17px;
  --r-sm:         11px;
  --r-xs:         8px;
  --r-chip:       99px;

  /* Sombras suaves — el sistema usa sombra, no borde duro */
  --sh-1: 0 1px 2px rgba(20,22,29,.04), 0 1px 3px rgba(20,22,29,.03);
  --sh-2: 0 2px 8px rgba(20,22,29,.05), 0 8px 24px rgba(20,22,29,.05);
  --sh-3: 0 12px 40px rgba(20,22,29,.12);
  --sh-4: 0 24px 64px rgba(20,22,29,.18);
  --sh-rail: 2px 0 16px rgba(15,16,23,.10);

  /* Layout */
  --rail-w:       78px;
  --sidebar-w:    252px;   /* shell legacy, hasta migrar a rail */
  --bottomnav-h:  62px;
  --topbar-h:     66px;

  /* Motion */
  --ease:         cubic-bezier(.4, 0, .2, 1);
  --t-fast:       .13s var(--ease);
  --t:            .2s var(--ease);
}


/* ═══ §2 · CAPA DE COMPATIBILIDAD ═══════════════════════════════════════════
   Nombres viejos → paleta nueva. Sostiene los 429 inline styles de views.js.
   Borrar recién cuando views.js esté normalizado (deuda técnica separada).   */
:root {
  --bg:          var(--canvas);
  --bg2:         var(--panel-3);
  --card:        var(--panel);
  --card2:       var(--panel-3);
  --card-bg:     var(--panel);
  --surface:     var(--panel);
  --input-bg:    var(--panel);

  --border:      var(--hairline);
  --border2:     var(--hairline-2);

  --text:        var(--ink);
  --text2:       var(--ink-2);
  --muted:       var(--ink-3);
  --muted2:      var(--ink-3);
  --muted3:      var(--ink-4);
  --text-muted:  var(--ink-3);

  --accent:      var(--brand);
  --accent-s:    var(--brand-tint);
  --primary:     var(--brand);

  --green:       var(--ok);      --green-s:  var(--ok-tint);
  --red:         var(--bad);     --red-s:    var(--bad-tint);
  --amber:       var(--warn);    --amber-s:  var(--warn-tint);
  --violet-s:    var(--violet-tint);
  --danger:      var(--bad);
  --success:     var(--ok);
  --warning:     var(--warn);

  --mono:        var(--font);    /* JetBrains Mono retirado — ya no se carga */

  /* Tokens de medida heredados */
  --pad-page:    26px 32px 96px;
  --fs-title:    28px;
  --fw-title:    800;
  --btn-pad:     10px 17px;
  --btn-fs:      13.5px;
  --btn-r:       var(--r-sm);
  --input-h:     42px;
  --input-fs:    14px;
  --input-r:     var(--r-sm);
}


/* ═══ §3 · TEMA OSCURO (opcional, vía .bio-theme-toggle) ═══════════════════ */
:root[data-theme="dark"] {
  --canvas:      #0f1017;
  --panel:       #181a24;
  --panel-2:     #1c1f2a;
  --panel-3:     #1f2230;

  --ink:         #eef1f7;
  --ink-2:       #c4cad6;
  --ink-3:       #8b92a3;
  --ink-4:       #666d7d;

  --hairline:    #262a37;
  --hairline-2:  #2d3240;
  --hairline-3:  #333949;

  --brand:       #7c74f0;
  --brand-tint:  rgba(124,116,240,.16);

  --ok:   #34d399;  --ok-tint:     rgba(52,211,153,.14);
  --bad:  #fb7185;  --bad-tint:    rgba(251,113,133,.14);
  --warn: #fbbf24;  --warn-tint:   rgba(251,191,36,.14);
  --violet: #a78bfa; --violet-tint: rgba(167,139,250,.14);
  --cyan: #22d3ee;  --cyan-tint:   rgba(34,211,238,.14);

  --sh-1: 0 1px 2px rgba(0,0,0,.30);
  --sh-2: 0 2px 8px rgba(0,0,0,.30), 0 8px 24px rgba(0,0,0,.24);
  --sh-3: 0 12px 40px rgba(0,0,0,.45);
  --sh-4: 0 24px 64px rgba(0,0,0,.55);
}


/* ═══ §4 · RESET Y BASE ════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
}

::selection { background: var(--brand-tint); color: var(--brand-dark); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--hairline); border-radius: 99px;
  border: 3px solid var(--canvas);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
::-webkit-scrollbar-track { background: transparent; }

input::placeholder, textarea::placeholder { color: var(--ink-4); }

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


/* ═══ §5 · UTILIDADES ══════════════════════════════════════════════════════
   Estas clases se usan cientos de veces en views.js y NO existían en el CSS.
   Definirlas es el cambio de mayor impacto/riesgo de todo el rediseño:
   ~370 usos de clase que hoy no pintan nada pasan a pintar.               */

/* Texto */
.small        { font-size: 12.5px; }
.muted        { color: var(--ink-3); }
.text-muted   { color: var(--ink-3); }
.mono         { font-family: var(--font); font-variant-numeric: tabular-nums; }
.num          { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 700; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.fw-500       { font-weight: 500; }
.fw-700       { font-weight: 700; }
.link         { color: var(--brand); font-weight: 600; cursor: pointer; }
.link:hover   { color: var(--brand-dark); text-decoration: underline; }
.danger       { color: var(--bad); }
.pos          { color: var(--ok); font-weight: 600; }
.neg          { color: var(--bad); font-weight: 600; }

/* Layout */
.full         { grid-column: 1 / -1; width: 100%; }
.grid-2       { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3       { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.flex         { display: flex; align-items: center; gap: 10px; }
.flex-row     { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.flex-col     { display: flex; flex-direction: column; gap: 10px; }
.gap-sm       { gap: 8px; }
.mt           { margin-top: 16px; }
.mb           { margin-bottom: 16px; }
.clickable    { cursor: pointer; transition: opacity var(--t-fast); }
.clickable:hover { opacity: .78; }
.icon         { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }

/* Estado vacío corto (`.empty` suelto en views.js) */
.empty {
  text-align: center; color: var(--ink-3);
  padding: 44px 20px; font-size: 14px;
}


/* ═══ §6 · RAIL (desktop) ══════════════════════════════════════════════════ */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: var(--rail-w);
  background: linear-gradient(180deg, var(--rail-a), var(--rail-b));
  box-shadow: var(--sh-rail);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0 12px;
  padding-top: calc(16px + env(safe-area-inset-top));
}
.rail-brand {
  width: 42px; height: 42px; border-radius: 13px;
  background: var(--gold-grad);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px; flex: 0 0 auto;
  box-shadow: 0 4px 14px rgba(196,127,28,.34);
}
.rail-brand i { font-size: 23px; color: #fff; }

.rail-links {
  flex: 1; width: 100%; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  scrollbar-width: none;
}
.rail-links::-webkit-scrollbar { display: none; }

.rail-links a {
  position: relative;
  width: 46px; height: 46px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.46);
  transition: background var(--t-fast), color var(--t-fast);
  flex: 0 0 auto;
}
.rail-links a i { font-size: 21px; }
.rail-links a:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.92); }
.rail-links a.active { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.44); }

/* Tooltip del rail */
.rail-links a::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--rail-a); color: #fff;
  font-size: 12.5px; font-weight: 600; font-family: var(--font);
  padding: 6px 11px; border-radius: var(--r-xs);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--t-fast), transform var(--t-fast);
  box-shadow: var(--sh-3); z-index: 5;
}
.rail-links a:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

.rail-sep { width: 30px; height: 1px; background: rgba(255,255,255,.10); margin: 9px 0; flex: 0 0 auto; }

.rail-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; }
.rail-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--gold-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; cursor: pointer;
  border: 2px solid rgba(255,255,255,.14);
}


/* ═══ §7 · SIDEBAR LEGACY ══════════════════════════════════════════════════
   El shell actual de app.php todavía renderiza .sidebar/.topbar. Se re-estila
   en la paleta nueva para que el deploy 1 no rompa nada. Cuando app.php pase
   al rail, este bloque se puede borrar.                                     */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--rail-a), var(--rail-b));
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--t);
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--sh-rail);
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,16,23,.55); backdrop-filter: blur(2px); z-index: 50;
}
.sidebar-overlay.show { display: block; }

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px; flex: 0 0 auto;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
  width: 40px; height: 40px; border-radius: 13px;
  background: var(--gold-grad);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  box-shadow: 0 4px 14px rgba(196,127,28,.34);
}
.brand-icon i { font-size: 22px; color: #fff; }
.brand-name {
  font-family: var(--font-display); font-weight: 800;
  letter-spacing: .04em; font-size: 15px; color: #fff;
}
.brand-sub { font-size: 10.5px; color: rgba(255,255,255,.44); letter-spacing: .1em; margin-top: 2px; }

.sidebar-links { flex: 1; overflow-y: auto; padding: 8px 12px; }
.nav-group-label {
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
  color: rgba(255,255,255,.32); font-weight: 700; padding: 16px 10px 7px;
}
.sidebar-links a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: var(--r-sm);
  color: rgba(255,255,255,.68); font-weight: 500; font-size: 14px;
  margin-bottom: 2px; transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-links a i { font-size: 18px; flex: 0 0 auto; color: rgba(255,255,255,.42); transition: color var(--t-fast); }
.sidebar-links a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-links a:hover i { color: #fff; }
.sidebar-links a.active { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.36); }
.sidebar-links a.active i { color: #fff; }
.nav-soon {
  font-size: 9px; color: rgba(255,255,255,.4);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 5px; padding: 1px 6px; margin-left: auto;
}

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 11px; flex: 0 0 auto;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; flex: 0 0 auto;
}
.sidebar-user-name {
  font-size: 13px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.44); margin-top: 1px; }
.sidebar-logout {
  background: none; border: none; color: rgba(255,255,255,.5);
  cursor: pointer; font-size: 18px; display: flex; align-items: center;
  padding: 5px; border-radius: var(--r-xs); transition: color var(--t-fast), background var(--t-fast);
}
.sidebar-logout:hover { color: #fff; background: rgba(255,255,255,.09); }


/* ═══ §8 · TOPBAR ══════════════════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 17px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 40;
  padding-top: calc(13px + env(safe-area-inset-top));
}
.topbar-title {
  font-family: var(--font-display); font-weight: 800;
  letter-spacing: .03em; font-size: 15px; flex: 1; color: var(--ink);
}
.topbar-greet { flex: 1; min-width: 0; }
.topbar-greet .hi { font-size: 12px; color: var(--ink-3); }
.topbar-greet .who {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: 0 0 auto;
}
.icon-btn {
  background: none; border: none; color: var(--ink-2);
  cursor: pointer; font-size: 21px; display: flex; align-items: center;
  padding: 7px; border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--panel-3); color: var(--ink); }

/* Buscador ⌘K */
.omni {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-3); border: 1px solid var(--hairline);
  border-radius: var(--r-chip); padding: 8px 15px;
  color: var(--ink-3); font-size: 13.5px; cursor: pointer;
  min-width: 210px; transition: border-color var(--t-fast), background var(--t-fast);
}
.omni:hover { border-color: var(--ink-4); background: var(--panel); }
.omni i { font-size: 16px; }
.omni-hint {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 2px 6px; color: var(--ink-3);
}

/* Campana */
.bell { position: relative; }
.bell-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bad); border: 2px solid var(--panel);
}


/* ═══ §9 · TABS DE SECCIÓN ═════════════════════════════════════════════════ */
.section-tabs {
  display: flex; gap: 4px; align-items: center;
  background: var(--panel); border-bottom: 1px solid var(--hairline);
  padding: 0 32px; overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 0; z-index: 30;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs a, .section-tabs button {
  position: relative; background: none; border: none; cursor: pointer;
  padding: 15px 15px 13px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-3); white-space: nowrap; font-family: var(--font);
  transition: color var(--t-fast);
}
.section-tabs a:hover, .section-tabs button:hover { color: var(--ink); }
.section-tabs a.active, .section-tabs button.active { color: var(--brand); }
.section-tabs a.active::after, .section-tabs button.active::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 0;
  height: 2px; background: var(--brand); border-radius: 2px 2px 0 0;
}


/* ═══ §10 · BOTTOM NAV (móvil) ═════════════════════════════════════════════ */
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: rgba(255,255,255,.94);
    backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--hairline);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 18px rgba(20,22,29,.06);
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    height: var(--bottomnav-h); color: var(--ink-3);
    font-size: 10.5px; font-weight: 600;
    transition: color var(--t-fast);
  }
  .bottom-nav a i { font-size: 22px; }
  .bottom-nav a.active { color: var(--brand); }
}


/* ═══ §11 · MAIN ═══════════════════════════════════════════════════════════ */
.main { padding: 20px 17px 96px; min-height: 100vh; }


/* ═══ §12 · PAGE HEAD ══════════════════════════════════════════════════════
   Hoy hay 3 layouts distintos para lo mismo (dashboard / clientes /
   operaciones). Este es el patrón único. `.page-header` y `.page-title`
   son alias de las variantes que ya usa views.js.                          */
.page-head, .page-header {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 14px; margin-bottom: 22px;
}
.page-head-left { flex: 1; min-width: 0; }
.page-head h1, .page-header h1, .page-title {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 800; letter-spacing: -.025em;
  color: var(--ink);
}
.page-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 3px; }
.page-head .btn, .page-header .btn { margin-left: auto; }

.count-chip {
  display: inline-flex; align-items: center;
  background: var(--panel-3); border: 1px solid var(--hairline);
  border-radius: var(--r-chip); padding: 4px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
}

.tc-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-chip); padding: 8px 14px;
  font-size: 13px; color: var(--ink-2); font-weight: 600;
  white-space: nowrap; box-shadow: var(--sh-1);
  font-variant-numeric: tabular-nums;
}
.tc-chip i { color: var(--ok); font-size: 15px; }

.section-label {
  font-family: var(--font); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); margin: 0 0 12px;
}


/* ═══ §13 · PANELES Y CARDS ════════════════════════════════════════════════ */
.panel {
  background: var(--panel); border-radius: var(--r-panel);
  box-shadow: var(--sh-2); padding: 24px; margin-bottom: 18px;
}
.card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--sh-1);
}
.card-head, .card-header { margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.card-head .btn, .card-header .btn { margin-left: auto; }
.card-title {
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
  letter-spacing: -.015em; color: var(--ink);
}
.card-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

.grid-a { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; }


/* ═══ §14 · KPIs ═══════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 18px;
}
.kpi-card, .kpi-grid .kpi, .kpi {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 19px 20px;
  display: flex; flex-direction: column; gap: 11px;
  box-shadow: var(--sh-1);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.kpi-card:hover, .kpi:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }

.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label {
  font-size: 10.5px; letter-spacing: .085em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
.kpi-icon { font-size: 19px; color: var(--ink-4); }
.kpi-value {
  font-family: var(--font-num);
  font-size: 27px; font-weight: 700; letter-spacing: -.03em;
  color: var(--ink); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 12px; color: var(--ink-3); }

.kpi-green  .kpi-value, .kpi-value.kpi-green,  .kpi-green  { color: var(--ok); }
.kpi-red    .kpi-value, .kpi-value.kpi-red,    .kpi-red    { color: var(--bad); }
.kpi-yellow .kpi-value, .kpi-value.kpi-yellow, .kpi-yellow { color: var(--warn); }
.kpi-accent .kpi-value, .kpi-value.kpi-accent, .kpi-accent { color: var(--brand); }

.caja-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }


/* ═══ §15 · INFO-ROW ═══════════════════════════════════════════════════════
   97 usos en views.js — el componente más usado de todo el sistema.
   El ERP no es "tablas", son listas de pares clave/valor. Acá va el foco.  */
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--hairline-2);
  font-size: 13.5px; gap: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--ink-3); white-space: nowrap; font-weight: 500; }
.info-row .v {
  font-weight: 600; text-align: right; color: var(--ink);
  font-variant-numeric: tabular-nums;
}


/* ═══ §16 · TABLAS ═════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); overflow: hidden; margin-bottom: 18px;
  box-shadow: var(--sh-1);
}
.table-wrap table, table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table-wrap thead th, .data-table thead th {
  background: var(--panel-3); padding: 12px 16px; text-align: left;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-3); white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}
.table-wrap thead th.r, .data-table thead th.r { text-align: right; }

.table-wrap tbody tr, .data-table tbody tr {
  border-top: 1px solid var(--hairline-2); cursor: pointer;
  transition: background var(--t-fast);
}
.table-wrap tbody tr:hover, .data-table tbody tr:hover { background: var(--panel-3); }
.table-wrap tbody td, .data-table tbody td {
  padding: 13px 16px; color: var(--ink-2); vertical-align: middle;
}
.table-wrap tbody td.r, .data-table tbody td.r { text-align: right; font-variant-numeric: tabular-nums; }
.actions-col { text-align: right; white-space: nowrap; }

.table-wrap .empty-state, .empty-state {
  text-align: center; color: var(--ink-3);
  padding: 46px 16px; font-size: 13.5px;
}


/* ═══ §17 · BUSCADOR ═══════════════════════════════════════════════════════ */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 0 14px;
  max-width: 380px; margin-bottom: 18px; box-shadow: var(--sh-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-bar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.search-bar i { font-size: 17px; color: var(--ink-4); }
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--ink); padding: 12px 0; font-size: 14px;
}

/* Barra de filtros — hoy los selects quedan pegados al buscador */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.filter-bar .search-bar { margin-bottom: 0; }


/* ═══ §18 · BOTONES ════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  padding: 10px 17px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; font-family: var(--font);
  background: var(--panel); color: var(--ink);
  box-shadow: var(--sh-1); white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:hover  { background: var(--panel-3); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn i { font-size: 16px; }

.btn-primary {
  background: var(--brand); color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px rgba(79,70,229,.26);
}
.btn-primary:hover { background: var(--brand-dark); border-color: transparent; }

.btn-secondary { background: var(--panel); color: var(--ink-2); }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--panel-3); border-color: transparent; }

.btn-danger { background: var(--bad-tint); color: var(--bad); border-color: transparent; box-shadow: none; }
.btn-danger:hover { background: var(--bad); color: #fff; border-color: transparent; }

.btn-blue { background: var(--brand-tint); color: var(--brand); border-color: transparent; box-shadow: none; }
.btn-blue:hover { background: var(--brand); color: #fff; }

.btn-gold {
  background: var(--gold-grad); color: #fff; border-color: transparent;
  box-shadow: 0 2px 10px rgba(196,127,28,.30);
}

/* 79 usos en views.js, no existía */
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--r-xs); gap: 6px; }
.btn-sm i { font-size: 14px; }

.btn-icon {
  padding: 8px; width: 34px; height: 34px; border-radius: var(--r-xs);
}
.btn-icon i { font-size: 16px; }

.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }


/* ═══ §19 · BADGES / CHIPS ═════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--r-chip);
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.badge-green,  .b-green   { background: var(--ok-tint);     color: var(--ok);     }
.badge-red,    .b-red     { background: var(--bad-tint);    color: var(--bad);    }
.badge-amber,  .b-yellow  { background: var(--warn-tint);   color: var(--warn);   }
.badge-warning            { background: var(--warn-tint);   color: var(--warn);   }
.badge-blue,   .b-blue    { background: var(--brand-tint);  color: var(--brand);  }
.badge-violet, .b-purple  { background: var(--violet-tint); color: var(--violet); }
.badge-cyan               { background: var(--cyan-tint);   color: var(--cyan);   }
.badge-gray,   .b-gray,
.badge-muted,  .b-muted   { background: var(--panel-3);     color: var(--ink-3);  }

/* Las .b-* de views.js no siempre traen .badge — que funcionen solas */
.b-green, .b-red, .b-yellow, .b-blue, .b-purple, .b-gray, .b-muted {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--r-chip);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge-lg { padding: 6px 15px; font-size: 13px; }


/* ═══ §20 · FORMULARIOS ════════════════════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-full, .form-grid label.full { grid-column: 1 / -1; }

.form-grid label, .form-grid .form-group, .form-group {
  display: flex; flex-direction: column; gap: 7px;
  font-size: 12.5px; color: var(--ink-3); font-weight: 600;
  min-width: 0; line-height: 1.35;
}
.form-label { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }

.form-input, .form-select, .form-textarea,
.cod-fila input, .cod-fila select, #gc_wrap input, #gc_wrap select,
.form-grid input:not([type="checkbox"]):not([type="radio"]),
.form-grid select, .form-grid textarea,
.modal-body input:not([type="checkbox"]):not([type="radio"]),
.modal-body select, .modal-body textarea {
  width: 100%; box-sizing: border-box;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  padding: 11px 14px; font-size: 14px; font-weight: 500;
  font-family: inherit; outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-grid input:hover, .form-grid select:hover, .form-grid textarea:hover,
.modal-body input:hover, .modal-body select:hover, .modal-body textarea:hover {
  border-color: var(--ink-4);
}
.form-input:focus, .form-select:focus, .form-textarea:focus,
.cod-fila input:focus, #gc_wrap input:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
.form-textarea, .form-grid textarea, .modal-body textarea { min-height: 86px; resize: vertical; }
.form-grid select, .modal-body select { cursor: pointer; }
.form-select option { background: var(--panel); color: var(--ink); }

/* Controles nativos del main — :where() = especificidad 0, no pisa lo de arriba */
:where(#main) :where(select, input[type="text"], input[type="search"], input[type="number"],
input[type="date"], input[type="month"], input[type="tel"], input[type="email"],
input[type="password"], input:not([type]), textarea) {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); color: var(--ink);
  padding: 10px 13px; font-size: 13.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
:where(#main) :where(select) { cursor: pointer; }
#main select:focus,
#main input:not([type="checkbox"]):not([type="radio"]):focus,
#main textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}


/* ═══ §21 · MODALES ════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,22,29,.42);
  backdrop-filter: blur(3px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fadeIn .16s var(--ease);
}
.modal {
  background: var(--panel); border-radius: var(--r-panel);
  width: min(640px, 100%); max-height: 90vh; overflow-y: auto;
  box-shadow: var(--sh-4);
  animation: modalIn .22s var(--ease);
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 17px; border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; background: var(--panel); z-index: 3;
}
.modal-header h2 { font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.modal-close {
  background: none; border: none; color: var(--ink-3); cursor: pointer;
  font-size: 22px; display: flex; align-items: center;
  padding: 5px; border-radius: var(--r-xs); transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { color: var(--ink); background: var(--panel-3); }

.modal-body { padding: 24px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.modal-footer, .modal-actions {
  padding: 17px 24px; border-top: 1px solid var(--hairline);
  display: flex; justify-content: flex-end; gap: 11px;
  position: sticky; bottom: 0; background: var(--panel); z-index: 3;
}
.modal-footer .btn { min-height: 41px; }

/* Modal simple: h3 + form-grid + footer (patrón mayoritario en views.js) */
.modal > h3 {
  position: sticky; top: 0; z-index: 3; margin: 0;
  padding: 22px 24px 16px; background: var(--panel);
  font-family: var(--font-display); font-size: 18px; font-weight: 800;
  border-bottom: 1px solid var(--hairline);
}
.modal > .form-grid { padding: 22px 24px; }
.modal p.small.muted { margin-top: 14px; }

/* Modales globales openModal (M-series) */
.gm-body { padding: 24px; display: flex; flex-direction: column; gap: 15px; }
.gm-body h3 { font-family: var(--font-display); margin: 0 0 4px; font-size: 18px; font-weight: 800; color: var(--ink); }
.gm-body label, .gm-body .form-group {
  display: flex; flex-direction: column; gap: 7px;
  font-size: 12.5px; color: var(--ink-3); font-weight: 600;
}
.gm-body input, .gm-body select, .gm-body textarea {
  width: 100%; box-sizing: border-box; padding: 11px 14px;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); color: var(--ink);
  font-size: 14px; font-weight: 500;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.gm-body input:focus, .gm-body select:focus, .gm-body textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
.gm-body .modal-actions {
  padding: 15px 0 0; margin-top: 6px; border-top: 1px solid var(--hairline);
  position: static; background: none;
}

/* Confirmación */
.confirm-box {
  background: var(--panel); border-radius: var(--r-panel);
  padding: 32px; max-width: 400px; width: 100%; text-align: center;
  box-shadow: var(--sh-4);
}
.confirm-box h3 { font-family: var(--font-display); font-size: 18px; font-weight: 800; margin-bottom: 11px; }
.confirm-box p { color: var(--ink-3); font-size: 14px; margin-bottom: 24px; }
.confirm-btns { display: flex; gap: 11px; justify-content: center; }


/* ═══ §22 · VISTA DETALLE ══════════════════════════════════════════════════ */
.detail-card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 22px; margin-bottom: 18px;
  box-shadow: var(--sh-1);
}
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0 32px;
}
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--hairline-2);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--ink-3); font-size: 13px; }
.detail-value {
  font-weight: 600; font-size: 13.5px; text-align: right;
  font-variant-numeric: tabular-nums;
}


/* ═══ §23 · ALERTAS ════════════════════════════════════════════════════════ */
.alert {
  padding: 14px 17px; border-radius: var(--r-sm); margin-bottom: 16px;
  font-size: 14px; display: flex; align-items: flex-start; gap: 11px;
}
.alert i { font-size: 18px; flex: 0 0 auto; margin-top: 1px; }
.alert-error { background: var(--bad-tint);   color: var(--bad);   }
.alert-info  { background: var(--brand-tint); color: var(--brand-dark); }
.alert-warn  { background: var(--warn-tint);  color: var(--warn);  }
.alert-ok    { background: var(--ok-tint);    color: var(--ok);    }


/* ═══ §24 · ESTADOS VACÍOS Y CARGA ═════════════════════════════════════════ */
.loading-view { text-align: center; color: var(--ink-3); padding: 64px 0; }
.empty-view {
  text-align: center; padding: 60px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty-icon { font-size: 42px; color: var(--ink-4); margin-bottom: 8px; }
.empty-text { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.empty-hint { font-size: 13px; color: var(--ink-3); }
.empty-view .btn { margin-top: 14px; }

.skeleton {
  background: linear-gradient(90deg, var(--panel-3) 25%, var(--hairline-3) 50%, var(--panel-3) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: var(--r-xs);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }


/* ═══ §25 · TOAST ══════════════════════════════════════════════════════════ */
.toast-root, #toastRoot {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  z-index: 200; pointer-events: none;
}
.toast {
  background: var(--rail-a); color: #fff;
  border-radius: var(--r-sm); padding: 12px 22px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--sh-3); animation: toastIn .22s var(--ease);
  white-space: nowrap;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ═══ §26 · TABS (Caja, Comisiones) ════════════════════════════════════════ */
.tabs { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.tabs button, .tab-btn {
  background: var(--panel); border: 1px solid var(--hairline);
  color: var(--ink-3); padding: 9px 19px; border-radius: var(--r-chip);
  cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 600;
  transition: all var(--t-fast);
}
.tabs button:hover, .tab-btn:hover { border-color: var(--ink-4); color: var(--ink); }
.tabs button.active, .tab-btn.active {
  background: var(--brand); border-color: transparent; color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.26);
}


/* ═══ §27 · CALENDARIO ═════════════════════════════════════════════════════ */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin-top: 16px; }
.cal-day-label {
  text-align: center; font-size: 10.5px; font-weight: 700;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em;
  padding-bottom: 9px;
}
.cal-cell {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 9px; min-height: 78px;
  display: flex; flex-direction: column; gap: 4px;
}
.cal-cell.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint); }
.cal-cell.other-month { opacity: .4; }
.cal-num { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.cal-event {
  font-size: 10.5px; font-weight: 600; border-radius: 5px;
  padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-event.proxima { background: var(--warn-tint); color: var(--warn); }
.cal-event.vencida { background: var(--bad-tint);  color: var(--bad);  }
.cal-event.cobrada { background: var(--ok-tint);   color: var(--ok);   }


/* ═══ §28 · CRM KANBAN ═════════════════════════════════════════════════════ */
.kanban {
  display: grid; grid-auto-flow: column; grid-auto-columns: 272px;
  gap: 16px; overflow-x: auto; padding-bottom: 10px;
}
.kanban-col {
  background: var(--panel-3); border-radius: var(--r);
  padding: 15px; display: flex; flex-direction: column; gap: 11px;
}
.kanban-col-header {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 700; margin-bottom: 4px;
}
.kanban-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.kanban-count { margin-left: auto; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.kanban-card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 14px; cursor: pointer;
  box-shadow: var(--sh-1);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.kanban-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.kanban-card-name { font-size: 13.5px; font-weight: 700; }
.kanban-card-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.kanban-card-val {
  font-family: var(--font-num); font-size: 15px; font-weight: 700;
  color: var(--brand); margin-top: 9px; font-variant-numeric: tabular-nums;
}


/* ═══ §29 · VENCIMIENTOS / RANKING ═════════════════════════════════════════ */
.venc-leyenda { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.venc-leyenda-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3); }
.venc-dot { width: 9px; height: 9px; border-radius: 50%; }

.ranking-item { margin-bottom: 16px; }
.ranking-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; margin-bottom: 7px;
}
.ranking-name { font-weight: 600; }
.ranking-val {
  font-family: var(--font-num); color: var(--ink-2);
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.ranking-bar-bg { height: 9px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.ranking-bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), #6d64f5);
  transition: width .5s var(--ease);
}

.proxvenc-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--hairline-2);
}
.proxvenc-info { flex: 1; min-width: 0; }
.proxvenc-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proxvenc-date { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.proxvenc-monto {
  font-family: var(--font-num); font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}


/* ═══ §30 · FOTOS ══════════════════════════════════════════════════════════ */
.foto-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.foto {
  position: relative; aspect-ratio: 4/3; border-radius: var(--r-sm);
  overflow: hidden; background: var(--panel-3); box-shadow: var(--sh-1);
}
.foto img { width: 100%; height: 100%; object-fit: cover; }
.foto .del {
  position: absolute; top: 7px; right: 7px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(20,22,29,.66); color: #fff; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; opacity: 0; transition: opacity var(--t-fast);
}
.foto:hover .del { opacity: 1; }


/* ═══ §31 · MÓDULOS NUEVOS ═════════════════════════════════════════════════ */

/* — B.1 · LIENZO PRO — */
.lienzo-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--warn-tint); color: var(--warn);
  border-radius: var(--r-sm); padding: 13px 18px; margin-bottom: 20px;
  font-size: 13.5px; font-weight: 600;
  position: sticky; top: 0; z-index: 35;
}
.lienzo-banner i { font-size: 19px; }
.lienzo-banner .btn { margin-left: auto; }

.pro-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--gold-grad); color: #fff;
  font-size: 9.5px; font-weight: 800; letter-spacing: .08em;
  padding: 3px 8px; border-radius: var(--r-chip); text-transform: uppercase;
}

.escenarios {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px;
}
.escenario {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 20px; box-shadow: var(--sh-1);
}
.escenario.b { border-color: var(--warn); background: linear-gradient(180deg, var(--warn-tint), var(--panel) 60px); }
.escenario-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 16px;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
}

/* Celdas editables del sandbox */
[contenteditable="true"].edit, .edit-cell {
  background: var(--warn-tint); border-radius: 6px;
  padding: 2px 7px; outline: none; cursor: text;
  border-bottom: 2px dashed var(--warn); font-weight: 700;
  transition: background var(--t-fast);
}
[contenteditable="true"].edit:focus, .edit-cell:focus {
  background: var(--panel); border-bottom-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.delta { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up   { color: var(--ok);  }
.delta.down { color: var(--bad); }

/* — B.2 · GENERADOR DE INFORMES — */
.builder {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; align-items: end;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 20px; margin-bottom: 20px;
  box-shadow: var(--sh-1);
}
.builder .btn { align-self: end; }

.galeria {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 16px;
}
.informe-card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 20px; cursor: pointer;
  box-shadow: var(--sh-1); display: flex; flex-direction: column; gap: 9px;
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}
.informe-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); border-color: var(--brand); }
.informe-card .ic {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  background: var(--brand-tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.informe-card h4 { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.informe-card p { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }

.export-row { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }

/* — B.3 · PORTAL VENDEDOR — */
.portal-hero {
  background: linear-gradient(135deg, var(--rail-a), var(--rail-b));
  border-radius: var(--r-panel); padding: 26px; margin-bottom: 20px;
  color: #fff; box-shadow: var(--sh-2);
}
.portal-hero h2 { font-family: var(--font-display); font-size: 22px; font-weight: 800; }
.portal-hero .sub { color: rgba(255,255,255,.62); font-size: 13.5px; margin-top: 5px; }
.portal-stats { display: flex; gap: 26px; margin-top: 20px; flex-wrap: wrap; }
.portal-stat .n {
  font-family: var(--font-num); font-size: 25px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.portal-stat .l {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: rgba(255,255,255,.52); font-weight: 700; margin-top: 3px;
}

.stock-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 16px;
}
.stock-card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--sh-1);
  cursor: pointer; transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.stock-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.stock-foto { aspect-ratio: 16/10; background: var(--panel-3); position: relative; }
.stock-foto img { width: 100%; height: 100%; object-fit: cover; }
.stock-foto .badge { position: absolute; top: 11px; left: 11px; }
.stock-body { padding: 16px; }
.stock-name { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.stock-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.stock-precio {
  font-family: var(--font-num); font-size: 19px; font-weight: 700;
  color: var(--ink); margin-top: 11px; font-variant-numeric: tabular-nums;
}

/* Simulador de financiación */
.simulador {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--r-panel); padding: 24px; box-shadow: var(--sh-2);
}
.sim-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.sim-out {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: var(--r); padding: 24px; margin-top: 20px;
  color: #fff; text-align: center;
}
.sim-cuota {
  font-family: var(--font-num); font-size: 40px; font-weight: 800;
  letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.05;
}
.sim-cuota-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.7); font-weight: 700; margin-bottom: 7px;
}
.sim-detalle {
  display: flex; justify-content: center; gap: 26px;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.2); flex-wrap: wrap;
}
.sim-detalle div { font-size: 12px; color: rgba(255,255,255,.72); }
.sim-detalle b { display: block; font-size: 15px; color: #fff; font-weight: 700; margin-top: 2px; }

/* Rango de plazo */
.sim-range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 99px; background: var(--hairline); outline: none; }
.sim-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); cursor: pointer; border: 3px solid var(--panel);
  box-shadow: var(--sh-2);
}


/* ═══ §32 · TOGGLE DE TEMA ═════════════════════════════════════════════════ */
.bio-theme-toggle {
  position: fixed; right: 18px; bottom: 18px; z-index: 99999;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--panel);
  color: var(--ink-2); cursor: pointer; box-shadow: var(--sh-2);
  font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.bio-theme-toggle:hover { transform: scale(1.07); box-shadow: var(--sh-3); }

@media (max-width: 860px) {
  .bio-theme-toggle { bottom: calc(var(--bottomnav-h) + 14px + env(safe-area-inset-bottom)); }
}


/* ═══ §33 · DESKTOP ════════════════════════════════════════════════════════ */
@media (min-width: 861px) {
  .topbar { display: none; }
  .sidebar { transform: translateX(0); }
  .sidebar-overlay { display: none !important; }
  .main { margin-left: var(--sidebar-w); padding: 26px 32px 64px; }

  /* Cuando app.php migre al rail (deploy 2), agregar .shell-rail al <body> */
  body.shell-rail .main    { margin-left: var(--rail-w); }
  body.shell-rail .sidebar { display: none; }
  body.shell-rail .topbar  { display: flex; margin-left: var(--rail-w); }
}


/* ═══ §34 · MÓVIL ══════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  .rail { display: none; }
  .main { padding-bottom: calc(var(--bottomnav-h) + 26px + env(safe-area-inset-bottom)); }

  .grid-a, .grid-2, .grid-3, .escenarios, .caja-kpis, .form-grid,
  .detail-grid, .sim-inputs { grid-template-columns: 1fr !important; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 21px; }
  .page-head h1, .page-header h1, .page-title { font-size: 23px; }

  .section-tabs { padding: 0 17px; }
  .search-bar { max-width: none; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r-panel) var(--r-panel) 0 0; max-height: 93vh; width: 100%; }
  .modal-body { padding: 20px 17px; }
  .modal > h3 { padding: 20px 17px 14px; }
  .modal > .form-grid { padding: 17px; }
  .modal-footer, .modal > .modal-footer { padding: 14px 17px; }
  .modal-footer .btn { flex: 1; min-height: 47px; }

  /* iOS no hace zoom si el input es ≥16px */
  .form-grid input, .form-grid select, .form-grid textarea,
  .modal-body input, .modal-body select, .modal-body textarea,
  .gm-body input, .gm-body select, .gm-body textarea { font-size: 16px; padding: 13px 15px; }

  .sim-cuota { font-size: 33px; }
  .toast-root, #toastRoot { bottom: calc(var(--bottomnav-h) + 20px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stock-grid, .galeria { grid-template-columns: 1fr; }
}


/* ═══ §35 · IMPRESIÓN ══════════════════════════════════════════════════════ */
@media print {
  .rail, .sidebar, .topbar, .bottom-nav, .section-tabs,
  .bio-theme-toggle, .btn, .modal-backdrop { display: none !important; }
  .main { margin: 0; padding: 0; }
  body { background: #fff; font-size: 11pt; }
  .card, .panel, .table-wrap, .kpi-card {
    box-shadow: none; border: 1px solid #ddd; break-inside: avoid;
  }
}


/* ═══ §36 · ACCESIBILIDAD ══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* KPI: importe principal grande y equivalente en la otra moneda debajo, chico */
.kpi-value{ white-space: normal; line-height: 1.15; }
.kpi-value .mon-alt{ display:block; font-size:13px; font-weight:600; opacity:.5; margin-top:3px; white-space:nowrap; letter-spacing:0; }

/* ---- Respiro parejo dentro de los modales ----
   Todo lo que va suelto dentro de un modal (titulos de seccion, textos de ayuda,
   bloques repetibles) toma el mismo margen lateral que los campos. */
.modal > .sec-tit,
.modal > .sub-tit,
.modal > #cod_lista_ed,
.modal > #cod_add_ed,
.modal > #gc_wrap,
.modal > p,
.modal > div:not(.form-grid):not(.modal-actions):not(.tabla-wrap){
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
}
.modal > #cod_add_ed{ padding-top:7px; padding-bottom:7px; margin-left:24px; margin-right:24px; padding-left:12px; padding-right:12px; width:auto; }
.modal > .sec-tit{ margin-top:20px; margin-bottom:10px; }
.modal > .sec-tit:first-of-type{ margin-top:6px; }
.modal .cod-fila{ padding:12px 14px !important; margin-bottom:10px !important; }
.modal .cod-fila + .cod-fila{ margin-top:0; }

.modal > #gc_wrap{ margin-left:24px !important; margin-right:24px !important; padding-left:14px !important; padding-right:14px !important; }
