/* ═══ documentos.css — Documents, Gantt Chart, Column Mapping ═══ */

/* ═══ DOCUMENTOS ═══ */
.doc-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 2000;
}
.doc-modal.active { display: flex; }
.doc-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--sp-5) var(--sp-6);
    min-width: 400px;
    max-width: 520px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    /* modalBoxIn → replaced by GSAP */
}
.doc-modal-box h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}
.doc-label {
    font-size: 0.68rem;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 3px;
}

/* Card de documento */
.doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.doc-card:hover {
    border-color: var(--border-hover);
}
.doc-card-header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    cursor: pointer;
    user-select: none;
}
.doc-card-header:hover { background: var(--bg-muted); }
.doc-code-badge {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--info);
    background: var(--info-muted);
    border: 1px solid var(--border);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}
.doc-tipo-badge {
    font-size: 0.6rem;
    color: var(--text-muted);
    background: var(--bg-muted);
    border: 1px solid var(--border);
    padding: 1px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
    font-family: var(--mono);
}
.doc-nombre {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-rev-actual {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: var(--r-pill);
    white-space: nowrap;
    border: 1px solid transparent;
}
.doc-rev-actual.rev-a { color: var(--warning); background: var(--warning-muted); border-color: var(--border); }
.doc-rev-actual.rev-b { color: var(--warning); background: var(--warning-muted); border-color: var(--border); }
.doc-rev-actual.rev-c { color: var(--destructive); background: var(--destructive-muted); border-color: var(--border); }
.doc-rev-actual.rev-0 { color: var(--success); background: var(--success-muted); border-color: var(--border); }
.doc-estado-badge {
    font-size: 0.62rem;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    font-weight: 600;
    font-family: var(--mono);
    border: 1px solid transparent;
}
.doc-estado-badge.en_elaboracion { color: var(--text-secondary); background: var(--bg-muted); border-color: var(--border); }
.doc-estado-badge.rev_interna { color: var(--info); background: var(--info-muted); border-color: var(--border); }
.doc-estado-badge.enviado_cliente { color: var(--purple); background: var(--purple-muted); border-color: var(--border); }
.doc-estado-badge.aprobado { color: var(--success); background: var(--success-muted); border-color: var(--border); }
.doc-estado-badge.aprobado_obs { color: var(--info); background: var(--info-muted); border-color: var(--border); }
.doc-estado-badge.rechazado { color: var(--destructive); background: var(--destructive-muted); border-color: var(--border); }
/* PDF drop zone en revisión */
.rev-pdf-drop {
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--dur-fast) var(--ease);
    min-height: 40px;
}
.rev-pdf-drop:hover { border-color: var(--border-focus); }
.rev-pdf-drop.drag-over {
    border-color: var(--primary);
    background: var(--bg-muted);
}
.rev-pdf-drop #rev-pdf-placeholder {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
}
.rev-pdf-drop #rev-pdf-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* PDF link en timeline */
.doc-timeline-pdf {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    color: var(--destructive);
    background: var(--destructive-muted);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-top: 4px;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease);
    text-decoration: none;
}
.doc-timeline-pdf:hover {
    background: var(--bg-muted);
    color: var(--destructive-hover);
}
.doc-timeline-pdf i { font-size: 0.6rem; }

.doc-linked-task {
    font-size: 0.6rem;
    color: var(--info);
    font-family: var(--mono);
    background: var(--info-muted);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}
.doc-linked-task i { font-size: 0.5rem; opacity: 0.6; }
.doc-card-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.doc-card-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 3px 5px;
    border-radius: var(--radius-sm);
    transition: all var(--dur-fast) var(--ease);
}
.doc-card-actions button:hover { color: var(--text-primary); background: var(--bg-muted); }

