/* CatNote — finance.css (tramo 5/11 de styles.css). No reordenar los <link>. */
/* ===== FINANCE ===== */
.finance-label {
    margin-top: 10px;
}

.finance-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
    padding-top: 100px;
    padding-left: 60px;
    padding-right: 16px;
}

.finance-card {
    background: var(--bg-surface);
    border-radius: 16px;
    padding: 18px;
    min-width: 0;
}

.finance-new-movement-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: none;
    background: var(--accent);
    color: var(--accent-on);
    border-radius: 20px;
    height: 36px;
    padding: 2px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    /* El botón va en su propia fila dentro de .finance-movements, que es flex
       en COLUMNA: sin align-self se estiraría a todo lo ancho, porque el
       contenedor trae align-items: stretch (en el header, que era flex en
       fila, no hacía falta). El margen de abajo lo separa de los filtros,
       con el mismo ritmo de 22px que usa la columna (2026-09-14). */
    align-self: flex-start;
    margin-bottom: 22px;
    transition: opacity 0.15s;
}

.finance-new-movement-btn:hover {
    opacity: 0.9;
}

.finance-new-movement-btn svg {
    flex-shrink: 0;
}

/* Card Resumen: el bloque oscuro se retiró — la referencia de diseño
   (Estructura finanzas 120926) no usa tarjetas, todo va sobre el fondo. */

.budget-bar {
    width: 100%;
    height: 20px;
    border-radius: 10px;
    background: var(--bg-surface);
    overflow: hidden;
}

.budget-progress {
    display: block;
    width: 0%;
    height: 100%;
    background: #009B3A;
    border-radius: 18px;
    transition: width 0.35s ease, background 0.5s ease;
}

.budget-progress.warning {
    background: #f97316;
}

.budget-progress.danger {
    background: #ef4444;
}

/* ===== PRESUPUESTO: barra de gasto =====
   El monto y el umbral se configuran en Configuración › Preferencias; la
   línea del umbral vive solo en la barra de esa pantalla, junto al campo
   del porcentaje. En Finanzas la barra es de solo lectura y muestra lo
   gastado del mes, sin línea de umbral (Eder, 2026-11-10). Las reglas
   .budget-amount* del editor inline desaparecieron con él. */
.budget-bar-wrap {
    position: relative;
    width: 100%;
    margin: 14px 0 6px;
}

/* La línea "Queda X de Y" bajo la barra es SOLO móvil (Eder, 2026-09-27):
   en web la zona vive con "X por mes" y "Gastado…/Quedan…". Se pinta en el
   bloque móvil de Finanzas. */
.budget-line {
    display: none;
}

/* La línea del umbral es solo un indicador (Configuración › Preferencias):
   se ve en su % pero no se agarra. */
.budget-alert-line.is-static {
    cursor: default;
}

/* Línea vertical de umbral de alerta, sobresale un poco de la barra */
.budget-alert-line {
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: 80%;
    width: 3px;
    margin-left: -1.5px;
    padding: 0;
    border: none;
    background: var(--text);
    border-radius: 2px;
    cursor: ew-resize;
    touch-action: none;
    z-index: 3;
}

.budget-alert-line::before {
    /* área de agarre ampliada para mouse/touch */
    content: '';
    position: absolute;
    inset: -8px -9px;
}

