/* ========================================================================
   TABLA DE PARTIDAS — aspecto de hoja de cálculo y filtros en los encabezados
   ========================================================================
   Mismo formato que la tabla de Graplanix (_graplanix.css): encabezado gris
   claro, rejilla fina, letra de 11.5 px, estados solo con color de texto.
   Se enlaza DESPUÉS de styles.css (que fija el encabezado azul con !important).
   Todo cuelga de #partidasView / #partidasTable: el modal de partidas no cambia.
   Filtros: js/modules/partidas-filtro-columnas.js (clases ptd-fc-*).
   ======================================================================== */

#partidasView {
    --ptd-fuente: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --ptd-cabecera: #f3f3f3;
    --ptd-linea: #c8c8c8;
    --ptd-linea-suave: #e4e4e4;
    --ptd-texto: #262626;
}

/* ── Contenedor ─────────────────────────────────────────────────────────── */
#partidasView .partidas-table-container {
    border: 1px solid var(--ptd-linea);
    border-radius: 0;
    box-shadow: none;
}
#partidasView .partidas-table-container::after { display: none; }

/* ── Rejilla ────────────────────────────────────────────────────────────── */
#partidasView table#partidasTable {
    font-family: var(--ptd-fuente);
    color: var(--ptd-texto);
    border-collapse: separate !important;   /* con «collapse» los bordes del encabezado fijo se van con el scroll */
    border-spacing: 0;
}

#partidasView table#partidasTable thead,
#partidasView table#partidasTable thead tr { background: var(--ptd-cabecera) !important; box-shadow: none !important; }

#partidasView table#partidasTable thead tr th {
    background: var(--ptd-cabecera) !important;
    color: #333 !important;
    font-family: var(--ptd-fuente);
    font-size: 11.5px !important;
    font-weight: 400 !important;
    line-height: 1.25;
    padding: 5px 16px 5px 6px !important;   /* a la derecha va la flecha del filtro */
    border: 0;
    border-right: 1px solid var(--ptd-linea);
    border-bottom: 1px solid var(--ptd-linea);
    min-width: 0;
}
#partidasView table#partidasTable thead tr th:last-child { border-right: 0; }

#partidasView table#partidasTable tbody tr { height: 24px; transition: none; }

#partidasView table#partidasTable tbody td {
    font-family: var(--ptd-fuente) !important;
    font-size: 11.5px !important;
    font-weight: 400;
    line-height: 1.25;
    padding: 3px 6px !important;
    color: var(--ptd-texto);
    border: 0;
    border-right: 1px solid var(--ptd-linea-suave);
    border-bottom: 1px solid #ececec;
    background-clip: padding-box;
}
#partidasView table#partidasTable tbody td:last-child { border-right: 0; }

#partidasView table#partidasTable tbody tr:hover td { background-color: #e8f2fb; }

/* ── Alineación por columna (las reglas nth-child de styles.css son de una tabla anterior) ── */
#partidasView table#partidasTable tbody td.codigo { text-align: left; color: #5f6b7a; white-space: nowrap; }
#partidasView table#partidasTable tbody td.descripcion { text-align: left; }
#partidasView table#partidasTable tbody td.unidad,
#partidasView table#partidasTable tbody td.desfase,
#partidasView table#partidasTable tbody td.documentos { text-align: center; }
#partidasView table#partidasTable tbody td.cantidad,
#partidasView table#partidasTable tbody td.precio-unitario,
#partidasView table#partidasTable tbody td.subtotal,
#partidasView table#partidasTable tbody td.apu-meta,
#partidasView table#partidasTable tbody td.porcentaje-avance,
#partidasView table#partidasTable tbody td.porcentaje-costo,
#partidasView table#partidasTable tbody td.porcentaje-retraso,
#partidasView table#partidasTable tbody td.gasto,
#partidasView table#partidasTable tbody td.vac {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#partidasView table#partidasTable tbody td.unidad { color: #5f5f5f; }

/* ── Estados: solo el color del número, sin fondo ni marca lateral ───────── */
#partidasView table#partidasTable tbody td.avance-excedido,
#partidasView table#partidasTable tbody td.avance-alto,
#partidasView table#partidasTable tbody td.avance-medio,
#partidasView table#partidasTable tbody td.costo-excedido,
#partidasView table#partidasTable tbody td.costo-normal,
#partidasView table#partidasTable tbody td.retraso-bien,
#partidasView table#partidasTable tbody td.retraso-atrasado,
#partidasView table#partidasTable tbody td.retraso-no-iniciado,
#partidasView table#partidasTable tbody td.vac-positivo,
#partidasView table#partidasTable tbody td.vac-negativo,
#partidasView table#partidasTable tbody td.vac-neutro {
    background-color: transparent !important;
    border-left: 0;
    border-radius: 0 !important;
    font-weight: 600 !important;
}
#partidasView table#partidasTable tbody td.avance-excedido,
#partidasView table#partidasTable tbody td.costo-excedido,
#partidasView table#partidasTable tbody td.retraso-no-iniciado,
#partidasView table#partidasTable tbody td.vac-negativo { color: #b91c1c !important; }
#partidasView table#partidasTable tbody td.avance-alto,
#partidasView table#partidasTable tbody td.costo-normal,
#partidasView table#partidasTable tbody td.retraso-bien,
#partidasView table#partidasTable tbody td.vac-positivo { color: #15803d !important; }
#partidasView table#partidasTable tbody td.avance-medio,
#partidasView table#partidasTable tbody td.retraso-atrasado { color: #b45309 !important; }
#partidasView table#partidasTable tbody td.vac-neutro { color: #5f5f5f !important; font-weight: 400 !important; }
#partidasView table#partidasTable tbody tr:hover td[class*="avance-"],
#partidasView table#partidasTable tbody tr:hover td[class*="costo-"],
#partidasView table#partidasTable tbody tr:hover td[class*="retraso-"],
#partidasView table#partidasTable tbody tr:hover td[class*="vac-"] { background-color: #e8f2fb !important; }

