:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #1b2430; --muted: #5f6b7a; --line: #e2e7ee; --line2: #eef1f5;
  --accent: #0f5f5c; --accent-2: #138a85; --accent-soft: #e3f1f0; --side: #0e2a33; --side-ink: #c8d6dc;
  --ok: #1f7a3d; --ok-soft: #e4f4e9; --warn: #9a6200; --warn-soft: #fdf2dc; --err: #b42318; --err-soft: #fde8e6; --info-soft: #e8f0fb;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--err); }
.nowrap { white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; padding: 4px 8px 14px; font-size: 15px; }
.brand .dot { width: 26px; height: 26px; border-radius: 6px; background: var(--accent-2); display: grid; place-items: center; font-size: 13px; }
.side .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7f98a2; margin: 14px 8px 4px; }
.side a { display: block; color: var(--side-ink); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 13.5px; }
.side a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.on { background: var(--accent-2); color: #fff; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .emp { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.top .emp img { height: 34px; max-width: 110px; object-fit: contain; }
.top select { max-width: 380px; }
.content { padding: 20px; max-width: 1500px; }
.menu-btn { display: none; }

/* Panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #cfd6df; border-radius: 6px; padding: 6px 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent-2); }
input[type=checkbox] { width: auto; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px; align-items: end; }
.form .wide { grid-column: span 2; }
.form .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters > div { min-width: 140px; }
.btn { font: inherit; border: 1px solid #cfd6df; background: #fff; color: var(--ink); padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn:hover { background: #f6f8fa; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { background: var(--accent-2); }
.btn.danger { color: var(--err); border-color: #f1b8b2; }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger-solid:hover { background: #912018; }
/* Menú de acciones (⋯) */
.menu-acc { position: absolute; z-index: 30; min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 24px rgba(16,24,40,.16); padding: 4px; }
.menu-acc button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px;
  border-radius: 6px; font: inherit; color: var(--ink); cursor: pointer; }