.budget-alert-label {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 9px;
    padding: 2px 7px;
    background: var(--text);
    color: var(--bg-app);
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.budget-alert-line:hover .budget-alert-label,
.budget-alert-line.dragging .budget-alert-label {
    opacity: 1;
}

/* Selector de tema (Configuración › Estilo). Vista previa como en
   "referencia configuracion.jpg" (Eder, 2026-11-09): cada opción es una mini
   ventana con un esqueleto de la ESTRUCTURA DE CATNOTE (barra lateral negra
   con logo y menú; al lado, título y filas de tareas con su círculo), pintada
   con los colores de su tema. La elegida se marca con el aro azul y el check
   de la referencia. */
.theme-picker {
    display: flex;
    gap: 12px;
    margin-top: 0;
    flex-wrap: wrap;
}

.theme-swatch {
    flex: 1 1 0;
    min-width: 0;
    background: transparent;
    border: 0;
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    transition: background 0.15s;
}

/* La mini ventana. El esqueleto NO cambia con el tema activo de la app: cada
   preview lleva sus propios colores, los del tema que representa. */
.theme-preview {
    position: relative;
    display: flex;
    width: 100%;
    aspect-ratio: 16 / 10;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--tp-bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

/* Claro: sidebar negra (como el panel de Catnote) y contenido blanco. */
.theme-swatch[data-theme="light"] .theme-preview {
    --tp-bg: #ffffff;
    --tp-side: #000000;
    --tp-side-item: rgba(255, 255, 255, 0.42);
    --tp-text: #111111;
    --tp-muted: #c9c9c9;
    --tp-card: #f4f4f4;
    --tp-line: #dcdcdc;
}

/* Oscuro: los tokens reales del tema (bg-app negro, panel #171819). */
.theme-swatch[data-theme="dark"] .theme-preview {
    --tp-bg: #000000;
    --tp-side: #171819;
    --tp-side-item: rgba(255, 255, 255, 0.24);
    --tp-text: #f3f4f6;
    --tp-muted: #3a3f46;
    --tp-card: #1c1f24;
    --tp-line: #2f343b;
}

.theme-swatch:hover .theme-preview {
    border-color: var(--text-muted);
}

/* Elegida: aro azul, igual que la tarjeta seleccionada de la referencia. */
.theme-swatch.active .theme-preview,
.theme-swatch:focus-visible .theme-preview {
    border-color: transparent;
    box-shadow: 0 0 0 2px var(--accent);
}

/* El check azul de la referencia, abajo a la derecha de la mini ventana. */
.theme-preview::after {
    content: "✓";
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.15s, transform 0.15s;
}

.theme-swatch.active .theme-preview::after {
    opacity: 1;
    transform: scale(1);
}

/* Sidebar del esqueleto: el panel oscuro de Catnote. */
.theme-preview-side {
    flex: 0 0 26%;
    display: flex;
    flex-direction: column;
    gap: 7%;
    padding: 9% 8%;
    box-sizing: border-box;
    background: var(--tp-side);
}

/* Sin logo en el sidebar simulado (Eder, 2026-11-11): el cuadro blanco se
   estiraba en un óvalo vertical dentro de la tarjeta. Solo quedan las líneas
   de menú. */
.theme-preview-item {
    width: 82%;
    height: 3px;
    border-radius: 2px;
    background: var(--tp-side-item);
    flex: none;
}

.theme-preview-item.is-short {
    width: 55%;
}

/* Contenido del esqueleto: título, subtítulo y filas de tareas. */
.theme-preview-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6%;
    padding: 9% 8% 7%;
    box-sizing: border-box;
    background: var(--tp-bg);
}

.theme-preview-title {
    width: 48%;
    height: 7px;
    border-radius: 3px;
    background: var(--tp-text);
    flex: none;
}

.theme-preview-sub {
    width: 30%;
    height: 4px;
    margin-bottom: 2%;
    border-radius: 2px;
    background: var(--tp-muted);
    flex: none;
}

/* Cada fila imita una tarea de la Ruta: círculo + línea de texto. */
.theme-preview-card {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
    gap: 6%;
    padding: 0 8%;
    box-sizing: border-box;
    border-radius: 6px;
    background: var(--tp-card);
}

.theme-preview-check {
    flex: none;
    width: 6px;
    height: 6px;
    box-sizing: border-box;
    border: 1.2px solid var(--tp-muted);
    border-radius: 50%;
}

.theme-preview-line {
    flex: 1 1 auto;
    height: 3px;
    border-radius: 2px;
    background: var(--tp-line);
}

.theme-preview-line.is-short {
    flex: 0 0 55%;
}

.theme-swatch-label {
    padding-left: 2px;
    font-size: 12.5px;
    color: var(--text);
    letter-spacing: 0.01em;
    text-align: left;
}

.theme-swatch.active .theme-swatch-label {
    color: var(--text);
    font-weight: 600;
}

/* Slider de alerta en config modal */
.budget-meta {
    margin-top: 7px;
    display: flex;
    justify-content: space-between;
    color: var(--text);
    font-size: 15px;
    font-weight: 400;
}

.payments-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    margin-top: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.payments-list {
    gap: 12px;
}

.payment-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0px 16px;
    background: var(--bg-surface);
    border-radius: 18px;
    min-height: 36px;
    transition: opacity 0.33s;
}