/* ── Títulos ────────────────────────────────────────────────────────────── */
#partidasView table#partidasTable tbody tr.partida-titulo td {
    background-color: #f7f8fa !important;
    color: #1f2937 !important;
    font-weight: 600 !important;
    font-style: normal;
    text-transform: none;
}
#partidasView table#partidasTable tbody tr.partida-titulo td.descripcion { color: #1f2937 !important; font-weight: 600 !important; }
#partidasView table#partidasTable tbody tr.partida-titulo:hover td { background-color: #eceff3 !important; }

#partidasView table#partidasTable tbody tr.ptd-vacia td {
    padding: 14px 10px !important;
    text-align: center;
    color: #6b7280;
    border-right: 0;
}
#partidasView table#partidasTable tbody tr.ptd-vacia:hover td { background-color: transparent; }

/* ── Flecha de filtro en el encabezado ──────────────────────────────────── */
#partidasTable .ptd-fc-btn {
    position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
    width: 11px; height: 16px; padding: 0; border: 0; border-radius: 2px;
    background: transparent; color: #6b7280; font-size: 10px; line-height: 16px;
    cursor: pointer; opacity: .55;
}
#partidasTable thead th:hover .ptd-fc-btn { opacity: 1; background: rgba(0, 0, 0, .06); }
#partidasView table#partidasTable thead tr th.ptd-fc-activo { color: #1d4ed8 !important; }
#partidasTable thead th.ptd-fc-activo .ptd-fc-btn { opacity: 1; color: #fff; background: #2563eb; font-size: 8px; }

/* ── Barra de filtros activos (junto al título de la tabla) ─────────────── */
.ptd-fc-barra { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; margin: 0 12px; font: 400 11.5px "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; color: #262626; }
.ptd-fc-cuenta { color: #5f5f5f; }
.ptd-fc-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 320px; padding: 1px 4px 1px 8px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; }
.ptd-fc-chip i { font-size: 9px; color: #2563eb; }
.ptd-fc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptd-fc-chip button { border: 0; background: none; color: #dc2626; font-size: 13px; line-height: 1; padding: 0 3px; cursor: pointer; }
.ptd-fc-todos { padding: 1px 8px; border: 1px solid #c8c8c8; border-radius: 3px; background: #fff; font-size: 11.5px; color: #262626; cursor: pointer; }
.ptd-fc-todos:hover { background: #f3f3f3; }

/* ── Menú del filtro (flotante en <body>) ───────────────────────────────── */
.ptd-fc-menu {
    position: fixed; z-index: 10060; width: 270px; display: flex; flex-direction: column;
    background: #fff; border: 1px solid #c8c8c8; border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; font-size: 12px; color: #222;
}
.ptd-fc-tit { padding: 7px 10px 5px; font-weight: 600; border-bottom: 1px solid #eee; }
.ptd-fc-tit span { display: block; font-weight: 400; color: #6b7280; font-size: 11px; margin-top: 2px; }
.ptd-fc-cond { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px; border-bottom: 1px solid #eee; background: #fafafa; }
.ptd-fc-cond label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font-weight: 400; }
.ptd-fc-cond input { width: 130px; padding: 2px 5px; border: 1px solid #c8c8c8; border-radius: 3px; font-size: 12px; }
.ptd-fc-buscar { margin: 6px 10px 4px; padding: 3px 6px; border: 1px solid #c8c8c8; border-radius: 3px; font-size: 12px; }
.ptd-fc-lista { flex: 1 1 auto; min-height: 60px; max-height: 260px; overflow-y: auto; margin: 0 10px; border: 1px solid #e5e5e5; padding: 2px 0; }
.ptd-fc-lista label { display: flex; align-items: center; gap: 6px; margin: 0; padding: 1px 6px; font-weight: 400; cursor: pointer; white-space: nowrap; }
.ptd-fc-lista label:hover { background: #eef4fd; }
.ptd-fc-lista label input { width: auto; margin: 0; flex: 0 0 auto; }
.ptd-fc-lista label span { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.ptd-fc-lista label em { font-style: normal; color: #9ca3af; font-size: 11px; }
.ptd-fc-lista .ptd-fc-todo { border-bottom: 1px solid #eee; }
.ptd-fc-mas { padding: 4px 8px; color: #6b7280; font-size: 11px; }
.ptd-fc-pie { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.ptd-fc-pie span { flex: 1; }
.ptd-fc-pie button { padding: 3px 10px; border: 1px solid #c8c8c8; border-radius: 3px; background: #fff; font-size: 12px; color: #222; cursor: pointer; }
.ptd-fc-pie button:disabled { opacity: .45; cursor: default; }
.ptd-fc-pie .ptd-fc-ok { background: #2563eb; border-color: #2563eb; color: #fff; }
