/* =========================================================
   AppFinanzas — hoja de estilos principal
   ========================================================= */

:root {
    /* Paleta refinada — enterprise */
    --azul-oscuro: #0f2e4a;
    --azul: #1e5a8e;
    --azul-claro: #3b82f6;
    --azul-suave: #eff6ff;
    --turquesa: #D1ECF1;
    --turquesa-fuerte: #14b8a6;
    --gris-50:  #f8fafc;
    --gris-100: #f1f5f9;
    --gris-200: #e2e8f0;
    --gris-300: #cbd5e1;
    --gris-400: #94a3b8;
    --gris-500: #64748b;
    --gris-600: #475569;
    --gris-700: #334155;
    --gris-900: #0f172a;
    --verde: #10b981;
    --verde-suave: #d1fae5;
    --rojo: #ef4444;
    --rojo-suave: #fee2e2;
    --amarillo: #f59e0b;
    --amarillo-suave: #fef3c7;
    --sombra: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .06);
    --sombra-hover: 0 4px 20px rgba(15, 23, 42, .12);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-w: 240px;
    --header-h: 60px;
    /* Google Fonts profesionales */
    --font-ui: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-num: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--font-ui);
    color: var(--gris-900);
    background: var(--gris-100);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';   /* Inter alternates */
    text-transform: uppercase;
}
/* Excepciones — email/contraseña conservan minúsculas */
input[type="email"], input[type="password"], code, .no-upper {
    text-transform: none !important;
}

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================================================
   LOGIN
   ========================================================= */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #0b3d64 0%, #12689f 60%, #3ea1d8 100%);
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
    padding: 40px 36px; width: 100%; max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
    width: 60px; height: 60px; border-radius: 14px; margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--azul-oscuro), var(--azul-claro));
    color: #fff; font-weight: 700; font-size: 22px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(11,61,100,.35);
}
.login-brand h1 { margin: 0; font-size: 22px; color: var(--azul-oscuro); }
.login-brand p { margin: 4px 0 0; color: var(--gris-500); font-size: 13px; }
.login-form label { display: block; margin-bottom: 14px; }
.login-form label span { display: block; margin-bottom: 5px; font-weight: 600; color: var(--gris-700); font-size: 13px; }
.login-form input {
    width: 100%; padding: 11px 14px; border: 1px solid var(--gris-300); border-radius: 8px;
    font-size: 15px; transition: border .15s, box-shadow .15s;
}
.login-form input:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(18,104,159,.15); }
.btn-primary {
    width: 100%; background: var(--azul-oscuro); color: #fff; border: 0;
    padding: 12px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
    transition: background .15s;
}
.btn-primary:hover { background: var(--azul); }
.login-hint { text-align: center; margin-top: 20px; font-size: 12px; color: var(--gris-500); }
.login-hint code { background: var(--gris-200); padding: 2px 6px; border-radius: 4px; }
.alert-error {
    background: #fef2f2; color: var(--rojo); border: 1px solid #fecaca;
    padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
}
.alert-success {
    background: #f0fdf4; color: var(--verde); border: 1px solid #bbf7d0;
    padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
}

/* =========================================================
   LAYOUT PRINCIPAL
   ========================================================= */
.layout { display: flex; min-height: 100vh; }

/* Layout con NAVBAR arriba (en lugar de sidebar) */
.layout-navbar {
    flex-direction: column;
}
nav.navbar {
    background: linear-gradient(90deg, var(--azul-oscuro), #072a45);
    color: #fff;
    display: flex; align-items: center; gap: 20px;
    padding: 0 20px; height: 56px;
    position: sticky; top: 0; z-index: 40;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.navbar-brand { display: flex; align-items: center; gap: 10px; }
.navbar-logo {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(135deg, var(--azul-claro), var(--turquesa-fuerte));
    color: var(--azul-oscuro); font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.navbar-title { font-size: 14px; font-weight: 700; letter-spacing: .3px; }
.navbar-sub { font-size: 10px; opacity: .6; text-transform: uppercase; letter-spacing: .8px; }
.navbar-links { display: flex; gap: 4px; align-items: center; flex: 1; }
.navbar-links a {
    color: rgba(255,255,255,.85); font-size: 13px; font-weight: 500;
    padding: 8px 14px; border-radius: 6px;
    text-decoration: none;
    transition: background .15s;
}
.navbar-links a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.navbar-links a.active { background: var(--azul); color: #fff; box-shadow: inset 0 -3px 0 var(--turquesa-fuerte); }

/* Dropdown Configuración */
.navbar-dropdown { position: relative; }
.navbar-dropdown-btn {
    background: transparent; border: 0; cursor: pointer;
    color: rgba(255,255,255,.85); font-size: 13px; font-weight: 500;
    padding: 8px 14px; border-radius: 6px;
    transition: background .15s;
}
.navbar-dropdown-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.navbar-dropdown-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 0;
    background: #fff; border-radius: 8px; min-width: 200px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2); border: 1px solid var(--gris-200);
    padding: 6px; z-index: 45;
}
.navbar-dropdown:hover .navbar-dropdown-menu { display: block; }
.navbar-dropdown-menu a {
    display: block; padding: 8px 12px; color: var(--gris-700);
    font-size: 13px; text-decoration: none; border-radius: 4px;
}
.navbar-dropdown-menu a:hover { background: var(--gris-100); color: var(--azul-oscuro); text-decoration: none; }
.navbar-dropdown-menu a.active { background: var(--azul); color: #fff; }

/* Zona derecha (empresa + usuario + salir) — flotante al final del navbar */
.navbar-right {
    position: absolute; top: 0; right: 20px; height: 56px;
    display: flex; align-items: center; gap: 10px; z-index: 41;
}

/* Cabecera de página: título a la izquierda, toolbar a la derecha, misma línea */
.page-header {
    background: #fff; border-bottom: 1px solid var(--gris-200);
    padding: 10px 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
    display: flex; align-items: center; gap: 20px;
    flex-wrap: nowrap;
}
.page-header-info { flex: 0 0 auto; }
.page-header h1 { margin: 0; font-size: 16px; color: var(--gris-900); font-weight: 600; line-height: 1.2; }
.page-header .subtitle { color: var(--gris-500); font-size: 12px; margin-top: 2px; line-height: 1.3; }
/* Toolbar dentro del header: flota a la derecha */
.page-header .grid-toolbar {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 0 0 auto !important;
    border-radius: 0;
    flex: 0 0 auto;
    width: auto;
    display: flex; align-items: center;
}
.page-header .grid-toolbar .right { margin-left: 0; display: flex; align-items: center; gap: 6px; }

/* Main y content sin margen lateral (ya no hay sidebar) */
.main-navbar { margin-left: 0 !important; width: 100%; }
.content-navbar { padding: 10px 12px; }
.grid-wrap { max-height: calc(100vh - 200px); }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--azul-oscuro) 0%, #072a45 100%);
    color: #fff;
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 30;
}
.sidebar .brand {
    padding: 18px 20px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .logo {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--azul-claro), var(--turquesa-fuerte));
    color: var(--azul-oscuro); font-weight: 700;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.sidebar .brand h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.sidebar .brand small { display: block; opacity: .6; font-size: 11px; }

.sidebar nav { flex: 1; padding: 16px 10px; overflow-y: auto; }
.sidebar nav .section { text-transform: uppercase; font-size: 10px; letter-spacing: 1.2px; color: rgba(255,255,255,.4); padding: 12px 12px 6px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; margin: 2px 0; border-radius: 8px;
    color: rgba(255,255,255,.85); font-size: 14px; font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--azul); color: #fff; box-shadow: inset 3px 0 0 var(--turquesa-fuerte); }
.sidebar nav a .icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar .user-box {
    padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; gap: 10px;
}
.sidebar .user-box .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--azul-claro); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.sidebar .user-box .info { flex: 1; overflow: hidden; }
.sidebar .user-box .info strong { display: block; font-size: 13px; }
.sidebar .user-box .info small { display: block; font-size: 11px; opacity: .6; text-transform: uppercase; }
.sidebar .user-box a { color: rgba(255,255,255,.7); font-size: 16px; }

/* Contenido principal */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--gris-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 18px; color: var(--gris-900); font-weight: 600; }
.topbar .subtitle { color: var(--gris-500); font-size: 12px; margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 24px; }

/* Botones */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; border: 0; cursor: pointer;
    font-size: 13px; font-weight: 600; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-blue { background: var(--azul); color: #fff; }
.btn-blue:hover { background: var(--azul-oscuro); }
.btn-turquesa { background: var(--turquesa-fuerte); color: var(--azul-oscuro); }
.btn-turquesa:hover { background: var(--turquesa); }
.btn-outline { background: #fff; color: var(--azul); border: 1px solid var(--azul-claro); }
.btn-outline:hover { background: var(--gris-100); }
.btn-red { background: var(--rojo); color: #fff; }
.btn-red:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--gris-700); }
.btn-ghost:hover { background: var(--gris-200); }

/* Cards */
.card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--sombra);
    padding: 20px; margin-bottom: 20px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; color: var(--gris-700); }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi {
    background: #fff; border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--sombra);
    border-left: 4px solid var(--azul);
}
.kpi.green { border-color: var(--verde); }
.kpi.red   { border-color: var(--rojo); }
.kpi.yellow{ border-color: var(--amarillo); }
.kpi.dark  { border-color: var(--azul-oscuro); }
.kpi .label { color: var(--gris-500); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--gris-900); margin-top: 6px; }
.kpi .sub   { font-size: 12px; color: var(--gris-500); margin-top: 4px; }

/* =========================================================
   GRID FINANCIERO (tipo Excel)
   ========================================================= */