.payment-row.paid {
    opacity: 0.4;
}

.payment-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    opacity: 0.25;
    transition: opacity 0.2s;
}

.payment-row:hover .payment-toggle,
.payment-row.paid .payment-toggle {
    opacity: 1;
}

.payment-name {
    flex: 1;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.payment-row.paid .payment-name {
    text-decoration: line-through;
    color: #aaa;
}

.payment-row.overdue .payment-name {
    color: #fb0000;
}

.payment-amount {
    font-size: 14px;
    font-weight: bold;
    color: var(--text);
    flex-shrink: 0;
}

.payment-overdue-badge {
    font-size: 12px;
    font-weight: 500;
    color: #ffffff;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff3b30;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.finance-movements {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.finance-movements-title {
    font-size: 35px;
    font-weight: 500;
    line-height: 1;
}

/* Header row with title + view toggle */
.finance-movements-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Table / Chart toggle switch */
.movements-view-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface-hover, rgba(0,0,0,0.05));
    border-radius: 10px;
    padding: 3px;
    gap: 0;
}

.mv-toggle-btn {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted, #999);
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.25s;
    padding: 0;
}

.mv-toggle-btn.active {
    color: var(--text, #333);
}

.mv-toggle-slider {
    position: absolute;
    z-index: 0;
    top: 3px;
    left: 3px;
    width: 32px;
    height: 28px;
    background: var(--bg-surface, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.movements-view-toggle.chart .mv-toggle-slider {
    transform: translateX(32px);
}

/* Movements chart */
.movements-chart-wrap {
    margin-top: 12px;
}

.movements-chart-wrap.hidden {
    display: none;
}

.chart-block {
    position: relative;
}

.chart-block-line {
    height: 280px;
}

.chart-block-pie {
    height: 250px;
}

/* Mensaje de "sin datos" centrado dentro del espacio del gráfico, no debajo */
.chart-block .section-empty {
    position: absolute;
    inset: 0;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.chart-block-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Pastel al lado del gráfico de gastos en pantallas amplias; apilado en móvil */
.charts-grid {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.charts-grid-left {
    flex: 1 1 60%;
    min-width: 0;
}

.charts-grid-right {
    flex: 1 1 40%;
    min-width: 0;
}

.chart-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.chart-view-toggle {
    display: inline-flex;
    background: var(--border);
    border-radius: 999px;
    padding: 2px;
}

.cv-toggle-btn {
    border: none;
    background: none;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.cv-toggle-btn.active {
    background: var(--bg-app);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

@media (max-width: 640px) {
    .charts-grid {
        flex-direction: column;
        gap: 0;
    }
}

.chips-strip-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.chips-scroll-btn {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
}

.chips-scroll-btn:hover {
    background: var(--bg-surface-hover);
}

/* Contenedor de las píldoras de Finanzas: idéntico al de Tareas (.area-chips).
   Eder, 2026-10-02: replica exacta de las píldoras de categorías de Tareas. */
.finance-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-behavior: smooth;
    min-width: 0;
    flex: 1;
}

.finance-filters::-webkit-scrollbar { display: none; }

.chip {
    border: none;
    background: var(--bg-surface);
    color: var(--text);
    border-radius: 20px;
    height: 44px;
    padding: 2px 26px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.chip.active {
    background: var(--text);
    color: var(--bg-app);
}

/* Chip siendo arrastrado para reordenar la franja de áreas. */
.chip-dragging {
    position: relative;
    z-index: 5;
    opacity: 0.92;
    background: var(--bg-surface-hover);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
    will-change: transform;
}

.chip-add {
    width: 42px;
    padding: 0;
    justify-content: center;
    color: #000000;
    background: #f5f5f5;
    border: 0px dashed var(--border);
    transition: color 0.15s, border-color 0.15s;
}

.chip-add:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.chip-add.editing {
    width: auto;
    padding: 0 22px;
    background: var(--bg-surface);
    border: none;
    color: var(--text);
}

.movements-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* UNA sola vista por movimiento (Eder, 2026-10-02): izquierda el nombre y,
   debajo, categoría + fecha ("Ago 15"); derecha el monto. La fecha y el monto
   ya no son columnas propias: viven dentro de la primera celda. Quedan 3
   columnas —contenido | ×— más la de monto. */
.movements-table th:nth-child(1),
.movements-table td:nth-child(1) {
    width: 100%;
}

.movements-table th:nth-child(2),
.movements-table td:nth-child(2) {
    width: 120px;
    text-align: right;
    white-space: nowrap;
}

.movements-table th:nth-child(3),
.movements-table td:nth-child(3) {
    width: 44px;
    text-align: center;
}

/* La cabecera de columnas ya no se muestra: la píldora del movimiento se
   explica sola (Eder, 2026-10-02). La fila sigue en el DOM porque
   initMovementsSort engancha el orden por fecha en sus th[data-sort]. */
.movements-table thead {
    display: none;
}

.movements-table-wrap {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0px;
}

.movements-table th,
.movements-table td {
    text-align: left;
    padding: 6px 10px;
}

.movements-table th {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-surface);
}

.movements-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.movements-table th[data-sort]::after {
    content: '↕';
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.35;
}

.movements-table th[data-sort].sort-asc::after {
    content: '▲';
    opacity: 1;
}

.movements-table th[data-sort].sort-desc::after {
    content: '▼';
    opacity: 1;
}

.movements-table td {
    color: var(--text);
    font-size: 13px;
    font-weight: 400;
    border-bottom: none;
}

.movements-table .pos {
    color: #009B3A;
    font-weight: 400;
}

.movements-table .neg {
    color: #FF3B30;
    font-weight: 400;
}

/* El monto de la vista única lleva el color encima (rojo gasto, verde
   ingreso) y el peso de las cifras grandes. */
.movements-table td.mv-amount-cell.pos,
.movements-table .mv-amount-cell.pos {
    color: #009B3A;
    font-weight: 600;
}

.movements-table td.mv-amount-cell.neg,
.movements-table .mv-amount-cell.neg {
    color: #FF3B30;
    font-weight: 600;
}

/* ===== Movimientos en WEB: una CÁPSULA por movimiento =====
   Eder, 2026-09-27: "replicar el modo de píldora de cada movimiento en
   finanzas que hay en móvil ahora en web". Cada fila pasa a ser la misma
   cápsula gris que en móvil (--bg-surface, radio 18px, aire entre ellas).
   Diferencia con móvil: aquí se conservan TODAS las columnas —categoría,
   fecha, monto y la × de borrar— y la cabecera (que ordena al tocarla), que
   van DENTRO de la cápsula. Solo web: el bloque móvil lo maquilla aparte. */
@media (min-width: 641px) {
    .movements-table {
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .movements-table tbody tr {
        --movement-pill-bg: var(--bg-surface);
        background: var(--movement-pill-bg);
        border-radius: 18px;
    }

    .movements-table td {
        border-bottom: none;
        padding: 12px 14px;
        /* El fondo va en las CELDAS: Chromium pinta el redondeado de un <tr>
           solo por la derecha (la izquierda queda en punta). Con las celdas
           contiguas del mismo color la cápsula se ve entera por las cuatro
           esquinas (Eder, 2026-10-27). */
        background: var(--movement-pill-bg, transparent);
        border-radius: 0;
    }

    .movements-table td:first-child {
        border-top-left-radius: 18px;
        border-bottom-left-radius: 18px;
    }

    .movements-table td:last-child {
        border-top-right-radius: 18px;
        border-bottom-right-radius: 18px;
    }

    /* La cabecera NO es cápsula: es la línea de referencia que ordena. */
    .movements-table thead tr {
        background: none;
        border-radius: 0;
    }

    .movements-table thead th {
        padding: 6px 14px;
    }

    /* Ni el estado vacío ni el pie ("cargar mes anterior") son cápsulas. */
    .movements-table tbody tr:has(td.section-empty),
    .movements-table tfoot tr {
        background: none;
        border-radius: 0;
    }

    .movements-table tbody tr:has(td.section-empty) td,
    .movements-table tfoot td {
        background: transparent;
        border-radius: 0;
    }

    /* El "sin hover" de estas cápsulas NO se toca aquí: esas reglas viven más
       abajo en el archivo, junto a las suyas (OJO de cascada — una regla puesta
       aquí arriba perdía contra las originales de más abajo). */
}

.movement-delete-cell {
    padding: 4px 0 !important;
}

.movement-delete-btn {
    background: none;
    border: none;
    color: #bbb;
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

/* Sin cambio de color al hover: las píldoras de movimientos no reaccionan
   (Eder, 2026-09-27). */
.movement-delete-btn:hover {
    color: #bbb;
}

/* ===== MOVEMENT NEW ROW ===== */
.movement-new-tbody {
    position: sticky;
    top: 38px;
    z-index: 1;
    background: var(--bg-surface);
}

.movement-new-row td {
    padding: 8px 4px;
    border-bottom: 1px solid #ececec;
}

/* ===== PREV-MONTH SECTION ===== */
#prev-month-tfoot td,
.prev-month-section-header td {
    padding: 0;
}

.prev-month-load-btn,
.prev-month-section-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-muted, #888);
    font-size: 12px;
    padding: 12px 9px;
    cursor: pointer;
    text-align: center;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: left;
    gap: 6px;
    font-weight: 600;
}

.prev-month-load-btn:hover,
.prev-month-section-btn:hover {

}

.prev-month-section-rows td {
    opacity: 0.75;
}

.prev-month-month-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #888);
    padding: 6px 4px 2px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-top: 1px solid var(--border, #e5e5e5);
}

.movement-new-input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    padding: 2px 8px;
}

/* ===== SIN contorno azul al tocar la caja de "nuevo movimiento" =====
   Eder, 2026-09-27: "al abrir nuevo movimiento en general, web y movil, al dar
   clic en la caja para llenar espacios se aparece un contorno azul que no me
   gusta, no quiero que aparezca". Se apaga el anillo de foco de TODO el renglón
   de alta —concepto, monto, el botón de categoría, la píldora de fecha, el +
   —, en web y en móvil (era el :focus del navegador, que .movement-new-input
   ya se quitaba pero los demás no). */
.movement-new-row :focus,
.movement-new-row :focus-visible,
#movement-new-tbody :focus,
#movement-new-tbody :focus-visible,
.movement-edit-input:focus,
.movement-edit-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.movement-new-input::placeholder {
    color: var(--text-muted);
}

.movement-new-amount {
    text-align: left;
    transition: color 0.15s ease;
}

.movement-new-amount.neg {
    color: #FF3B30;
}

.movement-new-amount.pos {
    color: #009B3A;
}

.movement-new-cat-wrap {
    position: relative;
}

.movement-new-cat-btn {
    width: 100%;
    background: transparent;
    border: none;
    padding: 2px 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-align: left;
}

.movement-new-cat-btn svg {
    color: #888;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.movement-new-cat-btn.open svg {
    transform: rotate(180deg);
}

.movement-new-cat-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
    font-size: 14px;
}

.movement-new-cat-label.placeholder {
    color: var(--text-muted);
}

.movement-new-cat-menu {
    position: fixed;
    z-index: 9000;
    min-width: 100px;
    max-height: 161px;
    overflow-y: auto;
    background: var(--bg-app);
    padding: 8px 0;
    padding-right: 28px;
}

.movement-new-cat-option {
    display: block;
    width: 100%;
    padding: 4px 10px;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.movement-new-cat-option:hover {
    background: var(--bg-surface);
}

.movement-new-cat-empty {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.movement-new-cat-sep {

}

.movement-new-cat-new {
    font-weight: 600;
    color: var(--accent, #3b82f6);
}

.movement-new-cat-input {
    display: block;
    width: calc(100% - 16px);
    margin: 4px 8px;
    padding: 6px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--accent, #3b82f6);
    border-radius: 6px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}

.movement-new-date-pill,
.movement-date-pill {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    padding: 4px 10px;
}

/* La píldora de FECHA de los movimientos se centra (Eder, 2026-09-27: "la
   píldora de la fecha en movimientos, la noto con mucho espacio en blanco a la
   derecha, centra la fecha e igual espacio en los lados"): el texto al medio y
   el aire repartido parejo a los lados. OJO: selector COMPUESTO —
   .note-meta-item vive más abajo en el archivo y con uno solo ganaba su
   justify-content: left y su padding asimétrico. */
.note-meta-item.movement-date-pill,
.note-meta-item.movement-new-date-pill {
    justify-content: center;
    /* Más angosta, un poco (Eder, 2026-09-27: "mas angosta, un poco esa
       cajita de la fecha"): de 12px a 6px por lado. */
    padding-left: 6px;
    padding-right: 6px;
}

.movement-new-add-btn {
    background: #000;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, opacity 0.15s ease;
    padding: 0;
}

.movement-new-add-btn:hover {
    background: #333;
}

.movement-new-add-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== INLINE EDIT EN MOVIMIENTOS GUARDADOS ===== */
.movement-edit-input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    padding: 0;
}

.movements-table tbody#movements-tbody td {
    cursor: text;
}

.movements-table tbody#movements-tbody td.movement-delete-cell {
    cursor: default;
}

.movement-cell-editable {
    transition: background 0.12s ease;
    position: relative;
}

/* SIN realce al hover (Eder, 2026-09-27: "hay mucho hover ... manejemos nada
   de reacción en hover en esas píldoras de movimientos en WEB"). */
.movement-cell-editable:hover {
    /* Sin realce, pero conservando el fondo de la cápsula que ahora pinta
       cada celda (antes lo pintaba la fila). */
    background: var(--movement-pill-bg, transparent);
}

/* ===== TRANSACTION ITEM (Eder, 2026-10-02) =====
   Cada movimiento es UNA píldora reutilizable con dos bloques:
   - Izquierda (flex-1): título + subtítulo "Categoría · Fecha".
   - Derecha: el monto en la moneda elegida — rojo si es gasto, verde si es
     ingreso.
   SIN icono por ahora (Eder, 2026-10-02: "vamos a quitar lo de los iconos
   porque no se agregan bien"). */
.movements-table td:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    text-align: left;
}

.mv-main {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Subtítulo: "Categoría · Fecha". */
.mv-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-subtle);
}

.mv-sep {
    flex: 0 0 auto;
    opacity: 0.7;
}

/* Categoría y fecha NO se editan como texto: abren desplegables
   (Eder, 2026-10-03). */
.mv-cat {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.mv-date {
    flex: 0 0 auto;
    cursor: pointer;
    padding: 0;
    background: none;
    min-height: 0;
    border-radius: 4px;
}

.mv-cat:hover,
.mv-date:hover {
    opacity: 0.8;
}

/* Monto: alineado a la derecha, en negrita, con el color pos/neg. */
.movements-table td.mv-amount-cell {
    text-align: right;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
}

/* ===== FINANZAS — layout de la referencia "Estructura finanzas 120926" =====
   Todo va prefijado con #finance-screen a propósito: .finance-row,
   .finance-value, .arrow-*, .section-sub y .section-title los comparte el
   Overview (que renderiza la misma fila resumen en #overview-finance-rows) y
   ahí NO debe cambiar nada. Tampoco hay tarjetas: la referencia dibuja todo
   sobre el fondo. */
#finance-screen {
    /* Fondo real de la tabla: los th son sticky y las filas de entrada y de
       "mes anterior" van pegadas; todas necesitan tapar lo que pasa debajo.
       En escritorio el fondo de la pantalla es --bg-app (en móvil, --m-bg). */
    --fin-table-bg: var(--bg-app);
}

/* --- Saldo (izquierda) y presupuesto (derecha): van arriba, uno al lado del
   otro. Antes eran un solo bloque apilado; se separaron el 2026-09-13 a
   pedido de Eder, que los quiere en dos columnas. --- */
#finance-screen .finance-balance-col,
#finance-screen .finance-budget-col {
    min-width: 0;
}

#finance-screen .finance-amount {
    font-size: 36px;
    font-weight: 700;
}

#finance-screen .finance-net-row {
    gap: 10px;
}

