:root {
  --navy: #0f2a44;
  --navy-2: #173a5c;
  --gold: #f5b841;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #6b7a8c;
  --line: #e4e9f0;
  --pos: #1f9d6b;
  --neg: #d64545;
  --warn: #e39b22;
  --c1: #1f6fb2;
  --c2: #f5b841;
  --c3: #2fb59c;
  --c4: #e0605e;
  --c5: #8a6fd1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 16px rgba(16, 32, 56, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; font-size: 14px; overflow-x: clip; }
button, select, input { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- menú lateral ---------- */
:root { --side-w: 216px; }
.menu-mini { --side-w: 64px; }
.sidebar svg, .topbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--side-w);
  display: flex; flex-direction: column; background: #0b2136; color: #dfe8f2;
  transition: width .18s ease, transform .2s ease; overflow: hidden;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px; min-height: 64px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--gold); color: var(--navy); font-weight: 800; font-size: 18px;
}
.side-brand-txt { min-width: 0; }
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: .3px; color: #fff; }
.brand-sub { font-size: 11px; opacity: .7; line-height: 1.3; }
.side-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; overflow-y: auto; overflow-x: hidden; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #c6d3e1; text-decoration: none; font-weight: 600; white-space: nowrap;
}
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.active { background: rgba(245, 184, 65, .16); color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.side-sep { margin: 12px 4px 4px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.1);
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: #7f93a8; white-space: nowrap; }
.side-colapsar {
  display: flex; align-items: center; gap: 12px; margin: 8px 10px 14px; padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: #8fa3b8; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.side-colapsar:hover { background: rgba(255,255,255,.07); color: #fff; }
@media (min-width: 761px) {
  .menu-mini .side-brand-txt, .menu-mini .side-nav span, .menu-mini .side-colapsar span, .menu-mini .side-sep span { display: none; }
  .menu-mini .side-colapsar svg { transform: rotate(180deg); }
  .menu-mini .side-nav a, .menu-mini .side-colapsar { justify-content: center; padding-left: 0; padding-right: 0; }
  .menu-mini .side-brand { justify-content: center; padding-left: 0; padding-right: 0; }
}
.side-backdrop { display: none; }
.shell { margin-left: var(--side-w); min-width: 0; transition: margin-left .18s ease; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 24px;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff;
}
.btn-menu, .btn-filtros, .sel-local { display: none; }

.locales { display: flex; background: rgba(255,255,255,.08); border-radius: 12px; padding: 4px; gap: 4px; }
.locales button {
  border: 0; background: transparent; color: #dfe8f2; padding: 7px 14px; border-radius: 9px;
  cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.locales button:hover { background: rgba(255,255,255,.08); }
.locales button.active { background: #fff; color: var(--navy); }

.controls { display: flex; gap: 10px; align-items: flex-end; margin-left: auto; flex-wrap: wrap; }
.filtros-extra { display: contents; }
.top-acciones { display: flex; align-items: center; gap: 10px; align-self: flex-end; }
.ctl { display: flex; flex-direction: column; gap: 2px; font-size: 11px; opacity: .95; }
.ctl span { opacity: .7; text-transform: uppercase; letter-spacing: .5px; }
.ctl select {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 6px 8px; min-width: 120px;
}
.ctl select option { color: var(--text); }
.mes-nav { display: flex; align-items: stretch; }
.mes-nav select { border-radius: 0; min-width: 150px; text-align: center; font-weight: 600; border-left: 0; border-right: 0; }
.mes-nav button {
  width: 32px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.1); color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer;
}
.mes-nav button:first-child { border-radius: 8px 0 0 8px; }
.mes-nav button:last-child { border-radius: 0 8px 8px 0; }
.mes-nav button:hover:not(:disabled) { background: rgba(255,255,255,.22); }
.mes-nav button:disabled { opacity: .35; cursor: default; }
.mes-nav select#sel-mes { min-width: 0; width: 102px; background: #fff; color: var(--navy); border-color: #fff; }
.mes-nav.inactivo select#sel-mes { background: rgba(255,255,255,.1); color: rgba(255,255,255,.45); border-color: rgba(255,255,255,.18); cursor: default; }
.ctl select.sel-corto { min-width: 0; width: 80px; }
.ctl select.sel-corto.activo { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.fuente { display: flex; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; overflow: hidden; }
.fuente button {
  border: 0; background: rgba(255,255,255,.1); color: #dfe8f2; padding: 6px 11px; cursor: pointer;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.fuente button:hover:not(.active) { background: rgba(255,255,255,.2); }
.fuente button.active { background: #fff; color: var(--navy); }
.fuente button.active[data-v="ajustes"] { background: var(--gold); color: var(--navy); }
.banner-ajustes {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; padding: 8px 14px;
  border-radius: 10px; background: #fff6df; border: 1px solid #f3d58b; color: #6b4e00; font-size: 13px;
}
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--warn); color: #fff; font-weight: 800;
}
.btn-refrescar {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 12.5px; font-weight: 600;
}
.btn-refrescar:hover { background: rgba(255, 255, 255, 0.2); }
.btn-refrescar.aviso { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn-refrescar:disabled { cursor: wait; opacity: 0.8; }
.btn-refrescar .ico { display: inline-block; font-size: 15px; line-height: 1; }
.btn-refrescar.cargando .ico { animation: girar 0.9s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- page / grid ---------- */
.page { padding: 20px 24px 60px; max-width: 1680px; margin: 0 auto; }
.page > * + *, .page-body > * + * { margin-top: 16px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: 2fr 1fr; }
.g-12 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1100px) { .g-2, .g-3, .g-21, .g-12 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; min-width: 0; position: relative;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card-title { font-weight: 700; font-size: 14px; }
.card-sub { color: var(--muted); font-size: 12px; }
.card-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.evo-range { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.evo-range select { border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; background: #fff; font-size: 12px; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.chart { width: 100%; height: 320px; }
.chart.tall { height: 420px; }
.chart.short { height: 240px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------- KPI ---------- */
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 24px; font-weight: 750; letter-spacing: -.3px; white-space: nowrap; }
.kpi-value.pos { color: var(--pos); }
.kpi-value.neg { color: var(--neg); }
.kpi-foot { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.kpi-delta { display: inline-flex; gap: 4px; align-items: baseline; white-space: nowrap; cursor: help; }
.kpi-note { flex-basis: 100%; }
.delta { font-weight: 700; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.kpi.accent { border-top: 3px solid var(--gold); }

/* ---------- segmented ---------- */
.seg { display: inline-flex; background: #e6ecf4; border: 1px solid #cfd9e6; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--navy); transition: background .12s, color .12s; }
.seg button:hover:not(.active) { background: rgba(15, 42, 68, .08); }
.seg button.active { background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(15, 42, 68, .25); }
.seg.multi button { padding: 5px 8px; }
.seg.multi button.todos { margin-left: 4px; border-left: 1px solid #cfd9e6; border-radius: 0 7px 7px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; max-height: 560px; border-radius: 10px; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th, .tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td.txt, .tbl th.txt { text-align: left; }
.tbl thead th {
  position: sticky; top: 0; background: #f7f9fc; color: var(--muted); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .3px; z-index: 2; cursor: default;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sorted-asc::after { content: " ▲"; font-size: 9px; }
.tbl thead th.sorted-desc::after { content: " ▼"; font-size: 9px; }
.tbl tbody tr:hover td { background: #f8fafd; }
.tbl tr.clickable { cursor: pointer; }
.tbl tfoot td { font-weight: 700; background: #f7f9fc; position: sticky; bottom: 0; }
.num-neg { color: var(--neg); }
.num-salida, .tbl tfoot td.num-salida { color: #7a5a00; background: #fff3c4; font-weight: 600; }
.num-entrada, .tbl tfoot td.num-entrada { color: #1a5590; background: #e6f0fb; font-weight: 600; }
.num-pos { color: var(--pos); }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef2f7; color: var(--muted); }
.badge.ok { background: #e3f5ee; color: var(--pos); }
.badge.pend { background: #fff3dc; color: #a86a00; }
.badge.bad { background: #fde7e7; color: var(--neg); }

/* statement (EERR / flujo) */
.stmt th:first-child, .stmt td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 260px; }
.stmt thead th:first-child { background: #f7f9fc; z-index: 3; }
.stmt tr.lvl0 td { font-weight: 700; background: #fbfcfe; }
.stmt tr.lvl0 td:first-child { background: #fbfcfe; }
.stmt tr.lvl1 td:first-child { padding-left: 30px; color: #3b4a5c; }
.stmt tr.lvl2 td:first-child { padding-left: 62px; color: var(--muted); font-size: 0.95em; }
.stmt tr.lvl3 td:first-child { padding-left: 90px; color: var(--muted); font-size: 0.9em; }
.stmt tr.lvl3 td { font-size: 0.9em; }
.stmt tr.total td { font-weight: 800; background: #eef4fb; border-top: 2px solid #c9d8ea; }
.stmt tr.total td:first-child { background: #eef4fb; }
.stmt tr.grand td { background: var(--navy); color: #fff; }
.stmt tr.grand td:first-child { background: var(--navy); }
.stmt tr.grand td.num-neg { color: #ffb4b4; }
.stmt tr.ratio td { font-style: italic; color: var(--muted); font-weight: 600; }
.stmt tr.memo td { color: var(--muted); }
.stmt tr.memo td:first-child { font-style: italic; }
.stmt .toggle { display: inline-block; width: 16px; cursor: pointer; color: var(--muted); user-select: none; }
.stmt td.cell-click { cursor: pointer; }
.stmt td.cell-click:hover { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.stmt td.sel { background: #fff8e6 !important; }
.stmt tr.grand td.sel { background: #23466b !important; }
.stmt td.tono-1 { background: #eef4fd; }
.stmt td.tono-2 { background: #ecf7f0; }
.stmt td.tono-3 { background: #fff6e0; }
.stmt tr.lvl0 td.tono-1, .stmt tr.total td.tono-1 { background: #dde9fb; }
.stmt tr.lvl0 td.tono-2, .stmt tr.total td.tono-2 { background: #d9efe1; }
.stmt tr.lvl0 td.tono-3, .stmt tr.total td.tono-3 { background: #fdebbd; }
.stmt tr.grand td.tono-1 { background: #2b5d94; }
.stmt tr.grand td.tono-2 { background: #2a6b4f; }
.stmt tr.grand td.tono-3 { background: #7a5a16; }
.stmt tbody tr:hover td.tono-1, .stmt tbody tr:hover td.tono-2, .stmt tbody tr:hover td.tono-3 { filter: brightness(0.97); }
.stmt tr.fila-tono-1 td:first-child { box-shadow: inset 4px 0 0 #6f9fe0; color: #1f4e8c; font-weight: 600; }
.stmt tr.fila-tono-2 td:first-child { box-shadow: inset 4px 0 0 #5fb98a; color: #1d6b45; font-weight: 600; }
.stmt thead th.tono-1 { background: #d3e3fa; color: #1f4e8c; }
.stmt thead th.tono-2 { background: #cfeadb; color: #1d6b45; }
.stmt thead th.tono-3 { background: #fbe3a6; color: #7a5200; }
.stmt thead th.tono-1 .th-sub, .stmt thead th.tono-2 .th-sub, .stmt thead th.tono-3 .th-sub { color: inherit; opacity: .75; }
.stmt .pct { color: var(--muted); font-size: 12px; }
.stmt .th-sub { font-size: 10px; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; }

/* ---------- estado de resultados y flujo de fondos ---------- */
.kpi-destacados .kpi { padding: 18px 20px; }
.kpi-destacados .kpi-value { font-size: 30px; }
.estado-fila { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.estado-tabla { flex: 0 1 auto; min-width: min(100%, 680px); max-width: 100%; }
.estado-lateral { flex: 1 1 340px; min-width: 0; display: grid; gap: 16px; }
.estado-fila.con-comp .estado-tabla { flex-basis: 100%; }
.estado-fila.con-comp .estado-lateral { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.switch-comp { padding: 5px 12px 5px 6px; border: 1px solid #cfd9e6; background: #e6ecf4; border-radius: 999px; transition: background .15s; }
.switch-comp .switch-txt { color: var(--navy); font-weight: 700; min-width: 0; }
.switch-comp.on { background: var(--navy); border-color: var(--navy); }
.switch-comp.on .switch-txt { color: #fff; }
.switch-comp.off { opacity: .5; cursor: not-allowed; }
/* calendario de cheques */
.cal-fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); align-items: start; gap: 16px; margin: 16px 0; }
.cal-fila > * { min-width: 0; }
.cal-fila > * + * { margin-top: 0; }
.cal > * + * { margin-top: 10px; }
.cal-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 10px 12px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav .btn { padding: 4px 10px; }
.cal-titulo { font-weight: 800; font-size: 16px; color: var(--navy); min-width: 130px; text-align: center; }
.cal-acciones { justify-self: end; display: flex; align-items: center; gap: 8px; }
.cal-chk { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.cal-subtotal { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius);
  background: linear-gradient(90deg, #e6f6f1, #fff); border: 1px solid #cdebe1; border-left: 4px solid #2a9d8f; }
.cal-subtotal strong { color: #1f7f74; font-size: 16px; }
.cal-badge { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #3f6f68;
  border: 1px solid #b9ddd3; border-radius: 999px; padding: 3px 9px; background: #fff; }
.cal-link { margin-left: auto; border: 0; background: none; color: var(--navy); font-weight: 700; font-size: 12px; cursor: pointer; }
.cal-link:disabled { color: var(--muted); cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(70px, .75fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); padding: 2px 0 4px; }
.cal-dow:last-child { font-size: 10px; }
.cal-dia, .cal-total { min-height: 64px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc;
  padding: 6px 4px; text-align: center; font-size: 11px; color: var(--muted); overflow: hidden; }
.cal-total { background: #f1f6fc; border-color: #dbe7f5; display: flex; flex-direction: column; justify-content: center; }
.cal-num { font-weight: 800; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.cal-cant { font-weight: 700; color: var(--text); }
.cal-cub { color: #5b7fa6; }
.cal-prov { margin-top: 3px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-tot-lbl { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--text); }
.cal .con-datos { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.cal .con-datos:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.cal .rojo { background: #fdeeee; border-color: #f2c4c4; }
.cal .rojo .cal-cant { color: var(--neg); }
.cal .amarillo { background: #fff9e3; border-color: #f3e2a4; }
.cal .amarillo .cal-cant { color: #a86a00; }
.cal .verde { background: #eaf8f2; border-color: #bfe6d5; }
.cal .verde .cal-cant { color: var(--pos); }
.cal .cub { background: #eef3f9; border-color: #d3dfec; }
.cal-dia.hoy { border: 2px solid var(--navy); }
@media (max-width: 760px) {
  .cal-grid { gap: 3px; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(48px, .7fr); }
  .cal-prov { display: none; }
  .cal-dia, .cal-total { min-height: 52px; font-size: 10px; }
}

.filtro-propio { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sel-filtro { border: 1px solid #cfd9e6; background: #e6ecf4; color: var(--navy); border-radius: 8px; padding: 5px 8px; font-weight: 700; font-size: 13px; cursor: pointer; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12, 24, 40, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .12s ease-out;
}
.modal {
  background: #fff; border-radius: 16px; width: min(1100px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-head .crumbs { color: var(--muted); font-size: 12px; }
.modal-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sem-nav { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.sem-nav h3 { flex: 0 1 auto; }
.sem-nav .btn {
  width: 32px; height: 32px; flex-shrink: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1; border-radius: 50%;
  background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(15, 42, 68, .25);
}
.sem-nav .btn:hover:not(:disabled) { background: var(--navy-2); transform: scale(1.06); }
.sem-nav .btn:disabled { background: #e4e9f0; border-color: #e4e9f0; color: #a9b4c2; box-shadow: none; cursor: default; }
.modal-nav .seg button, .seg.strong button { font-size: 13px; padding: 6px 14px; }
.drill-label { font-size: 13px; font-weight: 700; color: var(--navy); }
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot { padding: 10px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.btn:hover { background: #f5f7fa; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type=search] { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 220px; }
.toolbar select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; }

.empty { padding: 30px; text-align: center; color: var(--muted); }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.notice { background: #fff8e6; border: 1px solid #f3dca5; color: #7a5600; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.notice.info { background: #eef4fb; border-color: #cfdcec; color: #2b4867; }

/* ---------- planilla editable ---------- */
.save-state { font-size: 12px; font-weight: 600; margin-left: auto; }
.save-state.saving { color: var(--muted); }
.save-state.ok { color: var(--pos); }
.save-state.err { color: var(--neg); }
.tbl-edit td { vertical-align: middle; padding-top: 5px; padding-bottom: 5px; }
.tbl-edit tr.fila-inactiva td { color: #9aa7b6; }
.tbl-edit tr.fila-inactiva .link { color: #7d8fa3; }
.link { color: var(--navy); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.id-art { font-size: 11px; margin-right: 6px; }
.input { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: #fff; }
.input:focus { outline: 2px solid rgba(31, 111, 178, .35); border-color: var(--c1); }
.input:disabled { background: #f3f5f8; color: #b3bdc9; }
.input-money { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.input-num { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.input-num::placeholder { color: #9aa7b6; }
.input.edit { border-color: var(--gold); background: #fffaf0; box-shadow: inset 3px 0 0 var(--gold); color: var(--text); }
.form-dist { display: flex; flex-direction: column; gap: 12px; padding: 4px 2px; }
.form-fila { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.campo { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; flex: 1 1 180px; }
.campo .input { font-size: 13px; color: var(--text); width: 100%; box-sizing: border-box; }
.campo .input-money { width: 100%; }
.campo .input-money .input { text-align: right; font-variant-numeric: tabular-nums; }
.dist-preview { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.dist-linea { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.dist-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:disabled { background: #c5cfdb; border-color: #c5cfdb; cursor: default; }
.socios-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.tbl td.col-saldo { font-weight: 700; }
.ref-bares { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; margin-bottom: 14px; }
.ref-titulo { align-self: center; font-weight: 700; color: var(--navy); margin-right: 6px; }
.ref-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; border: 1px solid #dfe6ef; border-radius: 10px; background: #f7f9fc; min-width: 150px; }
.ref-item .ref-label { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.ref-item b { font-size: 1.15em; }
.ref-item.ref-total { background: #eef4fb; border-color: #c9d8ea; }
.socios-mes td, .socios-mes th { white-space: nowrap; }
.socios-mes tr.fila-click { cursor: pointer; }
.socios-mes tr.fila-click:hover td { background: #f1f6fd; }
.modal-socio-head { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mes-nav-modal { display: flex; align-items: center; gap: 12px; }
.mes-nav-modal h3 { margin: 0; min-width: 170px; text-align: center; }
.mes-nav-modal .btn { font-size: 18px; line-height: 1; padding: 4px 12px; }
.modal-socio { width: 100%; }
.modal-socio td:first-child { white-space: normal; }
.modal-socio td:last-child { white-space: nowrap; }
.modal-socio tr.fila-click { cursor: pointer; }
.modal-socio tr.fila-click:hover td { background: #f1f6fd; }
.modal-socio tr.fila-saldo td { background: #f7f9fc; }
.socio-notas { margin: 10px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.5; }
.ref-access-wrap, .evolucion-wrap { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.tbl.evolucion { width: 100%; font-size: 12.5px; }
.ref-access-titulo { font-size: 12px; margin-bottom: 6px; }
.tbl.ref-access { width: 100%; font-size: 12px; }
.tbl.ref-access td:first-child { white-space: normal; }
.seg.seg-sm button { padding: 4px 9px; font-size: 12px; }
.seg.edit { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(245, 184, 65, .35); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #cfd6df; transition: background .15s; flex-shrink: 0; }
.switch .slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .slider { background: var(--pos); }
.switch input:checked + .slider::after { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid rgba(31, 111, 178, .45); outline-offset: 2px; }
.switch-txt { font-size: 12px; font-weight: 600; min-width: 52px; }
.switch.edit .slider { box-shadow: 0 0 0 2px var(--gold); }

.socio-name { font-weight: 600; }
.socio-part { margin-left: 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.bar-mini { height: 6px; border-radius: 3px; background: #e9eef5; overflow: hidden; margin-top: 4px; }
.bar-mini > span { display: block; height: 100%; background: var(--c1); }

/* ---------- tablas en el celular: lista de dos líneas (ui.table) ---------- */
.tbl-movil { font-size: 13px; }
.tm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px 8px; color: var(--muted); font-size: 12px; }
.tm-orden { display: flex; align-items: center; gap: 6px; }
.tm-orden select { border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; background: #fff; font-size: 12px; max-width: 150px; }
.tm-orden button { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.tm-fila { padding: 9px 4px; border-bottom: 1px solid var(--line); }
.tm-fila.clic { cursor: pointer; }
.tm-fila.clic:active { background: #f1f6fd; }
.tm-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tm-titulo { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.tm-monto { font-weight: 700; white-space: nowrap; }
.tm-sub { margin-top: 2px; color: var(--muted); font-size: 11.5px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tm-fila.tm-total { background: #f7f9fc; border-radius: 8px; border-bottom: 0; margin-top: 4px; padding: 10px 8px; }
.tm-fila.tm-total .tm-titulo { font-weight: 800; }
.tm-mas { display: block; width: 100%; margin-top: 8px; }
.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px 8px 0; vertical-align: top; width: 42%; border-bottom: 1px solid var(--line); }
.kv td { text-align: right; padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.kv td.clic { cursor: pointer; text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.kv-nota { margin-top: 10px; color: var(--muted); font-size: 12px; }
.concepto-txt.clic { cursor: pointer; text-decoration: underline dotted rgba(91, 108, 128, .6); text-underline-offset: 3px; }

/* ---------- celular ---------- */
@media (max-width: 760px) {
  :root, .menu-mini { --side-w: 0px; }
  .sidebar { width: 264px; transform: translateX(-100%); }
  .menu-abierto .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .side-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(12, 24, 40, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s; }
  .menu-abierto .side-backdrop { opacity: 1; pointer-events: auto; }
  .side-colapsar { display: none; }
  .side-nav a { padding: 12px; }

  .topbar { padding: 8px 10px; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .btn-menu { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px;
    background: rgba(255,255,255,.1); color: #fff; cursor: pointer; }
  .locales { display: none; }
  .sel-local { display: block; flex: 1; min-width: 0; height: 38px; padding: 0 10px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.1); color: #fff; font-weight: 700; }
  .sel-local option { color: var(--text); }
  .top-acciones { order: 2; align-self: center; gap: 6px; }
  .btn-refrescar { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 10px; }
  .btn-refrescar .txt { display: none; }
  .icon-btn { width: 34px; height: 34px; }
  .controls { order: 3; flex-basis: 100%; margin-left: 0; gap: 8px; align-items: center; flex-wrap: nowrap; }
  .ctl-mes { flex: 1; min-width: 0; }
  .ctl-mes > span { display: none; }
  .mes-nav { width: 100%; }
  .mes-nav select#sel-mes { flex: 1; width: auto; min-width: 0; }
  .mes-nav button { width: 40px; height: 36px; }
  .btn-filtros { display: inline-flex; align-items: center; gap: 6px; height: 36px; max-width: 55%; padding: 0 12px;
    border-radius: 8px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.1); color: #fff;
    font-weight: 600; font-size: 12.5px; white-space: nowrap; cursor: pointer; }
  .btn-filtros span { overflow: hidden; text-overflow: ellipsis; }
  .btn-filtros svg { width: 16px; height: 16px; }
  .btn-filtros.activo { border-color: var(--gold); color: var(--gold); }
  .filtros-extra { display: none; }
  .filtros-extra.abierto { display: grid; position: absolute; left: 0; right: 0; top: 100%; z-index: 31;
    grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 12px 14px 16px;
    background: var(--navy-2); box-shadow: 0 12px 24px rgba(0,0,0,.25); }
  .filtros-extra .ctl:nth-child(n+3) { grid-column: 1 / -1; }
  .filtros-extra .ctl select, .ctl select.sel-corto { width: 100%; min-width: 0; height: 36px; }
  .fuente button { flex: 1; padding: 9px 8px; }

  .page { padding: 14px 12px 48px; }
  .page > * + *, .page-body > * + * { margin-top: 12px; }
  .page-head { margin: 2px 0 12px; }
  .page-head h1 { font-size: 18px; }
  .page-head .sub { font-size: 12px; }
  .section-title { margin: 20px 0 10px; font-size: 14px; }
  .grid { gap: 10px; }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 12px; border-radius: 12px; }
  .kpi { padding: 11px 12px; gap: 4px; }
  .kpi-label { font-size: 10.5px; letter-spacing: .2px; }
  .kpi-value, .kpi-destacados .kpi-value { font-size: 18px; white-space: normal; overflow-wrap: anywhere; }
  .kpi-destacados .kpi { padding: 12px; }
  .kpi-foot { font-size: 11px; gap: 2px 8px; }
  .kpi-delta { white-space: normal; }
  .chart { height: 260px; }
  .chart.tall { height: 320px; }
  .chart.short { height: 220px; }
  .card-tools { justify-content: flex-start; }
  .seg { flex-wrap: wrap; max-width: 100%; }
  .toolbar input[type=search] { min-width: 0; width: 100%; }
  .toolbar > * { max-width: 100%; }
  .banner-ajustes { font-size: 12px; }
  .ref-bares { gap: 8px; }
  .ref-titulo { flex-basis: 100%; }
  .ref-item { min-width: 0; flex: 1 1 calc(50% - 4px); padding: 8px 10px; }
  .estado-tabla { min-width: 0; }
  .estado-fila.con-comp .estado-lateral { grid-template-columns: 1fr; }
  .cal-head { display: flex; flex-wrap: wrap; justify-content: space-between; }
  .cal-acciones { justify-self: auto; }
  .filtro-propio { flex-wrap: wrap; }

  .table-wrap { max-height: none; }
  .tbl th, .tbl td { padding: 7px 6px; }
  .tbl thead th { white-space: normal; font-size: 11px; vertical-align: bottom; }
  .m-ocultar { display: none !important; }
  .stmt th:first-child, .stmt td:first-child { position: static; min-width: 0; white-space: normal; }
  .stmt tr.lvl1 td:first-child { padding-left: 18px; }
  .stmt tr.lvl2 td:first-child { padding-left: 32px; }
  .stmt tr.lvl3 td:first-child { padding-left: 44px; }
  .socios-mes td.txt, .socios-mes th.txt { white-space: normal; }

  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal { width: 100%; max-height: none; height: 100dvh; border-radius: 0; }
  .modal-head { padding: 10px 12px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  .modal-head h3 { font-size: 15px; }
  .modal-body { padding: 12px; }
  .modal-foot { padding: 8px 12px; flex-wrap: wrap; }
  .mes-nav-modal { gap: 8px; }
  .mes-nav-modal h3 { min-width: 0; font-size: 15px; }

  .tbl-edit thead { display: none; }
  .tbl-edit, .tbl-edit tbody { display: block; }
  .tbl-edit tr { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
  .tbl-edit td { display: block; padding: 0 !important; border: 0; text-align: left; white-space: normal; }
  .tbl-edit td:nth-child(1) { grid-column: 1 / -1; }
  .tbl-edit td:nth-child(2) { grid-column: 1; font-size: 12px; color: var(--muted); }
  .tbl-edit td:nth-child(3), .tbl-edit td:nth-child(4) { font-size: 12px; color: var(--muted); text-align: right; }
  .tbl-edit td:nth-child(5) { display: none; }
  .tbl-edit td:nth-child(6) { grid-column: 1; }
  .tbl-edit td:nth-child(7) { grid-column: 2 / -1; justify-self: end; }
  .tbl-edit td:nth-child(8) { grid-column: 1 / 3; display: flex; align-items: center; gap: 8px; }
  .tbl-edit td:nth-child(8)::before { content: "Valor hora"; font-size: 12px; color: var(--muted); white-space: nowrap; }
  .tbl-edit td:nth-child(8):has(input:disabled) { display: none; }
  .tbl-edit td:nth-child(9) { grid-column: 3; justify-self: end; }
  .tbl-edit td[colspan] { grid-column: 1 / -1; }
}