/* Timeline de revisiones */
.doc-timeline {
    padding: 0 14px 12px;
    border-top: 1px solid var(--border);
    display: none;
}
.doc-card.expanded .doc-timeline { display: block; }
.doc-timeline-entry {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.74rem;
    position: relative;
}
.doc-timeline-entry:last-child { border-bottom: none; }
.doc-timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-hover);
    margin-top: 4px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.doc-timeline-entry.aprobado .doc-timeline-dot { background: var(--success); }
.doc-timeline-entry.rechazado .doc-timeline-dot { background: var(--destructive); }
.doc-timeline-entry.enviado .doc-timeline-dot { background: var(--warning); }
.doc-timeline-entry.elaboracion .doc-timeline-dot { background: var(--info); }
.doc-timeline-line {
    position: absolute;
    left: 3px;
    top: 16px;
    bottom: -8px;
    width: 2px;
    background: var(--border);
}
.doc-timeline-entry:last-child .doc-timeline-line { display: none; }
.doc-timeline-rev {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.68rem;
    min-width: 36px;
}
.doc-timeline-info { flex: 1; min-width: 0; }
.doc-timeline-estado {
    font-weight: 500;
    color: var(--text-primary);
}
.doc-timeline-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.doc-timeline-comment {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-top: 3px;
    padding: 4px 8px;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--border-hover);
}
/* Transmittal badge en timeline */
.doc-timeline-transmittal {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-size: 0.65rem;
    font-family: var(--mono);
}
.doc-timeline-transmittal .tr-number {
    color: var(--text-secondary);
    background: var(--info-muted);
    padding: 1px 7px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.doc-timeline-transmittal .tr-number i {
    font-size: 0.55rem;
    opacity: 0.6;
    margin-right: 3px;
}
.doc-timeline-transmittal .tr-code {
    padding: 1px 7px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.6rem;
    letter-spacing: 0.3px;
}
.doc-timeline-transmittal .tr-code.code-ASB { background: var(--success-muted); color: var(--success); border: 1px solid var(--border); }
.doc-timeline-transmittal .tr-code.code-ASC { background: var(--success-muted); color: var(--success); border: 1px solid var(--border); }
.doc-timeline-transmittal .tr-code.code-ACC { background: var(--warning-muted); color: var(--warning); border: 1px solid var(--border); }
.doc-timeline-transmittal .tr-code.code-REC { background: var(--destructive-muted); color: var(--destructive); border: 1px solid var(--border); }
.doc-timeline-transmittal .tr-code.code-AIC { background: var(--info-muted); color: var(--info); border: 1px solid var(--border); }

/* Estadísticas resumen */
.doc-stats {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    margin-bottom: 3px;
}
.doc-stat {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.doc-stat strong {
    color: var(--text-primary);
    font-size: 0.82rem;
}

/* ═══ GANTT & COLUMN MAPPING ═══ */

/* ═══ GANTT CHART ═══ */
.gantt-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    text-align: center;
    transition: all var(--dur-fast) var(--ease);
    cursor: pointer;
}
.gantt-upload-zone:hover, .gantt-upload-zone.drag-over {
    border-color: var(--border-focus);
    background: var(--bg-muted);
}
.gantt-container {
    display: flex;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    max-height: 520px;
    box-shadow: var(--shadow-sm);
}
.gantt-table {
    min-width: 500px;
    max-width: 500px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
}
.gantt-table-header, .gantt-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.gantt-table-header {
    background: var(--bg-muted);
    position: sticky;
    top: 0;
    z-index: 5;
}
.gantt-th {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: var(--sp-3) var(--sp-2);
    font-family: var(--mono);
}
.gantt-row {
    transition: background var(--dur-fast) var(--ease);
    min-height: 36px;
}
.gantt-row:hover {
    background: var(--bg-muted);
}
.gantt-row.no-dates {
    background: var(--bg-muted);
    border-left: 2px solid var(--text-muted);
}
.gantt-row.milestone {
    background: var(--purple-muted);
}
.gantt-col-code { width: 80px; flex-shrink: 0; }
.gantt-col-name { flex: 1; min-width: 0; }
.gantt-cell-code {
    font-size: 0.68rem;
    color: var(--info);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ═══ Resizable columns ═══ */
.gantt-th {
    position: relative;
    user-select: none;
}
.gantt-th .col-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 6;
    background: transparent;
    transition: background var(--dur-fast) var(--ease);
}
.gantt-th .col-resize-handle:hover,
.gantt-th .col-resize-handle.active {
    background: var(--primary);
}
.gantt-table.resizing {
    cursor: col-resize;
    user-select: none;
}
.gantt-table.resizing * {
    cursor: col-resize !important;
}
.gantt-col-start, .gantt-col-end { width: 80px; flex-shrink: 0; }
.gantt-col-resp { width: 65px; flex-shrink: 0; }
.gantt-col-pct { width: 40px; flex-shrink: 0; text-align: center; }
.gantt-col-hh { width: 40px; flex-shrink: 0; text-align: center; font-size: .65rem; color: var(--text-secondary); }
.gantt-col-del { width: 28px; flex-shrink: 0; text-align: center; font-size: .6rem; color: var(--text-muted); cursor: pointer; opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.gantt-row:hover .gantt-col-del { opacity: 1; }
.gantt-col-del:hover { color: var(--destructive); }

.gantt-cell {
    font-size: 0.75rem;
    padding: 4px 6px;
    color: var(--text-primary);
    font-family: var(--mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gantt-cell-name {
    font-family: var(--sans);
    font-size: 0.78rem;
    cursor: pointer;
}
.gantt-cell-name:hover { color: var(--primary); }
.gantt-cell input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--mono);
    font-size: 0.73rem;
    width: 100%;
    padding: 2px 0;
}
.gantt-cell input:focus { outline: none; border-bottom-color: var(--border-focus); }

.gantt-pct-bar {
    width: 28px; height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 3px;
}
.gantt-pct-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* Timeline */
.gantt-timeline {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
}
.gantt-timeline-header {
    display: flex;
    background: var(--bg-muted);
    position: sticky;
    top: 0;
    z-index: 5;
    min-height: 34px;
    border-bottom: 1px solid var(--border);
}
.gantt-time-col {
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    padding: 4px 0;
    font-family: var(--mono);
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.gantt-time-col.weekend { background: var(--bg-muted); }
.gantt-time-col.today { background: var(--bg-hover); color: var(--text-primary); font-weight: 600; }

.gantt-timeline-body {
    position: relative;
}

/* Línea vertical "Hoy" — atraviesa todas las filas del Gantt.
   Se inserta desde js/gantt.js con la posición calculada según la
   fecha actual dentro del rango. Solo visible si hoy cae en el rango. */
.gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--red, #ef4444);
    opacity: 0.75;
    pointer-events: none;
    z-index: 2;
    box-shadow: 0 0 0 1px rgb(239 68 68 / .15);
}
.gantt-today-line::before {
    content: 'HOY';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono, monospace);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--red, #ef4444);
    background: var(--background, #fff);
    padding: 0 3px;
    border-radius: 2px;
    line-height: 1.2;
    white-space: nowrap;
}
.gantt-bar-row {
    height: 36px;
    position: relative;
    border-bottom: 1px solid var(--border);
}
.gantt-bar {
    position: absolute;
    top: 7px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: all var(--dur-fast) var(--ease);
    display: flex;
    align-items: center;
    overflow: hidden;
    min-width: 6px;
    box-shadow: var(--shadow-sm);
}
.gantt-bar:hover {
    box-shadow: var(--shadow-md);
    z-index: 3;
}
.gantt-bar:active { cursor: grabbing; }
.gantt-bar-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: var(--radius-sm);
    opacity: 0.3;
}
.gantt-bar-progress {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    border-radius: var(--radius-sm);
    opacity: 0.9;
}
.gantt-bar-label {
    position: relative;
    z-index: 1;
    font-size: 0.6rem;
    color: #fff;
    padding: 0 6px;
    white-space: nowrap;
    font-family: var(--sans);
}
.gantt-bar-handle {
    position: absolute;
    top: 0; bottom: 0; width: 6px;
    cursor: col-resize;
    z-index: 4;
}
.gantt-bar-handle.left { left: 0; }
.gantt-bar-handle.right { right: 0; }
.gantt-bar-handle:hover { background: rgba(255,255,255,0.2); }

/* Drag from gantt to calendar indicator */
.gantt-row .gantt-cell-name .drag-cal-icon {
    opacity: 0;
    margin-left: 4px;
    font-size: 0.6rem;
    color: var(--info);
    transition: opacity var(--dur-fast) var(--ease);
    cursor: grab;
}
.gantt-row:hover .gantt-cell-name .drag-cal-icon { opacity: 0.7; }
.gantt-row:hover .gantt-cell-name .drag-cal-icon:hover { opacity: 1; }

/* Bar colors by progress — semanticos solidos */
.gantt-color-0 { --bar-color: var(--primary); }
.gantt-color-1 { --bar-color: var(--info); }
.gantt-color-2 { --bar-color: var(--success); }
.gantt-color-3 { --bar-color: var(--purple); }
.gantt-color-4 { --bar-color: var(--info); }
.gantt-color-5 { --bar-color: var(--warning); }

/* ═══ GANTT COLUMN MAPPING MODAL ═══ */
.map-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 2100;
}
.map-modal.active { display: flex; }
.map-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--sp-5) var(--sp-6);
    width: 640px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    /* modalBoxIn → replaced by GSAP */
}
.map-modal-box h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--sp-1);
}
.map-modal-box .map-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.map-header-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 1rem;
    padding: 10px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
}
.map-header-row label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.map-header-row select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.75rem;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.map-header-row select:focus { outline: none; border-color: var(--border-focus); }
.map-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1rem;
}
.map-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: border-color var(--dur-fast) var(--ease);
}
.map-field.mapped { border-color: var(--success); }
.map-field.required { border-color: var(--destructive); }
.map-field.required.mapped { border-color: var(--success); }
.map-field-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex; align-items: center; gap: 5px;
}
.map-field-label .req {
    font-size: 0.55rem;
    color: var(--destructive);
    font-weight: 700;
}
.map-field-label .opt {
    font-size: 0.55rem;
    color: var(--text-muted);
}
.map-field select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.78rem;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
}
.map-field select:focus { outline: none; border-color: var(--border-focus); }
.map-preview {
    margin-bottom: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.map-preview-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 8px 12px;
    display: flex; align-items: center; gap: 6px;
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
}
.map-preview-title .map-count {
    margin-left: auto;
    font-size: 0.65rem;
    color: var(--text-primary);
    font-weight: 600;
}
.map-preview-scroll {
    overflow-x: auto;
    max-height: 220px;
    overflow-y: auto;
}
.map-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    font-family: var(--mono);
}
.map-preview-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
.map-preview-table th {
    background: var(--bg-muted);
    color: var(--text-primary);
    padding: 7px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.map-preview-table th i {
    margin-right: 4px;
    font-size: 0.6rem;
    opacity: 0.6;
}
.map-preview-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.73rem;
}
.map-preview-table tbody tr {
    transition: background var(--dur-fast) var(--ease);
}
.map-preview-table tbody tr:hover td {
    background: var(--bg-muted);
}
.map-preview-table tbody tr:nth-child(even) td {
    background: var(--bg-muted);
}
.map-preview-table .row-num {
    color: var(--text-muted);
    font-size: 0.6rem;
    text-align: center;
    width: 30px;
    min-width: 30px;
    padding: 6px 4px;
}
.map-preview-table .cell-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.65rem;
}
.map-preview-none {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}
.map-preview-none i { margin-right: 6px; opacity: 0.5; }
.map-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    align-items: center;
}
.map-stats {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-right: auto;
}
.map-stats strong { color: var(--text-secondary); font-weight: 600; }
.map-auto-badge {
    display: inline-block;
    font-size: 0.58rem;
    color: var(--success);
    background: var(--success-muted);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    margin-left: 6px;
}