#finance-screen .finance-hide-btn {
    opacity: 0.5;
}

#finance-screen .section-sub {
    font-size: 18px;
    color: #AEAEB2;
}

#finance-screen .section-title {
    font-size: 36px;
    margin-bottom: 14px;
    margin-top: 50px;
}

/* El título del presupuesto abre su propia columna (se separó del saldo el
   2026-09-13), así que ese margen de 50px —que servía para despegarlo del
   bloque de arriba— aquí solo lo dejaría más bajo que el saldo. Mismo criterio
   que .finance-movements-title, que ya lo anula. */
#finance-screen .finance-budget-col > .section-title:first-child {
    margin-top: 0px;
}

/* Píldora del resumen del mes (la genera financeRowsHtml): flechas de
   ingreso/gasto a la izquierda y el selector de mes al extremo derecho. */
#finance-screen .finance-row {
    background: var(--pill-bg);
    border-radius: 18px;
    min-height: 44px;
    padding: 0 22px;
    font-size: 13px;
    font-weight: 400;
    gap: 10px;
}

#finance-screen .finance-summary-row {
    gap: 10px;
}

/* Los colores de las flechas de Eder en ESTA pantalla: los de su referencia
   (#009B3A verde y #E90909 rojo), igual que antes. Van por `color` porque sus
   paths llevan fill="currentColor" (así el mismo dibujo sirve para el Overview,
   que conserva #009B3A/#ef4444). Si algún día se cambia el svg por uno con
   fill propio, esta regla deja de pintarlo: hay que mirar el svg también. */