.grid-toolbar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    background: #fff; padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--sombra);
    margin-bottom: 16px; flex-wrap: wrap;
}
.grid-toolbar .left, .grid-toolbar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-toolbar select, .grid-toolbar input[type=text], .grid-toolbar input[type=date] {
    border: 1px solid var(--gris-300); border-radius: 6px; padding: 7px 10px; font-size: 13px; background: #fff;
}
.grid-toolbar select:focus, .grid-toolbar input:focus { outline: none; border-color: var(--azul); }

.grid-wrap {
    background: #fff; border-radius: var(--radius); box-shadow: var(--sombra);
    overflow: auto; max-height: calc(100vh - 220px);
}

table.finanzas {
    border-collapse: collapse; width: 100%; font-size: 11px;
    min-width: 0;
}
table.finanzas th, table.finanzas td {
    border: 1px solid var(--gris-300);
    padding: 3px 4px; text-align: center; vertical-align: middle;
    white-space: nowrap;
    cursor: pointer;
    font-size: 11px;
}
table.finanzas thead th { padding: 4px 3px; font-size: 10px; }
table.finanzas th.col-etiq, table.finanzas td.col-etiq {
    min-width: 130px; max-width: 130px;
    padding-left: 4px !important; padding-right: 4px !important;
    font-size: 11px; overflow: hidden; text-overflow: ellipsis;
    text-align: center !important;
}
table.finanzas thead th.col-etiq { font-size: 11px; }
table.finanzas th.col-acc, table.finanzas td.col-acc { width: 26px; min-width: 26px; padding: 2px !important; }
/* Sub-columnas PRES/EJEC/SAL más angostas */
table.finanzas input {
    font-size: 11px; padding: 0 !important;
}
/* Sub-encabezados más compactos */
table.finanzas thead th.sh-pres,
table.finanzas thead th.sh-ejec,
table.finanzas thead th.sh-sal,
table.finanzas tr.anx-subhead th { font-size: 9px !important; padding: 3px 1px !important; letter-spacing: 0; }
table.finanzas td input { cursor: text; }
table.finanzas thead th {
    background: var(--azul-oscuro); color: #fff; font-weight: 600;
    position: sticky; top: 0; z-index: 5;
    border-color: var(--azul);
    text-align: center;
}
table.finanzas thead th.grupo-mes {
    background: var(--azul); font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
}
table.finanzas thead th.col-total { background: #064273; }

table.finanzas th.col-etiq, table.finanzas td.col-etiq {
    text-align: left; background: #fff; position: sticky; left: 0; z-index: 4;
    min-width: 260px;
}
table.finanzas thead th.col-etiq { background: var(--azul-oscuro); z-index: 6; text-align: center; }

/* Fila SECCIÓN (INGRESOS, EGRESOS, Saldo Final) */
tr.row-seccion td { background: var(--azul-oscuro) !important; color: #fff !important; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
tr.row-seccion td.col-etiq { background: var(--azul-oscuro) !important; color: #fff !important; }

/* Fila GRUPO (proyección, ejecutados) */
tr.row-grupo td { background: #D1ECF1 !important; color: var(--azul-oscuro) !important; font-weight: 700; }
tr.row-grupo td.col-etiq { background: #D1ECF1 !important; color: var(--azul-oscuro) !important; }

/* Fila ITEM */
tr.row-item td { background: #fff; }
tr.row-item td.col-etiq {
    padding-left: 4px !important; padding-right: 4px !important;
    color: var(--gris-700); font-weight: 500; background: #fff;
    text-align: center !important;
}

/* Fila código (ej: C 1-13) */
tr.row-item td.col-etiq .cod {
    display: inline-block; color: var(--gris-900); font-weight: 700; width: 66px;
}

/* Celdas editables */
td.editable, td.editable-presupuesto { cursor: pointer !important; position: relative; }
td.editable input, td.editable-presupuesto input { cursor: text !important; }
td.editable.total { background: #f1f5f9 !important; font-weight: 700; }
td.editable:focus-within { z-index: 50; }
td.editable input {
    width: 100%; border: 0; background: transparent; text-align: center;
    font-size: 13px; padding: 0; outline: none; color: var(--gris-900);
    font-family: inherit;
}
/* Al hacer foco: el input flota por encima con ancho ampliado (mínimo 240px) para ver bien fórmulas */
table.finanzas td.editable:focus-within input,
table.finanzas td.editable-presupuesto:focus-within input {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    min-width: 240px !important;
    max-width: none !important;
    height: auto !important;
    min-height: 32px !important;
    padding: 6px 10px !important;
    background: #fff3cd !important;
    border: 2px solid #007bff !important;
    box-shadow: 0 6px 18px rgba(0,123,255,.25);
    z-index: 50;
    font-size: 14px !important;
    font-weight: 600;
    text-align: left !important;
    color: #212529 !important;
    box-sizing: border-box !important;
}
table.finanzas td.editable:focus-within,
table.finanzas td.editable-presupuesto:focus-within { padding: 0 !important; }
td.editable.saved { background: #ecfdf5 !important; transition: background 1s; }
td.editable.error { background: #fef2f2 !important; }

/* Sin marca visual para fórmula (quitada por preferencia del usuario) */
td.editable.has-formula { position: relative; }
td.no-editable { background: #fff; color: var(--gris-500); }
td.col-total { background: #fff !important; font-weight: 700; color: var(--azul-oscuro); }
tr.row-item td.col-total { background: #fff !important; }

/* Celda TOTAL PRESUPUESTO editable (solo items EGRESO) */
td.col-total.editable-presupuesto { background: #fff !important; cursor: cell; position: relative; }
td.col-total.editable-presupuesto:focus-within { z-index: 50; }
/* Al enfocar: el input flota por encima igual que las celdas semanales */
td.col-total.editable-presupuesto:focus-within input {
    position: absolute;
    top: 0; left: 0;
    min-width: 100%;
    width: auto;
    min-width: 200px;
    height: 100%;
    min-height: 30px;
    padding: 6px 10px !important;
    background: #fffbea;
    border: 2px solid var(--azul) !important;
    box-shadow: 0 6px 18px rgba(11,61,100,.25);
    z-index: 50;
    font-size: 14px !important;
    font-weight: 700;
    text-align: left !important;
    color: var(--gris-900);
    box-sizing: border-box;
}
td.col-total.editable-presupuesto input {
    width: 100%; border: 0; background: transparent; text-align: center;
    font-size: 13px; padding: 0; outline: none;
    color: var(--azul-oscuro); font-weight: 700;
    font-family: inherit;
}
td.col-total.editable-presupuesto.saved { background: #ecfdf5 !important; }
td.col-total.editable-presupuesto.error { background: #fef2f2 !important; }

/* Split ejecutado | presupuesto dentro de una misma celda TOTAL */
td.col-total.split-pres {
    padding: 4px 6px !important;
}
td.col-total.split-pres {
    display: table-cell; /* mantiene layout de tabla */
}
td.col-total.split-pres > * {
    display: inline-block;
    width: 48%;
    vertical-align: middle;
    text-align: center;
    box-sizing: border-box;
    padding: 0 4px;
}
td.col-total.split-pres .ejec {
    color: var(--gris-500);
    font-weight: 500;
    font-size: 12px;
    border-right: 1px dashed var(--gris-300);
}
td.col-total.split-pres .pres {
    font-weight: 700;
    color: var(--azul-oscuro);
}
td.col-total.split-pres input {
    width: 48% !important;
    display: inline-block;
    vertical-align: middle;
    text-align: right;
}
/* Cuando la fila es sección/grupo azul, texto blanco */
tr.row-seccion td.col-total.split-pres .ejec,
tr.row-grupo td.col-total.split-pres .ejec { color: rgba(255,255,255,.75); border-right-color: rgba(255,255,255,.3); }
tr.row-seccion td.col-total.split-pres .pres,
tr.row-grupo td.col-total.split-pres .pres { color: #fff; }

/* Alerta cromática por texto solamente (fondo blanco siempre) */
td.col-total.presupuesto-excedido,
td.col-total.presupuesto-ok {
    background: #fff !important;
    font-weight: 700;
}
/* Excedido = rojo */
td.col-total.presupuesto-excedido,
td.col-total.presupuesto-excedido .ejec,
td.col-total.presupuesto-excedido .pres,
td.col-total.presupuesto-excedido input {
    color: #dc2626 !important;
    font-weight: 700;
}
/* Dentro del presupuesto = verde */
td.col-total.presupuesto-ok,
td.col-total.presupuesto-ok .ejec,
td.col-total.presupuesto-ok .pres,
td.col-total.presupuesto-ok input {
    color: #16a34a !important;
    font-weight: 700;
}
/* En filas SECCIÓN / GRUPO: fondo pleno (rojo o verde) con texto blanco */
tr.row-seccion td.col-total.presupuesto-excedido,
tr.row-grupo   td.col-total.presupuesto-excedido {
    background: #dc2626 !important;
}
tr.row-seccion td.col-total.presupuesto-ok,
tr.row-grupo   td.col-total.presupuesto-ok {
    background: #16a34a !important;
}
tr.row-seccion td.col-total.presupuesto-excedido,
tr.row-seccion td.col-total.presupuesto-excedido .ejec,
tr.row-seccion td.col-total.presupuesto-excedido .pres,
tr.row-grupo   td.col-total.presupuesto-excedido,
tr.row-grupo   td.col-total.presupuesto-excedido .ejec,
tr.row-grupo   td.col-total.presupuesto-excedido .pres,
tr.row-seccion td.col-total.presupuesto-ok,
tr.row-seccion td.col-total.presupuesto-ok .ejec,
tr.row-seccion td.col-total.presupuesto-ok .pres,
tr.row-grupo   td.col-total.presupuesto-ok,
tr.row-grupo   td.col-total.presupuesto-ok .ejec,
tr.row-grupo   td.col-total.presupuesto-ok .pres {
    color: #fff !important;
    border-right-color: rgba(255,255,255,.4) !important;
}

/* Acciones fila (borrar concepto) */
td.acciones { text-align: center; }
td.acciones button {
    background: transparent; border: 0; color: var(--gris-500); cursor: pointer; font-size: 15px;
}
td.acciones button:hover { color: var(--rojo); }

/* Columna de acciones dentro del grid financiero */
table.finanzas th.col-acc, table.finanzas td.col-acc {
    width: 60px; text-align: center; padding: 4px 6px;
}
table.finanzas thead th.col-acc { background: var(--azul-oscuro); }
tr.row-seccion td.col-acc { background: var(--azul-oscuro) !important; }
tr.row-grupo td.col-acc { background: #D1ECF1 !important; }
tr.row-item td.col-acc { background: #fff; }
tr.row-item:nth-child(even) td.col-acc { background: #fbfdff; }
tr.row-item:hover td.col-acc { background: #eaf6ff !important; }

/* Botones de fila (eliminar / editar) */
.btn-del-fila, .btn-edit-fila {
    background: transparent; border: 0; cursor: pointer;
    color: var(--gris-500); font-size: 14px;
    padding: 2px 6px; border-radius: 4px; line-height: 1;
    transition: background .15s, color .15s;
}
.btn-del-fila:hover { color: var(--rojo); background: #fee2e2; }
.btn-edit-fila:hover { color: var(--azul); background: #e0f2fe; }
/* Los botones aparecen sutilmente hasta que el mouse pasa por la fila */
tr.row-item .btn-del-fila, tr.row-item .btn-edit-fila { opacity: .35; }
tr.row-item:hover .btn-del-fila, tr.row-item:hover .btn-edit-fila { opacity: 1; }

/* Períodos cerrados (bloqueados) */
table.finanzas th.th-cerrado { background: #6b7280 !important; }
table.finanzas td.td-cerrado {
    background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 6px, #eef2f7 6px, #eef2f7 12px) !important;
    color: var(--gris-700) !important;
    cursor: not-allowed;
    font-weight: 500;
}
tr.row-item td.td-cerrado:hover { background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 6px, #e2e8f0 6px, #e2e8f0 12px) !important; }
.lock, .unlock {
    display: inline-block; cursor: pointer;
    padding: 2px 6px; border-radius: 4px;
    transition: background .15s;
    font-size: 13px;
}
.lock:hover, .unlock:hover { background: rgba(255,255,255,.2); }
.unlock { opacity: .5; }
.unlock:hover { opacity: 1; }

/* Fila espaciadora entre TOTALES ↔ INGRESO ↔ EGRESOS — TODAS las celdas en blanco */
tr.row-sep td,
tr.row-sep td.col-etiq,
tr.row-sep td.col-cod,
tr.row-sep td.col-total,
tr.row-sep td.col-total.c-pres-w,
tr.row-sep td.col-total.c-ejec-w,
tr.row-sep td.col-total.c-sal-w,
tr.row-sep td.col-acc {
    height: 40px;
    background: #ffffff !important;
    background-color: #ffffff !important;
    border-color: transparent !important;
    border: 0 !important;
}
tr.row-sep + tr.anx-subhead th { border-top: 8px solid #fff !important; }

/* Fila espaciadora al final del grid */
tr.row-sep-final td {
    height: 32px;
    background: #fff !important;
    border-color: transparent !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
}

/* Modal (custom — override Bootstrap 4 .modal) */
.modal-back {
    position: fixed !important; inset: 0; background: rgba(15,23,42,.5);
    display: none; align-items: center; justify-content: center; z-index: 1060;
    opacity: 1 !important;
}
.modal-back.open { display: flex !important; }
.modal-back > .modal {
    position: static !important;
    display: block !important;
    background: #fff; border-radius: 12px; padding: 24px 26px; width: 100%;
    max-width: 460px; box-shadow: 0 30px 60px rgba(0,0,0,.3);
    overflow: visible; height: auto; pointer-events: auto;
    opacity: 1 !important;
}
.modal-back > .modal h3 { margin: 0 0 16px; color: var(--azul-oscuro); }
.modal-back > .modal label { display: block; margin-bottom: 12px; }
.modal-back > .modal label span { display: block; font-size: 12px; color: var(--gris-500); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.modal-back > .modal input, .modal-back > .modal select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--gris-300); border-radius: 6px; font-size: 14px;
}
.modal-back > .modal input:focus, .modal-back > .modal select:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(18,104,159,.15); }
.modal-back > .modal .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-back > .modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Toast */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--azul-oscuro); color: #fff; padding: 12px 20px;
    border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
    font-size: 13px; opacity: 0; transform: translateY(20px);
    transition: opacity .25s, transform .25s; z-index: 200;
    pointer-events: none;
    white-space: pre-line;  /* preserva saltos de línea (\n) */
    max-width: 380px;
    line-height: 1.45;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--rojo); }
.toast.success { background: var(--verde); }

/* Tabla reportes (simple, para listados) */
table.reporte { width: 100%; border-collapse: collapse; font-size: 13px; }
table.reporte th, table.reporte td { padding: 9px 12px; border-bottom: 1px solid var(--gris-200); text-align: left; }
table.reporte th { background: var(--gris-100); color: var(--gris-700); text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
table.reporte tr:hover td { background: #fbfdff; }
table.reporte td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ==== TABLA PROFESIONAL tipo Excel (para admin: Usuarios, Conceptos, Períodos) ==== */
.tabla-pro-wrap {
    background: #fff; border-radius: var(--radius); box-shadow: var(--sombra);
    overflow-x: auto;
}
table.tabla-pro {
    width: 100%; border-collapse: collapse; font-size: 13px;
    min-width: 800px;
}
table.tabla-pro thead th {
    background: var(--azul-oscuro); color: #fff;
    font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
    padding: 10px 12px; border: 1px solid var(--azul);
    text-align: center; white-space: nowrap;
    position: sticky; top: 0; z-index: 3;
}
table.tabla-pro thead th.left { text-align: left; }
table.tabla-pro tbody td {
    padding: 8px 12px; border: 1px solid var(--gris-200);
    vertical-align: middle;
    background: #fff;
    font-size: 13px;
}
table.tabla-pro tbody tr:nth-child(even) td { background: #fbfdff; }
table.tabla-pro tbody tr:hover td { background: #eaf6ff; }
table.tabla-pro tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tabla-pro tbody td.ctr { text-align: center; }
table.tabla-pro tbody td.id  { text-align: center; color: var(--gris-500); font-weight: 600; font-size: 12px; }
table.tabla-pro tbody td.strong { font-weight: 700; color: var(--azul-oscuro); }

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 700; letter-spacing: .4px;
    line-height: 1.4;
}
.badge-admin  { background: #fef3c7; color: #92400e; }
.badge-user   { background: #dbeafe; color: #1e40af; }
.badge-on     { background: #dcfce7; color: #166534; }
.badge-off    { background: #fee2e2; color: #991b1b; }
.badge-info   { background: #e0f2fe; color: #075985; }

/* Botones de fila (acciones) */
.acc-row { display: inline-flex; gap: 4px; align-items: center; justify-content: center; }
.acc-btn {
    background: transparent; border: 1px solid transparent;
    padding: 5px 10px; border-radius: 6px; cursor: pointer;
    font-size: 13px; color: var(--gris-500);
    transition: all .12s;
    display: inline-flex; align-items: center; gap: 4px;
}
.acc-btn:hover { background: var(--gris-100); color: var(--azul-oscuro); border-color: var(--gris-300); }
.acc-btn.primary { background: var(--azul); color: #fff; font-weight: 600; font-size: 12px; }
.acc-btn.primary:hover { background: var(--azul-oscuro); border-color: var(--azul-oscuro); }
.acc-btn.primary:disabled { background: var(--gris-300); color: var(--gris-500); cursor: not-allowed; }
.acc-btn.danger  { color: var(--rojo); }
.acc-btn.danger:hover  { background: #fef2f2; border-color: #fecaca; color: var(--rojo); }
.acc-btn.edit    { color: var(--azul); }
.acc-btn.edit:hover    { background: #eff6ff; border-color: #bfdbfe; }

/* Estado inline */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-on  { background: var(--verde); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.dot-off { background: var(--rojo);  box-shadow: 0 0 0 3px rgba(220,38,38,.15); }

/* ============ SELECTOR DE EMPRESA (topbar) ============ */
.emp-switch { position: relative; }
.emp-switch-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, var(--azul-oscuro), var(--azul));
    color: #fff; border: 0; padding: 8px 14px; border-radius: 8px;
    cursor: pointer; font-weight: 700; font-size: 13px; letter-spacing: .5px;
    box-shadow: 0 2px 6px rgba(11,61,100,.25);
    transition: transform .1s;
}
.emp-switch-btn:hover { transform: translateY(-1px); }
.emp-switch-btn:active { transform: translateY(0); }
.emp-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #4ade80; box-shadow: 0 0 6px #4ade80;
}
.emp-caret { font-size: 10px; opacity: .8; }

.emp-menu {
    display: none; position: absolute; top: calc(100% + 8px); right: 0;
    background: #fff; border-radius: 12px;
    box-shadow: 0 12px 30px rgba(15,23,42,.18); border: 1px solid var(--gris-200);
    min-width: 240px; z-index: 100;
    overflow: hidden;
    animation: emp-menu-in .15s ease-out;
}
@keyframes emp-menu-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.emp-switch.open .emp-menu { display: block; }

.emp-menu-title {
    padding: 10px 14px; font-size: 10px; font-weight: 700; letter-spacing: 1px;
    color: var(--gris-500); text-transform: uppercase;
    background: #f8fafc; border-bottom: 1px solid var(--gris-200);
}
.emp-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer;
    transition: background .1s;
    border-bottom: 1px solid var(--gris-100);
}
.emp-item:last-child { border-bottom: 0; }
.emp-item:hover { background: #f0f9ff; }
.emp-item.active { background: #ecfeff; }
.emp-dot-item {
    width: 8px; height: 8px; border-radius: 50%;
    background: #94a3b8; flex-shrink: 0;
}
.emp-item:nth-child(2) .emp-dot-item { background: #14b8a6; }
.emp-item:nth-child(3) .emp-dot-item { background: #f97316; }
.emp-item:nth-child(4) .emp-dot-item { background: #eab308; }
.emp-item:nth-child(5) .emp-dot-item { background: #22c55e; }
.emp-item:nth-child(6) .emp-dot-item { background: #3b82f6; }
.emp-item-txt { flex: 1; }
.emp-item-name { font-weight: 700; font-size: 13px; color: var(--gris-900); }
.emp-item-desc { font-size: 11px; color: var(--gris-500); }
.emp-check { color: var(--verde); font-weight: 700; font-size: 16px; }

/* Usuario y logout en topbar */
.user-hdr {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 10px 4px 4px; border-radius: 8px;
    background: var(--gris-100);
}
.user-hdr-av {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--azul), var(--azul-claro));
    color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.user-hdr-txt { line-height: 1.2; }
.user-hdr-name { font-size: 12px; font-weight: 700; color: var(--gris-900); }
.user-hdr-rol { font-size: 10px; color: var(--gris-500); text-transform: uppercase; }

.btn-logout {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--rojo); color: #fff !important; padding: 8px 14px;
    border-radius: 8px; font-size: 12px; font-weight: 700; letter-spacing: .5px;
    text-decoration: none !important;
    transition: background .15s;
}
.btn-logout:hover { background: #b91c1c; }

/* ============ TABLA-PRO: paginación, ordenamiento y controles ============ */
.tp-toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 14px;
    background: #f8fafc; border-bottom: 1px solid var(--gris-200);
}
.tp-toolbar .grow { flex: 1; }
.tp-toolbar input.tp-search {
    padding: 7px 12px 7px 32px; border: 1px solid var(--gris-300); border-radius: 6px;
    font-size: 13px; min-width: 220px;
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 24 24'><path d='M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/></svg>") no-repeat 9px center;
}
.tp-toolbar input.tp-search:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(18,104,159,.15); }
.tp-toolbar select.tp-size {
    padding: 7px 10px; border: 1px solid var(--gris-300); border-radius: 6px;
    font-size: 13px; background: #fff; cursor: pointer;
}
.tp-toolbar .tp-info { font-size: 12px; color: var(--gris-500); }
.tp-toolbar .tp-info b { color: var(--azul-oscuro); }

/* Header sortable */
table.tabla-pro thead th.sortable { cursor: pointer; position: relative; user-select: none; }
table.tabla-pro thead th.sortable:hover { background: var(--azul); }
table.tabla-pro thead th.sortable::after {
    content: '⇅'; margin-left: 6px; opacity: .35; font-size: 10px;
}
table.tabla-pro thead th.sort-asc::after  { content: '▲'; opacity: 1; color: #7cd4d4; }
table.tabla-pro thead th.sort-desc::after { content: '▼'; opacity: 1; color: #7cd4d4; }

/* Paginación (footer) */
.tp-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 14px; background: #f8fafc; border-top: 1px solid var(--gris-200);
    flex-wrap: wrap;
}
.tp-foot .tp-info { font-size: 12px; color: var(--gris-500); }
.tp-pag { display: flex; gap: 4px; }
.tp-pag button {
    background: #fff; border: 1px solid var(--gris-300); color: var(--gris-700);
    min-width: 34px; height: 32px; padding: 0 10px; border-radius: 6px;
    cursor: pointer; font-size: 13px; font-weight: 600; transition: all .1s;
}
.tp-pag button:hover:not(:disabled) { background: var(--azul); color: #fff; border-color: var(--azul); }
.tp-pag button.active { background: var(--azul-oscuro); color: #fff; border-color: var(--azul-oscuro); }
.tp-pag button:disabled { opacity: .4; cursor: not-allowed; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .btn-toggle { display: inline-flex !important; }
}
.btn-toggle { display: none; background: transparent; border: 0; cursor: pointer; color: var(--gris-700); font-size: 20px; }

/* =========================================================
   TABLAS FINANCIERAS — BOOTSTRAP 4 + DATATABLES
   Estilo estándar Bootstrap 4 con clases table + table-sm + table-hover
   ========================================================= */

.grid-wrap {
    background: #ffffff;
    border: 1px solid #dee2e6;                /* border color Bootstrap */
    border-radius: 0.25rem;                    /* rounded */
    overflow: auto;
    max-height: calc(100vh - 180px);
    position: relative;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);   /* shadow-sm Bootstrap */
}

/* --- Tabla base — Bootstrap 4 (.table + .table-sm + .table-hover) --- */
table.finanzas {
    border-collapse: collapse;
    border-spacing: 0;
    width: auto;
    min-width: 100%;
    table-layout: auto;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    line-height: 1.4;
    color: #212529;
    background-color: #ffffff;
    margin-bottom: 0;
    font-variant-numeric: tabular-nums;
}
table.finanzas th, table.finanzas td {
    padding: 0.3rem 0.5rem;
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
}

/* --- HEADER: Bootstrap thead-dark --- */
table.finanzas thead th {
    background-color: #0F2E4A !important;
    color: #ffffff;
    padding: 0.35rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.72rem;
    line-height: 1.2;
    font-family: var(--font-ui);
    letter-spacing: .2px;
    text-transform: uppercase;
    border-bottom: 2px solid #212529;
    border-top: 0;
    position: sticky; top: 0; z-index: 10;
    white-space: nowrap;
    height: 26px;
    box-sizing: border-box;
}
/* Solo etiquetas de texto (no fechas ni números) más pequeñas */
table.finanzas thead th.grupo-mes,
table.finanzas thead th.col-etiq,
table.finanzas thead th.col-total,
table.finanzas thead th.sh-pres,
table.finanzas thead th.sh-ejec,
table.finanzas thead th.sh-sal {
    font-size: 0.58rem !important;
    letter-spacing: .3px;
}
/* SEMANAS, CONCEPTO y celdas de etiqueta izquierda: centradas */
table.finanzas thead th.col-etiq,
table.finanzas tr.anx-subhead th.col-etiq,
table.finanzas tr.anx-subhead th.subhead-rubros,
table.finanzas th.subhead-rubros {
    text-align: center !important;
    padding-left: 0.4rem !important;
    padding-right: 0.4rem !important;
}
tr.row-seccion td.col-etiq {
    text-align: center !important;
    padding-left: 0.4rem !important;
    padding-right: 0.4rem !important;
    font-size: 0.58rem !important;
    letter-spacing: .3px;
}
table.finanzas thead th.grupo-mes {
    background-color: #495057 !important;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
}
table.finanzas thead th.col-total {
    background-color: #0F2E4A !important;
    color: #ffffff;
    border-left: 1px solid #212529;
    font-weight: 700;
}

/* --- Sub-headers PRES/EJEC/SAL — Bootstrap bg-light --- */
table.finanzas thead th.sh-pres,
table.finanzas thead th.sh-ejec,
table.finanzas thead th.sh-sal,
table.finanzas tr.anx-subhead th {
    background-color: #f8f9fa !important;
    color: #495057;
    font-size: 0.625rem !important;
    font-weight: 600;
    padding: 0.35rem 0.25rem !important;
    letter-spacing: .3px;
    text-transform: uppercase;
    border-bottom: 1px solid #dee2e6;
    border-top: 1px solid #e9ecef;
}
/* Sub-header CONCEPTO + PRESUPUESTO/EJECUTADO/SALDO — toda la fila con fondo #12689F */
table.finanzas tr.anx-subhead th,
table.finanzas tr.anx-subhead th.sh-pres,
table.finanzas tr.anx-subhead th.sh-ejec,
table.finanzas tr.anx-subhead th.sh-sal,
table.finanzas tr.anx-subhead th.col-etiq {
    background-color: #12689F !important;
    background: #12689F !important;
    color: #ffffff !important;
    font-family: var(--font-ui) !important;
    font-size: 0.58rem !important;
    font-weight: 700 !important;
    padding: 0.35rem 0.35rem !important;
    height: 26px !important;
    line-height: 1.2 !important;
    box-sizing: border-box;
    border-top: 0 !important;
    border-bottom: 1px solid #0F5A8C !important;
}
table.finanzas tr.anx-subhead th.subhead-rubros,
table.finanzas thead th.subhead-rubros,
th.subhead-rubros {
    background-color: #12689F !important;
    background: #12689F !important;
    color: #ffffff !important;
    font-family: var(--font-ui) !important;
    font-size: 0.58rem !important;
    font-weight: 700 !important;
    letter-spacing: .5px !important;
    text-transform: uppercase;
    border-top: 0;
    border-bottom: 1px solid #0F5A8C;
    padding: 0.35rem 0.35rem !important;
    height: 26px !important;
}

/* --- Sticky: CÓD y RUBRO --- */
table.finanzas th.col-etiq,
table.finanzas td.col-etiq {
    position: sticky; z-index: 4;
    background-color: #ffffff;
    text-align: left !important;
    padding: 0.35rem 0.6rem !important;
    font-weight: 500;
    color: #212529;
    min-width: 150px; max-width: 200px;
    border-right: 1px solid #dee2e6;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.finanzas th.col-cod,
table.finanzas td.col-cod {
    position: sticky; left: 0; z-index: 4;
    background-color: #ffffff;
    min-width: 55px; max-width: 70px;
    font-weight: 600; color: #6c757d;
    padding: 0.35rem 0.4rem !important;
    text-align: center;
    border-right: 1px solid #dee2e6;
    font-family: var(--font-num);
    font-size: 0.6875rem;
}
table.finanzas th.col-cod + th.col-etiq,
table.finanzas td.col-cod + td.col-etiq { left: 55px; }
table.finanzas thead th.col-etiq,
table.finanzas thead th.col-cod {
    background-color: #0F2E4A !important;
    color: #ffffff !important;
    text-align: center !important;
    z-index: 12;
}

/* --- Cuerpo (table-hover Bootstrap) --- */
table.finanzas tbody td {
    padding: 0.35rem 0.4rem;
    text-align: center;
    background-color: #ffffff;
    color: #212529;
    vertical-align: middle;
    transition: background-color .08s ease;
}
tr.row-item:nth-child(odd) td,
tr.row-item:nth-child(odd) td.col-etiq,
tr.row-item:nth-child(odd) td.col-cod { background-color: rgba(0, 0, 0, 0.02); }
tr.row-item:hover td,
tr.row-item:hover td.col-etiq,
tr.row-item:hover td.col-cod { background-color: rgba(0, 123, 255, 0.075) !important; }

/* --- Grupos: Bootstrap table-info (celeste claro) --- */
tr.row-grupo td {
    background-color: #d1ecf1 !important;
    color: #0c5460 !important;
    font-weight: 700 !important;
    font-size: 0.75rem;
    padding: 0.4rem 0.4rem !important;
    border-top: 1px solid #bee5eb;
    border-bottom: 1px solid #bee5eb;
}
tr.row-grupo td.col-etiq {
    background-color: #d1ecf1 !important;
    color: #0c5460 !important;
    border-left: 3px solid #17a2b8;
    border-right: 1px solid #bee5eb;
    padding-left: 0.6rem !important;
}
tr.row-grupo td.col-cod {
    background-color: #d1ecf1 !important;
    color: #0c5460 !important;
    font-weight: 700;
    border-right: 1px solid #bee5eb;
}
tr.row-grupo:hover td,
tr.row-grupo:hover td.col-etiq,
tr.row-grupo:hover td.col-cod { background-color: #d1ecf1 !important; }

/* --- Secciones: Bootstrap bg-dark --- */
tr.row-seccion td {
    background-color: #0F2E4A !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 0.4rem !important;
    border-top: 1px solid #23272b;
    border-bottom: 1px solid #23272b;
}
tr.row-seccion td.col-etiq {
    background-color: #0F2E4A !important;
    color: #ffffff !important;
    border-left: 3px solid #17a2b8;
    border-right: 1px solid #495057;
    padding-left: 0.6rem !important;
}
tr.row-seccion td.col-cod  {
    background-color: #0F2E4A !important;
    color: #ced4da !important;
    border-right: 1px solid #495057;
}
/* Sub-columnas PRES/EJEC/SAL dentro de la fila EGRESOS/TOTALES (SECCION) — compactas */
tr.row-seccion td.c-pres-w,
tr.row-seccion td.c-ejec-w,
tr.row-seccion td.c-sal-w {
    padding: 0.35rem 0.35rem !important;
    text-align: left !important;
    font-weight: 700 !important;
    font-size: 0.66rem !important;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap !important;
    color: #ffffff !important;
    min-width: 62px !important;
    width: 62px !important;
    max-width: none !important;
    border-right: 1px solid #495057 !important;
    overflow: visible !important;
    box-sizing: border-box;
}
tr.row-seccion td.c-sal-w { border-right: 2px solid #6c757d !important; }
tr.row-seccion td.c-sal-w.saldo-neg { color: #ff8a95 !important; }

/* --- Sub-columnas PRES / EJEC / SAL — compactas, alineadas a la izquierda --- */
table.finanzas td.c-pres-w,
table.finanzas td.c-ejec-w,
table.finanzas td.c-sal-w,
table.finanzas td.c-pres,
table.finanzas td.c-ejec,
table.finanzas td.c-sal {
    font-family: var(--font-num);
    font-size: 0.64rem !important;
    padding: 0.25rem 0.35rem !important;
    min-width: 62px !important;
    width: 62px !important;
    max-width: none !important;
    color: #212529;
    font-weight: 500;
    text-align: left !important;
    white-space: nowrap !important;
    overflow: visible !important;
    letter-spacing: 0;
    box-sizing: border-box;
}
table.finanzas td.c-pres-w, table.finanzas td.c-pres { border-left: 1px solid #dee2e6; }
table.finanzas td.c-sal-w, table.finanzas td.c-sal {
    border-right: 1px solid #dee2e6 !important;
}
table.finanzas th.sh-sal { border-right: 1px solid #ced4da !important; }

/* Saldos: text-danger Bootstrap para negativos */
table.finanzas td.c-sal-w.saldo-neg,
table.finanzas td.c-sal.sal-neg { color: #dc3545 !important; font-weight: 700; }
table.finanzas td.c-sal-w.saldo-pos,
table.finanzas td.c-sal.sal-pos { color: #212529; font-weight: 500; }
table.finanzas td.c-sal-w.saldo-zero,
table.finanzas td.c-sal.sal-zero { color: #adb5bd; }

/* --- TOTAL MES / ACUMULADO — ancho suficiente para valores grandes, centrados --- */
table.finanzas td.col-total {
    background-color: #d1ecf1 !important;
    font-weight: 500;
    color: #212529;
    font-family: var(--font-num);
    font-size: 0.7rem !important;
    padding: 0.35rem 0.55rem !important;
    min-width: 105px !important;
    width: 105px !important;
    max-width: none !important;
    border-left: 1px solid #bee5eb;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: visible !important;
    box-sizing: border-box;
    letter-spacing: 0;
}
tr.row-item td.col-total { background-color: #ffffff !important; border-left: 1px solid #dee2e6 !important; }
tr.row-item:nth-child(odd) td.col-total { background-color: rgba(0, 0, 0, 0.02) !important; }
tr.row-item:hover td.col-total { background-color: rgba(0, 123, 255, 0.075) !important; }
tr.row-grupo td.col-total {
    background-color: #D1ECF1 !important;
    color: #0c5460 !important;
    border-left: 1px solid #17a2b8;
}
tr.row-seccion td.col-total {
    background-color: #0c5460 !important;
    color: #ffffff !important;
    border-left: 1px solid #17a2b8;
}

/* --- Inputs editables (form-control style) --- */
table.finanzas td.editable input,
table.finanzas td.editable-presupuesto input {
    font-family: var(--font-num);
    font-size: 0.64rem;
    color: #495057;
    font-weight: 500;
    background: transparent;
    text-align: left;
    border: 0;
    padding: 0 0.35rem;
}
table.finanzas td.editable { transition: background-color .08s ease, box-shadow .08s ease; }
table.finanzas td.editable:hover { background-color: #fff3cd !important; }
table.finanzas td.editable:focus-within {
    background-color: #fff3cd !important;
    box-shadow: inset 0 0 0 2px #007bff;
    z-index: 3;
}

/* --- Botones acción con estilo Bootstrap btn-link --- */
.btn-del-fila, .btn-edit-fila {
    background: transparent; border: 0;
    width: 22px; height: 22px; border-radius: 0.2rem;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0;
    transition: opacity .12s, background-color .12s, color .12s;
    color: #6c757d; font-size: 12px;
}
tr:hover .btn-del-fila, tr:hover .btn-edit-fila { opacity: 1; }
.btn-del-fila:hover { background: #f8d7da; color: #dc3545; }
.btn-edit-fila:hover { background: #d1ecf1; color: #007bff; }

/* Banda INGRESO: barra oscura uniforme sin sub-encabezados PRES/EJEC/SAL */
tr.band-ingreso th,
tr.band-ingreso td {
    background-color: #0F2E4A !important;
    color: #ffffff !important;
    border-color: #0F2E4A !important;
    padding: 0.6rem 0.5rem !important;
    height: 34px;
}
tr.band-ingreso th.subhead-rubros {
    background-color: #0F2E4A !important;
    color: #ffffff !important;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
    text-transform: uppercase;
}

/* Grupos colapsables (INGRESOS POR PESCA, OTROS INGRESOS) */
tr.row-grupo td.etiq-grupo { cursor: pointer; user-select: none; }
tr.row-grupo td.etiq-grupo:hover { background-color: #bee5eb !important; }

/* Filas turquesas: eliminar bordes internos entre PRES/EJEC/SAL para que se vean como una sola celda */
tr.row-grupo td.c-pres-w,
tr.row-grupo td.c-ejec-w,
tr.row-grupo td.c-sal-w,
tr.row-grupo td.col-total.c-pres-w,
tr.row-grupo td.col-total.c-ejec-w,
tr.row-grupo td.col-total.c-sal-w {
    border-left: 0 !important;
    border-right: 0 !important;
    background-color: #D1ECF1 !important;
}

/* Forzar #D1ECF1 en TODAS las celdas de las filas de grupo (INGRESOS POR PESCA, OTROS INGRESOS) */
table.finanzas tr.row-grupo > td,
table.finanzas tr.row-grupo > td.col-etiq,
table.finanzas tr.row-grupo > td.col-cod,
table.finanzas tr.row-grupo > td.col-total,
table.finanzas tr.row-grupo > td.col-acc,
table.finanzas tr.row-grupo > td.no-editable,
table.finanzas tr.row-grupo > td.editable {
    background-color: #D1ECF1 !important;
    background: #D1ECF1 !important;
}

/* Separador entre semanas: borde azul en la última sub-columna de cada semana (SAL) */
table.finanzas td.c-sal-w,
table.finanzas td.c-sal {
    border-right: 2px solid #0F2E4A !important;
}
table.finanzas th.sh-sal {
    border-right: 2px solid #0F2E4A !important;
}
/* En filas de INGRESO (turquesas + sus items), asegurar el borde azul también sobre celdas colspan=3 */
tr.row-grupo td.no-editable.c-sal-w,
tr.row-item td.editable + td.no-editable,
tr.row-item td[colspan="3"] {
    border-right: 2px solid #0F2E4A !important;
}
.grp-caret {
    display: inline-block;
    width: 12px; margin-right: 6px;
    font-size: 9px; color: #0c5460;
    transition: transform .12s;
}

/* Fila "+ Nueva fila" para agregar ítems a INGRESOS POR PESCA / OTROS INGRESOS */
tr.row-add td { background-color: #f8f9fa !important; border-bottom: 1px solid #dee2e6; padding: 0.25rem 0.4rem !important; }
tr.row-add td.col-etiq-add { text-align: left; padding-left: 0.9rem !important; }
.btn-add-fila {
    background: transparent;
    border: 1px dashed #17a2b8;
    color: #17a2b8;
    padding: 0.15rem 0.6rem;
    border-radius: 0.25rem;
    font-size: 0.7rem; font-weight: 600;
    cursor: pointer;
    transition: all .12s;
}
.btn-add-fila:hover {
    background-color: #17a2b8; color: #fff; border-style: solid;
}

/* --- Scrollbar --- */
.grid-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.grid-wrap::-webkit-scrollbar-track { background: #f8f9fa; }
.grid-wrap::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 5px; border: 2px solid #f8f9fa; }
.grid-wrap::-webkit-scrollbar-thumb:hover { background: #6c757d; }
.grid-wrap::-webkit-scrollbar-corner { background: #f8f9fa; }

/* ==== OVERRIDE FINAL — CONCEPTO en anx-subhead con #12689F ==== */
html body table.finanzas tr.anx-subhead th.col-etiq,
html body table.finanzas tr.anx-subhead th.col-etiq.subhead-rubros,
html body table.finanzas tr.anx-subhead th.subhead-rubros {
    background-color: #12689F !important;
    background: #12689F !important;
    background-image: none !important;
    color: #ffffff !important;
}

/* ==== CENTRAR ETIQUETAS (SEMANAS / CONCEPTO) — override final ==== */
html body table.finanzas thead th.col-etiq,
html body table.finanzas tr.anx-subhead th.col-etiq,
html body table.finanzas tr.anx-subhead th.subhead-rubros {
    text-align: center !important;
    padding-left: 0.4rem !important;
    padding-right: 0.4rem !important;
}
/* Filas de SECCION (EGRESOS, SALDO FINAL DE CAJA) — alineadas a la izquierda como INGRESO */
html body table.finanzas tr.row-seccion td.col-etiq {
    text-align: left !important;
    padding-left: 0.75rem !important;
    padding-right: 0.4rem !important;
}

/* ==== Indicador visual de celdas editables (todas menos row-grupo celeste) ==== */
html body table.finanzas tr.row-item td.editable {
    cursor: text !important;
    position: relative;
}
html body table.finanzas tr.row-item td.editable::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 1px dashed transparent;
    transition: border-color .12s;
}
html body table.finanzas tr.row-item td.editable:hover::after {
    border-color: #adb5bd;
}
html body table.finanzas tr.row-item td.editable:hover {
    background-color: #fff8e1 !important;
}

/* ==== Separador visual entre meses ==== */
table.finanzas th.mes-end,
table.finanzas td.mes-end,
table.finanzas th.sh-pres.mes-end {
    border-right: 3px solid #0F2E4A !important;
}
table.finanzas thead th.grupo-mes.mes-end {
    border-right: 3px solid #ffffff !important;
}

/* ==== STICKY: cabeceras del thead + banda INGRESOS al scroll ==== */
/* Fila 1 (mes-año) */
html body table.finanzas thead tr:nth-child(1) th {
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
}
/* Fila 2 (CONCEPTO / PRES/EJEC/SALDO) */
html body table.finanzas thead tr:nth-child(2) th {
    position: sticky !important;
    top: 26px !important;
    z-index: 29 !important;
}
/* Fila 3 (SEMANAS / fechas / ACUMULADO) */
html body table.finanzas thead tr:nth-child(3) th {
    position: sticky !important;
    top: 52px !important;
    z-index: 28 !important;
}

/* ==== Ingreso de datos: fila 1 del thead (mes/año) toda en gris uniforme ==== */
html body #tblFin thead tr:nth-child(1) th,
html body #tblFin thead tr:nth-child(1) th.col-etiq,
html body #tblFin thead tr:nth-child(1) th.col-acc,
html body #tblFin thead tr:nth-child(1) th.grupo-mes {
    background-color: #495057 !important;
    color: #ffffff !important;
    border-color: #495057 !important;
}

/* Mes/año (JULIO 2026) siempre centrado */
html body table.finanzas thead th.grupo-mes {
    text-align: center !important;
}

/* ==== OVERRIDE FINAL: input flotante grande, expandido hacia la izquierda ==== */
html body table.finanzas td.editable:focus-within input,
html body table.finanzas td.editable-presupuesto:focus-within input,
html body table.finanzas td.col-total.editable-presupuesto:focus-within input {
    position: absolute !important;
    top: 0 !important;
    left: auto !important;
    right: 0 !important;
    bottom: auto !important;
    width: 260px !important;
    min-width: 260px !important;
    max-width: none !important;
    height: 34px !important;
    padding: 6px 10px !important;
    background: #fff3cd !important;
    border: 2px solid #007bff !important;
    box-shadow: 0 6px 18px rgba(0,123,255,.25) !important;
    z-index: 100 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-align: left !important;
    color: #212529 !important;
    box-sizing: border-box !important;
}

/* ==== Columna % (EJEC/PRES) ==== */
table.finanzas th.sh-pct,
table.finanzas th.sh-pct.mes-end {
    background-color: #12689F !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 0.58rem !important;
    padding: 0.35rem 0.35rem !important;
}
table.finanzas td.col-total-pct {
    background-color: #f8f9fa !important;
    font-family: var(--font-num);
    font-size: 0.72rem !important;
    font-weight: 700;
    padding: 0.4rem 0.5rem !important;
    min-width: 62px !important;
    width: 62px !important;
    text-align: center !important;
    color: #212529;
    white-space: nowrap;
    border-left: 1px solid #dee2e6;
}
tr.row-item td.col-total-pct { background-color: #ffffff !important; }
tr.row-item:hover td.col-total-pct { background-color: rgba(0, 123, 255, 0.075) !important; }
tr.row-grupo td.col-total-pct { background-color: #D1ECF1 !important; color: #0c5460 !important; }
tr.row-seccion td.col-total-pct { background-color: #0F2E4A !important; color: #ffffff !important; }
tr.row-seccion.band-ingreso td.col-total-pct { background-color: #0F2E4A !important; color: #ffffff !important; }

/* Códigos de color por rango de % */
table.finanzas td.col-total-pct.pct-bajo  { color: #dc3545 !important; }
table.finanzas td.col-total-pct.pct-medio { color: #ffc107 !important; }
table.finanzas td.col-total-pct.pct-alto  { color: #28a745 !important; }

/* ==== Celdas sin presupuesto asignado en Ingreso de datos ==== */
table.finanzas td.sin-asignado {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    text-align: center !important;
    font-weight: 700 !important;
    cursor: not-allowed !important;
    font-size: 0.9rem;
}
table.finanzas td.sin-asignado:hover {
    background-color: #f5c6cb !important;
}

/* ==== KPI SALDO estilo dashboard (arriba de INGRESOS) ==== */
tr.row-kpi-saldo td {
    background-color: #ffffff !important;
    padding: 6px 5px !important;
    vertical-align: middle;
    border: 0 !important;
    height: 82px;
}
tr.row-kpi-saldo td.col-etiq.kpi-saldo-label {
    background-color: #ffffff !important;
    color: #0F2E4A !important;
    font-weight: 800 !important;
    letter-spacing: 1.5px;
    text-align: center !important;
    font-size: 0.78rem !important;
    padding: 8px 6px !important;
    line-height: 1.2;
    border: 0 !important;
    white-space: nowrap;
}

/* Contenedor tipo card */
tr.row-kpi-saldo td.kpi-cell {
    background-color: transparent !important;
    padding: 6px 8px !important;
    text-align: left;
}
tr.row-kpi-saldo td.kpi-cell .kpi-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 8px 10px;
    height: 68px;
    box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 3px 8px rgba(15,23,42,.05);
    border-left: 3px solid #adb5bd;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 4px;
    min-width: 0;
    transition: transform .12s, box-shadow .12s;
}
tr.row-kpi-saldo td.kpi-cell:hover .kpi-card {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(15,23,42,.08), 0 6px 14px rgba(15,23,42,.08);
}
tr.row-kpi-saldo td.kpi-cell:hover .kpi-card {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(15,23,42,.08), 0 8px 20px rgba(15,23,42,.10);
}
.kpi-card .kpi-title {
    font-family: var(--font-ui);
    font-size: 0.55rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    line-height: 1;
    text-align: center;
}
.kpi-card .kpi-value {
    font-family: var(--font-num);
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.3px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.kpi-card .kpi-sub {
    font-family: var(--font-ui);
    font-size: 0.5rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    line-height: 1;
    text-align: center;
}

/* Color coding por resultado */
tr.row-kpi-saldo td.kpi-cell.kpi-pos .kpi-card { border-left-color: #28a745; }
tr.row-kpi-saldo td.kpi-cell.kpi-pos .kpi-value { color: #28a745; }
tr.row-kpi-saldo td.kpi-cell.kpi-neg .kpi-card { border-left-color: #dc3545; }
tr.row-kpi-saldo td.kpi-cell.kpi-neg .kpi-value { color: #dc3545; }
tr.row-kpi-saldo td.kpi-cell.kpi-zero .kpi-card { border-left-color: #adb5bd; }
tr.row-kpi-saldo td.kpi-cell.kpi-zero .kpi-value { color: #6c757d; }

/* Card del ACUMULADO del mes — un poco más destacada */
tr.row-kpi-saldo td.kpi-cell-mes .kpi-card {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-left-width: 4px;
    border-top: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
}
tr.row-kpi-saldo td.kpi-cell-mes.kpi-pos .kpi-card { border-left-color: #28a745; }
tr.row-kpi-saldo td.kpi-cell-mes.kpi-neg .kpi-card { border-left-color: #dc3545; }
tr.row-kpi-saldo td.kpi-cell-mes .kpi-value { font-size: 1.1rem; }

tr.row-kpi-saldo td.kpi-saldo-pct {
    background-color: transparent !important;
    border: 0 !important;
}

/* ==== Columna espaciadora ENTRE última semana y ACUMULADO DEL MES ==== */
/* Espaciador blanco + borde de apertura AZUL OSCURO en el acumulado */
html body table.finanzas th.acum-start,
html body table.finanzas td.acum-start,
html body table.finanzas tr.row-seccion td.acum-start,
html body table.finanzas tr.row-seccion.band-ingreso td.acum-start,
html body table.finanzas tr.row-grupo td.acum-start,
html body table.finanzas tr.row-item td.acum-start,
html body table.finanzas tr.row-kpi-saldo td.acum-start,
html body table.finanzas tr.row-kpi-saldo td.kpi-cell-mes.acum-start {
    border-left: 48px solid #ffffff !important;
    border-left-color: #ffffff !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    background-clip: padding-box !important;
    box-shadow: inset 3px 0 0 #0F2E4A !important;
}


/* Borde de "cierre" en la última celda de la semana antes del espaciador */
html body table.finanzas td:has(+ td.acum-start),
html body table.finanzas th:has(+ th.acum-start),
html body table.finanzas td.close-mes,
html body table.finanzas th.close-mes {
    border-right: 3px solid #0F2E4A !important;
    box-shadow: inset -3px 0 0 #0F2E4A !important;
}

/* ==== Centrar valores en la banda INGRESOS ==== */
html body table.finanzas tr.row-seccion.band-ingreso td.c-pres-w,
html body table.finanzas tr.row-seccion.band-ingreso td.col-total.c-pres-w {
    text-align: center !important;
}

/* ==== Centrar valores en filas de GRUPO turquesa e ITEMS INGRESO/SALDO ==== */
html body table.finanzas tr.row-grupo td.c-pres-w,
html body table.finanzas tr.row-grupo td.c-ejec-w,
html body table.finanzas tr.row-grupo td.c-sal-w,
html body table.finanzas tr.row-grupo td.no-editable,
html body table.finanzas tr.row-grupo td.col-total,
html body table.finanzas tr.row-item td.editable,
html body table.finanzas tr.row-item td.no-editable,
html body table.finanzas tr.row-item td.c-pres-w,
html body table.finanzas tr.row-item td.c-ejec-w,
html body table.finanzas tr.row-item td.c-sal-w,
html body table.finanzas tr.row-item td.col-total,
html body table.finanzas tr.row-item td.editable input,
html body table.finanzas tr.row-item td.editable-presupuesto,
html body table.finanzas tr.row-item td.editable-presupuesto input {
    text-align: center !important;
}

/* ==== FORZAR centrado en TODAS las filas turquesas (row-grupo) ==== */
html body table.finanzas tr.row-grupo > td,
html body table.finanzas tr.row-grupo > td.c-pres-w,
html body table.finanzas tr.row-grupo > td.c-ejec-w,
html body table.finanzas tr.row-grupo > td.c-sal-w,
html body table.finanzas tr.row-grupo > td.no-editable,
html body table.finanzas tr.row-grupo > td.col-total,
html body table.finanzas tr.row-grupo > td.col-total-pct {
    text-align: center !important;
}
/* Excepto la etiqueta (col-etiq) que se queda a la izquierda */
html body table.finanzas tr.row-grupo > td.col-etiq,
html body table.finanzas tr.row-grupo > td.col-etiq.etiq-grupo {
    text-align: left !important;
}

/* ==== Forzar centrado en filas turquesas (row-grupo) - override final ==== */
html body #tblFin tr.row-grupo td.c-pres-w,
html body #tblFin tr.row-grupo td.c-ejec-w,
html body #tblFin tr.row-grupo td.c-sal-w,
html body #tblFin tr.row-grupo td.no-editable,
html body #tblFin tr.row-grupo td.col-total,
html body #tblFin tr.row-grupo td.col-total.c-pres-w,
html body #tblFin tr.row-grupo td.col-total.c-ejec-w,
html body #tblFin tr.row-grupo td.col-total.c-sal-w,
html body #tblFin tr.row-grupo td.col-total-pct {
    text-align: center !important;
}

/* ==== Forzar centrado en TODAS las celdas de fila turquesa con múltiples clases ==== */
html body #tblFin table.finanzas tr.row-grupo td,
html body #tblFin table.finanzas tr.row-grupo td.no-editable.c-pres-w,
html body #tblFin table.finanzas tr.row-grupo td.no-editable.c-ejec-w,
html body #tblFin table.finanzas tr.row-grupo td.no-editable.c-sal-w {
    text-align: center !important;
}
html body #tblFin table.finanzas tr.row-grupo td.col-etiq,
html body #tblFin table.finanzas tr.row-grupo td.col-etiq.etiq-grupo {
    text-align: left !important;
}

/* Celda de fila turquesa con colspan=3 centrada */
html body #tblFin table.finanzas tr.row-grupo td.grupo-semana {
    text-align: center !important;
    background-color: #D1ECF1 !important;
    color: var(--azul-oscuro) !important;
    font-weight: 700 !important;
    padding: 0.4rem 0.5rem !important;
    font-family: var(--font-num);
    font-size: 0.72rem !important;
}

/* Celda arriba de ACUMULADO JULIO / % EJEC — fondo gris #495057 + spacer blanco a la izquierda */
html body #tblFin thead tr:nth-child(1) th.grupo-mes.acum-start,
html body table.finanzas thead th.grupo-mes.acum-start,
html body table.finanzas thead th.grupo-mes.acum-start.mes-end {
    background-color: #495057 !important;
    background: #495057 !important;
    color: #ffffff !important;
    border-left: 48px solid #ffffff !important;
    border-left-color: #ffffff !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    border-right: 0 !important;
    box-shadow: none !important;
    background-clip: padding-box !important;
}

/* Fila 1 (mes-año): sin borde de cierre entre JULIO 2026 y el spacer */
html body table.finanzas thead th.grupo-mes:has(+ th.acum-start),
html body table.finanzas thead th.grupo-mes:not(.acum-start) {
    border-right: 0 !important;
    box-shadow: none !important;
}

/* ==== Tipografía Poppins con números tabulares (como Reporte de Producción) ==== */
html body {
    font-family: var(--font-ui) !important;
    font-feature-settings: 'tnum' 1, 'lnum' 1;
    font-variant-numeric: tabular-nums lining-nums;
}
html body table.finanzas,
html body table.finanzas th,
html body table.finanzas td,
html body table.finanzas input {
    font-family: 'Poppins', var(--font-ui) !important;
    font-variant-numeric: tabular-nums lining-nums;
}
.kpi-card .kpi-value {
    font-family: 'Poppins', var(--font-ui) !important;
    font-variant-numeric: tabular-nums lining-nums;
}

/* ==== Centrar TODOS los valores de la columna ACUMULADO DEL MES ==== */
html body #tblFin table.finanzas td.col-total,
html body #tblFin table.finanzas td.col-total.c-pres-w,
html body #tblFin table.finanzas td.col-total.c-ejec-w,
html body #tblFin table.finanzas td.col-total.c-sal-w,
html body #tblFin table.finanzas td.col-total.editable-presupuesto,
html body #tblFin table.finanzas td.col-total-pct,
html body #tblFin table.finanzas td.col-total.editable-presupuesto input {
    text-align: center !important;
}

/* Fila EGRESOS (row-seccion azul) — ACUMULADO PRES/EJEC/SAL centrados */
html body #tblFin table.finanzas tr.row-seccion td.col-total,
html body #tblFin table.finanzas tr.row-seccion td.col-total.c-pres-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total-pct {
    text-align: center !important;
}

/* ==== FORZAR CENTRADO: fila EGRESOS azul (row-seccion) acumulado del mes ==== */
html body #tblFin table.finanzas tbody tr.row-seccion > td.col-total,
html body #tblFin table.finanzas tbody tr.row-seccion > td.col-total.c-pres-w,
html body #tblFin table.finanzas tbody tr.row-seccion > td.col-total.c-ejec-w,
html body #tblFin table.finanzas tbody tr.row-seccion > td.col-total.c-sal-w,
html body #tblFin table.finanzas tbody tr.row-seccion > td.col-total-pct,
html body #tblFin table.finanzas tbody tr.row-seccion > td.col-total.c-pres-w.acum-start {
    text-align: center !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

/* ==== SALDO en blanco absoluto en INGRESOS/KPI (sin bordes) ==== */
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-item td.col-total.c-sal-w:empty,
html body #tblFin table.finanzas tr.row-kpi-saldo td.kpi-cell:empty {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* ==== FORZAR blanco: celdas SAL vacías en toda la columna acumulado ==== */
html body #tblFin table.finanzas td.col-total.c-sal-w:empty,
html body #tblFin table.finanzas tr.row-item td.col-total.c-sal-w:empty,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-sal-w:empty,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-sal-w:empty,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-sal-w:empty,
html body #tblFin table.finanzas tr.row-kpi-saldo td.kpi-cell.kpi-cell-mes:empty {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* ==== Fondo blanco absoluto: SAL de row-grupo turquesa cuando está vacía ==== */
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-sal-w:empty {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    box-shadow: none !important;
}

/* ==== Columna SALDO del ACUMULADO en INGRESOS: fondo y bordes blancos ==== */
/* Solo celdas VACÍAS (ingresos/saldo) — no toca las de EGRESOS que sí tienen valor */
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.c-sal-w,
html body #tblFin table.finanzas tr.row-item td.col-total.c-sal-w:empty,
html body #tblFin table.finanzas tr.row-kpi-saldo td.kpi-cell.kpi-cell-mes:empty,
html body #tblFin table.finanzas tr.row-add td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-add td.c-sal-w {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    box-shadow: none !important;
}

/* ==== INGRESOS BAND: celda SALDO del acumulado BLANCA con bordes blancos ==== */
html body #tblFin table.finanzas tbody tr.row-seccion.band-ingreso td.col-total.c-sal-w,
html body #tblFin table.finanzas tbody tr.row-seccion.band-ingreso td.c-sal-w:empty,
html body #tblFin table.finanzas tbody tr.band-ingreso td.col-total.c-sal-w,
html body #tblFin table.finanzas tbody tr.band-ingreso td.c-sal-w {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 0 !important;
    border-top: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    box-shadow: none !important;
    color: transparent !important;
}

/* ==== ÚLTIMA REGLA: SALDO ACUMULADO en INGRESOS 100% blanco ==== */
html body #tblFin table.finanzas tr.row-seccion.band-ingreso > td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso > td.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo > td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo > td.c-sal-w,
html body #tblFin table.finanzas tr.row-item > td.col-total.c-sal-w:empty {
    background: #ffffff !important;
    background-color: #ffffff !important;
    background-image: none !important;
    border: 0 solid #ffffff !important;
    border-top-width: 0 !important;
    border-right-width: 0 !important;
    border-bottom-width: 0 !important;
    border-left-width: 0 !important;
    border-color: #ffffff !important;
    box-shadow: none !important;
    outline: 0 !important;
    color: #ffffff !important;
}

/* ==== FINAL: SAL sticky cells must have EXPLICIT white background ==== */
/* El z-index sticky requiere background sólido para no dejar ver contenido bajo */
html body #tblFin tr.row-grupo td.col-total.c-sal-w,
html body #tblFin tr.row-grupo td.c-sal-w,
html body #tblFin tr.row-seccion.band-ingreso td.col-total.c-sal-w,
html body #tblFin tr.row-seccion.band-ingreso td.c-sal-w,
html body #tblFin tr.row-item td.col-total.c-sal-w:empty {
    background-color: #ffffff !important;
    background-image: none !important;
    background: #ffffff !important;
    border: none !important;
    border-top: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-color: #ffffff !important;
    box-shadow: none !important;
    color: #ffffff !important;
    z-index: 15 !important;
}

/* ==== NUCLEAR: SAL cells INGRESOS - CERO bordes (ALL rows before EGRESOS) ==== */
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-sal-w,
html body #tblFin table.finanzas tr.row-item[data-parent="3"] td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-item[data-parent="6"] td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-add td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-add td.c-sal-w,
html body #tblFin table.finanzas tr.row-kpi-saldo td.kpi-cell.kpi-cell-mes:empty {
    border-top: 0 !important;
    border-top-width: 0 !important;
    border-top-style: none !important;
    border-bottom: 0 !important;
    border-bottom-width: 0 !important;
    border-bottom-style: none !important;
    border-left: 0 !important;
    border-right: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
}

/* ==== BORDES en la columna PRES del ACUMULADO MES (INGRESOS) ==== */
/* Restaurar bordes top/bottom + borde derecho para separación de EJEC */
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-pres-w.acum-start,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-pres-w.acum-start,
html body #tblFin table.finanzas tr.row-item[data-parent="3"] td.col-total.c-pres-w.acum-start,
html body #tblFin table.finanzas tr.row-item[data-parent="6"] td.col-total.c-pres-w.acum-start,
html body #tblFin table.finanzas tr.row-item[data-parent="3"] td.col-total.editable-presupuesto.c-pres-w.acum-start,
html body #tblFin table.finanzas tr.row-item[data-parent="6"] td.col-total.editable-presupuesto.c-pres-w.acum-start {
    border-top: 1px solid #dee2e6 !important;
    border-bottom: 1px solid #dee2e6 !important;
    border-right: 1px solid #dee2e6 !important;
}

/* ==== Columnas EJEC con fondo amarillo #faffd6 en Ingreso de datos ==== */
html body #tblFin table.finanzas td.c-ejec-w,
html body #tblFin table.finanzas td.col-total.c-ejec-w,
html body #tblFin table.finanzas td.c-ejec,
html body #tblFin table.finanzas tr th.sh-ejec,
html body #tblFin table.finanzas tr.row-item td.c-ejec-w,
html body #tblFin table.finanzas tr.row-item td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-grupo td.c-ejec-w,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion td.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.anx-inline td.c-ejec-w {
    background-color: #faffd6 !important;
    background: #faffd6 !important;
    background-image: none !important;
}

/* ==== Font-size GRANDE en toda la tabla de Ingreso de datos ==== */
html body #tblFin,
html body #tblFin table.finanzas,
html body #tblFin table.finanzas th,
html body #tblFin table.finanzas td,
html body #tblFin table.finanzas td.c-pres-w,
html body #tblFin table.finanzas td.c-ejec-w,
html body #tblFin table.finanzas td.c-sal-w,
html body #tblFin table.finanzas td.col-total,
html body #tblFin table.finanzas td.col-total.c-pres-w,
html body #tblFin table.finanzas td.col-total.c-ejec-w,
html body #tblFin table.finanzas td.col-total.c-sal-w,
html body #tblFin table.finanzas td.col-total-pct,
html body #tblFin table.finanzas td.col-etiq,
html body #tblFin table.finanzas th.col-etiq,
html body #tblFin table.finanzas td.editable,
html body #tblFin table.finanzas td.editable-presupuesto,
html body #tblFin table.finanzas td.editable input,
html body #tblFin table.finanzas td.editable-presupuesto input,
html body #tblFin table.finanzas td.no-editable,
html body #tblFin table.finanzas tr.row-item td,
html body #tblFin table.finanzas tr.row-grupo td,
html body #tblFin table.finanzas tr.row-seccion td {
    font-size: 25px !important;
    font-weight: 500;
    line-height: 1.3 !important;
}
/* Cabeceras / sub-headers */
html body #tblFin table.finanzas tr.anx-subhead th,
html body #tblFin table.finanzas thead th.grupo-mes,
html body #tblFin table.finanzas thead th.col-total,
html body #tblFin table.finanzas thead th.col-etiq,
html body #tblFin table.finanzas thead th {
    font-size: 17px !important;
    font-weight: 700;
    line-height: 1.3 !important;
}
/* Filas SECCION (INGRESOS/EGRESOS azul) — títulos destacados */
html body #tblFin table.finanzas tr.row-seccion td.col-etiq {
    font-size: 22px !important;
    font-weight: 800;
}
/* KPI cards */
html body #tblFin table.finanzas tr.row-kpi-saldo .kpi-card .kpi-value { font-size: 1.5rem !important; font-weight: 800; }
html body #tblFin table.finanzas tr.row-kpi-saldo .kpi-card .kpi-title { font-size: 13px !important; font-weight: 700; }
/* Ajustar altura de filas para que quepa el texto grande */
html body #tblFin table.finanzas tbody td { padding: 0.55rem 0.55rem !important; }
html body #tblFin table.finanzas tbody tr.row-seccion td { padding: 0.7rem 0.7rem !important; }

/* ==== Bandas INGRESOS/EGRESOS: MEGA GRANDE 42px ==== */
html body #tblFin table.finanzas tr.row-seccion td,
html body #tblFin table.finanzas tr.row-seccion td.col-etiq,
html body #tblFin table.finanzas tr.row-seccion td.c-pres-w,
html body #tblFin table.finanzas tr.row-seccion td.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion td.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total,
html body #tblFin table.finanzas tr.row-seccion td.col-total.c-pres-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion td.col-total-pct,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-etiq,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-pres-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-pres-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-seccion.band-ingreso td.col-total-pct {
    font-size: 60px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    padding: 1.2rem 0.7rem !important;
    letter-spacing: 0.5px;
}
/* También aumentar el font-size de las filas ITEMS y GRUPOS */
html body #tblFin table.finanzas tr.row-item td,
html body #tblFin table.finanzas tr.row-item td.c-pres-w,
html body #tblFin table.finanzas tr.row-item td.c-ejec-w,
html body #tblFin table.finanzas tr.row-item td.c-sal-w,
html body #tblFin table.finanzas tr.row-item td.col-total,
html body #tblFin table.finanzas tr.row-item td.col-total.c-pres-w,
html body #tblFin table.finanzas tr.row-item td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-item td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-item td.col-etiq,
html body #tblFin table.finanzas tr.row-item td.editable,
html body #tblFin table.finanzas tr.row-item td.editable input,
html body #tblFin table.finanzas tr.row-item td.editable-presupuesto,
html body #tblFin table.finanzas tr.row-item td.editable-presupuesto input,
html body #tblFin table.finanzas tr.row-item td.no-editable {
    font-size: 22px !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
    padding: 0.6rem 0.55rem !important;
}
/* Filas GRUPO turquesas */
html body #tblFin table.finanzas tr.row-grupo td,
html body #tblFin table.finanzas tr.row-grupo td.c-pres-w,
html body #tblFin table.finanzas tr.row-grupo td.c-ejec-w,
html body #tblFin table.finanzas tr.row-grupo td.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.col-total,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-pres-w,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-ejec-w,
html body #tblFin table.finanzas tr.row-grupo td.col-total.c-sal-w,
html body #tblFin table.finanzas tr.row-grupo td.col-etiq {
    font-size: 26px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    padding: 0.7rem 0.6rem !important;
}
/* Headers thead */
html body #tblFin table.finanzas thead th,
html body #tblFin table.finanzas thead th.grupo-mes,
html body #tblFin table.finanzas thead th.col-total,
html body #tblFin table.finanzas thead th.col-etiq,
html body #tblFin table.finanzas tr.anx-subhead th {
    font-size: 20px !important;
    font-weight: 700 !important;
}