.menu-acc button:hover { background: #f2f5f8; }
.menu-acc button.peligro { color: var(--err); }
.menu-acc button:disabled { color: #aab3bf; cursor: default; background: none; }
.menu-acc hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.btn-menu { border: 1px solid transparent; background: none; border-radius: 6px; padding: 2px 9px; font-size: 16px; line-height: 1; cursor: pointer; color: var(--muted); }
.btn-menu:hover, .btn-menu.on { background: #eef2f6; border-color: var(--line); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Tables */
/* Encabezados fijos:
   1) .barra-fija agrupa título, filtros y pestañas de cada pantalla y queda fija bajo la barra superior.
   2) Cada tabla (.tw) se desplaza dentro de su tarjeta con su(s) fila(s) de encabezado siempre visibles.
   --top-h y --fija-h los calcula app.js según la altura real de cada barra. */
:root { --top-h: 56px; --fija-h: 0px; }
.barra-fija { position: sticky; top: var(--top-h); z-index: 4; background: var(--bg); margin: -20px -20px 14px; padding: 14px 20px 0;
  border-bottom: 1px solid var(--line); box-shadow: 0 6px 10px -8px rgba(16,24,40,.25); }
.barra-fija > .head { margin-bottom: 10px; }
.barra-fija > .filters, .barra-fija > .filtros-an, .barra-fija > .an-cfg { margin-bottom: 10px; }
.barra-fija > .tabs { margin-bottom: 0; border-bottom: 0; }
.barra-fija > :last-child:not(.tabs) { margin-bottom: 12px; }
.tw { overflow: auto; max-height: calc(100vh - var(--top-h) - var(--fija-h) - 36px); }
.tw th.th-fijo { position: sticky; z-index: 2; box-shadow: inset 0 -1px 0 var(--line); }
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; position: sticky; top: 0; border-bottom: 1px solid var(--line); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f6faf9; }
tr.tot td { font-weight: 650; border-top: 2px solid var(--line); background: #fafbfc; }
tr.sub td { font-weight: 600; background: #f6f8fa; }
tr.final td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); }
tr.anul td { color: #9aa4b2; text-decoration: line-through; }
td.ind1 { padding-left: 22px; } td.ind2 { padding-left: 40px; color: var(--muted); }
.comp-head td { background: var(--accent-soft); font-weight: 600; }
/* Filtros de Análisis de cuentas: grilla alineada, todos los controles de la misma altura */
.filtros-an { display: grid; grid-template-columns: minmax(260px, 2.2fr) minmax(200px, 1.5fr) 150px 150px auto auto; gap: 12px; align-items: end; margin-bottom: 10px; }
.filtros-an > div { min-width: 0; }
.filtros-an select, .filtros-an input[type=date], .filtros-an .btn, .filtros-an .f-check { height: 36px; box-sizing: border-box; }
.filtros-an select, .filtros-an input[type=date] { padding: 0 8px; }
.filtros-an .f-check { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0 10px; border: 1px solid #cfd6df; border-radius: 6px; background: #fff;
  color: var(--ink); font-size: 13px; white-space: nowrap; cursor: pointer; }
.filtros-an .btn { padding: 0 18px; width: 100%; }
.an-cfg { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; min-height: 38px; }
.an-cfg-t { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.an-cfg-b { display: inline-flex; gap: 6px; }
.an-cfg-l { margin-left: auto; font-size: 12.5px; }
@media (max-width: 1100px) { .filtros-an { grid-template-columns: 1fr 1fr 1fr; } .filtros-an .f-cta { grid-column: span 2; } }
@media (max-width: 640px) { .filtros-an { grid-template-columns: 1fr 1fr; } .filtros-an .f-cta, .filtros-an .f-aux { grid-column: 1 / -1; } }
.f-fecha-cont { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.f-fecha-cont input { width: 150px; }
/* Separación entre grupos (comprobantes, cuentas, auxiliares, documentos) */
tr.sep td { height: 14px; padding: 0; border: 0; background: transparent !important; }
/* Flujo de caja proyectado */
table.tabla-flujo td:first-child, table.tabla-flujo th:first-child { position: sticky; left: 0; background: inherit; z-index: 1; min-width: 230px; }
table.tabla-flujo tr.fila-cat:hover td { background: #f2f7f7; }
table.tabla-flujo tr.vencidos td { color: var(--warn); font-weight: 600; }
table.tabla-flujo td.bajo-min { color: var(--warn); }
table.tabla-flujo tbody tr { background: #fff; }
table.tabla-flujo tr.tot td, table.tabla-flujo tr.sub td { background: #f6f8fa; }
table.tabla-flujo tr.comp-head td { background: var(--accent-soft); }
/* Movimientos agrupados por auxiliar y documento */
table.mov-doc tr.aux-head { cursor: pointer; }
table.mov-doc tr.aux-head td:first-child::before { content: '▾ '; color: var(--accent); }
table.mov-doc tbody.cerrado tr.aux-head td:first-child::before { content: '▸ '; }
table.mov-doc tr.doc-head td { background: #f6f8fa; font-weight: 600; border-top: 1px solid var(--line); }
table.mov-doc tr.doc-head td:first-child { padding-left: 18px; }
table.mov-doc tr.mov td:first-child { padding-left: 32px; }
table.mov-doc tr.mov.anterior td { color: var(--muted); }
table.mov-doc tr.sep-doc td { height: 6px; }
/* Detalle desplegable por auxiliar */
tr.aux-row td:first-child::before { content: '▸'; display: inline-block; width: 14px; color: var(--accent); transition: transform .15s; }
tr.aux-row.abierto td:first-child::before { transform: rotate(90deg); }
tr.aux-row.abierto td { background: var(--accent-soft); font-weight: 600; }
tr.det-aux td { background: #fbfcfd; font-size: 13px; }
tr.det-aux td:first-child { padding-left: 28px; }
tr.det-aux.det-head td { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.lines input, .lines select { padding: 4px 6px; font-size: 13px; }
.lines td { padding: 3px 4px; }
.lines input.req { border-color: var(--accent-2); background: #f2faf9; }
.lines tr.recien td { background: #fff7d6; transition: background .8s; }
.lines input.req::placeholder { color: var(--accent); font-style: italic; }

/* Badges */
.b { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b.ok { background: var(--ok-soft); color: var(--ok); }
.b.warn { background: var(--warn-soft); color: var(--warn); }
.b.err { background: var(--err-soft); color: var(--err); }
.b.info { background: var(--info-soft); color: #1d4f91; }
.b.mut { background: #eef1f5; color: var(--muted); }
.note { padding: 10px 12px; border-radius: 6px; background: var(--info-soft); font-size: 13px; margin: 8px 0; }
.note.warn { background: var(--warn-soft); }
.note.err { background: var(--err-soft); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Modal / toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal h2 { margin-top: 0; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: var(--shadow); font-size: 13.5px; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0e2a33, #0f5f5c); }
.login .card { width: min(400px, 92vw); padding: 26px; }

/* Report header (print) */
.rep-head { display: none; }
.logo-box { width: 180px; height: 90px; border: 1px dashed #cfd6df; border-radius: 8px; display: grid; place-items: center; background: #fafbfc; overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bar { height: 8px; border-radius: 4px; background: var(--accent-2); }
dl.ficha { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; margin: 0; }
dl.ficha dt { color: var(--muted); font-size: 12.5px; }
dl.ficha dd { margin: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; }
  .grid2 { grid-template-columns: 1fr; }
  .content { padding: 14px 16px; }
  .barra-fija { margin: -14px -16px 12px; padding: 12px 16px 0; }
  .form .wide { grid-column: auto; }
}

/* Elementos solo de impresión: encabezado, firmas y documento formal del comprobante */
.rep-head, .firmas, .decl, .print-only { display: none; }

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  html, body { background: #fff; font-size: 10.5px; color: #000; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .side, .top, .noprint, .filters, .tabs, #toasts, .head, .kpis, .note, .modal-bg { display: none !important; }
  .print-only { display: block !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; margin: 0; }
  a { color: inherit; text-decoration: none; }
  .b { padding: 0; background: none !important; color: #000 !important; font-weight: normal; }
  .muted { color: #444; }
  .rep-head { display: grid !important; grid-template-columns: 170px 1fr 1.3fr; gap: 12px; align-items: center; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .rep-head .rh-logo img { max-height: 60px; max-width: 165px; object-fit: contain; }
  .rep-head .rh-rs { font-weight: 700; font-size: 12.5px; }
  .rep-head .rh-tit { text-align: right; }
  .rep-head .rh-t { font-weight: 700; font-size: 14px; text-transform: uppercase; }
  table { background: #fff; }
  th { position: static; background: #e8eef3 !important; color: #000; border-bottom: 1px solid #555; }
  td, th { padding: 2.5px 5px; border-bottom: 1px solid #ddd; }
  tr { page-break-inside: avoid; }
  thead { display: table-header-group; }
  tr.tot td, tr.sub td { background: #f3f6f9 !important; }
  tr.final td { border-top: 1.5px solid #000; border-bottom: 3px double #000; }
  .comp-head td { background: #e3f1f0 !important; }
  .tw { overflow: visible; max-height: none; }
  .barra-fija { position: static; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .tw th.th-fijo { position: static; }
  .firmas { display: flex !important; justify-content: space-around; gap: 60px; margin-top: 70px; page-break-inside: avoid; }
  .firma { text-align: center; width: 240px; }
  .firma .linea { border-top: 1px solid #000; margin-bottom: 4px; }
  .firma .fn { font-weight: 600; min-height: 13px; }
  tr.aux-row td:first-child::before, table.mov-doc tr.aux-head td:first-child::before { content: none; }
  tr.sep td { height: 10px; border: 0 !important; background: transparent !important; }
  .decl { display: block !important; margin-top: 26px; font-size: 10.5px; text-align: justify; page-break-inside: avoid; }
}

/* Comprobante contable impreso */
.cdoc { font-size: 11px; color: #000; }
.cdoc .ch { display: grid; grid-template-columns: 150px 1fr 220px; gap: 14px; align-items: center; border-bottom: 2px solid #000; padding-bottom: 8px; }
.cdoc .ch img { max-height: 64px; max-width: 150px; object-fit: contain; }
.cdoc .rs { font-weight: 700; font-size: 13px; }
.cdoc .box { border: 1.5px solid #000; border-radius: 6px; text-align: center; padding: 8px; }
.cdoc .box .t { font-weight: 700; font-size: 13px; text-transform: uppercase; }
.cdoc .box .n { font-size: 18px; font-weight: 700; margin: 2px 0; }
.cdoc .meta { display: grid; grid-template-columns: 110px 1fr; gap: 3px 10px; margin: 10px 0; padding: 8px 10px; border: 1px solid #999; border-radius: 4px; }
.cdoc .meta b { font-weight: 600; }
.cdoc table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.cdoc th { background: #e8eef3 !important; border: 1px solid #777; padding: 4px 5px; font-size: 10px; text-transform: uppercase; color: #000; }
.cdoc td { border-left: 1px solid #777; border-right: 1px solid #777; border-bottom: 1px solid #ddd; padding: 3px 5px; }
.cdoc tr.ct td { border: 1px solid #777; font-weight: 700; background: #f3f6f9 !important; }
.cdoc .son { margin-top: 8px; padding: 6px 10px; border: 1px solid #999; border-radius: 4px; }
.cdoc .firmas4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 26px; margin-top: 64px; text-align: center; }
.cdoc .firmas4 .linea { border-top: 1px solid #000; margin-bottom: 3px; }
.cdoc .pie { margin-top: 18px; font-size: 9px; color: #555; display: flex; justify-content: space-between; border-top: 1px solid #ccc; padding-top: 4px; }
.cdoc .anulado { position: fixed; top: 40%; left: 10%; right: 10%; text-align: center; font-size: 90px; color: rgba(180,35,24,.18) !important; transform: rotate(-20deg); font-weight: 800; }
@media print {
  .content.cdoc-page > *:not(.cdoc) { display: none !important; }
  .cdoc.cert { page-break-after: always; }
  .cdoc.cert:last-child { page-break-after: auto; }
}

/* Proyectos (obras): itemizado en árbol con edición en línea */
table.pr-tabla td.pr-ed { cursor: text; }
table.pr-tabla td.pr-ed:hover { background: #f1f8f7; outline: 1px dashed var(--accent-2); outline-offset: -2px; }
table.pr-tabla tr.pr-falta td { background: #fffaf0; }
table.pr-tabla tr.sub td { font-weight: 600; }
.pr-tg { display: inline-block; width: 20px; border: 0; background: none; padding: 0; margin: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: center; }
input.pr-inp { padding: 2px 4px; min-width: 70px; width: 100%; border-color: var(--accent-2); }
table.pr-tabla td.num input.pr-inp { text-align: right; }
@media (max-width: 900px) { table.pr-tabla { min-width: 760px; } }
input[type=radio] { width: auto; }
#pr-res .kpis { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
@media (max-width: 700px) { dl.ficha { grid-template-columns: 1fr; } }
table.pr-tabla.pr-ancha { min-width: 1100px; }
table.pr-tabla td.pr-ed:focus { outline: 2px solid var(--accent-2); outline-offset: -2px; }

/* Proyectos (obras): Carta Gantt, avance y curva S */
:root { --gt-lw: 400px; }
@media (max-width: 700px) { :root { --gt-lw: 170px; } .gt-c-tot, .gt-c-pl { display: none !important; } }
.pr-prog { height: 6px; background: #e2e7ee; border-radius: 3px; overflow: hidden; margin: 3px 0 2px; }
.pr-prog i { display: block; height: 100%; background: var(--accent); }
.gt-card { padding: 0 !important; overflow: hidden; }
.gt-scroll { overflow: auto; max-height: calc(100vh - var(--top-h, 56px) - 140px); min-height: 220px; position: relative; }
.gt-scroll:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.gt-grid2 { display: grid; grid-template-columns: var(--gt-lw) max-content; width: max-content; }
.gt-lh, .gt-lb { position: sticky; left: 0; background: #fff; width: var(--gt-lw); border-right: 1px solid var(--line); }
.gt-lh { top: 0; z-index: 5; display: flex; align-items: flex-end; font-size: 12px; font-weight: 600; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.gt-lb { z-index: 3; }
.gt-rh { position: sticky; top: 0; z-index: 4; background: #fff; border-bottom: 1px solid var(--line); }
.gt-rh svg { display: block; }
.gt-rb { overflow: hidden; }
.gt-rb svg { display: block; }
.gt-lr { display: flex; align-items: center; border-bottom: 1px solid var(--line2); font-size: 12.5px; overflow: hidden; white-space: nowrap; box-sizing: border-box; }
.gt-lr.sub { background: #f1f5f9; font-weight: 600; }
.gt-nmw { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; padding-right: 4px; padding-left: 6px; }
.gt-lh .gt-nmw { padding-left: 8px; }
.gt-nm { background: none; border: 0; font: inherit; padding: 0; text-align: left; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
button.gt-nm { cursor: pointer; }
button.gt-nm:hover { text-decoration: underline; color: var(--accent); }
.gt-c { flex: none; text-align: right; padding: 0 6px; font-variant-numeric: tabular-nums; }
.gt-c-tot { width: 92px; } .gt-c-pl { width: 54px; } .gt-c-av { width: 54px; }
.gt-h1 { fill: #eef1f5; stroke: #d7dde5; } .gt-h2 { fill: #f8fafc; stroke: #e2e7ee; }
.gt-ht { font-size: 12px; font-weight: 600; fill: var(--ink); } .gt-ht2 { font-size: 11px; fill: var(--muted); }
.gt-zebra { fill: #fafbfc; } .gt-grp { fill: #f1f5f9; } .gt-grid { stroke: #eef1f5; }
.gt-base { fill: #cfe6e4; stroke: #8fc0bc; stroke-width: 1; } .gt-base.aviso { stroke: var(--err); stroke-dasharray: 3 2; }
.gt-real { fill: var(--accent); } .gt-real.atr { fill: var(--err); } .gt-real.fin { fill: var(--ok); }
.gt-plan { fill: #1d4f91; }
.gt-rombo { fill: var(--accent); stroke: #fff; } .gt-rombo.fin { fill: var(--ok); } .gt-rombo.atr { fill: var(--err); }
.gt-sum-base { fill: #9aa7b4; } .gt-sum-real, .gt-sum-cap { fill: #33495a; }
.gt-pct { font-size: 11px; fill: var(--muted); } .gt-warn { font-size: 13px; fill: var(--err); font-weight: 700; }
.gt-mango { fill: transparent; cursor: ew-resize; } .gt-mango:hover { fill: rgba(15, 95, 92, .35); }
.gt-bar:focus { outline: none; } .gt-bar:focus .gt-base, .gt-bar:focus-visible .gt-base { stroke: var(--accent); stroke-width: 2.5; }
.gt-vacio { fill: transparent; } .gt-vacio.ed { cursor: crosshair; } .gt-vacio.ed:hover { fill: rgba(19, 138, 133, .07); }
.gt-hoy { stroke: var(--err); stroke-width: 1.5; stroke-dasharray: 4 3; } .gt-corte { stroke: #1d4f91; stroke-width: 1.5; stroke-dasharray: 2 3; } .gt-contrato { stroke: #9a6200; stroke-width: 1; stroke-dasharray: 6 3; }
.gt-dep { fill: none; stroke: #5f6b7a; stroke-width: 1.2; } .gt-dep.mal { stroke: var(--err); stroke-width: 1.7; }
.gt-flag-hoy text { font-size: 10px; fill: var(--err); font-weight: 700; } .gt-flag-hoy path { stroke: var(--err); stroke-width: 2; }
.gt-flag-corte text { font-size: 10px; fill: #1d4f91; font-weight: 700; } .gt-flag-corte path { stroke: #1d4f91; stroke-width: 2; }
.gt-tip { position: fixed; z-index: 300; background: #1b2430; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 4px; pointer-events: none; white-space: nowrap; }
.gt-tip[hidden] { display: none; }
.gt-ley { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 8px 2px; }
.lg { display: inline-block; width: 16px; height: 10px; vertical-align: middle; margin-right: 4px; border-radius: 2px; }
.lg-base { background: #cfe6e4; border: 1px solid #8fc0bc; } .lg-real { background: var(--accent); } .lg-atr { background: var(--err); } .lg-fin { background: var(--ok); }
.lg-plan { background: #1d4f91; height: 3px; } .lg-rombo { width: 9px; height: 9px; transform: rotate(45deg); background: var(--accent); border-radius: 0; }
.lg-hoy { width: 0; height: 12px; border-left: 2px dashed var(--err); border-radius: 0; } .lg-corte { width: 0; height: 12px; border-left: 2px dotted #1d4f91; border-radius: 0; } .lg-contrato { width: 0; height: 12px; border-left: 2px dashed #9a6200; border-radius: 0; }
.lg-plan2 { background: #1d4f91; height: 3px; } .lg-real2 { background: var(--accent); height: 4px; } .lg-proy { height: 0; border-top: 3px dashed var(--warn); background: none; border-radius: 0; }
tr.av-rech td { background: var(--err-soft); }
td.av-c { min-width: 120px; } td.av-pv { min-width: 130px; }
.cs-wrap { overflow-x: auto; }
.cs-info { min-height: 18px; margin-bottom: 4px; color: var(--muted); }
.cs-grid { stroke: #e2e7ee; } .cs-grid.v { stroke: #eef1f5; } .cs-eje { font-size: 11px; fill: var(--muted); }
.cs-plan { fill: none; stroke: #1d4f91; stroke-width: 2.2; } .cs-real { fill: none; stroke: var(--accent); stroke-width: 3.2; } .cs-proy { fill: none; stroke: var(--warn); stroke-width: 2.4; stroke-dasharray: 6 4; }
.cs-hoy { stroke: var(--err); stroke-width: 1.2; stroke-dasharray: 4 3; } .cs-corte { stroke: #1d4f91; stroke-width: 1.2; stroke-dasharray: 2 3; }
.cs-cur { stroke: #5f6b7a; stroke-width: 1; } .cs-cur[hidden] { display: none; }
.cs-desv { stroke: var(--err); stroke-width: 2; } .cs-desvt { font-size: 12px; font-weight: 700; fill: var(--err); }
#cs-area:focus { outline: 2px solid var(--accent-2); }

/* Gantt: días no hábiles; Avance: tabla ancha y tarjetas por partida en pantallas angostas */
.gt-nohabil { fill: rgba(95, 107, 122, .10); }
.gt-base, .gt-mango, .gt-rombo { touch-action: none; }
table.av-tabla { min-width: 1000px; }
@media (max-width: 700px) {
  table.av-tabla { min-width: 0 !important; width: 100%; display: block; }
  table.av-tabla tbody { display: block; }
  table.av-tabla tr.av-cab { display: none; }
  table.av-tabla tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
  table.av-tabla td { display: flex; justify-content: space-between; align-items: center; border: 0 !important; padding: 1px 0 !important; text-align: right; background: none !important; }
  table.av-tabla td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 11px; margin-right: 8px; text-align: left; }
  table.av-tabla td.av-k { grid-column: 1 / -1; order: -5; justify-content: flex-start; font-weight: 600; padding-left: 0 !important; }
  table.av-tabla td.av-n { grid-column: 1 / -1; order: -4; justify-content: flex-start; text-align: left; flex-wrap: wrap; }
  table.av-tabla td.av-c { grid-column: 1 / -1; order: -3; margin: 4px 0; }
  table.av-tabla td.av-c input { flex: 1; max-width: 60%; margin-left: auto; font-size: 16px; padding: 6px 8px; }
  table.av-tabla td.av-pv { grid-column: 1 / -1; order: -2; }
  table.av-tabla td.av-u { display: none; }
  table.av-tabla td:last-child { grid-column: 1 / -1; justify-content: flex-end; gap: 6px; }
  table.av-tabla tr.av-rech { background: var(--err-soft); }
}
.cs-mk-plan { fill: #1d4f91; } .cs-mk-real { fill: var(--accent); }
@media (max-width: 700px) { table.av-tabla td:empty { display: none !important; } }

/* Celular: cabecera y pestañas compactas, y cifras en una franja que se expande */
.kpi-franja { margin-bottom: 10px; }
.kpi-franja > summary { cursor: pointer; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; font-weight: 600; box-shadow: var(--shadow); list-style: none; }
.kpi-franja > summary::-webkit-details-marker { display: none; }
.kpi-franja > summary::after { content: '▾'; float: right; color: var(--accent); }
.kpi-franja[open] > summary::after { content: '▴'; }
.kpi-franja .kpis { margin-top: 8px; }
@media (max-width: 700px) {
  .pr-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .pr-tabs button { white-space: nowrap; padding: 6px 10px; flex: none; }
  #pr-tit { font-size: 16px; }
  #pr-sub { font-size: 12px; }
  #pr-acc .btn { padding: 3px 8px; font-size: 12px; }
  .pr-head .actions .btn { padding: 4px 8px; }
}

/* Proyectos (obras): Estados de pago (Fase 3) */
button.ep-ver { white-space: nowrap; background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; text-decoration: underline; }
tr.ep-anul td { color: var(--muted); text-decoration: line-through; } tr.ep-anul td .b { text-decoration: none; }
.ep-subtabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; margin-top: 10px; }
.ep-subtabs button { white-space: nowrap; flex: none; }
.ep-subtabs button[aria-selected="true"] { color: var(--accent); border-bottom: 2px solid var(--accent); font-weight: 600; }
.ep-ded-row { display: grid; grid-template-columns: 120px 2fr 1.2fr 130px auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.ep-doc { color: #111; font-size: 12.5px; }
.ep-doc h3 { margin: 14px 0 6px; font-size: 13.5px; }
.ep-doc table { border-collapse: collapse; width: 100%; margin: 4px 0 8px; }
.ep-doc th, .ep-doc td { border-bottom: 1px solid #e2e7ee; padding: 3px 6px; vertical-align: top; }
.ep-doc th { background: #e8eef3; text-align: left; font-size: 11.5px; }
.ep-doc th.num, .ep-doc td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ep-doc td.ep-k { background: #f3f6f9; font-weight: 600; width: 16%; }
.ep-doc tr.tot td, .ep-doc tr.sub td { background: #f3f6f9; font-weight: 600; }
.ep-doc tr.final td { border-top: 1.5px solid #111; border-bottom: 3px double #111; font-weight: 700; }
.ep-doc table.ep-item { min-width: 1250px; font-size: 11.5px; }
.ep-doc table.ep-pago, .ep-doc table.ep-cierre, .ep-doc table.ep-ret, .ep-doc table.ep-ant { max-width: 760px; }
.ep-enc { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 6px; margin-bottom: 10px; }
.ep-enc .ep-tit { text-align: right; } .ep-enc .t { font-weight: 700; font-size: 15px; }
.ep-firmas { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 28px; margin-top: 60px; text-align: center; }
.ep-firma .linea { border-top: 1px solid #111; margin-bottom: 4px; } .ep-firma .fn { min-height: 14px; font-weight: 600; }
.ep-pantalla .ep-pb { border-top: 2px dashed #b8c2cf; margin-top: 18px; padding-top: 8px; }
.ep-preview { overflow-x: auto; background: #f1f4f8; }
.ep-preview .ep-doc { background: #fff; padding: 14px; min-width: 760px; }
#ep-print-root { display: none; }
@media print {
  body.ep-printing > *:not(#ep-print-root) { display: none !important; }
  body.ep-printing #ep-print-root { display: block !important; }
  #ep-print-root .ep-doc { font-size: 9.5px; }
  #ep-print-root .ep-doc table.ep-item { min-width: 0; font-size: 8.5px; }
  #ep-print-root .ep-pb { page-break-before: always; }
  #ep-print-root tr { page-break-inside: avoid; }
  #ep-print-root thead { display: table-header-group; }
  #ep-print-root .ep-firmas { page-break-inside: avoid; }
}
@media (max-width: 700px) {
  table.ep-tabla { display: block; min-width: 0 !important; width: 100%; }
  table.ep-tabla tbody { display: block; }
  table.ep-tabla tr.ep-cab { display: none; }
  table.ep-tabla tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
  table.ep-tabla td { display: flex; justify-content: space-between; align-items: center; border: 0 !important; padding: 1px 0 !important; text-align: right; background: none !important; }
  table.ep-tabla td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 11px; margin-right: 8px; text-align: left; }
  table.ep-tabla td:first-child { grid-column: 1 / -1; justify-content: flex-start; font-size: 15px; }
  table.ep-tabla td:first-child::before { display: none; }
  table.ep-tabla td:empty { display: none !important; }
  table.ep-tabla td:last-child { grid-column: 1 / -1; }
  .ep-doc table.ep-car, .ep-doc table.ep-car tbody, .ep-doc table.ep-car tr { display: block; }
  .ep-doc table.ep-car td { display: block; border: 0; padding: 1px 0; width: auto !important; }
  .ep-doc table.ep-car td.ep-k { background: none; font-size: 11px; color: var(--muted); margin-top: 6px; }
  .ep-doc table.ep-car td:empty { display: none; }
  .ep-ded-row { grid-template-columns: 1fr 1fr; } .ep-ded-row input[name=d_glosa] { grid-column: 1 / -1; }
  table.ep-docs-ed, table.ep-docs-ed tbody, table.ep-docs-ed tr, table.ep-mo-ed, table.ep-mo-ed tbody, table.ep-mo-ed tr { display: block; }
  table.ep-docs-ed thead, table.ep-mo-ed thead { display: none; }
  table.ep-docs-ed td, table.ep-mo-ed td { display: block; border: 0; padding: 2px 0; }
  table.ep-docs-ed td[data-l]::before, table.ep-mo-ed td[data-l]::before { content: attr(data-l); display: block; color: var(--muted); font-size: 11px; }
  table.ep-docs-ed tr, table.ep-mo-ed tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .ep-preview .ep-doc { min-width: 640px; }
}
/* Proyección financiera (Fase 4) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fp-ing { fill: var(--ok); opacity: .85; } .fp-egr { fill: var(--err); opacity: .75; }
.fp-cero { stroke: #5f6b7a; stroke-width: 1; } .fp-saldo { fill: none; stroke: #1d4f91; stroke-width: 2.6; } .fp-pt { fill: #1d4f91; }
.fp-max path { fill: var(--err); stroke: #fff; stroke-width: 1; } .fp-max text { font-size: 12px; font-weight: 700; fill: var(--err); }
.lg-ing { background: var(--ok); } .lg-egr { background: var(--err); } .lg-saldo { background: #1d4f91; height: 3px; } .lg-max { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid var(--err); border-radius: 0; background: none; }
#fp-area:focus { outline: 2px solid var(--accent-2); }

/* Portal de módulos */
.portal-hero { background: #fde7dc; border-radius: 16px; padding: 18px 24px; margin-bottom: 16px; }
.portal-hero h1 { margin: 0 0 4px; }
.mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 14px; }
.mod { display: flex; flex-direction: column; gap: 6px; background: #fff; border: 1px solid #e3e6ea; border-radius: 14px; padding: 16px; color: inherit; text-decoration: none; box-shadow: 0 1px 3px #0001; }
.mod:hover { border-color: #0f5f5c; box-shadow: 0 3px 10px #0002; }
.mod.off { opacity: .5; cursor: not-allowed; }
.mod .ico { width: 44px; height: 44px; border-radius: 10px; background: #e6eefb; color: #1a56c4; display: grid; place-items: center; font-size: 20px; font-weight: 700; }
a.brand { color: inherit; text-decoration: none; display: block; }