#finance-screen .arrow-up {
    color: #009B3A;
}

#finance-screen .arrow-down {
    color: #E90909;
}

/* Adecuación a OSCURO (2026-09-13, al entrar los dibujos de Eder a los cuatro
   temas). El rojo de su referencia (#E90909) es un rojo muy saturado y sobre la
   píldora oscura (#1c1f24) se queda en 3.55:1 de contraste: se ve, pero apagado,
   mientras el verde está en 7.99:1 y el rojo del Overview en 4.4:1. En Oscuro el
   egreso pasa al #FF3B30 que la tabla de movimientos ya usa para los gastos, que
   sube a 4.67:1 y además empareja la flecha con la columna de abajo.
   El VERDE no se toca: #009B3A conserva buen contraste (4.5:1) sobre oscuro.
   La referencia de Finanzas define solo el tema claro (decisión de Eder), así
   que estos son los mismos números adaptados, no unos nuevos. */
[data-theme="dark"] #finance-screen .arrow-down {
    color: #FF3B30;
}

#finance-screen .finance-value {
    font-size: 13px;
    min-width: 0;
    font-weight: 400;
}

#finance-screen .finance-period-btn {
    color: var(--text);
    font-weight: 500;
    gap: 6px;
}

#finance-screen .finance-period-label {
    font-size: 20px;
}