/* ═════════════════════════════════════════════════════════════════════
   Vista grilla estilo Excel para Control Documental
   Look-and-feel inspirado en Excel: header oscuro con letras de columna,
   números de fila a la izquierda, líneas de grilla finas, padding compacto.
   ═════════════════════════════════════════════════════════════════════ */
.docs-grid-wrap {
    overflow: auto;
    max-height: calc(100vh - 320px);
    border: 1px solid #4a4a4a;
    background: #ffffff;
    margin-top: 12px;
    /* Tipografía Calibri-like (la default de Excel) */
    font-family: Calibri, "Segoe UI", system-ui, -apple-system, sans-serif;
}
.docs-grid {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 12px;
    table-layout: fixed;
    color: #000;
    background: #fff;
}

/* Fila de letras de columna estilo Excel (A, B, C, ...) */
.docs-grid__head-letters th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #444444;
    color: #d8d8d8;
    font-weight: 400;
    font-size: 12px;
    height: 22px;
    text-align: center;
    border-right: 1px solid #2a2a2a;
    border-bottom: 1px solid #2a2a2a;
    padding: 0;
    user-select: none;
    cursor: default;
}
.docs-grid__head-letters th:first-child {
    background: #444444;
    border-right: 1px solid #2a2a2a;
    width: 40px;
}

