/* --- ESTILOS GENERALES Y RESET --- */
:root {
    --bg-main: #f4f5f7; 
    --bg-column: #ebecf0; 
    --bg-card: #ffffff;
    --text-main: #172b4d; 
    --text-muted: #5e6c84; 
    --border: #dfe1e6;
    --primary: #0052cc; 
    --accent-red: #de350b; 
    --accent-yellow: #ffab00; 
    --accent-green: #00875a;
    --accent-dark: #42526e;
    --shadow-modal: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-elevated: 0 10px 40px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

/* FIX MAC M1: Usamos 'dvh' para altura dinámica real */
body { 
    background-color: var(--bg-main); 
    color: var(--text-main); 
    height: 100vh;      /* Fallback */
    height: 100dvh;     /* Altura real descontando barras del navegador */
    overflow: hidden; 
}

/* --- LAYOUT APP --- */
.app-container { display: flex; flex-direction: column; height: 100%; }
.top-bar { height: 55px; background: white; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 20px; flex-shrink: 0; }

/* LOGO */
.logo { font-size: 1.1rem; font-weight: 800; color: var(--primary); display: flex; align-items: center; gap: 8px; letter-spacing: -0.5px; }
.logo i { font-size: 1.2rem; }

/* USER CHIP */
.user-controls { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; background: #f4f5f7; border: 1px solid #dfe1e6; padding: 4px 12px 4px 4px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; color: var(--text-main); transition: 0.2s; }
.user-chip:hover { background: #ebecf0; }
.user-avatar { width: 24px; height: 24px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; }

/* TOOLBAR */
.toolbar { padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.toolbar-actions { display: flex; gap: 10px; align-items: center; }

/* WIDGET FINANCIERO (Header) */
.financial-widget { background: white; border: 1px solid #dfe1e6; border-radius: 8px; padding: 6px 18px; display: flex; align-items: center; gap: 18px; box-shadow: var(--shadow-card); }
.fw-item { display: flex; flex-direction: column; justify-content: center; }
.fw-label { font-size: 0.65rem; color: #5e6c84; font-weight: 700; text-transform: uppercase; display: flex; align-items: center; gap: 5px; margin-bottom: 3px; white-space: nowrap; letter-spacing: 0.5px; }
.fw-value { font-size: 1rem; font-weight: 800; line-height: 1; letter-spacing: -0.5px; }
.val-green { color: var(--accent-green); } .val-red { color: var(--accent-red); } .val-purple { color: #8e44ad; }
.fw-mini-counts { display: flex; gap: 8px; font-size: 0.75rem; font-weight: 700; color: #172b4d; }
.fw-mini-counts span { background: #f4f5f7; padding: 2px 6px; border-radius: 4px; border: 1px solid #ebecf0; }
.fw-divider { width: 1px; height: 28px; background-color: #ebecf0; }
@media (max-width: 1100px) { .financial-widget { display: none; } }

/* BUSCADOR & FILTROS */
.search-wrapper { position: relative; }
.search-wrapper i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.85rem; pointer-events: none; }
.search-wrapper input { padding-left: 32px; height: 38px; line-height: 38px; padding-top: 0; padding-bottom: 0; border-radius: 20px; border: 1px solid #dfe1e6; width: 200px; transition: 0.2s; font-size: 0.85rem;}
.search-wrapper input:focus { width: 220px; border-color: var(--primary); outline: none; }

.filter-wrapper { position: relative; }
.filter-wrapper i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.8rem; pointer-events: none; }
.filter-select { padding-left: 32px; padding-right: 25px; height: 38px; line-height: 38px; padding-top: 0; padding-bottom: 0; border-radius: 20px; border: 1px solid #dfe1e6; background-color: white; color: var(--text-main); font-size: 0.85rem; cursor: pointer; appearance: none; -webkit-appearance: none; min-width: 170px; }
.filter-select:focus { border-color: var(--primary); outline: none; }

/* LOADERS */
.loader-container { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--text-muted); z-index: 5; background: rgba(255,255,255,0.9); padding: 20px; border-radius: 10px; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(0,82,204,0.1); border-left-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- BOARD (KANBAN) --- */
/* FIX MAC: min-height: 0 permite que el flex-child haga scroll correctamente */
.board-container { 
    flex: 1; 
    display: flex; 
    gap: 12px; 
    padding: 0 0 20px 20px; 
    overflow-x: auto; 
    position: relative; 
    min-height: 0; 
}
.board-container::after { content: ""; display: block; min-width: 30px; height: 100%; flex-shrink: 0; }

.column { flex: 1; min-width: 280px; background: var(--bg-column); border-radius: 8px; display: flex; flex-direction: column; max-height: 100%; border: 1px solid var(--border); }
.column:last-child { margin-right: 20px; }

.column-header { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; border-radius: 8px 8px 0 0; background: rgba(255,255,255,0.5); }
.column-header h3 { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.2px; }
.c-red { border-top: 3px solid var(--accent-red); color: var(--accent-red); }
.c-yellow { border-top: 3px solid var(--accent-yellow); color: #b76e00; }
.c-blue { border-top: 3px solid #0065ff; color: #0065ff; }
.c-purple { border-top: 3px solid #8e44ad; color: #8e44ad; }
.c-green { border-top: 3px solid var(--accent-green); color: var(--accent-green); }
.count { background: rgba(9,30,66,0.08); padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; color: var(--text-main); }
.column-content { flex: 1; padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

/* CARDS */
.card { background: white; padding: 10px 12px; border-radius: 6px; box-shadow: 0 1px 2px rgba(9,30,66,0.25); cursor: grab; transition: 0.2s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(9,30,66,0.1); }
.card h4 { font-size: 0.9rem; margin-bottom: 6px; color: var(--text-main); font-weight: 600; }
.card-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
.card-date { font-size: 0.7rem; color: #97a0af; margin-top: 8px; display: flex; align-items: center; gap: 4px; border-top: 1px solid #f4f5f7; padding-top: 6px; }

/* BADGES */
.card-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.badge { font-size: 0.65rem; padding: 3px 8px; border-radius: 4px; font-weight: 700; display: inline-block; letter-spacing: 0.3px; }
.badge.web { background: #e6fcff; color: #00b8d9; border: 1px solid #00b8d9; } 
.badge.app { background: #e6fcff; color: #00b8d9; border: 1px solid #00b8d9; }
.badge.soft { background: #e6fcff; color: #00b8d9; border: 1px solid #00b8d9; }
.badge.mant { background: #fff0b3; color: #172b4d; border: 1px solid #ffab00; }
.badge.mod-monthly { background: #ebecf0; color: #172b4d; } 
.badge.mod-once { background: #ebecf0; color: #172b4d; }
.badge.st-green { background: var(--accent-green); color: white; border: none; padding: 4px 10px; } 
.badge.st-internal { background: var(--accent-dark); color: white; border: none; padding: 4px 10px; }
.badge.st-orange { background: #fff0b3; color: #172b4d; border: 1px solid #ffab00; } 
.badge.st-red { background: var(--accent-red); color: white; border: none; animation: pulse 2s infinite; }

/* --- MODALES --- */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(9,30,66,0.5); backdrop-filter: blur(2px); display: none; justify-content: center; align-items: center; z-index: 100; }
.overlay.active { display: flex; }

/* FIX MAC: Ajuste de altura máxima del modal */
.modal-box { 
    background: white; 
    padding: 30px; 
    border-radius: 12px; 
    width: 100%; 
    max-width: 550px; 
    box-shadow: var(--shadow-modal); 
    max-height: 85dvh; 
    overflow-y: auto; 
    position: relative; 
}
.modal-large { max-width: 1100px; }
.modal-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; flex-wrap: wrap; gap: 10px; }
.close-modal { font-size: 1.8rem; cursor: pointer; color: var(--text-muted); transition: 0.2s; line-height: 1; }
.close-modal:hover { color: var(--text-main); }

/* BOTÓN CERRAR ABSOLUTO (PARA EVITAR PROBLEMAS DE VISIBILIDAD) */
.close-modal-absolute { position: absolute; top: 15px; right: 15px; z-index: 50; background: #f4f5f7; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--text-muted); cursor: pointer; transition: 0.2s; line-height: 1; }
.close-modal-absolute:hover { background: #ebecf0; color: #172b4d; }

.modal-title { color: var(--text-main); font-size: 1.5rem; margin: 0; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.modal-title i { color: var(--primary); }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 15px; background: #f4f5f7; padding: 8px 15px; border-radius: 8px; margin-right: 20px; }
.month-nav button { background: white; border: 1px solid #dfe1e6; color: var(--text-muted); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.month-nav button:hover { background: var(--primary); color: white; border-color: var(--primary); }
.month-nav span { font-weight: 800; color: var(--text-main); font-size: 0.95rem; min-width: 120px; text-align: center; text-transform: capitalize; }

.login-header { text-align: center; margin-bottom: 25px; }
.login-logo { width: 80px; height: auto; margin: 0 auto 15px; display: block; }
.login-header h2 { font-size: 1.6rem; color: var(--primary); margin-bottom: 8px; font-weight: 800; }
.login-header p { font-size: 0.95rem; color: var(--text-muted); }

/* View Project */
.view-header { margin-bottom: 25px; border-bottom: 1px solid #ebecf0; padding-bottom: 20px; padding-right: 20px; }
.view-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#viewTitle { font-size: 1.8rem; font-weight: 800; color: var(--text-main); margin: 0; line-height: 1.2; }
.view-badges-container { display: flex; gap: 8px; }
.view-client-meta { font-size: 1rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; font-weight: 500; }
.view-client-meta i { color: #97a0af; }
.view-body { font-size: 1rem; color: #172b4d; }
.view-section { margin-bottom: 30px; }
.view-section label { font-size: 0.85rem; font-weight: 700; color: #5e6c84; text-transform: uppercase; margin-bottom: 8px; display: block; letter-spacing: 0.5px; }
#viewDesc { line-height: 1.6; color: #42526e; }
.financial-summary-card { background: #f8f9fa; border: 1px solid #ebecf0; border-radius: 12px; padding: 20px; }
.fs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.fs-item label { font-size: 0.8rem; font-weight: 700; color: #5e6c84; text-transform: uppercase; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.fs-item label i { color: var(--primary); font-size: 1rem; }
.fs-value { font-size: 1.3rem; font-weight: 700; color: var(--text-main); display: block; }
.amount-text { color: var(--accent-green); font-weight: 800; font-size: 1.5rem; }
.billing-warning { background: #ffebe6; color: var(--accent-red); padding: 12px; border-radius: 8px; font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 10px; margin-top: 15px; border: 1px solid #ffbdad; }
.billing-warning i { font-size: 1.1rem; }
.success-msg { color: var(--accent-green); background: #e3fcef; padding: 12px; text-align: center; border-radius: 8px; margin-top: 15px; font-size: 1rem; font-weight: 700; border: 1px solid #a8ebd2; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;}
.btn-payment { background: var(--accent-green); color: white; border: none; width: 100%; padding: 12px; border-radius: 8px; font-size: 1rem; font-weight: 700; cursor: pointer; margin-top: 15px; transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; }
.btn-payment:hover { background: #006644; }
.btn-edit { background: white; color: var(--text-main); border: 2px solid var(--border); width: 100%; padding: 12px; border-radius: 8px; font-size: 1rem; font-weight: 700; cursor: pointer; margin-top: 25px; transition: 0.2s; }
.btn-edit:hover { border-color: var(--text-muted); background: #f4f5f7; }
.btn-anular { background: white; border: 1px solid #de350b; color: #de350b; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; transition: 0.2s; letter-spacing: 0.5px; margin-left: auto; }
.btn-anular:hover { background: #ffebe6; }

/* Dashboard Styles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.kpi-card { background: white; border: 1px solid #dfe1e6; border-radius: 12px; padding: 15px 20px; display: flex; align-items: center; gap: 15px; transition: transform 0.2s; min-height: 100px; box-shadow: var(--shadow-card); }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 5px 20px rgba(0,0,0,0.05); }
.kpi-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; flex-shrink: 0; }
.kpi-data { display: flex; flex-direction: column; width: 100%; }
.kpi-data label { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; margin-bottom: 5px; letter-spacing: 0.5px; }
.kpi-data strong { font-size: 1.6rem; color: var(--text-main); line-height: 1.1; font-weight: 800; }
.kpi-data span { font-size: 0.8rem; opacity: 0.8; margin-top: 3px; font-weight: 500; }
.kpi-blue .kpi-icon { background: var(--primary); } .kpi-blue strong { color: var(--primary); }
.kpi-green .kpi-icon { background: var(--accent-green); } .kpi-green strong { color: var(--accent-green); }
.kpi-red .kpi-icon { background: var(--accent-red); } .kpi-red strong { color: var(--accent-red); }
.kpi-purple .kpi-icon { background: #8e44ad; } .kpi-purple strong { color: #8e44ad; }
.kpi-split { display: flex; width: 100%; justify-content: space-between; align-items: center; }
.kpi-sub { display: flex; flex-direction: column; align-items: flex-start; }
.kpi-sub strong { font-size: 1.5rem; } 
.kpi-sub span { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 25px; margin-bottom: 30px; }
.chart-container { background: white; border: 1px solid #dfe1e6; border-radius: 12px; padding: 25px; position: relative; height: 350px; box-shadow: var(--shadow-card); }
.chart-container h4 { font-size: 1rem; color: var(--text-main); margin-bottom: 20px; text-align: center; font-weight: 700; }
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } .chart-container { height: 300px; } .report-summary-cards { grid-template-columns: 1fr; } }
.report-table-container { border: 1px solid #dfe1e6; border-radius: 12px; overflow: hidden; background: white; box-shadow: var(--shadow-card); }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.report-table th { background: #f4f5f7; color: #5e6c84; font-size: 0.8rem; text-transform: uppercase; padding: 15px 20px; text-align: left; font-weight: 700; letter-spacing: 0.5px; }
.report-row-main { border-bottom: 1px solid #ebecf0; cursor: pointer; transition: 0.1s; }
.report-row-main:hover { background: #f9f9fb; }
.report-row-main td { padding: 12px 20px; color: #172b4d; vertical-align: middle; }
.row-flex { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-title { font-weight: 700; color: #172b4d; min-width: 120px; }

/* FIX FECHAS BONITAS (V4.7.0) */
.meta-timeline { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; }
.date-pill { padding: 2px 8px; border-radius: 4px; display: flex; align-items: center; gap: 5px; font-weight: 600; }
.dp-billed { background-color: #e6fcff; color: #00b8d9; border: 1px solid #b3f5ff; }
.dp-paid { background-color: #e3fcef; color: #006644; border: 1px solid #abf5d1; }
.timeline-arrow { color: #97a0af; font-size: 0.7rem; }

.inv-pill { background: white; padding: 3px 8px; border-radius: 4px; font-family: monospace; font-size: 0.8rem; border: 1px solid #dfe1e6; color: #42526e; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.detail-row { background: #fafbfc; border-bottom: 1px solid #dfe1e6; }
.inner-table { width: 100%; font-size: 0.9rem; }
.inner-table td { padding: 10px 20px; border-bottom: 1px dashed #eee; color: #42526e; vertical-align: middle; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 0; }
.dot-green { background: var(--accent-green); } .dot-orange { background: var(--accent-yellow); } .dot-red { background: var(--accent-red); }

/* --- FORMULARIOS BASE (Proyectos) --- */
.form-group { margin-bottom: 15px; }
.form-row { display: flex; gap: 15px; } .form-row .form-group { flex: 1; }
label { display: block; font-size: 0.85rem; font-weight: 600; color: #44546f; margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 2px solid #dfe1e6; border-radius: 6px; font-size: 0.95rem; transition: 0.2s; color: var(--text-main); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(0,82,204,0.1); }
.checkbox-group { display: flex; align-items: center; gap: 10px; background: #f4f5f7; padding: 8px 12px; border-radius: 6px; border: 2px solid #dfe1e6; } .checkbox-group input { width: auto; box-shadow: none; } .checkbox-group label { margin: 0; cursor: pointer; }
.invoice-input-group { display: flex; gap: 0; margin-top: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-radius: 8px; }
.invoice-input-group select { width: 95px; border-radius: 8px 0 0 8px; border-right: 1px solid #dfe1e6; background: #f4f5f7; font-size: 0.8rem; }
.invoice-input-group input[type="date"] { width: 130px; border-radius: 0; border-right: 1px solid #dfe1e6; border-left: none; font-size: 0.85rem; padding: 8px 5px; color: #42526e; }
.invoice-input-group input[type="text"] { flex: 1; border-radius: 0; border-left: none; }
.invoice-input-group button { border-radius: 0 8px 8px 0; padding: 0 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px; padding-top: 20px; border-top: 1px solid #ebecf0; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 0.95rem; transition: 0.2s; } .btn-primary:hover { background: #0047b3; }
.btn-secondary { background: white; color: #42526e; border: 2px solid #dfe1e6; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 0.95rem; transition: 0.2s; } .btn-secondary:hover { background: #f4f5f7; border-color: #c1c7d0; }
.btn-danger { background: white; color: var(--accent-red); border: 2px solid var(--accent-red); padding: 10px; width: 100%; margin-top: 15px; cursor: pointer; border-radius: 6px; font-weight: 700; transition: 0.2s; } .btn-danger:hover { background: #ffebe6; }
.hidden { display: none !important; }
.app-footer { height: 40px; background: white; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; }

/* --- FORMULARIOS GASTOS Y CAPITAL (V3.9.3 - DISEÑO SEPARADO) --- */
.expense-section { margin-top: 30px; padding-top: 20px; border-top: 2px dashed #dfe1e6; }
.expense-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.expense-header h3 { font-size: 1rem; color: #de350b; display: flex; align-items: center; gap: 8px; }

/* Contenedor Flex con GAP para separar */
.expense-form-row, 
.capital-form-row { 
    display: flex; 
    gap: 10px; /* Clave para que no se vean pegados */
    margin-bottom: 15px; 
    align-items: center; 
}

/* Inputs Independientes (Bordes Completos) */
.expense-form-row input, .capital-form-row input {
    border: 1px solid #dfe1e6;
    border-radius: 8px; /* Bordes redondeados para todos */
    height: 38px;
    padding: 0 10px;
    background: white;
    font-size: 0.85rem;
}

/* Ancho Fecha */
.expense-form-row input[type="date"], 
.capital-form-row input[type="date"] {
    width: 140px;
    flex: none;
    color: #42526e;
}

/* Ancho Descripción */
.expense-form-row input[type="text"], 
.capital-form-row input[type="text"] {
    flex: 1; /* Ocupa el resto */
}

/* Ancho Monto */
.expense-form-row .amount-input, 
.capital-form-row .amount-input {
    width: 120px;
    flex: none;
    text-align: right;
}

/* Botones (+) */
.expense-form-row button, 
.capital-form-row button {
    height: 38px;
    width: 38px;
    border-radius: 8px;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    flex: none;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}

/* Colores específicos */
.expense-form-row button { background: #de350b; }
.expense-form-row button:hover { background: #bf2600; }
.capital-form-row button { background: #0052cc; }
.capital-form-row button:hover { background: #003d85; }

/* Focus State */
.expense-form-row input:focus, .capital-form-row input:focus {
    border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(0,82,204,0.1);
}

/* TABLAS DATOS */
.expenses-table, .data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.expenses-table th, .data-table th { text-align: left; padding: 8px; color: #5e6c84; font-size: 0.75rem; border-bottom: 1px solid #dfe1e6; }
.expenses-table td, .data-table td { padding: 8px; border-bottom: 1px solid #ebecf0; color: #172b4d; }
.expenses-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.exp-date, .dt-date { color: #97a0af; font-size: 0.75rem; width: 60px; }
.exp-amount, .dt-amount-neg { font-weight: 700; color: #de350b; text-align: right; }
.dt-amount-pos { font-weight: 700; color: #0052cc; text-align: right; }
.btn-del-exp, .btn-del-row { background: none; border: none; color: #97a0af; cursor: pointer; font-size: 0.8rem; margin-left: 10px; transition: 0.2s; }
.btn-del-exp:hover, .btn-del-row:hover { color: #de350b; }

/* BALANCE FINAL (Estilo Blanco Clean) */
.final-balance-card { 
    margin-top: 30px; 
    background: white; 
    padding: 30px; 
    border-radius: 16px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: var(--shadow-elevated);
    border: 1px solid #ebecf0;
}
@media (max-width: 900px) { 
    .final-balance-card { flex-direction: column; gap: 20px; } 
    .fb-math { transform: rotate(90deg); margin: 10px 0; } 
}

.fb-item { text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.fb-label { font-size: 0.75rem; font-weight: 700; color: #5e6c84; text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.5px; }
.fb-val { font-size: 1.4rem; font-weight: 800; display: block; line-height: 1.2; }

.fb-yellow { color: #ffab00; } 
.fb-green { color: #00875a; } 
.fb-blue { color: #0052cc; } 
.fb-red { color: #de350b; }   
.fb-final-result { font-size: 1.8rem; color: #172b4d; } /* Color oscuro elegante */

.fb-math { font-size: 1.8rem; color: #c1c7d0; font-weight: 300; padding: 0 10px; margin-top: 18px; }

.btn-link-capital { background: none; border: none; color: #0052cc; font-size: 0.9rem; font-weight: 700; cursor: pointer; margin-top: 20px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-link-capital:hover { text-decoration: underline; }

/* --- BITÁCORA / COMENTARIOS (NUEVO V4.4.0) --- */
.comments-section {
    margin-top: 30px;
    border-top: 1px solid #ebecf0;
    padding-top: 20px;
}
.comments-section label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #172b4d;
    text-transform: uppercase;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.comments-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px;
}
.comment-item {
    background: #f4f5f7;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid #dfe1e6;
    position: relative;
    transition: 0.2s;
}
.comment-item:hover { background: #ebecf0; }
.comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #dfe1e6;
}
.comment-date {
    font-size: 0.7rem;
    color: #5e6c84;
    font-weight: 600;
    display: flex; align-items: center; gap: 5px;
}
.comment-actions {
    display: flex;
    gap: 8px;
}
.btn-mini {
    font-size: 0.75rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: 0.2s;
}
.btn-edit-comment { color: #0052cc; }
.btn-edit-comment:hover { transform: scale(1.1); }
.btn-del-comment { color: #97a0af; }
.btn-del-comment:hover { color: #de350b; transform: scale(1.1); }
.comment-text {
    font-size: 0.9rem;
    color: #172b4d;
    white-space: pre-wrap; /* Respeta saltos de línea */
    line-height: 1.4;
}
.comment-input-box {
    display: flex;
    gap: 10px;
    background: white;
    border-top: 1px solid #ebecf0;
    padding-top: 15px;
}
.comment-input-box textarea {
    flex: 1;
    height: 50px;
    resize: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 0.9rem;
    border: 2px solid #dfe1e6;
    font-family: 'Inter', sans-serif;
}
.comment-input-box textarea:focus {
    border-color: var(--primary);
    outline: none;
}
.comment-input-box button {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1.1rem;
}
.btn-send-default { background: var(--primary); color: white; }
.btn-send-default:hover { background: #003d85; }
.btn-send-edit { background: var(--accent-yellow); color: #172b4d; } 
.btn-send-edit:hover { background: #ff9900; }