/* --- Presupuesto: caption editable + barra + "Quedan" --- */
#finance-screen #finance-budget-caption {
    margin-bottom: 18px;
}

#finance-screen .budget-bar-wrap {
    margin: 0 0 12px;
}

#finance-screen .budget-bar {
    height: 44px;
    border-radius: 18px;
    background: var(--pill-bg);
}

#finance-screen .budget-progress {
    border-radius: 18px;
}

/* El "Gastado:" no está en la referencia: se oculta aquí, pero el span sigue
   existiendo y finance.js lo sigue escribiendo (no romper ese contrato). */
#finance-screen #finance-budget-spent {
    display: none;
}

#finance-screen .budget-meta {
    justify-content: flex-end;
    margin-top: 0;
    font-size: 13px;
}

#finance-screen #finance-budget-remaining {
    color: var(--text);
}

/* --- Columna derecha: movimientos --- */
#finance-screen .finance-movements-header {
    justify-content: space-between;
    margin-bottom: 10px;
}

#finance-screen .finance-movements-title {
    font-size: 36px;
    font-weight: 700;
    margin-top: 0px;
}

#finance-screen .finance-new-movement-btn {
    height: 44px;
    border-radius: 22px;
    padding: 0 24px;
    font-size: 13px;
    font-weight: 500;
}