/* Fila de labels descriptivos (Code, Tipo, Nombre, ...) */
.docs-grid__head-labels th {
    position: sticky;
    top: 22px; /* debajo de las letras */
    z-index: 3;
    background: #f2f2f2;
    color: #2a2a2a;
    font-weight: 600;
    font-size: 11px;
    text-align: left;
    padding: 4px 8px;
    border-right: 1px solid #d4d4d4;
    border-bottom: 1px solid #a6a6a6;
    user-select: none;
    white-space: nowrap;
    height: 24px;
}
.docs-grid__head-labels th.is-sortable { cursor: pointer; }
.docs-grid__head-labels th.is-sortable:hover { background: #e8e8e8; }
.docs-grid__head-labels th.is-sorted { color: #217346; /* verde Excel */ background: #e8f3eb; }
.docs-grid__head-labels th.has-filter { background: #e0eddc; }
.docs-grid__head-labels th .sort-chev { font-size: 8px; margin-left: 4px; opacity: .7; }
.docs-grid__th-inner {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.docs-grid__head-labels th .docs-grid__label-text {
    flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.docs-grid__filter-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #666;
    padding: 1px 4px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 10px;
    flex-shrink: 0;
    line-height: 1;
}
.docs-grid__filter-btn:hover { background: #d8d8d8; border-color: #888; color: #000; }
.docs-grid__filter-btn.is-active {
    background: #217346;
    color: #fff;
    border-color: #1a5c38;
}
.docs-grid__filter-btn.is-active:hover { background: #1a5c38; }

/* Popover de filtro tipo Excel */
.docs-grid__filter-pop {
    width: 260px;
    max-height: 420px;
    background: #fff;
    border: 1px solid #888;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    font-family: Calibri, "Segoe UI", system-ui, sans-serif;
    font-size: 12px;
    color: #000;
}
.docs-grid__filter-sort {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #d4d4d4;
}
.docs-grid__filter-sort-btn {
    background: #fff;
    border: 0;
    text-align: left;
    padding: 7px 12px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #000;
}
.docs-grid__filter-sort-btn:hover { background: #e8f3eb; }
.docs-grid__filter-sort-btn i { color: #217346; width: 14px; }

.docs-grid__filter-search {
    position: relative;
    padding: 6px;
    border-bottom: 1px solid #d4d4d4;
}
.docs-grid__filter-search > i {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 11px;
    pointer-events: none;
}
.docs-grid__filter-search input {
    width: 100%;
    padding: 5px 8px 5px 28px;
    border: 1px solid #c4c4c4;
    border-radius: 2px;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}
.docs-grid__filter-search input:focus { border-color: #217346; }

.docs-grid__filter-controls {
    border-bottom: 1px solid #d4d4d4;
    background: #fafafa;
}
.docs-grid__filter-all {
    font-weight: 600;
    background: #fafafa;
}

.docs-grid__filter-items {
    flex: 1;
    overflow-y: auto;
    max-height: 220px;
    padding: 2px 0;
}
.docs-grid__filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}
.docs-grid__filter-item:hover { background: #e8f3eb; }
.docs-grid__filter-item input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}
.docs-grid__filter-item-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.docs-grid__filter-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-top: 1px solid #d4d4d4;
    background: #f4f4f4;
    gap: 8px;
}
.docs-grid__filter-foot-actions {
    display: flex; gap: 6px;
}
.docs-grid__filter-foot button {
    padding: 4px 12px;
    border-radius: 2px;
    font-size: 11.5px;
    cursor: pointer;
    border: 1px solid #888;
    background: #fff;
    color: #000;
}
.docs-grid__filter-foot button:hover { background: #e8e8e8; }
.docs-grid__filter-btn-clear {
    color: #c0392b !important;
    border-color: #d4d4d4 !important;
    background: transparent !important;
    font-size: 11px !important;
}
.docs-grid__filter-btn-clear:hover { background: #fde8e8 !important; }
.docs-grid__filter-btn-apply {
    background: #217346 !important;
    color: #fff !important;
    border-color: #1a5c38 !important;
    font-weight: 600;
}
.docs-grid__filter-btn-apply:hover { background: #1a5c38 !important; }
.docs-grid__row-num-h {
    background: #444444 !important;
    border-right: 1px solid #2a2a2a !important;
    width: 40px;
    padding: 0 !important;
}

/* Números de fila estilo Excel (a la izquierda) */
.docs-grid__row-num {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #f2f2f2;
    color: #2a2a2a;
    font-weight: 400;
    font-size: 11px;
    text-align: center;
    width: 40px;
    border-right: 1px solid #a6a6a6;
    border-bottom: 1px solid #d4d4d4;
    padding: 0 4px;
    user-select: none;
}
.docs-grid tbody tr:hover .docs-grid__row-num {
    background: #d9e9d2;
    color: #217346;
}

/* Celdas del cuerpo: estilo Excel limpio */
.docs-grid tbody td {
    padding: 3px 8px;
    border-right: 1px solid #d4d4d4;
    border-bottom: 1px solid #d4d4d4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    height: 22px;
    background: #fff;
    color: #000;
    font-size: 12px;
}
.docs-grid tbody tr[data-doc-id]:not(.docs-grid__row-detail):hover td:not(.is-selected) {
    background: #f5f9f3;
}
.docs-grid td.mono { font-family: Consolas, "Courier New", monospace; font-size: 11.5px; }
.docs-grid td.align-right { text-align: right; }

/* Celda editable: cursor cell-cross-hair */
.docs-grid td.is-editable { cursor: cell; }

/* Celda seleccionada: borde verde estilo Excel */
.docs-grid td.is-selected {
    outline: 2px solid #217346;
    outline-offset: -2px;
    background: #fff;
    position: relative;
    z-index: 1;
}

/* Celda editando */
.docs-grid td.is-editing {
    padding: 0;
    outline: 2px solid #217346;
    outline-offset: -2px;
    background: #fff;
}
.docs-grid td.is-editing input,
.docs-grid td.is-editing select {
    width: 100%; height: 100%;
    box-sizing: border-box;
    border: 0;
    padding: 2px 7px;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    color: #000;
    outline: none;
}

.docs-grid td.flash-saved { animation: docs-grid-flash .3s ease-out; }
@keyframes docs-grid-flash {
    0% { background: #c8e6c9; }
    100% { background: transparent; }
}
.docs-grid td.is-error { background: #fde8e8; outline: 2px solid #c0392b; outline-offset: -2px; }

/* Botón expandir / chevron */
.docs-grid__expand-btn {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 2px 4px;
    color: var(--text3, var(--text-tertiary));
    transition: transform .15s ease, color .15s ease;
}
.docs-grid__expand-btn:hover { color: var(--text); }
.docs-grid__expand-btn i { transition: transform .15s ease; }
.docs-grid__expand-btn.is-open i { transform: rotate(90deg); color: var(--claude, #4a80ff); }

/* Icono PDF en columna Rev */
.docs-grid__rev-text { font-family: var(--mono, monospace); }
.docs-grid__rev-pdf-icon {
    margin-left: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 11px;
    color: var(--text3, var(--text-tertiary));
}
.docs-grid__rev-pdf-icon.is-cloud { color: var(--info, #4a80ff); }
.docs-grid__rev-pdf-icon.is-local { color: #c0392b; }
.docs-grid__rev-pdf-icon:hover { opacity: .75; }

/* Badges de estado: sutiles, estilo Excel (sin fondo redondeado fuerte) */
.docs-grid .estado-badge {
    padding: 1px 6px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 500;
    text-transform: lowercase;
    display: inline-block;
    border: 1px solid transparent;
}
.docs-grid .estado-aprobado        { background: #d4edda; color: #155724; border-color: #b8d8be; }
.docs-grid .estado-aprobado_obs    { background: #e6f3d4; color: #4a6b00; border-color: #cae5a3; }
.docs-grid .estado-rechazado       { background: #f8d7da; color: #721c24; border-color: #efb7be; }
.docs-grid .estado-enviado_cliente { background: #cfe2f3; color: #1a4674; border-color: #a4c5e8; }
.docs-grid .estado-rev_interna     { background: #e3d7f4; color: #5b21b6; border-color: #c5b3e0; }
.docs-grid .estado-en_elaboracion  { background: #fff3cd; color: #856404; border-color: #ffe59c; }

.docs-grid__cat {
    font-size: 11px;
    text-transform: lowercase;
    padding: 1px 6px;
    border-radius: 2px;
    background: #f0f0f0;
    color: #666;
    border: 1px solid #d4d4d4;
}
.docs-grid__cat--adicional {
    background: #e7f1fb;
    color: #1a4674;
    border-color: #a4c5e8;
}

.docs-grid__cmt-badge {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffe59c;
    padding: 0 6px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    font-family: Consolas, "Courier New", monospace;
}

/* Acciones (botones) en última columna */
.docs-grid__actions { display: flex; gap: 1px; justify-content: flex-start; }
.docs-grid__actions button {
    background: transparent;
    border: 1px solid transparent;
    color: #666;
    padding: 1px 5px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 10.5px;
}
.docs-grid__actions button:hover { background: #f0f0f0; color: #000; border-color: #c0c0c0; }

/* Fila expandida: detalle inline */
.docs-grid__row-detail td {
    background: var(--surface2, var(--bg-elevated));
    padding: 0 !important;
    border-bottom: 2px solid var(--border-strong, var(--border));
}
.docs-grid__detail {
    padding: 16px 24px;
    animation: docs-grid-detail-slide .2s ease-out;
}
@keyframes docs-grid-detail-slide {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.docs-grid__detail-hdr {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.docs-grid__detail-hdr h3 { flex: 1; }
.docs-grid__detail-close {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text3);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.docs-grid__detail-close:hover { color: var(--red, #dc2626); border-color: var(--red, #dc2626); }
.docs-grid__detail-body { display: flex; flex-direction: column; gap: 14px; }
.docs-grid__detail-h {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text3);
    margin: 0 0 8px;
    display: flex; align-items: center; gap: 6px;
}
.docs-grid__detail-h > i { color: var(--text3); font-size: 10px; }
.docs-grid__detail-foot {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.docs-grid-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    color: var(--text3);
    font-size: .72rem;
}