/* Píldoras de categorías de Finanzas: MISMO estilo que las de Tareas
   (Eder, 2026-10-02: "las píldoras de categorías en web de tareas funcionan
   como quiero, replica en las de finanzas"). Antes #finance-screen .chip
   imponía su propio fondo/padding; ahora manda la regla base .chip. El chip
   activo lo pinta .chip.active igual que en Tareas. */

/* --- Tabla: sin bordes, tipografía de la referencia --- */
#finance-screen .movements-table th {
    font-size: 19px;
    font-weight: 700;
    padding: 10px 12px;
    background: var(--fin-table-bg);
}

#finance-screen .movements-table td {
    font-size: 13px;
    font-weight: 400;
    padding: 6px 10px;
}

#finance-screen .movement-new-tbody {
    background: var(--fin-table-bg);
}

/* La 5ª columna (eliminar) se queda SIEMPRE visible y activa (Eder,
   2026-09-27: "no se activa a menos que antes pases el mouse por el monto u
   otro lado, no deberia ser asi, debe estar siempre lista si pasas el
   mouse"). Antes se ocultaba y solo aparecía al pasar el cursor por la fila —
   el mismo "hover" que Eder pidió quitar de las cápsulas. OJO: se toca AQUÍ y
   no en el bloque de las cápsulas de web: una regla que está más arriba en el
   archivo pierde contra esta por el orden de cascada. NO se usa display:none —
   el colspan de la fila vacía y de #prev-month-tfoot, y el
   table-layout:fixed, dependen de que la columna siga existiendo.
   (Eder, 2026-10-02: la × es la 3ª columna de la vista única, no la 5ª.) */
#finance-screen #movements-tbody td:nth-child(3) {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: none), (pointer: coarse) {
    #finance-screen #movements-tbody td:nth-child(3) {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Saldo y presupuesto arriba, uno al lado del otro (saldo primero), y
   movimientos abajo cruzando las dos columnas. Solo en escritorio: en móvil
   manda el .finance-main apilado de la media query de ≤640px, que ya deja los
   tres en este mismo orden. */
@media (min-width: 641px) {
    #finance-screen .finance-main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 48px;
        row-gap: 28px;
        /* La fila de arriba toma su alto natural; movimientos se queda con el
           resto, que es el que necesita para su scroll interno. */
        grid-template-rows: auto minmax(0, 1fr);
    }

    /* Los movimientos cruzan las dos columnas. */
    #finance-screen .finance-movements {
        grid-column: 1 / -1;
    }
}

