/* ================================================================
 * Calma — Diseño editorial dual (Limited + Light)
 * Cambia el tema con [data-theme="light"] en <html>.
 * ================================================================ */

/* ---- Tokens de MOVIMIENTO (independientes del tema) ----
   Curvas con carácter; las de CSS por defecto son flojas. (emil-design-eng) */
:root {
    --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);    /* entradas/salidas: arranca rápido = se siente responsivo */
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);   /* movimiento/morph en pantalla */
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);    /* drawers / hojas tipo iOS */
    --dur-fast:    140ms;   /* feedback de pulsar */
    --dur:         200ms;   /* dropdowns, popovers, selects */
    --dur-modal:   280ms;   /* modales, drawers */
}

:root,
:root[data-theme="dark"] {
    --moss:          #1a2614;
    --moss-deep:     #0f1a0b;
    --forest:        #2b3d22;
    --forest-light:  #3a5130;
    --gold:          #b8976a;
    --gold-bright:   #d4b084;
    --cream:         #f5f1e8;
    --cream-dim:     #c8c3b5;
    --border:        rgba(184, 151, 106, 0.15);
    --border-hover:  rgba(184, 151, 106, 0.4);
    --success:       #7ea86a;
    --danger:        #c77766;
    --warning:       #d4b084;
    --bubble-grad-from: var(--forest);
    --bubble-grad-to:   var(--moss);
    --bg-radial-1: rgba(184, 151, 106, 0.06);
    --bg-radial-2: rgba(43, 61, 34, 0.4);
    --bg-dot: rgba(184, 151, 106, 0.02);
}

/* Fallback de tema claro garantizado por CSS: si el script pre-paint
   no corriera, sin atributo data-theme la página pintaría OSCURO (paleta
   por defecto del :root de arriba). Forzamos paleta clara cuando no hay
   data-theme o es "light", para eliminar el riesgo de flash oscuro. */
:root:not([data-theme]),
html:not([data-theme]),
:root[data-theme="light"] {
    --moss:          #ffffff;            /* paneles */
    --moss-deep:     #f8fafc;            /* fondo principal */
    --forest:        #f1f5f9;            /* burbuja claro */
    --forest-light:  #e2e8f0;
    --gold:          #4f46e5;            /* indigo como acento */
    --gold-bright:   #6366f1;
    --cream:         #0f172a;            /* texto principal */
    --cream-dim:     #64748b;            /* texto secundario */
    --border:        rgba(15, 23, 42, 0.08);
    --border-hover:  rgba(79, 70, 229, 0.3);
    --success:       #10b981;
    --danger:        #ef4444;
    --warning:       #f59e0b;
    --bubble-grad-from: #ffffff;
    --bubble-grad-to:   #f8fafc;
    --bg-radial-1: rgba(79, 70, 229, 0.04);
    --bg-radial-2: rgba(241, 245, 249, 0.6);
    --bg-dot: rgba(15, 23, 42, 0.025);
}

/* Suelo de fondo claro garantizado por CSS (anti-flash oscuro): aunque el
   JS pre-paint fallara, sin data-theme o en "light" el fondo base es claro. */
html:not([data-theme]),
html[data-theme="light"] {
    background: #f8fafc;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    background: var(--moss-deep);
    color: var(--cream);
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at top right, var(--bg-radial-1), transparent 50%),
        radial-gradient(ellipse at bottom left, var(--bg-radial-2), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle at 1px 1px, var(--bg-dot) 1px, transparent 0);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: 0;
}

.app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

a { color: inherit; text-decoration: none; }
button { background: none; border: none; color: inherit; cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; color: inherit; }

/* ============ iOS / MOBILE NATIVE FEEL ============ */
/* Evita que iOS reajuste tamaños de texto al rotar */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
/* Quita el flash gris azulado al tocar elementos en iOS */
* {
    -webkit-tap-highlight-color: transparent;
}
/* Controles interactivos: tap inmediato (sin delay de 300ms) */
a, button, label, select, summary,
[role="button"], [data-pane-target], .btn, .tfnav-tab {
    touch-action: manipulation;
}
/* Permite seleccionar texto donde tiene sentido, no en la UI */
input, textarea, [contenteditable] {
    -webkit-user-select: text;
    user-select: text;
}
/* Scroll con inercia en iOS (sin bloquear el scroll de la página) */
.app {
    -webkit-overflow-scrolling: touch;
}
/* Soporte de safe-area (notch / home indicator) como variables reutilizables */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

@media (max-width: 768px) {
    /* 16px mínimo en campos => iOS NO hace zoom al enfocar */
    input, select, textarea {
        font-size: 16px;
    }
    /* Inputs con clase propia y tamaño reducido (especificidad de clase gana
       a la regla de elemento de arriba): forzamos 16px en móvil igualmente
       para que iOS no haga zoom al enfocarlos. */
    .bug-input, .bug-input--mini, .bug-textarea {
        font-size: 16px;
    }
    /* Scroll suave con inercia en contenedores desplazables */
    .app, .modal-body, .detail-sidebar-nav, .table-wrap, .scroll-x {
        -webkit-overflow-scrolling: touch;
    }
    /* Objetivos táctiles cómodos (mín. ~44px Apple HIG) */
    .tfnav-tab, .tfnav-icon-btn, .btn, .bubble-action,
    .detail-sidebar-item, [data-pane-target] {
        min-height: 44px;
    }
    /* El contenido respeta el home indicator de iPhone */
    .app {
        padding-bottom: var(--safe-bottom, 0px);
    }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--moss-deep); }
::-webkit-scrollbar-thumb { background: var(--forest); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--forest-light); }

/* ============ FLASH MESSAGES ============ */
.flash-wrap {
    position: fixed;
    top: calc(24px + var(--safe-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(90vw, 480px);
}

.flash {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
    animation: slideDown 0.3s ease-out;
    transition: opacity 0.3s, transform 0.3s;
    backdrop-filter: blur(10px);
}

.flash__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.flash--success .flash__dot { background: var(--success); box-shadow: 0 0 12px var(--success); }
.flash--error .flash__dot   { background: var(--danger);  box-shadow: 0 0 12px var(--danger);  }
.flash--warning .flash__dot { background: var(--warning); box-shadow: 0 0 12px var(--warning); }
.flash--info .flash__dot    { background: var(--gold);    box-shadow: 0 0 12px var(--gold);    }

.flash__text { flex: 1; color: var(--cream); }
.flash__close {
    color: var(--cream-dim);
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s;
}
.flash__close:hover { color: var(--cream); }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ TOP BAR ============ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 48px;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    background: var(--moss-deep);
    background: color-mix(in srgb, var(--moss-deep) 75%, transparent);
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand { display: flex; align-items: center; gap: 14px; cursor: pointer; }

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--moss);
    border: 1.5px solid var(--gold);
    display: grid;
    place-items: center;
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    color: var(--gold);
    letter-spacing: -0.5px;
}

.brand-text {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--cream);
    letter-spacing: 0.5px;
}

.brand-text em { color: var(--gold); font-style: italic; font-weight: 400; }

.topbar-nav { display: flex; align-items: center; gap: 32px; }

.nav-link {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: color 0.3s;
    padding: 8px 0;
    position: relative;
}

.nav-link:hover { color: var(--cream); }

.nav-link.is-active {
    color: var(--gold);
}

.nav-link.is-active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gold);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border: 1px solid var(--border);
    border-radius: 40px;
    transition: border-color 0.3s ease;
}

.user-pill:hover { border-color: var(--border-hover); }

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--moss-deep);
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 500;
}

.user-name {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: var(--cream);
    text-align: left;
    line-height: 1;
    margin-bottom: 2px;
}

.user-role {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: left;
}

.user-logout { color: var(--cream-dim); transition: color 0.2s; margin-left: 4px; }
.user-pill:hover .user-logout { color: var(--gold); }

/* ============ PAGE LAYOUT ============ */
.page {
    padding: 56px 48px 80px;
    animation: fadeIn 0.5s ease;
    flex: 1;
}

/* Contenido pegado al menú lateral (margin-left:0) en vez de centrado:
   evita la franja blanca entre el sidebar y el contenido en ventanas
   anchas o descolocadas. Mantiene el tope de 1400px por legibilidad. */
.page-inner { max-width: 1400px; margin: 0 auto 0 0; }

/* ============ HEADER / HERO ============ */
.page-header {
    margin-bottom: 56px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 32px;
    flex-wrap: wrap;
}

.page-title {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(34px, 5vw, 50px);
    font-weight: 600;
    line-height: 1.05;
    color: var(--cream);
    letter-spacing: -1px;
}

.page-title em { color: inherit; font-style: normal; }

.page-subtitle {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 14px;
}

.period-jump {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--cream-dim);
    cursor: pointer;
    vertical-align: middle;
    transition: border-color .15s ease, color .15s ease;
}
.period-jump:hover { border-color: var(--moss, #6b8e23); color: var(--cream, #f5f0e6); }
.period-jump svg { flex: 0 0 auto; }
.period-jump input[type="month"] {
    border: 0;
    background: transparent;
    color: inherit;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    padding: 0;
    cursor: pointer;
    width: 0;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-width .2s ease, opacity .2s ease;
}
.period-jump:hover input[type="month"],
.period-jump:focus-within input[type="month"] { width: auto; max-width: 130px; opacity: 1; }
.period-jump input[type="month"]::-webkit-calendar-picker-indicator { cursor: pointer; filter: invert(0.6); }
@media (max-width: 768px) {
    .period-jump input[type="month"] { width: auto; max-width: 130px; opacity: 1; font-size: 16px; }
    .period-jump { padding: 6px 12px; }
}

.page-meta { text-align: right; }

.page-meta-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.page-meta-value {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 32px;
    font-weight: 400;
    color: var(--gold);
    margin-top: 4px;
    font-style: italic;
}

/* ============ BREADCRUMB / BACK LINK ============ */
.breadcrumb {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.breadcrumb a { color: var(--cream-dim); transition: color 0.2s; }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb .sep { opacity: 0.4; }
.breadcrumb .current { color: var(--gold); }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 24px;
    transition: color 0.3s;
}

.back-link:hover { color: var(--gold); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    border: 1px solid var(--border);
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--cream);
    background: transparent;
    transition: background var(--dur) var(--ease-out),
                border-color var(--dur) var(--ease-out),
                color var(--dur) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
    cursor: pointer;
}
/* Feedback de pulsar: la UI "escucha" al usuario (emil). Sutil, 0.97. */
.btn:active { transform: scale(0.97); }

.btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

/* ============ MICRO-INTERACCIONES (más vida) ============ */
/* Lift al pasar el ratón. Gateado a hover real para no afectar al táctil.
   El :active (pulsar) va después → gana al hover y hace scale (emil). */
@media (hover: hover) and (pointer: fine) {
    .client-card, .vault-card, .doc-card, .dash-card, .role-ref-card, .doc-folder-card {
        transition: transform var(--dur) var(--ease-out),
                    box-shadow var(--dur) var(--ease-out),
                    border-color var(--dur) var(--ease-out),
                    background var(--dur) var(--ease-out);
    }
    .client-card:hover, .vault-card:hover, .doc-card:hover,
    .dash-card:hover, .role-ref-card:hover, .doc-folder-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
    }
    .btn:hover  { transform: translateY(-1px); }
    .btn:active { transform: scale(0.97); }
}

/* Entrada escalonada (stagger) de las listas de documentos al cargar.
   `both` + opacidad natural = nunca deja contenido invisible si algo falla. */
@keyframes calmaRise { from { opacity: 0; transform: translateY(8px); } }
.doc-items .doc-item { animation: calmaRise 360ms var(--ease-out) both; }
.doc-items .doc-item:nth-child(1) { animation-delay: 0ms; }
.doc-items .doc-item:nth-child(2) { animation-delay: 45ms; }
.doc-items .doc-item:nth-child(3) { animation-delay: 90ms; }
.doc-items .doc-item:nth-child(4) { animation-delay: 135ms; }
.doc-items .doc-item:nth-child(5) { animation-delay: 180ms; }
.doc-items .doc-item:nth-child(6) { animation-delay: 215ms; }
.doc-items .doc-item:nth-child(7) { animation-delay: 250ms; }
.doc-items .doc-item:nth-child(n+8) { animation-delay: 280ms; }

.btn--primary {
    background: var(--gold);
    color: var(--moss-deep);
    border-color: var(--gold);
}

.btn--primary:hover {
    background: var(--gold-bright);
    color: var(--moss-deep);
    border-color: var(--gold-bright);
}

.btn--success {
    background: rgba(126, 168, 106, 0.12);
    color: var(--success);
    border-color: rgba(126, 168, 106, 0.4);
}

.btn--success:hover {
    background: var(--success);
    color: var(--moss-deep);
    border-color: var(--success);
}

.btn--danger {
    background: rgba(199, 119, 102, 0.12);
    color: var(--danger);
    border-color: rgba(199, 119, 102, 0.4);
}

.btn--danger:hover {
    background: var(--danger);
    color: var(--moss-deep);
    border-color: var(--danger);
}

.btn--ghost { border-color: transparent; }
.btn--ghost:hover { border-color: var(--border-hover); color: var(--cream); }

.btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: grid;
    place-items: center;
    color: var(--cream-dim);
    border-color: transparent;
}

.btn--icon:hover { color: var(--gold); border-color: var(--border-hover); }

/* ============ BUBBLES (empresas & cuentas) ============
 * Tamaño fijo (no responsive estirado): siempre el mismo radio.
 * Distribución: hasta 5 por fila, alineadas a la izquierda.
 */
.bubbles-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 28px;
    max-width: 1280px;
}

.bubbles-grid--banks {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 24px;
}

.bubble {
    aspect-ratio: 1;
    width: 100%;
    max-width: 240px;
    background: linear-gradient(145deg, var(--bubble-grad-from), var(--bubble-grad-to));
    border: 1px solid var(--border);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 32px;
    text-align: center;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
    justify-self: start;
}

.bubble--small {
    padding: 28px;
    max-width: 220px;
}

.bubble--small .bubble-title { font-size: 22px; }

.bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--gold) 8%, transparent), transparent 60%);
    opacity: 0;
    transition: opacity 0.5s;
}

.bubble:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--border-hover);
    box-shadow: 0 24px 60px rgba(0,0,0,0.12), 0 0 40px rgba(184, 151, 106, 0.1);
}

.bubble:hover::before { opacity: 1; }

.bubble-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--gold);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.bubble-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 30px;
    font-weight: 500;
    color: var(--cream);
    line-height: 1.1;
    margin-bottom: 12px;
}

.bubble-title em { font-style: italic; color: var(--gold); }

.bubble-divider {
    width: 24px;
    height: 1px;
    background: var(--gold);
    margin: 10px auto;
    opacity: 0.4;
}

/* IBAN bajo el nombre del banco */
.bubble-iban {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    min-height: 18px;
}

.bubble-iban-text {
    font-family: 'DM Mono', 'DM Sans', monospace;
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--cream-dim);
    word-break: break-all;
}

.bubble-iban-text--empty { font-style: italic; opacity: 0.7; }

.bubble-iban-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--cream-dim);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, background 0.2s;
}

.bubble:hover .bubble-iban-edit { opacity: 1; }
.bubble-iban-edit:hover { color: var(--gold); background: rgba(255, 255, 255, 0.06); }

.bubble-iban-add {
    border: 1px dashed rgba(255, 255, 255, 0.22);
    background: transparent;
    color: var(--cream-dim);
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 14px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.bubble-iban-add:hover { border-color: var(--gold); color: var(--gold); }

/* Badge tipo de contacto (cliente / proveedor) en el listado de clientes */
.client-kind-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
}

.client-kind-badge--prov {
    background: color-mix(in srgb, var(--gold) 18%, transparent);
    color: var(--gold);
}

.client-kind-badge--both {
    background: rgba(255, 255, 255, 0.08);
    color: var(--cream-dim);
}

/* Etiquetas de color de Empresa / Proyecto en la ficha de Agente */
.agent-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.agent-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--tag, #6366f1);
    background: color-mix(in srgb, var(--tag, #6366f1) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--tag, #6366f1) 35%, transparent);
}

.agent-tag-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tag, #6366f1);
    flex: 0 0 auto;
}

.bubble-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.bubble-stat {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: var(--cream-dim);
    font-weight: 300;
}

.bubble-stat strong { color: var(--cream); font-weight: 400; }

.bubble-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 2;
}

.bubble:hover .bubble-actions { opacity: 1; }

/* Cuenta cancelada: X roja arriba a la derecha + tarjeta atenuada */
.bubble-cancelled-x {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: rgba(220, 53, 69, 0.14);
    color: #e5484d;
    border: 1px solid rgba(220, 53, 69, 0.45);
    z-index: 1;
    pointer-events: none;
}
.bubble--cancelled { opacity: 0.62; }
.bubble--cancelled:hover { opacity: 0.85; }
.bubble--cancelled .bubble-title { text-decoration: line-through; text-decoration-color: rgba(229, 72, 77, 0.6); }
/* Si hay acciones (hover), la X se aparta para no solaparse */
.bubble:hover .bubble-cancelled-x { opacity: 0; }

.bubble-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--moss);
    border: 1px solid var(--border);
    color: var(--cream-dim);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.bubble-action:hover { color: var(--gold); border-color: var(--gold); }
.bubble-action.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ============ EMPTY STATE ============ */
.empty {
    text-align: center;
    padding: 80px 24px;
    max-width: 520px;
    margin: 0 auto;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--moss);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    margin: 0 auto 24px;
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 40px;
    color: var(--gold);
    font-style: italic;
}

.empty-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 36px;
    color: var(--cream);
    margin-bottom: 12px;
}

.empty-title em { color: var(--gold); font-style: italic; }

.empty-text {
    font-size: 14px;
    color: var(--cream-dim);
    margin-bottom: 28px;
    line-height: 1.6;
}

/* ============ PANELS ============ */
.panel {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.panel-header {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.panel-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 26px;
    font-weight: 500;
    color: var(--cream);
}

.panel-title em { color: var(--gold); font-style: italic; }

.panel-body { padding: 24px 28px; }

/* ============ STAT CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    transition: border-color 0.3s;
}

.stat-card:hover { border-color: var(--border-hover); }

.stat-card-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card-value {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 40px;
    font-weight: 400;
    line-height: 1;
    color: var(--cream);
}

.stat-card-value.positive { color: var(--success); }
.stat-card-value.negative { color: var(--danger); }
.stat-card-value.gold     { color: var(--gold); }

.stat-card-sub {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    margin-top: 8px;
}

/* ============ TRANSACTIONS TABLE ============ */
.tx-table { width: 100%; }

.tx-head,
.tx-row {
    display: grid;
    grid-template-columns: 100px 1fr 150px 110px 80px;
    padding: 14px 28px;
    align-items: center;
    gap: 16px;
}

.tx-head {
    background: var(--moss-deep);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

.tx-row {
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.tx-row:hover { background: color-mix(in srgb, var(--gold) 4%, transparent); }
.tx-row:last-child { border-bottom: none; }

.tx-date {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--cream-dim);
    letter-spacing: 0.5px;
}

.tx-concept {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: var(--cream);
    font-weight: 400;
}

.tx-concept-sub {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    margin-top: 3px;
    letter-spacing: 0.5px;
}

.tx-amount {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 20px;
    font-weight: 500;
    text-align: right;
}

.tx-amount.in  { color: var(--success); }
.tx-amount.out { color: var(--danger); }

.tx-action { text-align: right; display: inline-flex; gap: 4px; justify-content: flex-end; align-items: center; }

.tx-delete,
.tx-edit {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--cream-dim);
    opacity: 0;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tx-row:hover .tx-delete,
.tx-row:hover .tx-edit { opacity: 0.7; }
.tx-delete:hover { opacity: 1; color: var(--danger); border-color: var(--danger); }
.tx-edit:hover { opacity: 1; color: var(--gold); border-color: var(--gold); }

/* ============ TOOLBAR + HEADERS ORDENABLES (tabla dinámica) ============ */

.tx-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--moss-deep) 30%, transparent);
}

.tx-search-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.tx-search-icon {
    position: absolute;
    left: 12px;
    color: var(--cream-dim);
    pointer-events: none;
}

.tx-search-input {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 36px 9px 36px;
    color: var(--cream);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.3px;
    transition: border-color 0.15s, background 0.15s;
}

.tx-search-input::placeholder {
    color: var(--cream-dim);
    opacity: 0.6;
    font-family: 'DM Mono', monospace;
    text-transform: none;
    letter-spacing: 0;
}

.tx-search-input:focus {
    outline: none;
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 4%, transparent);
}

.tx-search-clear {
    position: absolute;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--cream-dim);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.tx-search-clear:hover { color: var(--cream); background: color-mix(in srgb, var(--cream) 10%, transparent); }

.tx-toolbar-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid color-mix(in srgb, var(--gold) 25%, transparent);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: tx-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes tx-spin {
    to { transform: rotate(360deg); }
}

/* Headers ordenables */
.tx-th { font-family: inherit; }
.tx-th--sortable {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}
.tx-th--sortable:hover { color: var(--gold); }

.tx-sort-arrow {
    display: inline-block;
    min-width: 10px;
    font-size: 9px;
    color: var(--gold);
    opacity: 0.85;
    letter-spacing: 0;
}

/* Body se separa del head para reemplazo dinámico — sin afectar layout */
.tx-body { display: contents; }

/* Paginación: ahora con grupo de páginas y soporte de <button> */
.pagination__pages {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

button.page-link {
    background: transparent;
    cursor: pointer;
    font: inherit;
}
.page-link[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============ CHIPS / BADGES ============ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--cream-dim);
}

.chip--gold     { border-color: rgba(184, 151, 106, 0.4); color: var(--gold); }
.chip--success  { background: rgba(126, 168, 106, 0.12); color: var(--success); border-color: rgba(126, 168, 106, 0.3); }
.chip--danger   { background: rgba(199, 119, 102, 0.12); color: var(--danger);  border-color: rgba(199, 119, 102, 0.3); }
.chip--filled   { background: var(--gold); color: var(--moss-deep); border-color: var(--gold); }

/* ============ TABLE (generic, para usuarios) ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: var(--moss-deep);
    padding: 14px 28px;
    text-align: left;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    font-weight: 400;
}

.data-table tbody td {
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--cream);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--gold) 4%, transparent); }

/* ============ FORMS ============ */
.field { margin-bottom: 20px; }

.field-label {
    display: block;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.field-input,
.field-select,
.field-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--cream);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s, background 0.2s;
}

.field-input.font-mono { font-family: 'DM Mono', monospace; }

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
    outline: none;
    border-color: var(--gold);
    background: var(--moss);
}

.field-input::placeholder,
.field-textarea::placeholder { color: var(--cream-dim); opacity: 0.5; }

.field-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23c8c3b5' stroke-width='1.5'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.field-textarea { resize: vertical; min-height: 80px; }

.field-help {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    margin-top: 6px;
    letter-spacing: 0.5px;
}

.field-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
    position: relative;
}

.color-swatch input { position: absolute; opacity: 0; }
.color-swatch:has(input:checked) { border-color: var(--cream); transform: scale(1.1); }

/* ============ MODALS ============ */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--moss-deep) 70%, transparent);
    backdrop-filter: blur(8px);
    z-index: 1100;
    padding: 24px;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    animation: fadeIn 0.2s ease;
}

.modal-backdrop.is-open { display: flex; }

.modal {
    background: var(--moss);
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    padding: 36px;
    max-width: 520px;
    width: 100%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    position: relative;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    /* margin auto: si cabe se centra (combinado con flex del backdrop);
       si no cabe, el overflow-y permite scroll interno. */
    margin: auto;
}

.modal-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 32px;
    font-weight: 400;
    color: var(--cream);
    margin-bottom: 6px;
    padding-right: 32px;
}

.modal-title em { color: var(--gold); font-style: italic; }

.modal-sub {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 28px;
}

.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--cream-dim);
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.modal-close:hover { color: var(--gold); border-color: var(--border-hover); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* ============ MODAL · PREVIEW DE ADJUNTOS ============
 * Modal especial: cuerpo grande, footer con acciones, scroll interno.
 * Reutiliza .modal-backdrop / .modal / .modal-close del bloque anterior.
 */
.modal--attach {
    max-width: 920px;
    padding: 28px 28px 0; /* el footer se pega abajo */
    display: flex;
    flex-direction: column;
    height: min(86vh, 900px);
}

.modal--attach .modal-attach-header {
    padding-right: 48px; /* hueco para el botón cerrar */
    margin-bottom: 16px;
}

.modal--attach .modal-attach-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--cream);
    word-break: break-all;
    line-height: 1.35;
}

.modal--attach .modal-attach-subtitle {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 4px;
}

.modal--attach .modal-attach-body {
    flex: 1 1 auto;
    min-height: 0; /* permite que el iframe respete flex */
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--moss-deep);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-preview-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--moss-deep);
}

.attach-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    background:
        linear-gradient(45deg, var(--moss) 25%, transparent 25%) 0 0 / 16px 16px,
        linear-gradient(-45deg, var(--moss) 25%, transparent 25%) 0 8px / 16px 16px,
        linear-gradient(45deg, transparent 75%, var(--moss) 75%) 8px -8px / 16px 16px,
        linear-gradient(-45deg, transparent 75%, var(--moss) 75%) 8px 0 / 16px 16px,
        var(--moss-deep);
}

.attach-preview-fallback {
    padding: 40px;
    text-align: center;
    color: var(--cream-dim);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
}

.attach-preview-fallback p { margin: 4px 0; }

.modal--attach .modal-attach-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 0 20px;
    margin-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.modal--attach .modal-attach-footer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.attach-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--border-hover);
    border-radius: 10px;
    background: transparent;
    color: var(--cream);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.attach-action-btn:hover {
    background: var(--forest);
    border-color: var(--gold);
    color: var(--gold);
}

.attach-action-btn--primary {
    background: var(--gold);
    color: var(--moss-deep);
    border-color: var(--gold);
}

.attach-action-btn--primary:hover {
    background: var(--gold-bright);
    border-color: var(--gold-bright);
    color: var(--moss-deep);
}

.attach-action-btn--danger {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.attach-action-btn--danger:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border-color: var(--danger);
    color: var(--danger);
}

@media (max-width: 720px) {
    .modal--attach {
        height: 100dvh;
        max-height: 100dvh;
        max-width: 100vw;
        border-radius: 0;
        padding: 20px 16px 0;
    }
    .modal--attach .modal-attach-footer {
        flex-direction: column;
        align-items: stretch;
    }
    .modal--attach .modal-attach-footer-actions { width: 100%; }
    .attach-action-btn { flex: 1; justify-content: center; }
}

/* ============ FOOTER ============ */
.footer {
    padding: 32px 48px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer-text {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.footer-text em { color: var(--gold); font-style: italic; text-transform: none; }

.footer-legal-links {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.footer-legal-links a { color: var(--cream-dim); text-decoration: none; }
.footer-legal-links a:hover { color: var(--cream); text-decoration: underline; }
.footer-legal-links span { color: var(--cream-dim); opacity: .5; }

/* ============ THEME SWITCH ============ */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 4px;
}

.theme-toggle:hover {
    color: var(--gold);
    border-color: var(--border-hover);
}

.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ============ PERIOD SELECTOR ============ */
.period-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 24px;
}

.period-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.period-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.period-chip {
    padding: 6px 14px;
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.period-chip:hover { color: var(--cream); border-color: var(--border-hover); }
.period-chip.is-active { background: var(--gold); color: var(--moss-deep); border-color: var(--gold); }

.period-custom {
    display: none;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.period-custom.is-open { display: flex; }
.period-custom input[type="date"] {
    padding: 6px 10px;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--cream);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
}
.period-custom input[type="date"]:focus { outline: none; border-color: var(--gold); }

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.pagination__info {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-right: auto;
}

.page-link {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    display: inline-grid;
    place-items: center;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    text-decoration: none;
    transition: all 0.2s;
}

.page-link:hover {
    color: var(--gold);
    border-color: var(--border-hover);
}

.page-link.is-active {
    background: var(--gold);
    color: var(--moss-deep);
    border-color: var(--gold);
}

.page-link.is-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* ============ COMPANY MULTI-SELECT (asignaciones) ============ */
.companies-pick {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    background: var(--moss-deep);
}

.companies-pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.companies-pick-row:hover { background: color-mix(in srgb, var(--gold) 8%, transparent); }

.companies-pick-row input[type="checkbox"] {
    accent-color: var(--gold);
    width: 14px;
    height: 14px;
}

.companies-pick-row .name {
    font-size: 13px;
    color: var(--cream);
    flex: 1;
}

.companies-pick-row .kind-tag {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============ FILTER CHIPS ============ */
.filter-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 8px 18px;
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-chip:hover {
    color: var(--cream);
    border-color: var(--border-hover);
}

.filter-chip.is-active {
    background: var(--gold);
    color: var(--moss-deep);
    border-color: var(--gold);
}

.filter-chip-count {
    margin-left: 6px;
    opacity: 0.6;
    font-size: 10px;
}

/* ============ FILE-LIKE BUTTON for download ============ */
.attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.attach-btn:hover { color: var(--gold); border-color: var(--gold); }

.attach-btn.attach-btn--has {
    color: var(--success);
    border-color: rgba(126, 168, 106, 0.3);
    background: rgba(126, 168, 106, 0.08);
}

.attach-btn.attach-btn--has:hover {
    background: var(--success);
    color: var(--moss-deep);
    border-color: var(--success);
}

/* ============ TOOLBAR ============ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.toolbar-spacer { flex: 1; }

/* ============ LOGIN ============ */
.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.14);
}

.login-mark {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--moss-deep);
    border: 1.5px solid var(--gold);
    display: grid;
    place-items: center;
    font-family: 'DM Mono', monospace;
    font-size: 18px;
    color: var(--gold);
    margin: 0 auto 24px;
}

.login-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 44px;
    color: var(--cream);
    font-weight: 400;
    line-height: 1;
    margin-bottom: 8px;
}

.login-title em { color: var(--gold); font-style: italic; }

.login-sub {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 36px;
}

.login-form { text-align: left; }

.login-form .btn { width: 100%; justify-content: center; padding: 14px; }

.login-pw {
    position: relative;
}

.login-pw-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cream-dim);
    padding: 4px;
    transition: color 0.2s;
}

.login-pw-toggle:hover { color: var(--gold); }

/* ============ USERS ============ */
.role-chip {
    padding: 4px 10px;
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    display: inline-block;
    border: 1px solid;
}

.role-chip.root     { color: var(--gold);    border-color: rgba(184, 151, 106, 0.4); background: rgba(184, 151, 106, 0.1); }
.role-chip.contador { color: var(--success); border-color: rgba(126, 168, 106, 0.4); background: rgba(126, 168, 106, 0.1); }
.role-chip.viewer   { color: var(--cream-dim); border-color: var(--border); }

.user-cell {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-cell-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--moss-deep);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    flex-shrink: 0;
}

.user-cell-username {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.you-tag {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    color: var(--gold);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-left: 6px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.status-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-indicator.active { color: var(--success); }
.status-indicator.active .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-indicator.inactive { color: var(--cream-dim); }
.status-indicator.inactive .dot { background: var(--cream-dim); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
    .bubbles-grid,
    .bubbles-grid--banks { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .topbar { padding: 20px 24px; flex-wrap: wrap; gap: 16px; }
    .topbar-nav { width: 100%; justify-content: space-between; gap: 16px; }
    .page { padding: 40px 24px 60px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-meta { text-align: left; }
    .tx-head, .tx-row { grid-template-columns: 70px 1fr 100px 90px 70px; padding: 14px 16px; gap: 10px; }
    .tx-amount { font-size: 16px; }
    .field-row { grid-template-columns: 1fr; }
    .user-pill .user-name,
    .user-pill .user-role { display: none; }
    .bubbles-grid,
    .bubbles-grid--banks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .bubbles-grid,
    .bubbles-grid--banks { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    .bubble, .bubble--small { padding: 20px; }
}

@media (max-width: 560px) {
    .page-title { font-size: 40px; }
    .login-card { padding: 32px 24px; }
    .login-title { font-size: 36px; }
    .modal { padding: 28px 22px; }
    .footer { padding: 24px; }
}

/* ============ UTILITIES ============ */
.text-gold { color: var(--gold); }
.text-cream-dim { color: var(--cream-dim); }
.font-mono { font-family: 'DM Mono', monospace; }
.font-serif { font-family: 'DM Sans', system-ui, sans-serif; }
.italic { font-style: italic; }

.no-data {
    padding: 60px 20px;
    text-align: center;
    color: var(--cream-dim);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

*:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible { outline: none; }
input:focus-visible,
select:focus-visible,
textarea:focus-visible { border-color: var(--gold) !important; }

/* ================================================================
 * NUEVO MÓDULO: RENTABILIDAD DE PROYECTOS
 * Solo se aplica a las vistas /projects/*
 * ================================================================ */

/* ---- Vista 1: rejilla de meses ---- */
.months-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.month-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px 24px;
    text-decoration: none;
    color: var(--cream);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 180px;
}

.month-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.month-card--empty {
    border-style: dashed;
    background: transparent;
}

.month-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 4px;
}

.month-card-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 26px;
    font-weight: 500;
    color: var(--cream);
    text-transform: capitalize;
    line-height: 1;
}

.month-card-year {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
}

.month-card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--cream-dim);
}

.month-card-label {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 10px;
}

.month-card-value {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
}
.month-card-value.in  { color: var(--success); }
.month-card-value.out { color: var(--danger); }

.month-card-balance {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 26px;
    font-weight: 500;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    line-height: 1.1;
}

.month-card-foot {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.month-card-empty {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 24px;
    color: var(--cream-dim);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.month-card-empty-cta { color: var(--gold); }

/* ---- Vista 2: tabla de movimientos del mes ---- */
.pm-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 24px;
}

.pm-table {
    display: flex;
    flex-direction: column;
}

.pm-head,
.pm-row {
    display: grid;
    grid-template-columns: 36px 90px 1fr 110px 130px 110px 70px;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
}

.pm-head {
    background: var(--moss-deep);
    border-bottom: 1px solid var(--border);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.pm-h-amt { text-align: right; }

.pm-row {
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    transition: background 0.15s;
}

.pm-row:hover {
    background: color-mix(in srgb, var(--gold) 4%, transparent);
}

.pm-row:last-child {
    border-bottom: none;
}

.pm-row--pending {
    opacity: 0.65;
}

.pm-paid {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pm-paid-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    transition: all 0.15s;
}
.pm-paid-btn.is-paid {
    background: var(--success);
    color: var(--moss-deep);
    border-color: var(--success);
}
.pm-paid-btn.is-pending {
    color: var(--cream-dim);
}
.pm-paid-btn.is-pending:hover {
    color: var(--gold);
    border-color: var(--gold);
}

.pm-paid-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 12px;
}
.pm-paid-badge.is-paid {
    background: var(--success);
    color: var(--moss-deep);
    border-color: var(--success);
}
.pm-paid-badge.is-pending {
    color: var(--cream-dim);
}

.pm-date {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 0.5px;
}

.pm-desc {
    color: var(--cream);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pm-pag {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 0.5px;
}

.pm-cat {
    font-size: 11px;
}

.cat-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, transparent);
}

.pm-amt {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    text-align: right;
    font-weight: 500;
}
.pm-amt.in  { color: var(--success); }
.pm-amt.out { color: var(--danger); }

.pm-act {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.pm-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--cream-dim);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.15s;
}
.pm-action-btn:hover {
    color: var(--gold);
    border-color: var(--border);
}
.pm-action-btn--danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.muted {
    color: var(--cream-dim);
    opacity: 0.5;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
}

/* Responsive: en pantallas estrechas, las tablas pasan a una columna */
@media (max-width: 980px) {
    .pm-head,
    .pm-row {
        grid-template-columns: 30px 80px 1fr 100px 100px 70px;
        gap: 8px;
    }
    /* Categoría y acciones siguen visibles; solo apretamos columnas */
}

/* ============ NUEVO: Tabla resumen mensual del proyecto ============ */
.pm-summary-table {
    display: flex;
    flex-direction: column;
}

.pm-summary-head,
.pm-summary-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 70px;
    gap: 12px;
    align-items: center;
    padding: 12px 18px;
}

.pm-summary-head {
    background: var(--moss-deep);
    border-bottom: 1px solid var(--border);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.pm-summary-head .num { text-align: right; }

.pm-summary-row {
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--cream);
    transition: background 0.15s;
    font-size: 13px;
}
.pm-summary-row:hover {
    background: color-mix(in srgb, var(--gold) 4%, transparent);
}
.pm-summary-row:last-child { border-bottom: none; }

.pm-summary-row .num {
    text-align: right;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
}
.pm-summary-row .num.in  { color: var(--success); }
.pm-summary-row .num.out { color: var(--danger); }
.pm-summary-row .num.bal { font-weight: 500; }
.pm-summary-row .num.movs {
    color: var(--cream-dim);
    font-size: 11px;
}

.pm-summary-month {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 18px;
    color: var(--cream);
    text-transform: capitalize;
}

.pm-summary-row--total {
    background: var(--moss-deep);
    border-top: 2px solid var(--border);
    cursor: default;
    pointer-events: none;
}
.pm-summary-row--total .pm-summary-month {
    color: var(--gold);
}

/* ============ NUEVO: Tablas de categorías con barras ============ */
.cat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 32px;
}

@media (max-width: 980px) {
    .cat-grid { grid-template-columns: 1fr; }
}

.cat-table {
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
    gap: 18px;
}

.cat-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cat-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.cat-name {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 16px;
    color: var(--cream);
}

.cat-amount {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
}
.cat-amount.in  { color: var(--success); }
.cat-amount.out { color: var(--danger); }

.cat-bar {
    height: 4px;
    background: color-mix(in srgb, var(--cream-dim) 12%, transparent);
    border-radius: 2px;
    overflow: hidden;
}

.cat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cat-bar-fill.in  { background: var(--success); }
.cat-bar-fill.out { background: var(--danger); }

.cat-row-foot {
    display: flex;
    justify-content: space-between;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============ NUEVO: Select de categoría con botón Nueva ============ */
.cat-select-wrap {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.cat-select {
    flex: 1;
}

.cat-add-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.cat-new-inline {
    background: color-mix(in srgb, var(--gold) 6%, transparent);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-top: 12px;
}

.cat-new-inline .field-help {
    margin-top: 6px;
}

.cat-new-inline .field-help strong {
    color: var(--gold);
}

/* ============ NUEVO: Tabla de fijos recurrentes ============ */
.rec-table {
    display: flex;
    flex-direction: column;
}

.rec-head,
.rec-row {
    display: grid;
    grid-template-columns: 36px 1.4fr 130px 120px 70px 140px 110px 70px;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
}

.rec-head {
    background: var(--moss-deep);
    border-bottom: 1px solid var(--border);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.rec-h-amt { text-align: right; }
.rec-h-act { text-align: center; }

.rec-row {
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    transition: background 0.15s;
}
.rec-row:hover {
    background: color-mix(in srgb, var(--gold) 4%, transparent);
}
.rec-row:last-child {
    border-bottom: none;
}
.rec-row--inactive {
    opacity: 0.55;
}
.rec-row--inactive .rec-desc,
.rec-row--inactive .rec-amt {
    text-decoration: line-through;
    text-decoration-color: rgba(255,255,255,0.3);
}

.rec-act {
    display: flex;
    align-items: center;
    justify-content: center;
}

.rec-toggle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 14px;
    transition: all 0.15s;
}
.rec-toggle.is-on {
    background: var(--success);
    color: var(--moss-deep);
    border-color: var(--success);
}
.rec-toggle.is-off {
    color: var(--cream-dim);
}
.rec-toggle.is-off:hover {
    color: var(--success);
    border-color: var(--success);
}

.rec-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 14px;
}
.rec-badge.is-on  { background: var(--success); color: var(--moss-deep); border-color: var(--success); }
.rec-badge.is-off { color: var(--cream-dim); }

.rec-desc {
    color: var(--cream);
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rec-cat {
    font-size: 11px;
}

.rec-pag {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 0.5px;
}

.rec-day {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.rec-period {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 0.5px;
}

.rec-amt {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    text-align: right;
    font-weight: 500;
}
.rec-amt.in  { color: var(--success); }
.rec-amt.out { color: var(--danger); }

.rec-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* En tablet/móvil (<=1100px) la tabla de fijos pasa a tarjeta apilada
   (ver bloque más abajo). NO se usa una rejilla condensada intermedia
   porque escondía editar/borrar y, en modo selección, desbordaba. */

/* ============ NUEVO: Bloques por año ============ */
.year-block {
    margin-top: 32px;
}
.year-block:first-of-type {
    margin-top: 24px;
}

.year-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.year-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 38px;
    font-weight: 400;
    color: var(--gold);
    letter-spacing: 1px;
    margin: 0;
    line-height: 1;
}

.year-totals {
    display: flex;
    gap: 24px;
    align-items: baseline;
    font-family: 'DM Mono', monospace;
    font-size: 13px;
}

.year-total-item {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}
.year-total-item.in  { color: var(--success); }
.year-total-item.out { color: var(--danger); }
.year-total-item.bal {
    font-weight: 500;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

/* Sub-encabezado de año dentro de la tabla resumen mensual */
.pm-summary-yearhead {
    padding: 10px 18px;
    background: color-mix(in srgb, var(--gold) 8%, transparent);
    color: var(--gold);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
}

@media (max-width: 700px) {
    .year-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .year-title { font-size: 30px; }
    .year-totals { flex-wrap: wrap; gap: 12px; font-size: 12px; }
    .year-total-item.bal { padding-left: 0; border-left: none; }
}

/* ============ NUEVO: Tarjetas grandes por AÑO ============ */
.years-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.year-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px 30px;
    text-decoration: none;
    color: var(--cream);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 220px;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}

.year-card:hover {
    border-color: var(--gold);
    transform: translateY(-3px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.year-card--empty {
    border-style: dashed;
    background: transparent;
    min-height: 180px;
}

.year-card--current::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: linear-gradient(180deg, var(--gold), transparent);
    border-radius: 18px 0 0 18px;
}

.year-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.year-card-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 56px;
    font-weight: 400;
    color: var(--cream);
    line-height: 1;
    letter-spacing: 1px;
}

.year-card-badge {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gold);
    border: 1px solid var(--gold);
    padding: 3px 10px;
    border-radius: 40px;
}

.year-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.year-card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'DM Mono', monospace;
}

.year-card-label {
    font-size: 10px;
    color: var(--cream-dim);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.year-card-value {
    font-size: 13px;
}
.year-card-value.in  { color: var(--success); }
.year-card-value.out { color: var(--danger); }

.year-card-balance {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 32px;
    font-weight: 500;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    line-height: 1.1;
}

.year-card-foot {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.year-card-empty {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 32px;
    color: var(--cream-dim);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.year-card-empty-cta { color: var(--gold); }

/* ============ NUEVO: Iconitos de adjunto y vínculo bancario ============ */
.pm-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    margin-left: 6px;
    color: var(--cream-dim);
    text-decoration: none;
    transition: all 0.15s;
    vertical-align: middle;
}
.pm-flag--clip:hover {
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 12%, transparent);
}
.pm-flag--link {
    color: var(--success);
}

/* ============ NUEVO: Tabla de colaboradores ============ */
.pc-table { display: flex; flex-direction: column; }
.pc-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 16px;
    padding: 14px 22px;
    align-items: center;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
.pc-row--head {
    background: var(--moss-deep);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 1.4px;
    text-transform: uppercase;
    border-top: none;
    padding-top: 12px;
    padding-bottom: 12px;
}
.pc-row--inactive { opacity: 0.5; }
.pc-row .num { text-align: right; font-family: 'DM Mono', monospace; }
.pc-row .state { text-align: center; }
.pc-row .acts { display: flex; gap: 6px; justify-content: flex-end; }
.pc-name { font-weight: 500; color: var(--cream); }

.pc-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    padding: 4px 12px;
    border-radius: 40px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
}
.pc-toggle:hover { border-color: var(--gold); }
.pc-toggle.is-active {
    color: var(--success);
    border-color: var(--success);
}

/* ============ Sección de Reparto en mes/año/principal ============ */
.payout-block {
    margin-top: 32px;
    padding: 22px 28px;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.payout-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.payout-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 400;
    color: var(--cream);
}
.payout-title em { color: var(--gold); font-style: italic; }
.payout-net {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 1.2px;
    text-transform: uppercase;
}
.payout-net strong { color: var(--cream); margin-left: 8px; font-size: 15px; }
.payout-list { display: flex; flex-direction: column; }
.payout-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1.4fr;
    gap: 16px;
    padding: 12px 0;
    align-items: baseline;
    border-bottom: 1px dashed color-mix(in srgb, var(--border) 50%, transparent);
}
.payout-row:last-of-type { border-bottom: none; }
.payout-row .name { font-size: 14px; color: var(--cream); }
.payout-row .pct {
    text-align: right;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--cream-dim);
}
.payout-row .amount {
    text-align: right;
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    font-weight: 500;
}
.payout-row .amount.in  { color: var(--success); }
.payout-row .amount.out { color: var(--danger); }
.payout-warning {
    margin-top: 12px;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 1px solid var(--danger);
    border-radius: 8px;
    font-size: 12px;
    color: var(--cream);
}
.payout-empty {
    padding: 24px;
    text-align: center;
    color: var(--cream-dim);
    font-size: 13px;
}
.payout-empty a { color: var(--gold); text-decoration: underline; }

/* =====================================================================
   ============ RESPONSIVE MÓVIL — bloque consolidado ==================
   ====================================================================
   Foco: tablas que pierden información en móvil. Cada fila se convierte
   en una tarjeta apilada con etiquetas visibles para cada dato.
*/

/* ============ Layout general ============ */
@media (max-width: 720px) {
    /* Header de página: título y meta apilados */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .page-meta {
        text-align: left;
        align-self: flex-start;
    }
    .page-title {
        font-size: 32px;
        line-height: 1.1;
    }
    .page-meta-value {
        font-size: 24px;
    }

    /* Toolbar: wrap automático y botones a ancho completo */
    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    .toolbar-spacer { display: none; }
    .toolbar .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        justify-content: center;
        font-size: 11px;
        padding: 10px 12px;
    }
    .toolbar .btn--primary,
    .toolbar .btn--success,
    .toolbar .btn--danger {
        flex: 1 1 100%;
    }

    /* Breadcrumb: scroll horizontal si no cabe */
    .breadcrumb {
        font-size: 11px;
        white-space: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    /* Panel header: chip se va abajo si no cabe */
    .panel-header {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ============ TABLAS DE MOVIMIENTOS DEL PROYECTO (mes) ============ */
@media (max-width: 720px) {
    /* Cabecera de la tabla oculta en móvil */
    .pm-row--head { display: none; }

    /* Forzar que TODOS los grids antiguos no apliquen */
    .pm-row {
        display: grid !important;
        grid-template-columns: 36px 1fr !important;
        grid-template-rows: auto !important;
        grid-template-areas:
            "paid amt"
            "date date"
            "desc desc"
            "pag pag"
            "cat cat"
            "act act" !important;
        gap: 8px 10px !important;
        padding: 14px 16px !important;
        align-items: center;
    }
    .pm-row .pm-paid {
        grid-area: paid;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .pm-row .pm-amt {
        grid-area: amt;
        text-align: right;
        font-size: 20px;
        font-weight: 600;
        white-space: nowrap;
        overflow: visible;
    }
    .pm-row .pm-date  { grid-area: date; font-size: 11px; color: var(--cream-dim); }
    .pm-row .pm-desc  { grid-area: desc; font-size: 14px; line-height: 1.4; word-break: break-word; }
    .pm-row .pm-pag   { grid-area: pag; font-size: 13px; }
    .pm-row .pm-cat   { grid-area: cat; font-size: 13px; display: block !important; }
    .pm-row .pm-act {
        grid-area: act;
        display: flex !important;
        gap: 8px;
        justify-content: flex-end;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px dashed color-mix(in srgb, var(--border) 60%, transparent);
    }
    .pm-row .pm-act .pm-action-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    /* Etiquetas */
    /* TODO i18n: mover a HTML con t() */
    .pm-row .pm-pag::before {
        content: 'Pagador: ';
        font-family: 'DM Mono', monospace;
        font-size: 10px;
        color: var(--cream-dim);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-right: 4px;
    }
    /* TODO i18n: mover a HTML con t() */
    .pm-row .pm-cat::before {
        content: 'Categoría: ';
        font-family: 'DM Mono', monospace;
        font-size: 10px;
        color: var(--cream-dim);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-right: 4px;
    }
    .pm-row .pm-pag:has(.muted),
    .pm-row .pm-cat:has(.muted) { display: none; }

    /* Gastos / Ingresos en columna única */
    .pm-grid {
        grid-template-columns: 1fr !important;
        gap: 18px;
    }
}

/* ============ TABLA DE MOVIMIENTOS BANCARIOS ============ */
@media (max-width: 720px) {
    .tx-head { display: none; }

    .tx-row {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        grid-template-areas:
            "date amt"
            "concept concept"
            "attach acts" !important;
        gap: 6px 12px !important;
        padding: 14px 16px !important;
    }
    .tx-row .tx-date { grid-area: date; font-size: 11px; color: var(--cream-dim); }
    .tx-row .tx-amount { grid-area: amt; text-align: right; font-size: 18px; }
    .tx-row > div:has(.tx-concept) { grid-area: concept; }
    .tx-row .tx-concept { font-size: 14px; }
    .tx-row .tx-concept-sub { margin-top: 4px; font-size: 11px; }
    /* El bloque del adjunto y acciones */
    .tx-row > div:has(.attach-btn),
    .tx-row > div:has(.tx-delete) {
        padding-top: 6px;
        border-top: 1px dashed color-mix(in srgb, var(--border) 60%, transparent);
    }
    .tx-row .tx-action { grid-area: acts; justify-content: flex-end; }
}

/* ============ TABLA RESUMEN MENSUAL ============ */
@media (max-width: 720px) {
    .pm-summary-head { display: none; }

    .pm-summary-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px 12px;
        padding: 14px 16px;
        align-items: baseline;
    }
    .pm-summary-row .pm-summary-month {
        grid-column: 1 / -1;
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 4px;
    }
    .pm-summary-row .num {
        text-align: right;
        font-size: 13px;
    }
    .pm-summary-row .num::before {
        font-family: 'DM Mono', monospace;
        font-size: 9px;
        color: var(--cream-dim);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-right: 6px;
    }
    /* TODO i18n: mover a HTML con t() */
    .pm-summary-row .num.in::before  { content: 'Ingr:'; }
    .pm-summary-row .num.out::before { content: 'Gast:'; }
    .pm-summary-row .num.bal::before { content: 'Bal:'; }
    .pm-summary-row .num.movs::before { content: 'Movs:'; }
}

/* ============ TABLA DE FIJOS RECURRENTES ============ */
@media (max-width: 1100px) {
    .rec-head { display: none; }

    .rec-row {
        display: grid !important;
        grid-template-columns: auto 1fr !important;
        grid-template-areas:
            "act amt"
            "desc desc"
            "meta meta"
            "actions actions" !important;
        gap: 8px 12px !important;
        padding: 14px 16px !important;
        align-items: center;
    }
    .rec-row .rec-act     { grid-area: act; }
    .rec-row .rec-amt     { grid-area: amt; text-align: right; font-size: 18px; }
    .rec-row .rec-desc    { grid-area: desc; font-size: 14px; }

    /* Categoría, pagador, día y vigencia se apilan en una sola "meta" con etiquetas */
    .rec-row .rec-cat,
    .rec-row .rec-pag,
    .rec-row .rec-day,
    .rec-row .rec-period {
        grid-area: meta;
        font-size: 11px;
        color: var(--cream-dim);
        display: inline;
    }
    /* TODO i18n: mover a HTML con t() */
    .rec-row .rec-cat::before    { content: 'Cat: '; }
    .rec-row .rec-pag::before    { content: ' · Pag: '; }
    .rec-row .rec-day::before    { content: ' · '; }
    .rec-row .rec-period::before { content: ' · '; }

    /* Cuando hay un span "muted" (vacío), ocultamos la línea */
    .rec-row .rec-cat:has(.muted),
    .rec-row .rec-pag:has(.muted) {
        display: none;
    }

    .rec-row .rec-actions {
        grid-area: actions;
        justify-content: flex-end;
        padding-top: 6px;
        border-top: 1px dashed color-mix(in srgb, var(--border) 60%, transparent);
        display: flex;
        gap: 6px;
    }
}

/* ============ TABLA DE COLABORADORES (reparto) ============ */
@media (max-width: 720px) {
    .pc-row--head { display: none; }

    .pc-row {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "name pct"
            "state acts";
        gap: 8px 12px;
        padding: 14px 16px;
    }
    .pc-row .pc-name { grid-area: name; }
    .pc-row .num { grid-area: pct; text-align: right; font-size: 16px; }
    .pc-row .state { grid-area: state; text-align: left; }
    .pc-row .acts { grid-area: acts; justify-content: flex-end; }
}

/* ============ GRIDS DE TARJETAS ============ */
@media (max-width: 720px) {
    /* Tarjetas de meses dentro de un año: 2 columnas */
    .months-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }
    .month-card {
        padding: 16px !important;
        min-height: 140px !important;
    }
    .month-card-title { font-size: 18px !important; }
    .month-card-balance { font-size: 18px !important; }

    /* Tarjetas de años: 1 sola columna grande */
    .years-grid {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }
    .year-card {
        min-height: 180px;
        padding: 22px 24px;
    }
    .year-card-title {
        font-size: 44px;
    }
    .year-card-balance {
        font-size: 26px;
    }

    /* Grid de categorías: 1 columna */
    .cat-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Burbujas de empresas */
    .bubbles-grid--banks {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* ============ MODALES A PANTALLA COMPLETA EN MÓVIL ============ */
@media (max-width: 720px) {
    .modal-backdrop { padding: 0; }
    .modal {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 24px 18px;
        padding-top: calc(24px + var(--safe-top, 0px));
    }
    .modal-title {
        font-size: 24px;
        padding-right: 40px;
    }
    .modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
        padding-top: 16px;
        border-top: 1px solid var(--border);
        position: sticky;
        bottom: -24px;
        background: var(--moss);
        margin: 16px -18px -24px;
        padding: 16px 18px calc(24px + var(--safe-bottom, 0px));
    }
    .modal-actions .btn {
        width: 100%;
    }

    /* Field row (campos lado a lado) → apilados */
    .field-row {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* Selectores de categoría con botón "+ Nueva" */
    .cat-select-wrap {
        flex-direction: column;
        gap: 8px;
    }
    .cat-add-btn {
        width: 100%;
    }
}

/* ============ BLOQUES DE REPARTO (panel) ============ */
@media (max-width: 720px) {
    .payout-block {
        padding: 18px 16px;
    }
    .payout-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .payout-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 14px 0;
    }
    .payout-row .name { font-size: 15px; }
    .payout-row .pct { text-align: left; }
    .payout-row .amount {
        text-align: left;
        font-size: 24px;
    }
}

/* ============ PADDING GENERAL DEL CONTAINER ============ */
@media (max-width: 720px) {
    .page-inner {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
    .panel {
        border-radius: 12px;
    }
    .panel-header {
        padding: 14px 16px;
    }
    .panel-title {
        font-size: 18px;
    }
}

/* ============ AJUSTES EXTRA PARA MÓVILES PEQUEÑOS ============ */
@media (max-width: 420px) {
    .page-title { font-size: 26px; }
    .month-card-title { font-size: 16px !important; }
    .year-card-title { font-size: 36px; }

    /* Tarjetas de mes: 1 columna en móviles muy estrechos */
    .months-grid {
        grid-template-columns: 1fr !important;
    }

    /* Toolbar: cada botón ocupa todo el ancho */
    .toolbar .btn {
        flex: 1 1 100%;
    }
}

/* ============ Modal de Reportes PDF ============ */
.pdf-report-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 18px 0;
}
.pdf-report-option {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--cream);
    transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
a.pdf-report-option:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
}
.pdf-report-icon {
    flex: 0 0 auto;
    color: var(--gold);
    padding-top: 2px;
}
.pdf-report-text {
    flex: 1 1 auto;
    min-width: 0;
}
.pdf-report-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--cream);
    margin-bottom: 3px;
}
.pdf-report-desc {
    font-size: 12px;
    color: var(--cream-dim);
    line-height: 1.45;
}
.pdf-report-arrow {
    flex: 0 0 auto;
    color: var(--gold);
    font-size: 18px;
    align-self: center;
}
.pdf-report-option--with-select { cursor: default; }
.pdf-report-option--with-select:hover { transform: none; border-color: var(--border); }

/* Móvil: el bloque del select se apila en columna */
@media (max-width: 720px) {
    .pdf-report-option {
        padding: 14px;
        flex-wrap: wrap;
    }
    .pdf-report-option--with-select > .pdf-report-text > div:last-child {
        flex-wrap: wrap;
    }
    .pdf-report-option--with-select .btn { width: 100%; }
}

/* =====================================================================
   ============ Selección masiva: checkbox + barra flotante ============
   ===================================================================== */

/* Checkbox de selección dentro de filas */
.bulk-check {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    flex: 0 0 auto;
}
.bulk-check:hover { border-color: var(--gold); }
.bulk-check:checked {
    background: var(--gold);
    border-color: var(--gold);
}
.bulk-check:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid var(--moss);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
/* Cabecera "select-all" más grande */
.bulk-check--head {
    width: 16px;
    height: 16px;
}

/* Fila resaltada cuando está seleccionada */
.bulk-row-selected {
    background: color-mix(in srgb, var(--gold) 8%, transparent) !important;
}

/* Barra flotante de acciones masivas */
.bulk-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 200;
    background: var(--moss);
    border: 1px solid var(--gold);
    border-radius: 50px;
    padding: 10px 14px 10px 22px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
    max-width: calc(100vw - 32px);
    /* Inerte cuando está oculta: ni recibe clicks ni tapa nada */
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}
.bulk-bar.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}
.bulk-bar-count {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    color: var(--cream);
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.bulk-bar-count strong {
    color: var(--gold);
    font-weight: 500;
}
.bulk-bar-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.bulk-bar-actions .btn {
    padding: 8px 14px;
    font-size: 11px;
    border-radius: 30px;
}
.bulk-bar-clear {
    background: transparent;
    color: var(--cream-dim);
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-left: 1px solid var(--border);
    margin-left: 4px;
}
.bulk-bar-clear:hover { color: var(--cream); }

/* Móvil: la barra es más compacta y wrappea */
@media (max-width: 720px) {
    .bulk-bar {
        bottom: 12px;
        left: 12px;
        right: 12px;
        transform: translateY(120%);
        border-radius: 14px;
        padding: 12px 14px;
        flex-wrap: wrap;
        max-width: none;
    }
    .bulk-bar.is-visible {
        transform: translateY(0);
    }
    .bulk-bar-count { width: 100%; margin-bottom: 4px; }
    .bulk-bar-clear { border-left: none; margin-left: auto; }
}

/* Cabecera de tabla con checkbox: ajusto pm-row--head para que reserve espacio */
.pm-row--head .bulk-check-wrap,
.pm-row .bulk-check-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Cuando hay checkboxes (data-bulk-table presente), añadimos columna al inicio del grid */
.pm-table[data-bulk-table] .pm-head,
.pm-table[data-bulk-table] .pm-row {
    grid-template-columns: 28px 36px 90px 1fr 110px 130px 110px 70px;
}

/* En móvil oculto la cabecera y muevo el checkbox a la esquina */
@media (max-width: 720px) {
    .pm-table[data-bulk-table] .pm-head { display: none; }
    .pm-table[data-bulk-table] .pm-row {
        position: relative;
        padding-left: 38px !important;
    }
    .pm-table[data-bulk-table] .pm-row .bulk-check-wrap {
        position: absolute;
        top: 16px;
        left: 12px;
        z-index: 1;
    }
}

/* ============ Bulk para tabla bancaria (tx) ============ */
.tx-table[data-bulk-table] .tx-head,
.tx-table[data-bulk-table] .tx-row {
    grid-template-columns: 28px 100px 1fr 150px 110px 50px;
}
@media (max-width: 1100px) {
    .tx-table[data-bulk-table] .tx-head,
    .tx-table[data-bulk-table] .tx-row {
        grid-template-columns: 28px 70px 1fr 100px 90px 40px;
        padding: 14px 16px;
        gap: 10px;
    }
}
@media (max-width: 720px) {
    .tx-table[data-bulk-table] .tx-head { display: none; }
    .tx-table[data-bulk-table] .tx-row {
        position: relative;
        padding-left: 44px !important;
    }
    .tx-table[data-bulk-table] .tx-row .bulk-check-wrap {
        position: absolute;
        top: 14px;
        left: 14px;
        z-index: 1;
    }
}

/* ============ Bulk para fijos recurrentes ============ */
.rec-table[data-bulk-table] .rec-head,
.rec-table[data-bulk-table] .rec-row {
    grid-template-columns: 28px 36px 1.4fr 130px 120px 70px 140px 110px 70px;
}
@media (max-width: 1100px) {
    .rec-table[data-bulk-table] .rec-head { display: none; }
    .rec-table[data-bulk-table] .rec-row {
        position: relative;
        padding-left: 44px !important;
    }
    .rec-table[data-bulk-table] .rec-row .bulk-check-wrap {
        position: absolute;
        top: 14px;
        left: 14px;
        z-index: 1;
    }
}

/* ============ Modal de creación masiva ============ */
.modal--wide { max-width: 1100px !important; }
.bulk-create-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
    margin: 12px 0 16px;
    padding-right: 4px;
}
.bulk-create-row {
    display: grid;
    gap: 8px;
    padding: 10px;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    align-items: end;
}
/* Layout para movimientos del mes */
.bulk-create-row--mov {
    grid-template-columns: 90px 130px 110px 1fr 130px 130px 80px 36px;
}
/* Layout para fijos */
.bulk-create-row--rec {
    grid-template-columns: 90px 1fr 110px 60px 110px 130px 130px 36px;
}
.bulk-create-row .field-input,
.bulk-create-row .field-select {
    padding: 8px 10px;
    font-size: 13px;
    margin: 0;
}
.bulk-create-row label {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}
.bulk-create-row .bulk-row-del {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: var(--cream-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.bulk-create-row .bulk-row-del:hover {
    color: var(--danger);
    border-color: var(--danger);
}
.bulk-create-add-row {
    display: flex;
    justify-content: center;
    padding: 8px;
}
.bulk-create-summary {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 8px;
}
.bulk-create-errors {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 12px 0;
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.6;
}
.bulk-create-errors-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--danger);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* Móvil: filas verticales con etiquetas */
@media (max-width: 720px) {
    .modal--wide { max-width: 100% !important; }
    .bulk-create-row,
    .bulk-create-row--mov,
    .bulk-create-row--rec {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px;
    }
    .bulk-create-row > div:last-child {
        grid-column: 1 / -1;
        display: flex;
        justify-content: flex-end;
    }
    .bulk-create-table { max-height: none; }
}

/* =====================================================================
   ============ Temas adicionales (settings) ============
   ===================================================================== */

:root[data-theme="midnight"] {
    --moss:          #141414;
    --moss-deep:     #0a0a0a;
    --forest:        #1f1f1f;
    --forest-light:  #2a2a2a;
    --gold:          #d4a93a;
    --gold-bright:   #f0c25c;
    --cream:         #f5f1e8;
    --cream-dim:     #a8a29e;
    --border:        rgba(212, 169, 58, 0.18);
    --border-hover:  rgba(212, 169, 58, 0.45);
    --success:       #84cc66;
    --danger:        #e87a64;
    --warning:       #f0c25c;
    --bubble-grad-from: #1f1f1f;
    --bubble-grad-to:   #141414;
    --bg-radial-1: rgba(212, 169, 58, 0.05);
    --bg-radial-2: rgba(31, 31, 31, 0.4);
    --bg-dot: rgba(212, 169, 58, 0.02);
}

:root[data-theme="slate-blue"] {
    --moss:          #1a2332;
    --moss-deep:     #0f1825;
    --forest:        #2a3548;
    --forest-light:  #3d4a62;
    --gold:          #d4a554;
    --gold-bright:   #e6bc6e;
    --cream:         #e8eef5;
    --cream-dim:     #94a3b8;
    --border:        rgba(212, 165, 84, 0.18);
    --border-hover:  rgba(212, 165, 84, 0.45);
    --success:       #4ade80;
    --danger:        #f87171;
    --warning:       #fbbf24;
    --bubble-grad-from: #2a3548;
    --bubble-grad-to:   #1a2332;
    --bg-radial-1: rgba(212, 165, 84, 0.05);
    --bg-radial-2: rgba(42, 53, 72, 0.4);
    --bg-dot: rgba(212, 165, 84, 0.02);
}

/* ============ Fuentes de TÍTULOS ============ */
:root[data-font-title="inter"] {
    --font-title: 'Inter', sans-serif;
}
:root[data-font-title="helvetica"] {
    --font-title: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
:root[data-font-title="cormorant"] {
    --font-title: 'DM Sans', system-ui, sans-serif;
}
:root[data-font-title="playfair"] {
    --font-title: 'Playfair Display', serif;
}
:root[data-font-title="dmsans-bold"] {
    --font-title: 'DM Sans', sans-serif;
}
:root {
    --font-title: 'Inter', sans-serif; /* default */
}

/* Aplicar fuente de títulos a todos los elementos que la usan */
h1, h2, h3, .page-title, .panel-title, .modal-title,
.year-card-title, .month-card-title, .brand-text {
    font-family: var(--font-title) !important;
}

/* Inter como título: peso medio, ligero tracking negativo, SIN cursivas dorada */
:root[data-font-title="inter"] h1,
:root[data-font-title="inter"] h2,
:root[data-font-title="inter"] h3,
:root[data-font-title="inter"] .page-title,
:root[data-font-title="inter"] .panel-title,
:root[data-font-title="inter"] .modal-title,
:root[data-font-title="inter"] .tfhome-header-left h1,
:root[data-font-title="inter"] .tfcard-name,
:root[data-font-title="inter"] .detail-pane-title,
:root[data-font-title="inter"] .detail-sidebar-title {
    font-weight: 600;
    letter-spacing: -0.022em;
    font-style: normal;
}
/* Itálicas con palabra dorada (em) → en Inter no van con cursiva, solo color */
:root[data-font-title="inter"] h1 em,
:root[data-font-title="inter"] h2 em,
:root[data-font-title="inter"] .page-title em,
:root[data-font-title="inter"] .panel-title em,
:root[data-font-title="inter"] .modal-title em,
:root[data-font-title="inter"] .tfhome-header-left h1 em,
:root[data-font-title="inter"] .tfcard-name em,
:root[data-font-title="inter"] .detail-pane-title em {
    font-style: normal;
    color: var(--tf-accent, var(--gold));
    font-weight: inherit;
}

:root[data-font-title="dmsans-bold"] h1,
:root[data-font-title="dmsans-bold"] h2,
:root[data-font-title="dmsans-bold"] h3,
:root[data-font-title="dmsans-bold"] .page-title,
:root[data-font-title="dmsans-bold"] .panel-title,
:root[data-font-title="dmsans-bold"] .modal-title,
:root[data-font-title="dmsans-bold"] .year-card-title,
:root[data-font-title="dmsans-bold"] .month-card-title,
:root[data-font-title="dmsans-bold"] .brand-text {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Helvetica Neue como título: peso medio, espaciado ligero, sin itálicas */
:root[data-font-title="helvetica"] h1,
:root[data-font-title="helvetica"] h2,
:root[data-font-title="helvetica"] h3,
:root[data-font-title="helvetica"] .page-title,
:root[data-font-title="helvetica"] .panel-title,
:root[data-font-title="helvetica"] .modal-title,
:root[data-font-title="helvetica"] .year-card-title,
:root[data-font-title="helvetica"] .month-card-title,
:root[data-font-title="helvetica"] .brand-text,
:root[data-font-title="helvetica"] .tfhome-header-left h1,
:root[data-font-title="helvetica"] .tfcard-name,
:root[data-font-title="helvetica"] .detail-pane-title,
:root[data-font-title="helvetica"] .detail-sidebar-title {
    font-weight: 500;
    letter-spacing: -0.01em;
    font-style: normal;
}
/* En este tema las cursivas de Cormorant (em) quedarían raras, las quito */
:root[data-font-title="helvetica"] h1 em,
:root[data-font-title="helvetica"] h2 em,
:root[data-font-title="helvetica"] .page-title em,
:root[data-font-title="helvetica"] .panel-title em,
:root[data-font-title="helvetica"] .modal-title em,
:root[data-font-title="helvetica"] .tfhome-header-left h1 em,
:root[data-font-title="helvetica"] .tfcard-name em,
:root[data-font-title="helvetica"] .detail-pane-title em {
    font-style: normal;
    color: var(--tf-accent, var(--gold));
    font-weight: inherit;
}
/* Lo mismo cuando dmsans-bold es título */
:root[data-font-title="dmsans-bold"] h1 em,
:root[data-font-title="dmsans-bold"] h2 em,
:root[data-font-title="dmsans-bold"] .page-title em,
:root[data-font-title="dmsans-bold"] .panel-title em,
:root[data-font-title="dmsans-bold"] .modal-title em {
    font-style: normal;
    color: var(--tf-accent, var(--gold));
}

/* ============ Fuentes del CUERPO ============ */
:root[data-font-body="dmsans"] body { font-family: 'DM Sans', sans-serif; }
:root[data-font-body="inter"] body { font-family: 'Inter', sans-serif; font-weight: 450; }
:root[data-font-body="helvetica"] body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
:root[data-font-body="system"] body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ============ Tamaño de texto base ============ */
/* Aplicamos via font-size de :root, pero como muchos elementos usan px
   absolutos, también aplicamos un transform sutil al body. La opción más
   limpia es usar zoom en navegadores que lo soportan. */
:root[data-font-size="compact"]     body { zoom: 0.92; }
:root[data-font-size="normal"]      body { zoom: 1; }
:root[data-font-size="comfortable"] body { zoom: 1.10; }
/* Fallback usando font-size para los elementos heredables */
:root[data-font-size="compact"]     { font-size: 14px; }
:root[data-font-size="normal"]      { font-size: 16px; }
:root[data-font-size="comfortable"] { font-size: 18px; }

/* ============ Densidad de tablas ============ */
:root[data-density="compact"] .pm-row,
:root[data-density="compact"] .tx-row,
:root[data-density="compact"] .rec-row,
:root[data-density="compact"] .pc-row {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
}
:root[data-density="loose"] .pm-row,
:root[data-density="loose"] .tx-row,
:root[data-density="loose"] .rec-row,
:root[data-density="loose"] .pc-row {
    padding-top: 18px !important;
    padding-bottom: 18px !important;
}

/* =====================================================================
   ============ Botón engranaje + Modal de configuración ============
   ===================================================================== */
.settings-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    color: var(--cream);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}
.settings-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    transform: rotate(30deg);
}
.settings-btn svg { stroke-width: 1.5; }

/* Sección dentro del modal */
.settings-section {
    margin: 18px 0 24px;
}
.settings-section-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Grid de opciones */
.settings-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}
.settings-options--small {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* Botón de cada opción */
.settings-option {
    background: var(--moss-deep);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 14px 14px 12px;
    cursor: pointer;
    text-align: left;
    color: var(--cream);
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-option:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
}
.settings-option.is-active {
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, var(--moss-deep));
    box-shadow: 0 0 0 1px var(--gold) inset;
}
.settings-option-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--cream);
    line-height: 1.2;
}
.settings-option-desc {
    font-size: 11px;
    color: var(--cream-dim);
    line-height: 1.4;
}

/* Swatch de tema (mini cuadrado de color) */
.settings-swatch {
    width: 100%;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

/* Preview de fuente (Aa grande) */
.settings-option-preview {
    font-size: 22px;
    line-height: 1;
    margin-bottom: 4px;
    color: var(--gold);
}

/* Móvil: 2 columnas */
@media (max-width: 720px) {
    .settings-options,
    .settings-options--small {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .settings-option {
        padding: 10px;
    }
    .settings-option-label { font-size: 12px; }
    .settings-option-desc  { font-size: 10px; }
}

/* =====================================================================
   ============ MEJORAS BURBUJAS DE EMPRESAS/PROYECTOS ============
   ===================================================================== */

/* DESKTOP — el título escala según longitud, sin recortes */
@media (min-width: 721px) {
    .bubble {
        max-width: 260px;
        min-height: 240px;
        padding: 28px 24px;
    }
    .bubble-title {
        font-size: clamp(20px, 2.2vw, 30px);
        line-height: 1.05;
        word-break: break-word;
        hyphens: auto;
    }
    /* Si el nombre es largo (3+ palabras) usar tamaño aún más reducido */
    .bubble[data-long-name="1"] .bubble-title {
        font-size: clamp(18px, 1.8vw, 24px);
    }
}

/* MÓVIL — burbujas se transforman en tarjetas rectangulares amplias.
   Esto resuelve el problema de "Holding Invest SLU" o "Personal Susin Gonzalez"
   que se cortaban arriba y abajo dentro del círculo. */
@media (max-width: 720px) {
    /* Grid de burbujas: 2 columnas en móvil */
    .bubbles-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 14px !important;
        max-width: 100% !important;
    }

    /* La burbuja deja de ser circular y pasa a ser un card rectangular */
    .bubble {
        aspect-ratio: auto !important;          /* libera de la forma cuadrada */
        max-width: none !important;
        width: 100% !important;
        min-height: 200px;
        border-radius: 22px !important;          /* esquinas suaves, no círculo */
        padding: 22px 18px !important;
        justify-content: flex-start !important;  /* contenido arriba, no centrado */
        align-items: flex-start !important;
        text-align: left !important;
        gap: 8px;
        justify-self: stretch !important;
    }

    /* El gradiente decorativo también deja de ser círculo */
    .bubble::before {
        border-radius: 22px !important;
    }

    /* Título: tamaño legible y multilínea */
    .bubble-title {
        font-size: 24px !important;
        line-height: 1.15 !important;
        margin-bottom: 8px !important;
        word-break: break-word;
        hyphens: auto;
    }

    /* Divider más sobrio en card */
    .bubble-divider {
        margin: 6px 0 !important;
        opacity: 0.3;
    }

    .bubble-meta {
        margin-top: auto;       /* empuja "X cuentas" + balance al fondo del card */
    }
    .bubble-stat {
        font-size: 12px !important;
    }
    .bubble-stat strong {
        font-size: 14px;
    }

    /* Acciones (editar/eliminar) siempre visibles en móvil — el hover no existe */
    .bubble-actions {
        opacity: 1 !important;
        top: 12px !important;
        right: 12px !important;
    }
    .bubble-action {
        width: 28px;
        height: 28px;
    }

    /* Sin transform al "hover" — móvil no tiene hover real */
    .bubble:hover {
        transform: none !important;
    }
}

/* MÓVIL MUY ESTRECHO (<420px): una sola columna, cards más amplios */
@media (max-width: 420px) {
    .bubbles-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .bubble {
        min-height: 140px !important;
        padding: 20px 18px !important;
    }
    .bubble-title {
        font-size: 26px !important;
    }
}

/* También mejoramos cuentas bancarias dentro de una empresa (.bubbles-grid--banks) */
@media (max-width: 720px) {
    .bubbles-grid--banks {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 14px !important;
    }
}
@media (max-width: 420px) {
    .bubbles-grid--banks {
        grid-template-columns: 1fr !important;
    }
}


/* ================================================================
 * CALENDARIO TRIBUTARIO
 * ================================================================ */

.tax-notice {
    background: linear-gradient(135deg, rgba(184, 151, 106, 0.08), rgba(184, 151, 106, 0.02));
    border-left: 3px solid var(--gold);
    padding: 16px 22px;
    margin: 0 0 28px 0;
    border-radius: 4px;
}
.tax-notice-label {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-style: italic;
    font-size: 14px;
    color: var(--gold);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.tax-notice p {
    color: var(--cream-dim);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

.tax-year-nav {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-right: 24px;
}
.tax-year-current {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 28px;
    color: var(--gold);
    font-weight: 600;
    letter-spacing: 1px;
}
.tax-year-arrow {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    color: var(--cream-dim);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.tax-year-arrow:hover {
    color: var(--gold);
    background: rgba(184, 151, 106, 0.06);
}

.filter-chip {
    --chip-color: var(--gold);
    text-decoration: none;
}
.filter-chip.is-active {
    border-color: var(--chip-color);
    background: color-mix(in srgb, var(--chip-color) 15%, transparent);
}

/* Grid de meses */
.tax-months-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.tax-month-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: border-color 0.18s ease;
}
.tax-month-card:hover {
    border-color: var(--border-hover);
}
.tax-month-card.is-empty {
    opacity: 0.5;
}
.tax-month-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 14px;
}
.tax-month-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    color: var(--gold);
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
}
.tax-month-count {
    font-size: 12px;
    color: var(--cream-dim);
    background: rgba(184, 151, 106, 0.1);
    padding: 3px 10px;
    border-radius: 999px;
}
.tax-month-empty {
    font-size: 12px;
    color: var(--cream-dim);
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}
.tax-month-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tax-event {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(184, 151, 106, 0.04);
    border-left: 2px solid var(--gold);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.tax-event:hover {
    background: rgba(184, 151, 106, 0.10);
    transform: translateX(2px);
}
.tax-event.is-done {
    opacity: 0.5;
    border-left-color: var(--success);
    text-decoration: line-through;
    text-decoration-color: rgba(126, 168, 106, 0.6);
}
.tax-event.is-overdue:not(.is-done) {
    border-left-color: var(--danger);
    background: rgba(199, 119, 102, 0.08);
}
.tax-event.is-urgent:not(.is-done):not(.is-overdue) {
    border-left-color: var(--danger);
}
.tax-event.is-warning:not(.is-done):not(.is-overdue):not(.is-urgent) {
    border-left-color: var(--warning);
}

.tax-event-day {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 26px;
    color: var(--gold);
    font-weight: 700;
    min-width: 32px;
    line-height: 1;
}
.tax-event-body {
    flex: 1;
    min-width: 0;
}
.tax-event-title {
    font-size: 13px;
    color: var(--cream);
    line-height: 1.35;
    font-weight: 500;
    margin-bottom: 3px;
}
.tax-event-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--cream-dim);
    flex-wrap: wrap;
}
.tax-event-model {
    color: var(--gold);
    font-weight: 500;
}
.tax-event-period {
    font-style: italic;
}
.tax-event-badge {
    font-size: 10px;
    color: #fff;
    padding: 4px 9px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---------- Calendario visual mensual (rejilla navegable) ---------- */
.tax-cal {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-top: 24px;
}
.tax-cal-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 16px;
}
.tax-cal-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    color: var(--gold);
    font-weight: 600;
    margin: 0;
    min-width: 200px;
    text-align: center;
    letter-spacing: 0.5px;
}
.tax-cal-nav {
    background: rgba(184, 151, 106, 0.08);
    border: 1px solid var(--border);
    color: var(--gold);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.tax-cal-nav:hover {
    background: rgba(184, 151, 106, 0.16);
    border-color: var(--border-hover);
}
.tax-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 6px;
}
.tax-cal-weekdays span {
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--cream-dim);
    font-weight: 600;
    padding: 4px 0;
}
.tax-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}
.tax-cal-cell {
    min-height: 92px;
    background: rgba(184, 151, 106, 0.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}
.tax-cal-cell.is-blank {
    background: transparent;
    border-color: transparent;
}
.tax-cal-cell.has-events {
    background: rgba(184, 151, 106, 0.06);
}
.tax-cal-cell.is-today {
    border-color: var(--gold);
    box-shadow: inset 0 0 0 1px var(--gold);
}
.tax-cal-daynum {
    font-size: 13px;
    font-weight: 600;
    color: var(--cream-dim);
    line-height: 1;
}
.tax-cal-cell.is-today .tax-cal-daynum {
    color: var(--gold);
}
.tax-cal-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}
.tax-cal-chip {
    display: block;
    width: 100%;
    text-align: left;
    font-size: 10.5px;
    line-height: 1.25;
    color: #fff;
    background: var(--chip, var(--gold));
    border: none;
    border-left: 3px solid rgba(0, 0, 0, 0.28);
    border-radius: 4px;
    padding: 3px 6px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: filter 0.15s ease;
}
.tax-cal-chip:hover {
    filter: brightness(1.12);
}
.tax-cal-chip.is-done {
    opacity: 0.5;
    text-decoration: line-through;
}
.tax-cal-chip.is-overdue {
    box-shadow: 0 0 0 1px var(--danger);
}
@media (max-width: 640px) {
    .tax-cal { padding: 12px; }
    .tax-cal-title { font-size: 18px; min-width: 140px; }
    .tax-cal-weekdays { gap: 3px; }
    .tax-cal-weekdays span { font-size: 9px; }
    .tax-cal-grid { gap: 3px; }
    .tax-cal-cell { min-height: 60px; padding: 3px; gap: 2px; }
    .tax-cal-daynum { font-size: 11px; }
    .tax-cal-chip { font-size: 8.5px; padding: 2px 4px; border-left-width: 2px; }
}

/* Modal de detalle - se monta dentro de .modal estándar */
.modal--tax {
    max-width: 680px;
    padding: 0 !important;          /* el head/body internos llevan su propio padding */
    overflow: hidden;
}
.modal--tax .modal-close {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.2);
    z-index: 2;
}
.modal--tax .modal-close:hover {
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    border-color: transparent;
}
.tax-modal-loading {
    padding: 60px;
    text-align: center;
    color: var(--cream-dim);
    font-style: italic;
}
.tax-modal-head {
    padding: 28px 32px 24px;
    color: #fff;
}
.tax-modal-entity {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 10px;
}
.tax-modal-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 28px;
    font-weight: 500;
    margin: 0 0 8px 0;
    line-height: 1.2;
    color: #fff;
    padding-right: 40px;
}
.tax-modal-model {
    font-size: 13px;
    font-style: italic;
    opacity: 0.85;
}
.tax-modal-bodyx {
    padding: 8px 32px 16px;
}
.tax-modal-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 18px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.tax-modal-row:last-child { border-bottom: none; }
.tax-modal-row-label {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-style: italic;
    color: var(--gold);
    font-size: 14px;
}
.tax-modal-row-value {
    font-size: 14px;
    color: var(--cream);
    line-height: 1.55;
}
.tax-modal-row-value a { color: var(--gold); }
.tax-modal-confirmed {
    color: var(--success);
    font-size: 11px;
    margin-left: 8px;
    font-weight: 500;
}
.tax-modal-orientative {
    color: var(--cream-dim);
    font-size: 11px;
    margin-left: 8px;
    font-style: italic;
}
.tax-modal-list {
    margin: 0;
    padding-left: 18px;
}
.tax-modal-list li {
    margin-bottom: 4px;
}
.tax-modal-steps {
    counter-reset: tax-step;
    list-style: decimal;
}
.tax-modal-steps li {
    margin-bottom: 6px;
    line-height: 1.5;
}
.tax-modal-actions {
    padding: 16px 32px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    background: rgba(184, 151, 106, 0.03);
}

/* Vista de entidad */
.tax-entity-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 24px;
}
.tax-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.tax-card-head {
    padding: 22px 28px;
    color: #fff;
}
.tax-card-head-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 6px;
}
.tax-card-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    line-height: 1.25;
    flex: 1;
}
.tax-card-cat {
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    white-space: nowrap;
}
.tax-card-model {
    font-size: 13px;
    font-style: italic;
    opacity: 0.85;
}
.tax-card-body {
    padding: 22px 28px;
}
.tax-card-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 18px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.tax-card-row:last-child { border-bottom: none; }
.tax-card-label {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-style: italic;
    color: var(--gold);
    font-size: 14px;
}
.tax-card-value {
    font-size: 14px;
    color: var(--cream);
    line-height: 1.6;
}
.tax-card-value--accent {
    color: var(--gold);
    font-weight: 500;
}
.tax-card-list {
    margin: 0;
    padding-left: 18px;
}
.tax-card-list li {
    margin-bottom: 5px;
}
.tax-card-link {
    color: var(--gold);
    text-decoration: none;
    font-weight: 500;
}
.tax-card-link:hover {
    text-decoration: underline;
}

@media (max-width: 720px) {
    .tax-months-grid { grid-template-columns: 1fr; gap: 12px; }
    .tax-modal-row, .tax-card-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .tax-modal-head, .tax-modal-bodyx, .tax-modal-actions,
    .tax-card-head, .tax-card-body { padding-left: 18px; padding-right: 18px; }
    .tax-event-day { font-size: 22px; min-width: 26px; }
    .tax-year-nav { margin-right: 0; margin-bottom: 8px; }
}


/* ================================================================
 * WIDGET CALENDARIO TRIBUTARIO (en la home de cada empresa)
 * ================================================================ */

.tax-widget {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    margin-top: 32px;
    margin-bottom: 24px;
}

.tax-widget-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.tax-widget-eyebrow {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--cream-dim);
    margin-bottom: 6px;
}

.tax-widget-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 32px;
    font-weight: 400;
    color: var(--cream);
    margin: 0;
    line-height: 1;
}

.tax-widget-title em { color: var(--gold); font-style: italic; }

.tax-widget-stats {
    display: flex;
    gap: 24px;
}
.tax-widget-stat {
    text-align: right;
}
.tax-widget-stat-value {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 28px;
    color: var(--gold);
    font-weight: 600;
    line-height: 1;
}
.tax-widget-stat-label {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--cream-dim);
    margin-top: 4px;
}

.tax-widget-unlinked,
.tax-widget-empty {
    text-align: center;
    padding: 32px 20px;
    color: var(--cream-dim);
}
.tax-widget-unlinked p,
.tax-widget-empty p {
    margin: 0 0 16px 0;
    font-size: 14px;
}

.tax-widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tax-widget-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(184, 151, 106, 0.04);
    border-left: 2px solid var(--gold);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.tax-widget-item:hover {
    background: rgba(184, 151, 106, 0.10);
    transform: translateX(2px);
}
.tax-widget-item.is-warning { border-left-color: var(--warning); }
.tax-widget-item.is-urgent  { border-left-color: var(--danger); }

.tax-widget-date {
    text-align: center;
    min-width: 44px;
    line-height: 1;
}
.tax-widget-date-day {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 28px;
    color: var(--gold);
    font-weight: 700;
}
.tax-widget-date-mon {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--cream-dim);
    margin-top: 2px;
}

.tax-widget-body {
    flex: 1;
    min-width: 0;
}
.tax-widget-item-title {
    font-size: 14px;
    color: var(--cream);
    line-height: 1.35;
    font-weight: 500;
    margin-bottom: 3px;
}
.tax-widget-item-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--cream-dim);
    flex-wrap: wrap;
}
.tax-widget-item-model {
    color: var(--gold);
    font-weight: 500;
}
.tax-widget-item-period { font-style: italic; }

.tax-widget-days {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cream-dim);
    white-space: nowrap;
    flex-shrink: 0;
}
.tax-widget-days.is-overdue { color: var(--danger); font-weight: 600; }
.tax-widget-item.is-urgent .tax-widget-days { color: var(--danger); }
.tax-widget-item.is-warning .tax-widget-days { color: var(--warning); }

.tax-widget-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* ================================================================
 * Modal "ver todo el año" — versión refinada
 * ================================================================ */
.modal--tax-all {
    max-width: 720px;
    padding: 0 !important;             /* anula padding del .modal estándar */
    overflow: hidden;
    border: 1px solid var(--border-hover);
    background: var(--moss);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}

.tax-all-head {
    padding: 26px 32px 22px;
    color: #fff;
    position: relative;
    background: linear-gradient(180deg,
        var(--tax-head-color, #4F5B3A) 0%,
        color-mix(in srgb, var(--tax-head-color, #4F5B3A) 88%, #000) 100%);
}

.modal--tax-all .modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid transparent;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
}
.modal--tax-all .modal-close:hover {
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border-color: transparent;
}

.tax-all-eyebrow {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.78;
    margin-bottom: 6px;
}

.tax-all-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 28px;
    font-weight: 500;
    margin: 0;
    color: #fff;
    padding-right: 50px;
    line-height: 1.15;
    letter-spacing: 0.2px;
}

.tax-all-body {
    padding: 0;
    max-height: calc(90vh - 110px);
    overflow-y: auto;
    background: var(--moss);
}

/* Scrollbar más fina y discreta */
.tax-all-body::-webkit-scrollbar { width: 8px; }
.tax-all-body::-webkit-scrollbar-track { background: transparent; }
.tax-all-body::-webkit-scrollbar-thumb {
    background: rgba(184, 151, 106, 0.18);
    border-radius: 4px;
}
.tax-all-body::-webkit-scrollbar-thumb:hover {
    background: rgba(184, 151, 106, 0.32);
}

.tax-all-list {
    display: flex;
    flex-direction: column;
}

.tax-all-month {
    border-bottom: 1px solid var(--border);
}
.tax-all-month:last-child { border-bottom: none; }

.tax-all-month-name {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-style: italic;
    font-size: 16px;
    color: var(--gold);
    letter-spacing: 0.4px;
    padding: 14px 28px 8px;
    background: rgba(184, 151, 106, 0.025);
    position: sticky;
    top: 0;
    z-index: 1;
    backdrop-filter: blur(4px);
}

.tax-all-month-items {
    list-style: none;
    padding: 4px 16px 14px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tax-all-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-left: 2px solid transparent;
}
.tax-all-item:hover {
    background: rgba(184, 151, 106, 0.07);
    border-left-color: var(--gold);
}
.tax-all-item.is-done {
    opacity: 0.5;
}
.tax-all-item.is-done:hover { border-left-color: var(--success); }
.tax-all-item.is-overdue:not(.is-done) {
    background: rgba(199, 119, 102, 0.05);
}
.tax-all-item.is-overdue:not(.is-done):hover {
    border-left-color: var(--danger);
    background: rgba(199, 119, 102, 0.10);
}

.tax-all-day {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 26px;
    color: var(--gold);
    font-weight: 700;
    min-width: 36px;
    text-align: center;
    line-height: 1;
    flex-shrink: 0;
}

.tax-all-body-info {
    flex: 1;
    min-width: 0;
}
.tax-all-title-line {
    font-size: 13.5px;
    color: var(--cream);
    line-height: 1.35;
    font-weight: 500;
    margin-bottom: 3px;
}
.tax-all-meta {
    font-size: 11px;
    color: var(--cream-dim);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.tax-all-model { color: var(--gold); font-weight: 500; }
.tax-all-period { font-style: italic; }
.tax-all-meta-sep { opacity: 0.4; }

.tax-all-status {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--success);
    flex-shrink: 0;
    padding: 4px 10px;
    background: rgba(126, 168, 106, 0.10);
    border-radius: 999px;
}

@media (max-width: 720px) {
    .tax-widget { padding: 20px 16px; }
    .tax-widget-header { gap: 12px; }
    .tax-widget-stats { gap: 14px; }
    .tax-widget-stat-value { font-size: 22px; }
    .tax-widget-title { font-size: 24px; }
    .tax-widget-item { padding: 10px 12px; gap: 10px; }
    .tax-widget-date { min-width: 36px; }
    .tax-widget-date-day { font-size: 22px; }
    .tax-all-head { padding: 22px 22px 18px; }
    .tax-all-title { font-size: 22px; padding-right: 44px; }
    .tax-all-month-name { padding: 12px 18px 6px; font-size: 15px; }
    .tax-all-month-items { padding: 4px 8px 12px; }
    .tax-all-item { padding: 9px 10px; gap: 10px; }
    .tax-all-day { font-size: 22px; min-width: 28px; }
    .tax-all-title-line { font-size: 13px; }
}


/* ================================================================
 * Cabecera del widget: entidad vinculada + botón cambiar
 * ================================================================ */
.tax-widget-head-left {
    flex: 1;
    min-width: 0;
}
.tax-widget-entity-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--cream-dim);
}
.tax-widget-entity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tax-widget-entity-name {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--cream);
}
.tax-widget-entity-edit {
    background: none;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-family: 'DM Mono', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    margin-left: 6px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tax-widget-entity-edit:hover {
    color: var(--gold);
    border-color: var(--gold);
    background: rgba(184, 151, 106, 0.06);
}

/* Footer con link de gestionar */
.tax-widget-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.tax-widget-manage-link {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--cream-dim);
    text-decoration: none;
    transition: color 0.15s;
}
.tax-widget-manage-link:hover {
    color: var(--gold);
}

/* ================================================================
 * Vista "Gestionar obligaciones"
 * ================================================================ */
.tax-manage-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 24px;
}
.tax-manage-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.tax-manage-card:hover { border-color: var(--border-hover); }
.tax-manage-card.is-inactive { opacity: 0.55; }

.tax-manage-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 20px 14px;
    border-left: 3px solid var(--gold);
    background: rgba(184, 151, 106, 0.03);
}
.tax-manage-head-info { flex: 1; min-width: 0; }
.tax-manage-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--cream);
    margin: 0 0 8px 0;
    line-height: 1.25;
}
.tax-manage-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}
.tax-manage-cat {
    color: #fff;
    padding: 3px 9px;
    border-radius: 999px;
    font-family: 'DM Mono', monospace;
    letter-spacing: 0.5px;
    font-size: 10px;
    font-weight: 500;
}
.tax-manage-model {
    color: var(--gold);
    font-weight: 500;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
}
.tax-manage-rec {
    color: var(--cream-dim);
    font-style: italic;
    font-size: 12px;
}
.tax-manage-tag {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    padding: 3px 9px;
    border-radius: 999px;
}
.tax-manage-tag--off {
    background: rgba(199, 119, 102, 0.15);
    color: var(--danger);
}
.tax-manage-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.tax-manage-del {
    color: var(--danger) !important;
}
.tax-manage-del:hover {
    background: rgba(199, 119, 102, 0.10) !important;
    border-color: var(--danger) !important;
}
.tax-manage-body {
    padding: 14px 20px 18px;
}
.tax-manage-desc {
    color: var(--cream);
    font-size: 13px;
    line-height: 1.55;
    margin: 0 0 10px 0;
}
.tax-manage-rule {
    font-size: 12px;
    color: var(--cream-dim);
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.tax-manage-rule strong {
    color: var(--gold);
    font-family: 'DM Sans', system-ui, sans-serif;
    font-style: italic;
    font-weight: 400;
    font-size: 14px;
}

/* Bloques de regla en el modal */
.rule-block {
    background: rgba(184, 151, 106, 0.04);
    border-radius: 6px;
    padding: 14px 16px;
    margin: 12px 0;
}
.rule-help {
    font-size: 12px;
    color: var(--cream-dim);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    line-height: 1.45;
}
.rule-help strong { color: var(--gold); }

.field-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.field-row > .field { min-width: 120px; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--cream);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] { cursor: pointer; }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}
.flash--success {
    background: rgba(126, 168, 106, 0.10);
    color: var(--success);
    border-left: 3px solid var(--success);
}
.flash--error {
    background: rgba(199, 119, 102, 0.10);
    color: var(--danger);
    border-left: 3px solid var(--danger);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--cream-dim);
}
.empty-state p { margin-bottom: 16px; font-size: 14px; }

@media (max-width: 720px) {
    .tax-manage-head { flex-direction: column; }
    .tax-manage-actions { align-self: stretch; justify-content: flex-end; }
    .field-row { flex-direction: column; }
}


/* ================================================================
 * Dropdown del nav (Calendarios)
 * ================================================================ */
.nav-dropdown {
    position: relative;
    display: inline-block;
}
.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--moss);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    padding: 6px;
    min-width: 280px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    /* "Pop" desde el origen (arriba-derecha), curva fuerte (emil) */
    transform-origin: top right;
    transform: translateY(-6px) scale(0.97);
    transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
    z-index: 90;
}
.nav-dropdown.is-open .nav-dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}
/* Menú "teletransportado" a <body> en móvil (ver toggleNavDropdown en app.js).
   Vive fuera del .tfnav con overflow, así escapa del recorte de iOS Safari y
   se ve como una hoja flotante bajo la barra. Se aplica solo cuando JS le pone
   la clase, cosa que únicamente ocurre en móvil. */
body > .nav-dropdown-menu--portal {
    display: block;
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    bottom: auto;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 6px;
    background: var(--moss);
    border: 1px solid var(--border-hover);
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    z-index: 4000;
}
:root[data-theme="light"] body > .nav-dropdown-menu--portal {
    background: var(--moss, #fff);
    border-color: var(--border, rgba(0, 0, 0, 0.1));
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
body > .nav-dropdown-menu--portal .nav-dropdown-item {
    padding-left: 12px;
}
.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 5px;
    color: var(--cream);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s;
}
.nav-dropdown-item:hover {
    background: rgba(184, 151, 106, 0.08);
}
.nav-dropdown-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.nav-dropdown-label {
    flex: 1;
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 15px;
    letter-spacing: 0.2px;
}


/* ================================================================
 * Listado de calendarios (entidades fiscales)
 * ================================================================ */
.tax-entities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
    margin-top: 24px;
}
.tax-entity-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s, transform 0.15s;
}
.tax-entity-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}
.tax-entity-card.is-inactive { opacity: 0.55; }

.tax-entity-card-head {
    padding: 18px 22px 14px;
    color: var(--cream);
    background: transparent;
    border-top: 4px solid var(--head-color, #4F5B3A);
    position: relative;
}
.tax-entity-card-eyebrow {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--cream-dim);
    margin-bottom: 6px;
}
.tax-entity-card-name {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    font-weight: 500;
    margin: 0;
    line-height: 1.2;
    color: var(--cream);
}
.tax-entity-card-ident {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.5px;
    margin-top: 8px;
    color: var(--cream-dim);
}
.tax-entity-card-body { padding: 18px 22px; }

.tax-entity-card-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.tax-entity-card-stat-val {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 26px;
    color: var(--gold);
    font-weight: 600;
    line-height: 1;
}
.tax-entity-card-stat-lab {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--cream-dim);
    margin-top: 4px;
}
.tax-entity-card-notes {
    font-size: 12px;
    color: var(--cream-dim);
    line-height: 1.5;
    margin: 0 0 14px 0;
    padding: 10px 12px;
    background: rgba(184, 151, 106, 0.04);
    border-radius: 4px;
    border-left: 2px solid var(--border);
}
.tax-entity-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Inputs de color (igual que campos normales pero con altura ajustada) */
.field-color {
    height: 42px;
    padding: 4px;
    cursor: pointer;
}

/* Item destacado del dropdown ("Gestionar calendarios") */
.nav-dropdown-item--head {
    background: rgba(184, 151, 106, 0.06);
    color: var(--gold);
}
.nav-dropdown-item--head:hover {
    background: rgba(184, 151, 106, 0.14);
}
.nav-dropdown-item--head .nav-dropdown-label {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.nav-dropdown-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Iconos SVG de línea (helper icon()) — heredan el color del texto. */
.tf-icon {
    display: inline-block;
    vertical-align: -0.15em;
    flex-shrink: 0;
}
.nav-dropdown-icon .tf-icon { vertical-align: middle; }

/* Campana de notificaciones en la barra superior (junto al perfil) */
.tfnav-bell {
    transition: background .15s ease, color .15s ease;
}
.tfnav-bell:hover { background: rgba(255,255,255,.10); }
.tfnav-bell.is-active { background: rgba(255,255,255,.14); }

.nav-dropdown-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 8px;
}


/* ====================================================================
 * REDISEÑO TYPEFORM v1 — paleta clara, nav, home
 * ==================================================================== */

/* --- Paleta clara: blanco puro estilo Typeform --- */
:root[data-theme="light"] {
    /* Fondos blancos */
    --tf-bg:           #ffffff;          /* fondo principal: blanco puro */
    --tf-surface:      #ffffff;          /* tarjetas */
    --tf-surface-2:    #f5f5f4;          /* hover sutil / sidebar items */
    --tf-surface-3:    #ebebe9;          /* paneles activos / inputs hover */

    /* Tinta gris muy oscura, casi-negro pero no puro (estilo Typeform) */
    --tf-text:         #0a0a0a;          /* texto principal — más oscuro para mejor contraste */
    --tf-text-2:       #404040;          /* texto secundario — más oscuro que antes (#525252) */
    --tf-text-3:       #595959;          /* labels, eyebrows — más legibles que #737373 */

    /* Bordes neutros muy sutiles */
    --tf-border:       #e7e5e4;
    --tf-border-2:     #d6d3d1;

    /* Acento verde Typeform característico ("Ver planes") */
    --tf-accent:       #0e7c5a;
    --tf-accent-2:     #0a6346;
    --tf-accent-soft:  #ecfdf5;

    /* Estados */
    --tf-success:      #16a34a;
    --tf-warn:         #ca8a04;
    --tf-danger:       #dc2626;

    /* Reasignar variables existentes para compatibilidad */
    --moss:          var(--tf-surface);
    --moss-deep:     var(--tf-bg);
    --forest:        var(--tf-surface-3);
    --forest-light:  var(--tf-surface-2);
    --gold:          var(--tf-accent);
    --gold-bright:   var(--tf-accent-2);
    --cream:         var(--tf-text);
    --cream-dim:     var(--tf-text-2);
    --border:        var(--tf-border);
    --border-hover:  var(--tf-border-2);
    --success:       var(--tf-success);
    --danger:        var(--tf-danger);
    --warning:       var(--tf-warn);
    --bubble-grad-from: var(--tf-surface);
    --bubble-grad-to:   var(--tf-surface-2);
    --bg-radial-1: transparent;
    --bg-radial-2: transparent;
    --bg-dot: transparent;
}

/* Sin halo radial: fondo blanco limpio */
:root[data-theme="light"] body::before { display: none; }
:root[data-theme="light"] body {
    background: var(--tf-bg);
    color: var(--tf-text);
    /* Inter 450 (peso intermedio entre regular y medium) — más legible que 400 */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 450;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11'; /* alternativas estilísticas Inter */
}

/* ====================================================================
 * NAV v2 — tabs estilo Typeform (igual en claro y oscuro)
 * ==================================================================== */
.tfnav {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 14px 32px;
    padding-top: calc(14px + var(--safe-top, 0px));
    padding-left: calc(32px + var(--safe-left, 0px));
    padding-right: calc(32px + var(--safe-right, 0px));
    background: var(--tf-surface, var(--moss));
    border-bottom: 1px solid var(--tf-border, var(--border));
    position: sticky;
    top: 0;
    z-index: 50;
}
:root:not([data-theme="light"]) .tfnav {
    background: var(--moss);
    border-bottom-color: var(--border);
}

/* Brand */
.tfnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}
.tfnav-brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--tf-accent, var(--gold));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
}

/* Detalle premium: el anillo de Calma "respira" — pulso lento y sereno.
   Plano, sin sombras ni brillos, fiel a la marca. */
.calma-logo-ring {
    transform-origin: 50% 50%;
    animation: calma-breathe 5.5s ease-in-out infinite;
}
@keyframes calma-breathe {
    0%, 100% { opacity: .82; transform: scale(.97); }
    50%      { opacity: 1;   transform: scale(1.03); }
}
@media (prefers-reduced-motion: reduce) {
    .calma-logo-ring { animation: none; }
}

.tfnav-brand-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--tf-text, var(--cream));
    letter-spacing: -0.2px;
}

/* Tabs */
.tfnav-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}
.tfnav-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.tfnav-tab:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
}
.tfnav-tab.is-active {
    color: var(--tf-text, var(--cream));
    font-weight: 600;
}
.tfnav-tab.is-active::after {
    content: '';
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: -15px;
    height: 2px;
    background: var(--tf-text, var(--cream));
    border-radius: 1px;
}
.tfnav-tab-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: currentColor;
}
.tfnav-tab-chevron {
    width: 12px;
    height: 12px;
    opacity: 0.5;
    transition: transform 0.18s;
}
.nav-dropdown.is-open .tfnav-tab-chevron { transform: rotate(180deg); }

/* Right side */
.tfnav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* === Chip de cuenta (Susín · Propietario) ===
   Por defecto va a la DERECHA (tablet/móvil). En escritorio se mueve a la
   IZQUIERDA, pegado a la marca, mediante flex `order`. El menú desplegable
   abre alineado a la izquierda para no salirse por el borde de la pantalla. */
.tfnav > .tfnav-user-chip { order: 5; }
@media (min-width: 1100px) {
    .tfnav > .tfnav-user-chip { order: -1; margin-right: 2px; }
    #nav-dropdown-user .nav-dropdown-menu {
        left: 0;
        right: auto;
        transform-origin: top left;
    }
}

/* === Chip selector de idioma (ES / EN / FR / CA) ===
   Botón compacto con bandera + código del idioma activo y un menú con las
   cuatro opciones. Reutiliza la maquinaria de .nav-dropdown. */
.lang-switcher-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
    color: inherit;
    font: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.lang-switcher-toggle:hover {
    background: rgba(255, 255, 255, .09);
    border-color: rgba(255, 255, 255, .22);
}
.lang-switcher-flag {
    display: inline-block;
    width: 21px;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .09);
    line-height: 0;
}
/* La bandera SVG llena su contenedor (que la recorta a esquinas redondeadas). */
.flag-ico {
    display: block;
    width: 100%;
    height: 100%;
}
.lang-switcher-code {
    letter-spacing: .5px;
}
.lang-switcher .nav-dropdown-menu {
    min-width: 170px;
    right: 0;
    left: auto;
}
.lang-switcher-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Variante PLANA (login / landing): fila de banderas sin desplegable, para
   no depender del JS del nav. */
.lang-switcher-plain {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.lang-switcher-plain-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    color: inherit;
    opacity: .6;
    transition: background .15s ease, opacity .15s ease;
}
.lang-switcher-plain-item:hover {
    background: rgba(0, 0, 0, .06);
    opacity: 1;
}
.lang-switcher-plain-item.is-active {
    opacity: 1;
    background: rgba(184, 151, 106, .14);
    color: var(--gold);
}

/* Toggle tema */
.tfnav-theme {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tf-text-2, var(--cream-dim));
    transition: background 0.15s, color 0.15s;
}
.tfnav-theme:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
}
:root[data-theme="light"] .tfnav-theme .ic-moon { display: block; }
:root[data-theme="light"] .tfnav-theme .ic-sun  { display: none; }
:root:not([data-theme="light"]) .tfnav-theme .ic-moon { display: none; }
:root:not([data-theme="light"]) .tfnav-theme .ic-sun  { display: block; }

/* User pill */
.tfnav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--tf-border, var(--border));
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}
.tfnav-user:hover {
    background: var(--tf-surface-2, var(--forest-light));
    border-color: var(--tf-border-2, var(--border-hover));
}
.tfnav-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--tf-text, var(--cream));
    color: var(--tf-bg, var(--moss));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.3px;
}
.tfnav-user-name {
    font-size: 13px;
    color: var(--tf-text, var(--cream));
    font-weight: 500;
    line-height: 1;
}
.tfnav-user-role {
    font-size: 10px;
    color: var(--tf-text-3, var(--cream-dim));
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 2px;
    /* Una sola línea: el nombre de la organización va primero (en dorado) y el
       rol detrás; si no cabe, se trunca por el final sin partir en dos líneas. */
    display: block;
    max-width: 168px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dropdown del nav (calendarios) — adaptar al estilo */
:root[data-theme="light"] .nav-dropdown-menu {
    background: var(--tf-surface);
    border-color: var(--tf-border-2);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .nav-dropdown-item {
    color: var(--tf-text);
}
:root[data-theme="light"] .nav-dropdown-item:hover {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .nav-dropdown-item--head {
    background: var(--tf-accent-soft);
    color: var(--tf-accent);
}
:root[data-theme="light"] .nav-dropdown-label {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0;
    text-transform: none;
}
:root[data-theme="light"] .nav-dropdown-sep {
    background: var(--tf-border);
}

/* Ocultar topbar vieja cuando se usa la nueva */
.app-using-tfnav .topbar { display: none; }

/* ====================================================================
 * NAV v3 — sidebar lateral izquierdo (Bloque B)
 * El nav deja de ser una barra superior y pasa a ser una columna fija
 * a la izquierda. .layout es el contenedor flex (nav + main).
 * ==================================================================== */
.layout {
    display: flex;
    align-items: stretch;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.layout .tfnav {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    width: 248px;
    flex-shrink: 0;
    /* CAMBIO: antes height:100vh → la barra se quedaba a la altura de UNA
       pantalla y dejaba hueco blanco debajo en páginas largas. Con min-height
       + align-items:stretch del .layout, ahora se ESTIRA hasta el alto del
       contenido y su fondo llega al final de la página. */
    min-height: 100vh;
    align-self: stretch;
    padding: 22px 14px;
    border-bottom: none;
    border-right: 1px solid var(--tf-border, var(--border));
    /* overflow-y:auto + overflow-x:visible obligaba a recortar en horizontal
       (rompía el menú de cuenta). Lo dejamos visible. */
    overflow: visible;
}

/* Marca arriba */
.layout .tfnav-brand { padding: 0 6px 4px; }

/* Tabs apiladas verticalmente, ocupan el alto disponible */
.layout .tfnav-tabs {
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
}
.layout .tfnav-tab {
    width: 100%;
    justify-content: flex-start;
}
/* El indicador activo pasa de subrayado inferior a barra izquierda */
.layout .tfnav-tab.is-active::after {
    left: -14px;
    right: auto;
    top: 6px;
    bottom: 6px;
    width: 3px;
    height: auto;
    border-radius: 0 2px 2px 0;
}
.layout .tfnav-tab.is-active {
    background: var(--tf-surface-2, var(--forest-light));
}
/* Chevron de los desplegables al extremo derecho */
.layout .tfnav-tab-chevron { margin-left: auto; }

/* Desplegables del sidebar (Calendarios, Tareas): subsecciones inline tipo
   acordeón. El menú de usuario (#nav-dropdown-user) queda excluido: ese flota
   arriba a la derecha y abre como menú normal. */
.layout .tfnav .nav-dropdown { display: block; }
.layout .tfnav .nav-dropdown-toggle { width: 100%; }
.layout .tfnav .nav-dropdown:not(#nav-dropdown-user):not(#nav-dropdown-preview):not(#lang-switcher) .nav-dropdown-menu {
    position: static;
    top: auto; left: auto; right: auto;
    width: 100%;
    min-width: 0;
    margin: 2px 0 4px;
    padding: 0 0 0 4px;
    background: none;
    border: none;
    box-shadow: none;
    transform: none;
    opacity: 1;
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
    transition: max-height 0.22s ease;
}
.layout .tfnav .nav-dropdown:not(#nav-dropdown-user):not(#nav-dropdown-preview):not(#lang-switcher).is-open .nav-dropdown-menu {
    max-height: 600px;
    pointer-events: auto;
    transform: none;
}
/* Sangrado de los sub-items para que se lean como subsecciones */
.layout .tfnav .nav-dropdown:not(#nav-dropdown-user):not(#nav-dropdown-preview):not(#lang-switcher) .nav-dropdown-item {
    padding-left: 38px;
    font-size: 13px;
}
.layout .tfnav .nav-dropdown:not(#nav-dropdown-user):not(#nav-dropdown-preview):not(#lang-switcher) .nav-dropdown-item--head {
    padding-left: 12px;
}

/* Perfil flotante arriba a la derecha (fuera del sidebar). Solo contiene
   el desplegable de usuario; el resto se plegó dentro de su menú. */
.layout .tfnav-right {
    position: fixed;
    top: 14px;
    right: 18px;
    z-index: 200;
    width: auto;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    /* Pastilla con fondo para que el grupo no quede "flotando a la deriva"
       sobre el contenido al hacer scroll. */
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
}
.layout .tfnav-right > .nav-dropdown .tfnav-tab { width: 100%; }
.layout #nav-dropdown-user .tfnav-user {
    background: var(--tf-surface, var(--cream));
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
/* Menú de usuario y «Ver como»: abren hacia abajo, alineados a la derecha,
   como tarjeta flotante (no como acordeón inline del sidebar). */
.layout #nav-dropdown-user .nav-dropdown-menu,
.layout #nav-dropdown-preview .nav-dropdown-menu,
.layout #lang-switcher .nav-dropdown-menu {
    position: absolute;
    top: 100%;
    bottom: auto;
    left: auto;
    right: 0;
    transform: translateY(-6px);
}
.layout #nav-dropdown-user.is-open .nav-dropdown-menu,
.layout #nav-dropdown-preview.is-open .nav-dropdown-menu,
.layout #lang-switcher.is-open .nav-dropdown-menu {
    transform: translateY(0);
}
/* Reservar espacio arriba para que el contenido no quede bajo el perfil. */
.layout .page { padding-top: 84px; }

/* Herramientas (campana, buscar, tema, privacidad, ajustes, manual)
   en una fila compacta que envuelve */
.tfnav-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

/* Pill de usuario a ancho completo abajo */
.layout .tfnav-user { width: 100%; }

/* Móvil / pantallas estrechas: el sidebar vuelve a barra superior */
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .layout .tfnav {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        width: 100%;
        height: auto;
        min-height: 0;          /* anula el min-height:100vh de escritorio (si no, la barra superior móvil sería de 100vh) */
        align-self: auto;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 1px solid var(--tf-border, var(--border));
        overflow-x: auto;
        overflow-y: visible;
    }
    /* flex:0 1 auto = las pestañas no se ESTIRAN para rellenar el ancho, así
       los iconos quedan pegados en vez de dejar un hueco grande en medio. */
    .layout .tfnav-tabs { flex-direction: row; flex: 0 1 auto; gap: 4px; }
    /* CLAVE: en el sidebar de escritorio cada pestaña es width:100% con el icono
       a la izquierda. Esa regla no tiene media query y se colaba en móvil, dejando
       todo el ancho vacío entre icono e icono. En móvil la pestaña es solo su
       contenido (icono), centrada. */
    .layout .tfnav-tabs .tfnav-tab { width: auto; justify-content: center; }
    /* Los desplegables (Calendarios/Tareas/Soporte) son display:block en el
       sidebar (otra regla sin media query) → ocupaban ancho de más entre los
       iconos. En móvil van inline, como una pestaña normal. */
    .layout .tfnav-tabs .nav-dropdown { display: inline-flex; align-items: center; width: auto; }
    .layout .tfnav-tabs .nav-dropdown .tfnav-tab { width: auto; }
    /* CLAVE DEL HUECO: el menú de los desplegables de sección es un acordeón
       EN FLUJO (position:static; width:100%) que ocupaba ~142px de ancho
       invisible entre los iconos. Lo sacamos del flujo (fixed, hoja arriba),
       así el desplegable mide solo su icono y deja de empujar. */
    .layout .tfnav .nav-dropdown:not(#nav-dropdown-user):not(#nav-dropdown-preview) .nav-dropdown-menu {
        display: none;           /* cerrado: invisible y fuera del flujo (sin franja) */
        position: fixed;
        top: 56px;
        left: 12px;
        right: 12px;
        width: auto;
        min-width: 0;
        margin: 0;
        padding: 6px;
        background: var(--moss);
        border: 1px solid var(--border-hover);
        border-radius: 8px;
        box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
    .layout .tfnav .nav-dropdown:not(#nav-dropdown-user):not(#nav-dropdown-preview).is-open .nav-dropdown-menu {
        display: block;          /* solo al abrir */
    }
    /* los sub-items dejan de llevar el sangrado de acordeón */
    .layout .tfnav .nav-dropdown:not(#nav-dropdown-user):not(#nav-dropdown-preview) .nav-dropdown-item {
        padding-left: 12px;
    }
    .layout .tfnav-tab.is-active::after {
        left: 14px; right: 14px; top: auto; bottom: -13px;
        width: auto; height: 2px;
    }
    .layout .tfnav-tab.is-active { background: none; }
    .layout .tfnav-tab-chevron { margin-left: 0; }
    .layout .tfnav-right {
        /* En móvil el perfil va dentro de la barra superior (flujo normal),
           NO fijo. Así no flota sobre el contenido ni captura toques encima
           de lo que hay debajo. */
        position: static;
        top: auto;
        right: auto;
        flex-direction: row;
        align-items: center;
        width: auto;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        background: none;
        border: none;
        box-shadow: none;
        padding: 0;
    }
    .layout .tfnav .nav-dropdown-menu {
        top: calc(100% + 8px);
        left: auto;
        right: 0;
    }
    .layout .tfnav-user { width: auto; }
}

/* ====================================================================
 * HOME v2 — header + tarjetas estilo Typeform
 * ==================================================================== */
.tfhome {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 32px 64px;
}

.tfhome-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}
.tfhome-header-left h1 {
    font-family: 'DM Sans', 'Inter', serif;
    font-weight: 500;
    font-size: 38px;
    color: var(--tf-text, var(--cream));
    letter-spacing: -0.5px;
    line-height: 1.1;
    margin: 0;
}
.tfhome-header-left h1 em {
    font-style: italic;
    color: var(--tf-accent, var(--gold));
}
.tfhome-header-sub {
    color: var(--tf-text-2, var(--cream-dim));
    font-size: 14px;
    margin-top: 8px;
}

.tfhome-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 28px;
    padding: 0 14px;
    background: var(--tf-surface, #fff);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.tfhome-search:focus-within {
    border-color: var(--border-hover, var(--moss));
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.tfhome-search-ico {
    display: inline-flex;
    color: var(--tf-text-3, var(--cream-dim));
    flex: 0 0 auto;
}
.tfhome-search-input {
    flex: 1 1 auto;
    border: none;
    background: transparent;
    outline: none;
    padding: 14px 0;
    font-size: 15px;
    color: inherit;
}
/* Sin borde ni outline el foco era invisible: indicador accesible al tabular. */
.tfhome-search-input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold, #c9a86a) 35%, transparent);
    border-radius: 6px;
}
.tfhome-search-input::placeholder {
    color: var(--tf-text-3, var(--cream-dim));
}
.tfhome-search-btn {
    /* Oculto: creaba una "caja vacía" rara a la derecha. El buscador funciona
       igual al pulsar Enter, y así queda como caja única limpia (igual que el
       buscador de Ingresos / movimientos). */
    display: none;
    flex: 0 0 auto;
    border: none;
    background: var(--moss);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 9px;
    cursor: pointer;
}
.tfhome-search-btn:hover {
    opacity: .9;
}

.tfhome-stat {
    text-align: right;
}
.tfhome-stat-label {
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    font-weight: 500;
}
.tfhome-stat-value {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 32px;
    color: var(--tf-text, var(--cream));
    font-weight: 500;
    letter-spacing: -0.5px;
}

.tfhome-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.tfhome-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--tf-border, var(--border));
    flex: 1;
}
.tfhome-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--tf-text-2, var(--cream-dim));
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    position: relative;
    transition: color 0.15s;
}
.tfhome-tab:hover {
    color: var(--tf-text, var(--cream));
}
.tfhome-tab.is-active {
    color: var(--tf-text, var(--cream));
}
.tfhome-tab.is-active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--tf-text, var(--cream));
}
.tfhome-tab-count {
    margin-left: 6px;
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    font-weight: 400;
}

.tfhome-cta {
    background: var(--tf-text, var(--cream));
    color: var(--tf-bg, var(--moss));
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.15s, transform 0.1s;
}
.tfhome-cta:hover { opacity: 0.85; }
.tfhome-cta:active { transform: scale(0.98); }

/* Grid de tarjetas */
.tfhome-section {
    margin-bottom: 40px;
}
.tfhome-section-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 26px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    letter-spacing: -0.3px;
    margin: 0 0 16px 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.tfhome-section-count {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--tf-text-3, var(--cream-dim));
    background: var(--tf-surface-2, rgba(255,255,255,0.06));
    border-radius: 999px;
    padding: 2px 9px;
}

.tfhome-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.tfcard {
    display: flex;
    flex-direction: column;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 12px;
    padding: 22px 22px 18px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
    position: relative;
    overflow: hidden;
}
.tfcard:hover {
    border-color: var(--tf-border-2, var(--border-hover));
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.tfcard-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.tfcard-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.tfcard-kind {
    font-size: 10px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    padding-top: 4px;
}
.tfcard-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.tfcard:hover .tfcard-actions { opacity: 1; }
.tfcard-action {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text-2, var(--cream-dim));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.tfcard-action:hover {
    background: var(--tf-surface-3, var(--forest));
    color: var(--tf-text, var(--cream));
}
.tfcard-action.danger:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--tf-danger);
}

.tfcard-name {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    line-height: 1.2;
    margin: 0 0 4px 0;
    letter-spacing: -0.3px;
}
.tfcard-name em {
    font-style: italic;
    color: var(--tf-accent, var(--gold));
}
.tfcard-desc {
    font-size: 12px;
    color: var(--tf-text-2, var(--cream-dim));
    line-height: 1.4;
    margin-top: 4px;
}

.tfcard-divider {
    height: 1px;
    background: var(--tf-border, var(--border));
    margin: 14px 0 12px;
}

.tfcard-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.tfcard-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tfcard-stat-label {
    font-size: 10px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 500;
}
.tfcard-stat-value {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 21px;
    color: var(--tf-text, var(--cream));
    font-weight: 600;
    letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums;
}
.tfcard-stat-value.is-positive { color: var(--success); }
.tfcard-stat-value.is-negative { color: var(--tf-danger, var(--danger)); }

/* Tarjeta de "+" para crear */
.tfcard-create {
    border-style: dashed;
    background: transparent;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 200px;
    color: var(--tf-text-2, var(--cream-dim));
}
.tfcard-create:hover {
    color: var(--tf-text, var(--cream));
    border-color: var(--tf-text-2, var(--cream-dim));
    transform: translateY(-2px);
    box-shadow: none;
}
.tfcard-create-icon {
    font-size: 28px;
    font-weight: 300;
    margin-bottom: 6px;
}
.tfcard-create-label {
    font-size: 13px;
    font-weight: 500;
}

/* Empty state */
.tfhome-empty {
    text-align: center;
    padding: 80px 32px;
    border: 2px dashed var(--tf-border, var(--border));
    border-radius: 16px;
    color: var(--tf-text-2, var(--cream-dim));
}
.tfhome-empty h2 {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 28px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    margin: 0 0 8px 0;
}
.tfhome-empty p { margin-bottom: 24px; font-size: 14px; }

@media (max-width: 720px) {
    .tfnav { padding: 12px 16px; gap: 16px; }
    .tfnav-tabs { gap: 0; flex-wrap: nowrap; overflow-x: auto; }
    .tfnav-user-info { display: none; }
    .tfhome { padding: 20px 16px 48px; }
    .tfhome-header-left h1 { font-size: 28px; }
    .tfhome-stat-value { font-size: 24px; }
}

/* ====================================================================
 * Ajustes específicos del tema claro (Typeform real)
 * ==================================================================== */
:root[data-theme="light"] {
    color-scheme: light;
}

/* Tipografía global de tema claro: Inter peso 450 */
:root[data-theme="light"] body,
:root[data-theme="light"] button,
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
:root[data-theme="light"] body {
    font-weight: 450;
}

/* Pesos específicos para texto secundario y labels — más oscuros y con peso */
:root[data-theme="light"] .tfcard-desc,
:root[data-theme="light"] .tfhome-header-sub,
:root[data-theme="light"] .detail-pane-sub,
:root[data-theme="light"] .field-help,
:root[data-theme="light"] .tfcard-stat-label,
:root[data-theme="light"] .tfhome-stat-label,
:root[data-theme="light"] .detail-pane-stat-label {
    font-weight: 450;
    color: var(--tf-text-2);
}

/* Pero permitir que el selector de fuente del usuario gane si lo cambia */
:root[data-theme="light"][data-font-body="dmsans"] body { font-family: 'DM Sans', sans-serif; }
:root[data-theme="light"][data-font-body="helvetica"] body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
:root[data-theme="light"][data-font-body="system"] body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Modales: scrim oscuro neutral */
:root[data-theme="light"] .modal-backdrop {
    background: rgba(15, 15, 15, 0.5);
}
:root[data-theme="light"] .modal {
    background: var(--tf-surface);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
    color: var(--tf-text);
}

/* Inputs y selects */
:root[data-theme="light"] .field-input,
:root[data-theme="light"] .field-select,
:root[data-theme="light"] .field-textarea,
:root[data-theme="light"] input[type="text"],
:root[data-theme="light"] input[type="number"],
:root[data-theme="light"] input[type="email"],
:root[data-theme="light"] input[type="password"],
:root[data-theme="light"] input[type="date"],
:root[data-theme="light"] input[type="url"],
:root[data-theme="light"] input[type="search"],
:root[data-theme="light"] textarea,
:root[data-theme="light"] select {
    background: var(--tf-surface);
    border: 1px solid var(--tf-border-2);
    color: var(--tf-text);
}
:root[data-theme="light"] .field-input:focus,
:root[data-theme="light"] .field-select:focus,
:root[data-theme="light"] .field-textarea:focus,
:root[data-theme="light"] input:focus,
:root[data-theme="light"] textarea:focus,
:root[data-theme="light"] select:focus {
    border-color: var(--tf-text);
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 15, 15, 0.06);
}
:root[data-theme="light"] .field-label {
    color: var(--tf-text);
}
:root[data-theme="light"] .field-help {
    color: var(--tf-text-3);
}

/* Botones */
:root[data-theme="light"] .btn {
    color: var(--tf-text);
    border: 1px solid var(--tf-border-2);
    background: var(--tf-surface);
}
:root[data-theme="light"] .btn:hover {
    background: var(--tf-surface-2);
    border-color: var(--tf-text-3);
}
:root[data-theme="light"] .btn--primary {
    background: var(--tf-text);
    color: var(--tf-bg);
    border: none;
}
:root[data-theme="light"] .btn--primary:hover {
    background: #262626;
    color: var(--tf-bg);
}
:root[data-theme="light"] .btn--ghost {
    background: transparent;
    color: var(--tf-text);
    border: 1px solid var(--tf-border-2);
}
:root[data-theme="light"] .btn--ghost:hover {
    background: var(--tf-surface-2);
    border-color: var(--tf-text-3);
}

/* CTA verde Typeform (solo el destacado de "+ Nueva empresa" en home) */
:root[data-theme="light"] .tfhome-cta {
    background: var(--tf-accent);
    color: #fff;
}
:root[data-theme="light"] .tfhome-cta:hover {
    background: var(--tf-accent-2);
}

/* NAV principal */
:root[data-theme="light"] .tfnav {
    background: var(--tf-surface);
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .tfnav-brand-text {
    color: var(--tf-text);
}
:root[data-theme="light"] .tfnav-brand-mark {
    background: var(--tf-text);
    color: var(--tf-bg);
}
:root[data-theme="light"] .tfnav-tab {
    color: var(--tf-text-2);
}
:root[data-theme="light"] .tfnav-tab:hover {
    background: var(--tf-surface-2);
    color: var(--tf-text);
}
:root[data-theme="light"] .tfnav-tab.is-active {
    color: var(--tf-text);
}
:root[data-theme="light"] .tfnav-tab.is-active::after {
    background: var(--tf-text);
}
:root[data-theme="light"] .tfnav-theme {
    color: var(--tf-text-2);
}
:root[data-theme="light"] .tfnav-theme:hover {
    background: var(--tf-surface-2);
    color: var(--tf-text);
}
:root[data-theme="light"] .tfnav-user {
    border-color: var(--tf-border-2);
    color: var(--tf-text);
}
:root[data-theme="light"] .tfnav-user:hover {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .tfnav-user-avatar {
    background: #d97757;  /* avatar terracota como Typeform */
    color: #fff;
}
:root[data-theme="light"] .tfnav-user-name { color: var(--tf-text); }
:root[data-theme="light"] .tfnav-user-role { color: var(--tf-text-3); }

/* Dropdown nav */
:root[data-theme="light"] .nav-dropdown-menu {
    background: var(--tf-surface);
    border: 1px solid var(--tf-border-2);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .nav-dropdown-item { color: var(--tf-text); }
:root[data-theme="light"] .nav-dropdown-item:hover { background: var(--tf-surface-2); }
:root[data-theme="light"] .nav-dropdown-item--head {
    background: var(--tf-accent-soft);
    color: var(--tf-accent-2);
}
:root[data-theme="light"] .nav-dropdown-label {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0;
    text-transform: none;
}
:root[data-theme="light"] .nav-dropdown-sep { background: var(--tf-border); }

/* HOME */
:root[data-theme="light"] .tfhome-header-left h1 {
    color: var(--tf-text);
}
:root[data-theme="light"] .tfhome-header-left h1 em {
    color: var(--tf-accent);
}
:root[data-theme="light"] .tfhome-header-sub { color: var(--tf-text-2); }
:root[data-theme="light"] .tfhome-stat-label { color: var(--tf-text-3); }
:root[data-theme="light"] .tfhome-stat-value { color: var(--tf-text); }
:root[data-theme="light"] .tfhome-tabs { border-bottom-color: var(--tf-border); }
:root[data-theme="light"] .tfhome-tab { color: var(--tf-text-2); }
:root[data-theme="light"] .tfhome-tab:hover { color: var(--tf-text); }
:root[data-theme="light"] .tfhome-tab.is-active { color: var(--tf-text); }
:root[data-theme="light"] .tfhome-tab.is-active::after { background: var(--tf-text); }
:root[data-theme="light"] .tfhome-tab-count { color: var(--tf-text-3); }

/* Tarjetas empresa */
:root[data-theme="light"] .tfcard {
    background: var(--tf-surface);
    border-color: var(--tf-border);
    color: var(--tf-text);
}
:root[data-theme="light"] .tfcard:hover {
    border-color: var(--tf-text-3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}
:root[data-theme="light"] .tfcard-name { color: var(--tf-text); }
:root[data-theme="light"] .tfcard-name em { color: var(--tf-accent); }
:root[data-theme="light"] .tfcard-kind { color: var(--tf-text-3); }
:root[data-theme="light"] .tfcard-desc { color: var(--tf-text-2); }
:root[data-theme="light"] .tfcard-divider { background: var(--tf-border); }
:root[data-theme="light"] .tfcard-stat-label { color: var(--tf-text-3); }
:root[data-theme="light"] .tfcard-stat-value { color: var(--tf-text); }
:root[data-theme="light"] .tfcard-action {
    background: var(--tf-surface-2);
    color: var(--tf-text-2);
}
:root[data-theme="light"] .tfcard-action:hover {
    background: var(--tf-surface-3);
    color: var(--tf-text);
}

/* Página interior — breadcrumb / page-header (legacy) */
:root[data-theme="light"] .page-title { color: var(--tf-text); }
:root[data-theme="light"] .page-title em { color: var(--tf-accent); }
:root[data-theme="light"] .page-subtitle,
:root[data-theme="light"] .page-tagline { color: var(--tf-text-2); }
:root[data-theme="light"] .page-meta-label { color: var(--tf-text-3); }
:root[data-theme="light"] .page-meta-value { color: var(--tf-text); }
:root[data-theme="light"] .breadcrumb { color: var(--tf-text-3); }
:root[data-theme="light"] .breadcrumb a { color: var(--tf-text-2); }
:root[data-theme="light"] .breadcrumb a:hover { color: var(--tf-text); }

/* DETAIL LAYOUT (sidebar + topbar) */
:root[data-theme="light"] .detail-app { background: var(--tf-bg); }
:root[data-theme="light"] .detail-topbar {
    background: var(--tf-surface);
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .detail-back { color: var(--tf-text-2); }
:root[data-theme="light"] .detail-back:hover {
    background: var(--tf-surface-2);
    color: var(--tf-text);
}
:root[data-theme="light"] .detail-crumb-link { color: var(--tf-text-2); }
:root[data-theme="light"] .detail-crumb-link:hover { color: var(--tf-text); }
:root[data-theme="light"] .detail-crumb-current { color: var(--tf-text); }
:root[data-theme="light"] .detail-crumb-sep { color: var(--tf-text-3); }
:root[data-theme="light"] .detail-user {
    background: #d97757;
    color: #fff;
}

:root[data-theme="light"] .detail-sidebar {
    background: var(--tf-surface-2);
    border-right-color: var(--tf-border);
}
:root[data-theme="light"] .detail-sidebar-eyebrow { color: var(--tf-text-3); }
:root[data-theme="light"] .detail-sidebar-title { color: var(--tf-text); }
:root[data-theme="light"] .detail-sidebar-head {
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .detail-sidebar-item {
    color: var(--tf-text-2);
}
:root[data-theme="light"] .detail-sidebar-item:hover {
    background: var(--tf-surface-3);
    color: var(--tf-text);
}
:root[data-theme="light"] .detail-sidebar-item.is-active {
    background: var(--tf-surface);
    color: var(--tf-text);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
:root[data-theme="light"] .detail-sidebar-count {
    background: var(--tf-surface);
    color: var(--tf-text-3);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .detail-sidebar-item.is-active .detail-sidebar-count {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .detail-sidebar-badge {
    background: var(--tf-accent);
    color: #fff;
}
:root[data-theme="light"] .detail-sidebar-foot {
    border-top-color: var(--tf-border);
}

:root[data-theme="light"] .detail-pane-head {
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .detail-pane-title { color: var(--tf-text); }
:root[data-theme="light"] .detail-pane-title em { color: var(--tf-accent); }
:root[data-theme="light"] .detail-pane-sub { color: var(--tf-text-2); }
:root[data-theme="light"] .detail-pane-stat-label { color: var(--tf-text-3); }
:root[data-theme="light"] .detail-pane-stat-value { color: var(--tf-text); }

:root[data-theme="light"] .detail-cta-card {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .detail-cta-card-title { color: var(--tf-text); }
:root[data-theme="light"] .detail-cta-card-sub { color: var(--tf-text-2); }

:root[data-theme="light"] .detail-settings-list {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .detail-setting-row {
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .detail-setting-title { color: var(--tf-text); }
:root[data-theme="light"] .detail-setting-desc { color: var(--tf-text-2); }

/* Burbujas (vista de cuentas - bubbles-grid) */
:root[data-theme="light"] .bubble {
    background: var(--tf-surface);
    border: 1px solid var(--tf-border);
    color: var(--tf-text);
}
:root[data-theme="light"] .bubble:hover {
    border-color: var(--tf-text-3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}
:root[data-theme="light"] .bubble-label { color: var(--tf-text-3); }
:root[data-theme="light"] .bubble-title { color: var(--tf-text); }
:root[data-theme="light"] .bubble-title em { color: var(--tf-accent); }
:root[data-theme="light"] .bubble-divider { background: var(--tf-border); }
:root[data-theme="light"] .bubble-stat { color: var(--tf-text-2); }
:root[data-theme="light"] .bubble-stat strong { color: var(--tf-text); }
:root[data-theme="light"] .bubble-action {
    background: var(--tf-surface-2);
    color: var(--tf-text-2);
}
:root[data-theme="light"] .bubble-action:hover {
    background: var(--tf-surface-3);
    color: var(--tf-text);
}

/* Filter chips */
:root[data-theme="light"] .filter-chip {
    background: var(--tf-surface);
    border-color: var(--tf-border-2);
    color: var(--tf-text-2);
}
:root[data-theme="light"] .filter-chip:hover {
    color: var(--tf-text);
    border-color: var(--tf-text-3);
}
:root[data-theme="light"] .filter-chip.is-active {
    background: var(--tf-text);
    color: var(--tf-bg);
    border-color: var(--tf-text);
}
:root[data-theme="light"] .filter-chip-count {
    color: inherit;
    opacity: 0.6;
}

/* Toolbar / página de detalle de cuenta concreta */
:root[data-theme="light"] .panel,
:root[data-theme="light"] .panel-section {
    background: var(--tf-surface);
    border-color: var(--tf-border);
    color: var(--tf-text);
}
:root[data-theme="light"] .panel-title { color: var(--tf-text); }
:root[data-theme="light"] .panel-title em { color: var(--tf-accent); }

/* Widget calendario tributario */
:root[data-theme="light"] .tax-widget {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .tax-widget-title { color: var(--tf-text); }
:root[data-theme="light"] .tax-widget-title em { color: var(--tf-accent); }
:root[data-theme="light"] .tax-widget-eyebrow { color: var(--tf-text-3); }
:root[data-theme="light"] .tax-widget-entity-name { color: var(--tf-text-2); }
:root[data-theme="light"] .tax-widget-entity-edit {
    color: var(--tf-text-2);
    border-color: var(--tf-border-2);
}
:root[data-theme="light"] .tax-widget-entity-edit:hover {
    color: var(--tf-text);
    border-color: var(--tf-text-3);
}
:root[data-theme="light"] .tax-widget-stat-value { color: var(--tf-text); }
:root[data-theme="light"] .tax-widget-stat-label { color: var(--tf-text-3); }
:root[data-theme="light"] .tax-widget-item {
    background: var(--tf-surface-2);
    border-left-color: var(--tf-accent);
    color: var(--tf-text);
}
:root[data-theme="light"] .tax-widget-item:hover {
    background: var(--tf-surface-3);
}
:root[data-theme="light"] .tax-widget-item-title { color: var(--tf-text); }
:root[data-theme="light"] .tax-widget-item-meta,
:root[data-theme="light"] .tax-widget-days { color: var(--tf-text-2); }
:root[data-theme="light"] .tax-widget-footer { border-top-color: var(--tf-border); }
:root[data-theme="light"] .tax-widget-manage-link {
    color: var(--tf-text-2);
}
:root[data-theme="light"] .tax-widget-manage-link:hover {
    color: var(--tf-text);
}
:root[data-theme="light"] .tax-widget-empty,
:root[data-theme="light"] .tax-widget-unlinked {
    color: var(--tf-text-2);
}
:root[data-theme="light"] .tax-widget-header {
    border-bottom-color: var(--tf-border);
}

/* Modal "ver todo el año" / detalle obligación */
:root[data-theme="light"] .tax-modal-row {
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .tax-modal-row-label { color: var(--tf-text-2); }
:root[data-theme="light"] .tax-modal-row-value { color: var(--tf-text); }
:root[data-theme="light"] .tax-modal-actions { border-top-color: var(--tf-border); }
:root[data-theme="light"] .tax-modal-loading { color: var(--tf-text-2); }
:root[data-theme="light"] .tax-all-month {
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .tax-all-month-name {
    color: var(--tf-text);
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .tax-all-item {
    color: var(--tf-text);
}
:root[data-theme="light"] .tax-all-item:hover {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .tax-all-title-line { color: var(--tf-text); }
:root[data-theme="light"] .tax-all-meta { color: var(--tf-text-2); }

/* Tarjetas de gestión de obligaciones / entidades fiscales */
:root[data-theme="light"] .tax-manage-card,
:root[data-theme="light"] .tax-entity-card {
    background: var(--tf-surface);
    border-color: var(--tf-border);
    color: var(--tf-text);
}
:root[data-theme="light"] .tax-manage-title,
:root[data-theme="light"] .tax-entity-card-name { color: var(--tf-text); }
:root[data-theme="light"] .tax-manage-desc,
:root[data-theme="light"] .tax-manage-rule,
:root[data-theme="light"] .tax-entity-card-eyebrow,
:root[data-theme="light"] .tax-entity-card-ident,
:root[data-theme="light"] .tax-entity-card-stat-lab { color: var(--tf-text-2); }

/* Settings panel */
:root[data-theme="light"] .settings-panel {
    background: var(--tf-surface);
    color: var(--tf-text);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .settings-section-title {
    color: var(--tf-text-2);
}
:root[data-theme="light"] .settings-option {
    background: var(--tf-surface);
    border-color: var(--tf-border);
    color: var(--tf-text);
}
:root[data-theme="light"] .settings-option:hover {
    border-color: var(--tf-text-3);
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .settings-option.is-active {
    border-color: var(--tf-text);
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .settings-option-desc {
    color: var(--tf-text-3);
}

/* Selección de texto */
:root[data-theme="light"] ::selection {
    background: var(--tf-accent-soft);
    color: var(--tf-text);
}

/* Flash notices */
:root[data-theme="light"] .flash--success {
    background: #f0fdf4;
    color: #14532d;
    border-left-color: var(--tf-accent);
}
:root[data-theme="light"] .flash--error {
    background: #fef2f2;
    color: #991b1b;
    border-left-color: var(--tf-danger);
}
:root[data-theme="light"] .flash--info {
    background: #eff6ff;
    color: #1e40af;
    border-left-color: #3b82f6;
}

/* Tablas de movimientos / cualquier tabla genérica */
:root[data-theme="light"] table {
    color: var(--tf-text);
}
:root[data-theme="light"] th {
    color: var(--tf-text-3);
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] td {
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] tr:hover td {
    background: var(--tf-surface-2);
}

/* En tema claro, los títulos grandes en Cormorant pueden seguir siendo
   serif si el usuario lo elige. Pero en Inter+Inter se ven como Typeform. */
:root[data-theme="light"][data-font-title="cormorant"] .page-title,
:root[data-theme="light"][data-font-title="cormorant"] .tfhome-header-left h1,
:root[data-theme="light"][data-font-title="cormorant"] .detail-pane-title,
:root[data-theme="light"][data-font-title="cormorant"] .detail-sidebar-title,
:root[data-theme="light"][data-font-title="cormorant"] .tfcard-name,
:root[data-theme="light"][data-font-title="cormorant"] .modal-title {
    font-family: 'DM Sans', system-ui, sans-serif;
}


/* ====================================================================
 * DETAIL LAYOUT — sidebar + topbar minimalista (estilo Typeform)
 * ==================================================================== */

.detail-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--tf-bg, var(--moss-deep));
}

/* Topbar minimalista */
.detail-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 24px;
    background: var(--tf-surface, var(--moss));
    border-bottom: 1px solid var(--tf-border, var(--border));
    position: sticky;
    top: 0;
    z-index: 50;
    height: 56px;
    box-sizing: border-box;
}
.detail-back {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.detail-back:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
}
.detail-crumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    overflow: hidden;
}
.detail-crumb-link {
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.detail-crumb-link:hover { color: var(--tf-text, var(--cream)); }
.detail-crumb-sep {
    color: var(--tf-text-3, var(--cream-dim));
    opacity: 0.5;
}
.detail-crumb-current {
    color: var(--tf-text, var(--cream));
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.detail-topbar-spacer { flex: 1; }
.detail-topbar-actions {
    display: flex;
    gap: 8px;
}
.detail-user {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--tf-text, var(--cream));
    color: var(--tf-bg, var(--moss));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.3px;
    margin-left: 4px;
}

/* Shell sidebar + main */
.detail-shell {
    display: flex;
    flex: 1;
    align-items: stretch;
    min-height: 0;
}

.detail-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--tf-surface-2, var(--forest-light));
    border-right: 1px solid var(--tf-border, var(--border));
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}

/* Cabecera del sidebar (avatar + nombre empresa) */
.detail-sidebar-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 16px;
    border-bottom: 1px solid var(--tf-border, var(--border));
}
.detail-sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.detail-sidebar-info { min-width: 0; }
.detail-sidebar-eyebrow {
    font-size: 10px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 500;
    margin-bottom: 2px;
}
.detail-sidebar-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    color: var(--tf-text, var(--cream));
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Lista de items del sidebar */
.detail-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.detail-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--tf-text-2, var(--cream-dim));
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}
.detail-sidebar-item:hover {
    background: var(--tf-surface-3, var(--forest));
    color: var(--tf-text, var(--cream));
}
.detail-sidebar-item.is-active {
    background: var(--tf-surface, var(--moss));
    color: var(--tf-text, var(--cream));
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.detail-sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.detail-sidebar-icon svg {
    width: 18px;
    height: 18px;
}
.detail-sidebar-label { flex: 1; }
.detail-sidebar-count {
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    background: var(--tf-surface, var(--moss));
    padding: 1px 8px;
    border-radius: 999px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--tf-border, var(--border));
}
.detail-sidebar-item.is-active .detail-sidebar-count {
    background: var(--tf-surface-2, var(--forest-light));
}
.detail-sidebar-badge {
    font-size: 10px;
    background: var(--tf-accent, var(--gold));
    color: #fff;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Cabecera de grupo en el sidebar (p.ej. "Facturas" → Emitidas/Recibidas) */
.detail-sidebar-group-head {
    margin: 12px 12px 2px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--tf-text-3, var(--cream-dim));
    opacity: 0.7;
}
/* Subsección: item indentado bajo una cabecera de grupo */
.detail-sidebar-item--sub {
    padding-left: 26px;
}

.detail-sidebar-foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--tf-border, var(--border));
}

/* Main */
.detail-main {
    flex: 1;
    padding: 32px 40px 64px;
    overflow-x: hidden;
    min-width: 0;
}

/* Panes */
.detail-pane {
    display: none;
    animation: paneFade 0.2s ease;
}
.detail-pane.is-active { display: block; }

@keyframes paneFade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.detail-pane-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--tf-border, var(--border));
}
.detail-pane-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 32px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    margin: 0;
    letter-spacing: -0.4px;
    line-height: 1.15;
}
.detail-pane-title em {
    font-style: italic;
    color: var(--tf-accent, var(--gold));
}
.detail-pane-sub {
    color: var(--tf-text-2, var(--cream-dim));
    font-size: 14px;
    margin: 6px 0 0;
}
.detail-pane-stat {
    text-align: right;
}
.detail-pane-stat-label {
    font-size: 10px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 500;
    margin-bottom: 4px;
}
.detail-pane-stat-value {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 28px;
    color: var(--tf-text, var(--cream));
    font-weight: 500;
    letter-spacing: -0.4px;
}

/* CTA card (rentabilidad) */
.detail-cta-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 24px;
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 12px;
    background: var(--tf-surface, var(--moss));
}
.detail-cta-card-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 22px;
    color: var(--tf-text, var(--cream));
    font-weight: 500;
    margin-bottom: 4px;
}
.detail-cta-card-sub {
    color: var(--tf-text-2, var(--cream-dim));
    font-size: 13px;
    margin: 0;
    max-width: 540px;
}

/* Settings list */
.detail-settings-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 12px;
    overflow: hidden;
    background: var(--tf-surface, var(--moss));
}
.detail-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--tf-border, var(--border));
}
.detail-setting-row:last-child { border-bottom: none; }
.detail-setting-info { flex: 1; min-width: 0; }
.detail-setting-title {
    font-size: 15px;
    color: var(--tf-text, var(--cream));
    font-weight: 600;
    margin-bottom: 4px;
}
.detail-setting-desc {
    font-size: 13px;
    color: var(--tf-text-2, var(--cream-dim));
    line-height: 1.5;
}
.detail-setting-row--danger .detail-setting-title {
    color: var(--tf-danger, var(--danger));
}
.detail-btn-danger {
    color: var(--tf-danger, var(--danger)) !important;
    border-color: var(--tf-danger, var(--danger)) !important;
}

/* Móvil: sidebar arriba en lugar de a la izquierda */
@media (max-width: 900px) {
    .detail-shell { flex-direction: column; }
    .detail-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--tf-border, var(--border));
        padding: 16px;
    }
    .detail-sidebar-head { padding-bottom: 12px; }
    .detail-sidebar-nav {
        flex-direction: row;
        gap: 4px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .detail-sidebar-nav::-webkit-scrollbar { display: none; }
    .detail-sidebar-item { flex-shrink: 0; }
    /* En horizontal no hay agrupación vertical: ocultamos la cabecera de
       grupo y anulamos la indentación de las subsecciones. */
    .detail-sidebar-group-head { display: none; }
    .detail-sidebar-item--sub { padding-left: 12px; }
    .detail-sidebar-foot { display: none; }
    .detail-main { padding: 24px 16px 48px; }
    .detail-pane-title { font-size: 24px; }
    .detail-pane-stat-value { font-size: 22px; }
    .detail-cta-card { flex-direction: column; align-items: flex-start; }
    .detail-setting-row { flex-direction: column; align-items: flex-start; gap: 12px; }
}


/* ====================================================================
 * Pane Rentabilidad (proyectos)
 * ==================================================================== */

/* Resumen anual: cards horizontales pequeñas */
.prof-years {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}
.prof-year-card {
    flex: 1;
    min-width: 140px;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 10px;
    padding: 14px 18px;
}
.prof-year-label {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.2px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    margin-bottom: 6px;
}
.prof-year-balance {
    font-family: 'DM Sans', 'Inter', serif;
    font-size: 26px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    letter-spacing: -0.4px;
    line-height: 1.1;
}
.prof-year-balance.is-positive { color: var(--tf-success, var(--success)); }
.prof-year-balance.is-negative { color: var(--tf-danger, var(--danger)); }
.prof-year-meta {
    margin-top: 4px;
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
}

/* Sección de meses agrupados por año */
.prof-year-section { margin-bottom: 32px; }
.prof-year-section:last-child { margin-bottom: 0; }
.prof-year-section-head {
    font-family: 'DM Sans', 'Inter', serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--tf-text-3, var(--cream-dim));
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--tf-border, var(--border));
    letter-spacing: 0;
}

/* Grid de meses */
.prof-month-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

/* Variante compacta (>12 meses) */
.prof-months--compact .prof-month-grid {
    grid-template-columns: 1fr;
    gap: 0;
}
.prof-months--compact .prof-month-card {
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    gap: 16px;
}
.prof-months--compact .prof-month-card-head {
    flex-direction: column;
    align-items: flex-start;
    min-width: 100px;
    margin-bottom: 0;
}
.prof-months--compact .prof-month-card-balance {
    font-size: 18px;
    margin: 0;
    min-width: 110px;
    text-align: right;
}
.prof-months--compact .prof-month-card-bars {
    flex: 1;
    flex-direction: row;
    gap: 16px;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}
.prof-months--compact .prof-month-bar {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

/* Card de mes (vista por defecto) */
.prof-month-card {
    display: flex;
    flex-direction: column;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 10px;
    padding: 16px 18px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    position: relative;
}
.prof-month-card:hover {
    border-color: var(--tf-text-3, var(--border-hover));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.prof-month-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.prof-month-card-name {
    font-family: 'DM Sans', 'Inter', serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    line-height: 1.1;
    letter-spacing: -0.2px;
}
.prof-month-card-num {
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    font-family: 'DM Mono', monospace;
}

.prof-month-card-balance {
    font-size: 22px;
    font-weight: 600;
    color: var(--tf-text, var(--cream));
    margin-bottom: 12px;
    letter-spacing: -0.4px;
    font-variant-numeric: tabular-nums;
}
.prof-month-card-balance.is-positive { color: var(--tf-success, var(--success)); }
.prof-month-card-balance.is-negative { color: var(--tf-danger, var(--danger)); }

.prof-month-card-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--tf-border, var(--border));
    padding-top: 10px;
    margin-top: auto;
}
.prof-month-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    line-height: 1.2;
}
.prof-month-bar-label {
    color: var(--tf-text-3, var(--cream-dim));
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 500;
}
.prof-month-bar-val {
    font-variant-numeric: tabular-nums;
    color: var(--tf-text-2, var(--cream-dim));
    font-weight: 500;
}
.prof-month-bar--in .prof-month-bar-val { color: var(--tf-success, var(--success)); }
.prof-month-bar--out .prof-month-bar-val { color: var(--tf-danger, var(--danger)); }

.prof-month-card-arrow {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 14px;
    color: var(--tf-text-3, var(--cream-dim));
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
}
.prof-month-card:hover .prof-month-card-arrow {
    opacity: 1;
    transform: translateX(2px);
}

/* Empty state */
.prof-empty {
    text-align: center;
    padding: 60px 24px;
    border: 2px dashed var(--tf-border, var(--border));
    border-radius: 12px;
    color: var(--tf-text-2, var(--cream-dim));
}
.prof-empty h2 {
    font-family: 'DM Sans', 'Inter', serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    margin: 0 0 8px 0;
}
.prof-empty p {
    margin: 0 0 20px 0;
    font-size: 13px;
}

/* Mobile */
@media (max-width: 720px) {
    .prof-years { gap: 8px; }
    .prof-year-card { min-width: 120px; padding: 10px 14px; }
    .prof-year-balance { font-size: 22px; }
    .prof-month-grid { grid-template-columns: 1fr; }
    .prof-months--compact .prof-month-card {
        flex-direction: column;
        align-items: stretch;
    }
    .prof-months--compact .prof-month-card-bars { flex-direction: column; }
}

/* Tema claro: ajustes específicos */
:root[data-theme="light"] .prof-year-card,
:root[data-theme="light"] .prof-month-card {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .prof-year-section-head {
    color: var(--tf-text-3);
    border-bottom-color: var(--tf-border);
}
:root[data-theme="light"] .prof-empty {
    border-color: var(--tf-border);
}


/* ====================================================================
 * Pane Rentabilidad — Toolbar de acciones avanzadas
 * ==================================================================== */
.prof-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    padding: 12px;
    background: var(--tf-surface-2, var(--forest-light));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 10px;
}
.prof-toolbar-spacer { flex: 1; }
.prof-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
    font-family: inherit;
}
.prof-toolbar-btn:hover {
    background: var(--tf-surface-3, var(--forest));
    border-color: var(--tf-text-3, var(--border-hover));
}
.prof-toolbar-btn--primary {
    background: var(--tf-text, var(--cream));
    color: var(--tf-bg, var(--moss));
    border-color: var(--tf-text, var(--cream));
}
.prof-toolbar-btn--primary:hover {
    background: var(--tf-text-2, var(--cream-dim));
    color: var(--tf-bg, var(--moss));
}
@media (max-width: 720px) {
    .prof-toolbar { flex-direction: column; align-items: stretch; }
    .prof-toolbar-btn { justify-content: center; }
    .prof-toolbar-spacer { display: none; }
}

/* ====================================================================
 * Fuentes de datos — de dónde se extraen los datos de la entidad
 * ==================================================================== */
.prof-data-sources {
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem 1rem;
    border: 1px solid var(--tf-border, rgba(255,255,255,0.08));
    border-radius: 12px;
    background: var(--tf-surface-2, rgba(255,255,255,0.03));
}
.prof-data-sources-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--tf-text-2, var(--cream-dim));
    margin-bottom: 0.6rem;
}
.prof-data-sources-head svg { opacity: 0.8; flex: none; }
.prof-data-sources-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.prof-data-sources-list li {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--tf-text, var(--cream));
    padding-left: 0.9rem;
    position: relative;
    word-break: break-word;
}
.prof-data-sources-list li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--tf-text-2, var(--cream-dim));
}
.prof-data-sources-edit {
    margin-top: 0.7rem;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.82rem;
    color: var(--tf-accent, var(--gold));
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.prof-data-sources-edit:hover { opacity: 0.8; }

/* Lista de fuentes dentro de la tarjeta de configuración */
.detail-data-sources {
    list-style: none;
    margin: 0.45rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.detail-data-sources li {
    font-size: 0.85rem;
    line-height: 1.35;
    padding-left: 0.85rem;
    position: relative;
    word-break: break-word;
}
.detail-data-sources li::before {
    content: "›";
    position: absolute;
    left: 0;
    opacity: 0.6;
}

/* ====================================================================
 * Pane Rentabilidad — Reparto acumulado
 * ==================================================================== */
.prof-payout {
    margin-top: 32px;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 12px;
    overflow: hidden;
}
.prof-payout-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--tf-border, var(--border));
}
.prof-payout-title {
    font-family: 'DM Sans', 'Inter', serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    margin: 0;
    letter-spacing: -0.2px;
}
.prof-payout-title em {
    font-style: italic;
    color: var(--tf-accent, var(--gold));
}
.prof-payout-sub {
    font-size: 13px;
    color: var(--tf-text-2, var(--cream-dim));
    margin: 4px 0 0;
}
.prof-payout-badge {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--tf-border-2, var(--border-hover));
    color: var(--tf-text, var(--cream));
    flex-shrink: 0;
}
.prof-payout-badge.is-positive {
    color: var(--tf-success, var(--success));
    border-color: var(--tf-success, var(--success));
}
.prof-payout-badge.is-negative {
    color: var(--tf-danger, var(--danger));
    border-color: var(--tf-danger, var(--danger));
}

.prof-payout-list {
    padding: 8px 0;
}
.prof-payout-row {
    padding: 14px 24px;
    border-bottom: 1px solid var(--tf-border, var(--border));
}
.prof-payout-row:last-child { border-bottom: none; }

.prof-payout-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.prof-payout-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
}
.prof-payout-amount {
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.prof-payout-amount.is-positive { color: var(--tf-success, var(--success)); }
.prof-payout-amount.is-negative { color: var(--tf-danger, var(--danger)); }

.prof-payout-bar {
    height: 6px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}
.prof-payout-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}
.prof-payout-bar-fill.is-positive { background: var(--tf-success, var(--success)); }
.prof-payout-bar-fill.is-negative { background: var(--tf-danger, var(--danger)); }

.prof-payout-row-foot {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}

.prof-payout-warn {
    padding: 12px 24px;
    font-size: 12px;
    color: var(--tf-danger, var(--danger));
    background: rgba(220, 38, 38, 0.06);
    border-top: 1px solid var(--tf-border, var(--border));
}
.prof-payout-warn a {
    color: var(--tf-accent, var(--gold));
    margin-left: 6px;
}

.prof-payout-foot {
    padding: 12px 24px;
    border-top: 1px solid var(--tf-border, var(--border));
    text-align: right;
}
.prof-payout-foot-link {
    font-size: 13px;
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.prof-payout-foot-link:hover {
    color: var(--tf-text, var(--cream));
}

.prof-payout-empty {
    padding: 32px 24px;
    text-align: center;
    color: var(--tf-text-2, var(--cream-dim));
}
.prof-payout-empty p {
    margin: 0 0 14px;
    font-size: 13px;
}

/* Tema claro */
:root[data-theme="light"] .prof-toolbar {
    background: var(--tf-surface-2);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .prof-toolbar-btn {
    background: var(--tf-surface);
    border-color: var(--tf-border);
    color: var(--tf-text);
}
:root[data-theme="light"] .prof-toolbar-btn:hover {
    background: var(--tf-surface-2);
    border-color: var(--tf-text-3);
}
:root[data-theme="light"] .prof-toolbar-btn--primary {
    background: var(--tf-text);
    color: var(--tf-bg);
    border-color: var(--tf-text);
}
:root[data-theme="light"] .prof-toolbar-btn--primary:hover {
    background: #262626;
}
:root[data-theme="light"] .prof-payout,
:root[data-theme="light"] .prof-payout-row,
:root[data-theme="light"] .prof-payout-warn,
:root[data-theme="light"] .prof-payout-foot {
    border-color: var(--tf-border);
}
:root[data-theme="light"] .prof-payout {
    background: var(--tf-surface);
}
:root[data-theme="light"] .prof-payout-warn {
    background: #fef2f2;
}
:root[data-theme="light"] .prof-payout-bar {
    background: var(--tf-surface-2);
}


/* ====================================================================
 * Pane Fijos recurrentes
 * ==================================================================== */
.rec-section {
    margin-bottom: 32px;
}
.rec-section:last-child {
    margin-bottom: 0;
}
.rec-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0 12px;
    border-bottom: 1px solid var(--tf-border, var(--border));
    margin-bottom: 12px;
}
.rec-section-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--tf-text-3, var(--cream-dim));
}
.rec-section-total {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.rec-section-total.is-positive { color: var(--tf-success, var(--success)); }
.rec-section-total.is-negative { color: var(--tf-danger, var(--danger)); }

.rec-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rec-item {
    display: grid;
    grid-template-columns: 70px 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 8px;
    transition: border-color 0.15s, background 0.15s;
}
.rec-item:hover {
    border-color: var(--tf-text-3, var(--border-hover));
}
.rec-item--inactive { opacity: 0.6; }

.rec-item-day {
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    text-align: center;
    padding: 4px 8px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}
.rec-item-main {
    min-width: 0;
}
.rec-item-desc {
    font-size: 14px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rec-item-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 11px;
}
.rec-item-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text-2, var(--cream-dim));
    border-radius: 999px;
    font-weight: 500;
}
.rec-item-pag {
    color: var(--tf-text-3, var(--cream-dim));
}
.rec-item-amount {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--tf-text, var(--cream));
}
.rec-item-amount.is-positive { color: var(--tf-success, var(--success)); }
.rec-item-amount.is-negative { color: var(--tf-danger, var(--danger)); }
.rec-item-actions {
    display: flex;
    gap: 4px;
}
.rec-item-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--tf-border, var(--border));
    color: var(--tf-text-2, var(--cream-dim));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rec-item-btn:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
    border-color: var(--tf-text-3, var(--border-hover));
}

.rec-inactive-wrap {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--tf-border, var(--border));
}
.rec-inactive-toggle {
    cursor: pointer;
    font-size: 13px;
    color: var(--tf-text-2, var(--cream-dim));
    font-weight: 500;
    list-style: none;
    user-select: none;
}
.rec-inactive-toggle::before {
    content: '▸';
    margin-right: 6px;
    display: inline-block;
    transition: transform 0.15s;
}
.rec-inactive-wrap[open] .rec-inactive-toggle::before {
    transform: rotate(90deg);
}

/* Móvil */
@media (max-width: 720px) {
    .rec-item {
        grid-template-columns: 1fr auto;
        gap: 8px;
    }
    .rec-item-day { grid-column: 1; grid-row: 1; }
    .rec-item-amount { grid-column: 2; grid-row: 1; }
    .rec-item-main { grid-column: 1 / -1; grid-row: 2; }
    .rec-item-actions { grid-column: 2; grid-row: 2; }
}

/* ====================================================================
 * Pane Reparto / colaboradores
 * ==================================================================== */
.collab-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.collab-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.5fr) 80px 1fr 130px auto;
    align-items: center;
    gap: 18px;
    padding: 16px 20px;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 10px;
    transition: border-color 0.15s;
}
.collab-row:hover {
    border-color: var(--tf-text-3, var(--border-hover));
}
.collab-row.is-inactive { opacity: 0.55; }

.collab-info { min-width: 0; }
.collab-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--tf-text, var(--cream));
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.collab-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 2px 7px;
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text-3, var(--cream-dim));
    border-radius: 999px;
    font-weight: 500;
}
.collab-meta {
    font-size: 12px;
    color: var(--tf-text-3, var(--cream-dim));
    display: flex;
    gap: 8px;
}
.collab-pct {
    font-size: 16px;
    font-weight: 600;
    color: var(--tf-text, var(--cream));
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.collab-bar-wrap { width: 100%; }
.collab-bar {
    height: 8px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 999px;
    overflow: hidden;
}
.collab-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}
.collab-bar-fill.is-positive { background: var(--tf-success, var(--success)); }
.collab-bar-fill.is-negative { background: var(--tf-danger, var(--danger)); }
.collab-amount {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.collab-amount.is-positive { color: var(--tf-success, var(--success)); }
.collab-amount.is-negative { color: var(--tf-danger, var(--danger)); }

@media (max-width: 900px) {
    .collab-row {
        grid-template-columns: 1fr auto;
    }
    .collab-info { grid-column: 1 / -1; }
    .collab-pct { grid-column: 1; }
    .collab-amount { grid-column: 2; }
    .collab-bar-wrap { grid-column: 1 / -1; }
    .collab-actions { grid-column: 2; grid-row: 1; }
}

/* Tema claro */
:root[data-theme="light"] .rec-item,
:root[data-theme="light"] .collab-row {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .rec-item-day,
:root[data-theme="light"] .rec-item-tag,
:root[data-theme="light"] .collab-tag,
:root[data-theme="light"] .collab-bar {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .rec-item-btn {
    border-color: var(--tf-border);
    color: var(--tf-text-2);
}
:root[data-theme="light"] .rec-item-btn:hover {
    background: var(--tf-surface-2);
    color: var(--tf-text);
}
:root[data-theme="light"] .rec-section-head {
    border-bottom-color: var(--tf-border);
}


/* ====================================================================
 * Enlace de retorno en vistas legacy (minimalista, sin caja)
 * ==================================================================== */
.legacy-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    padding: 6px 10px;
    margin: 0 0 16px -10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    width: fit-content;
}
.legacy-back-link:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
}
.legacy-back-link:active {
    transform: translateX(-2px);
}
.legacy-back-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.legacy-back-link:hover svg {
    opacity: 1;
}


/* ====================================================================
 * RESPONSIVE MÓVIL — pase completo (estilo Typeform mobile)
 * Aplicado a partir de 720px de ancho (móviles y tablets pequeñas)
 * ==================================================================== */

/* ============ NAV RESPONSIVE: TABLET / MÓVIL HORIZONTAL ============
   Entre 720px y 1100px el nav original mantenía las tabs con texto
   completo + nombre/rol del usuario + brand-text → todo eso no cabe
   en ese rango y se rompe. Comprimimos progresivamente. */
@media (max-width: 1099px) and (min-width: 721px) {
    .tfnav {
        padding: 14px 20px;
        gap: 12px;
    }
    /* Brand: solo el cuadrado, sin texto */
    .tfnav-brand-text { display: none; }

    /* Tabs: solo iconos, sin texto */
    .tfnav-tabs { gap: 2px; }
    .tfnav-tab {
        padding: 8px 6px;
        gap: 0;                  /* sin texto: fuera el hueco fantasma icono↔texto */
        font-size: 0;            /* oculta texto manteniendo el icono */
    }
    .tfnav-tab .tfnav-tab-icon {
        width: 18px;
        height: 18px;
        font-size: 0;
    }
    .tfnav-tab .tfnav-tab-chevron { display: none; }
    /* Tab activo: punto en lugar de barra para no chocar con padding */
    .tfnav-tab.is-active::after {
        left: 50%;
        right: auto;
        bottom: -6px;
        width: 4px;
        height: 4px;
        border-radius: 50%;
        transform: translateX(-50%);
    }

    /* Lado derecho: el avatar circular ya basta, ocultamos nombre + rol */
    .tfnav-user-info { display: none; }
    .tfnav-user {
        padding: 4px 6px 4px 4px;
        gap: 0;
    }
    /* Asegurar que el avatar siempre se ve (puede que el theme tenga un
       display:none condicional o el flex parent lo comprima). */
    .tfnav-right { flex-shrink: 0; }
    .tfnav-user-avatar { display: inline-flex; }

    /* Dropdown de Calendarios: en tablet, el trigger queda cerca del
       borde izquierdo y el menú (280px) se salía por la izquierda.
       Lo fijamos al viewport con left/right en lugar de relativo al trigger. */
    .nav-dropdown-menu {
        position: fixed;
        top: 60px;
        left: 16px;
        right: 16px;
        min-width: auto;
        max-width: 360px;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
    /* Perfil y "Ver como": el layout sidebar les pone top:100% (más específico);
       en position:fixed eso = fuera de pantalla. Lo forzamos a la hoja fija. */
    .layout #nav-dropdown-user .nav-dropdown-menu,
    .layout #nav-dropdown-preview .nav-dropdown-menu {
        top: 60px;
        left: 16px;
        right: 16px;
        bottom: auto;
    }
}

@media (max-width: 720px) {

    /* ---- NAV PRINCIPAL ---- */
    .tfnav {
        padding: 10px 12px;
        padding-top: calc(10px + var(--safe-top, 0px));
        padding-left: calc(12px + var(--safe-left, 0px));
        padding-right: calc(12px + var(--safe-right, 0px));
        gap: 6px;
        flex-wrap: nowrap;
    }
    /* Brand: solo el logo, oculto el texto en móvil */
    .tfnav-brand-text { display: none; }
    .tfnav-brand-mark { width: 30px; height: 30px; font-size: 12px; }

    /* Tabs: oculto el texto, dejo solo iconos */
    .tfnav-tabs {
        gap: 0;
        flex: 1;
        overflow-x: auto;
        scrollbar-width: none;
        margin: 0 4px;
    }
    .tfnav-tabs::-webkit-scrollbar { display: none; }
    .tfnav-tab {
        padding: 8px 6px;
        gap: 0;                  /* sin texto: fuera el hueco fantasma icono↔texto */
        font-size: 0;            /* oculta texto */
        flex-shrink: 0;
    }
    .tfnav-tab .tfnav-tab-icon {
        width: 18px;
        height: 18px;
        font-size: 0;
    }
    .tfnav-tab .tfnav-tab-chevron {
        display: none;            /* simplificar dropdown trigger */
    }
    /* Tab activo: punto debajo en lugar de línea (para no chocar con borde inferior del nav) */
    .tfnav-tab.is-active::after {
        left: 50%;
        right: auto;
        bottom: -10px;
        width: 4px;
        height: 4px;
        border-radius: 50%;
        transform: translateX(-50%);
    }

    /* Lado derecho: compacto */
    .tfnav-right { gap: 4px; }
    .tfnav-theme {
        width: 32px;
        height: 32px;
    }
    .tfnav-user {
        padding: 3px 4px 3px 3px;
        gap: 0;
    }
    .tfnav-user-avatar {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }
    .tfnav-user-info { display: none; }   /* oculto nombre + role */

    /* Dropdown menus en móvil: más anchos */
    .nav-dropdown-menu {
        position: fixed;
        top: 56px;
        left: 12px;
        right: 12px;
        min-width: auto;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
    /* Perfil y "Ver como": forzar la hoja fija (el layout sidebar les pone
       top:100%, que en position:fixed los manda fuera de pantalla). */
    .layout #nav-dropdown-user .nav-dropdown-menu,
    .layout #nav-dropdown-preview .nav-dropdown-menu {
        top: 56px;
        left: 12px;
        right: 12px;
        bottom: auto;
    }

    /* ---- HOME ---- */
    .tfhome {
        padding: 16px 14px 56px;
    }
    .tfhome-header {
        margin-bottom: 20px;
        gap: 12px;
    }
    .tfhome-header-left h1 {
        font-size: 26px;
        line-height: 1.15;
    }
    .tfhome-header-sub {
        font-size: 13px;
        margin-top: 6px;
    }
    .tfhome-stat {
        text-align: left;
        width: 100%;
    }
    .tfhome-stat-label {
        font-size: 10px;
        margin-bottom: 4px;
    }
    .tfhome-stat-value {
        font-size: 22px;
    }

    /* Toolbar (tabs + CTA): apilado vertical */
    .tfhome-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 18px;
    }
    .tfhome-tabs {
        width: 100%;
        gap: 0;
        flex: none;
    }
    .tfhome-tab {
        flex: 1;
        text-align: center;
        padding: 10px 8px;
        font-size: 13px;
    }
    .tfhome-cta {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Grid: 1 columna */
    .tfhome-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Tarjeta: padding más cómodo, acciones siempre visibles (no hover) */
    .tfcard {
        padding: 18px;
        border-radius: 12px;
    }
    .tfcard-actions { opacity: 1; }
    .tfcard-action {
        width: 32px;
        height: 32px;
    }
    .tfcard-name {
        font-size: 22px;
    }
    .tfcard-stat-value {
        font-size: 14px;
    }

    /* Tarjeta de "+ crear": altura más compacta */
    .tfcard-create {
        min-height: 120px;
        padding: 24px;
    }

    /* ---- DETAIL LAYOUT (página de empresa) ---- */
    .detail-topbar {
        padding: 10px 12px;
        height: 52px;
        gap: 10px;
    }
    .detail-back {
        width: 32px;
        height: 32px;
    }
    .detail-crumb {
        font-size: 13px;
        gap: 6px;
        flex: 1;
        min-width: 0;
    }
    .detail-crumb-link { display: none; }   /* solo nombre actual */
    .detail-crumb-sep { display: none; }
    .detail-crumb-current {
        font-size: 14px;
        font-weight: 600;
    }
    /* Las acciones del topbar (+ Nueva cuenta, etc.) las mantenemos visibles
       pero compactas al lado del toggle de tema */
    .detail-topbar-actions {
        display: flex;
        gap: 6px;
    }
    .detail-topbar-actions .btn {
        padding: 6px 10px;
        font-size: 12px;
        white-space: nowrap;
    }
    /* Si el botón es solo "+ Nueva cuenta", en pantallas muy pequeñas
       lo recortamos al símbolo + */
    .detail-user {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }

    /* Sidebar como menú horizontal arriba */
    .detail-sidebar {
        padding: 12px;
        gap: 10px;
    }
    .detail-sidebar-head {
        padding: 4px 4px 10px;
        gap: 10px;
    }
    .detail-sidebar-avatar {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
    .detail-sidebar-eyebrow {
        font-size: 9px;
        letter-spacing: 1px;
    }
    .detail-sidebar-title {
        font-size: 18px;
    }

    /* Items horizontales como pills, scroll horizontal */
    .detail-sidebar-nav {
        gap: 6px;
        padding-bottom: 4px;
    }
    .detail-sidebar-item {
        padding: 8px 14px;
        gap: 8px;
        font-size: 13px;
        white-space: nowrap;
        border-radius: 999px;
        background: var(--tf-surface, var(--moss));
        border: 1px solid var(--tf-border, var(--border));
    }
    .detail-sidebar-group-head { display: none; }
    .detail-sidebar-item--sub { padding-left: 14px; }
    .detail-sidebar-item.is-active {
        background: var(--tf-text, var(--cream));
        color: var(--tf-bg, var(--moss));
        border-color: var(--tf-text, var(--cream));
        box-shadow: none;
    }
    .detail-sidebar-icon { width: 14px; height: 14px; }
    .detail-sidebar-icon svg { width: 14px; height: 14px; }
    .detail-sidebar-count {
        font-size: 10px;
        padding: 0 6px;
        background: rgba(0, 0, 0, 0.06);
        border: none;
    }
    .detail-sidebar-item.is-active .detail-sidebar-count {
        background: rgba(255, 255, 255, 0.18);
        color: inherit;
    }
    .detail-sidebar-badge {
        font-size: 9px;
        padding: 1px 6px;
    }

    /* Cuerpo */
    .detail-main {
        padding: 20px 14px 48px;
    }
    .detail-pane-head {
        gap: 12px;
        margin-bottom: 20px;
        padding-bottom: 14px;
    }
    .detail-pane-title {
        font-size: 22px;
    }
    .detail-pane-sub {
        font-size: 13px;
    }
    .detail-pane-stat {
        text-align: left;
    }
    .detail-pane-stat-value {
        font-size: 20px;
    }

    /* ---- BURBUJAS DE CUENTAS (pane Cuentas) ---- */
    .bubbles-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }
    .bubble {
        padding: 14px;
        max-width: none !important;
    }
    .bubble-title {
        font-size: 16px;
    }

    /* ---- WIDGET CALENDARIO TRIBUTARIO ---- */
    .tax-widget {
        padding: 16px;
        border-radius: 10px;
    }
    .tax-widget-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .tax-widget-stats {
        gap: 14px;
    }
    .tax-widget-title {
        font-size: 18px;
    }
    .tax-widget-item {
        padding: 10px 12px;
    }

    /* Modal "ver todas las del año": full screen */
    .modal-tax-all {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }

    /* ---- PANE RENTABILIDAD ---- */
    .prof-toolbar {
        padding: 8px;
    }
    .prof-toolbar-btn {
        font-size: 12px;
        padding: 7px 10px;
    }
    .prof-years {
        gap: 8px;
        margin-bottom: 18px;
    }
    .prof-year-card {
        min-width: 110px;
        padding: 10px 12px;
    }
    .prof-year-balance {
        font-size: 18px;
    }
    .prof-year-meta {
        font-size: 10px;
    }

    /* ---- MODALES en móvil: pantalla completa ---- */
    .modal-backdrop {
        align-items: stretch;
        padding: 0;
    }
    .modal {
        width: 100%;
        max-width: 100%;
        min-height: 100%;
        margin: 0;
        border-radius: 0;
        padding: 20px 16px 32px;
        max-height: none;
        overflow-y: auto;
    }
    .modal--wide,
    .modal--tax {
        max-width: 100%;
    }
    .modal-title {
        font-size: 22px;
        padding-right: 40px;       /* hueco para el botón cerrar */
    }
    .modal-close {
        top: 14px;
        right: 14px;
        width: 44px;
        height: 44px;
        font-size: 24px;
    }
    .modal-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 20px;
    }
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }
    /* En móvil, botón de borrar en danger zone va abajo del todo */
    .modal-actions [id$="-delete-btn"] {
        order: 99;
        margin-right: 0 !important;
        margin-top: 12px;
        border-top: 1px solid var(--tf-border, var(--border));
        padding-top: 16px;
        width: 100%;
    }

    /* Inputs y campos */
    .field-input,
    .field-select,
    .field-textarea,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="month"],
    input[type="date"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px;            /* evita zoom auto en iOS */
        padding: 11px 12px;
    }
    /* Inputs de chat: solo subimos el tamaño (sin tocar su padding) */
    .chat-input,
    .ai-chat-input {
        font-size: 16px;            /* evita zoom auto en iOS */
    }
    .field-row {
        flex-direction: column;
        gap: 12px;
    }
    .field-row > .field {
        flex: none;
        width: 100%;
    }

    /* ---- SETTINGS PANEL ---- */
    .settings-panel {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }
    .settings-options {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .settings-option {
        padding: 12px;
    }
    .settings-options--small {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .settings-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .settings-actions .btn {
        width: 100%;
    }

    /* ---- VISTAS LEGACY (mes individual, fijos, etc.) ---- */
    .legacy-back-link {
        margin: 0 0 12px;
        font-size: 14px;
        padding: 8px 12px;
    }

    /* Page header viejo */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .page-title {
        font-size: 28px !important;
    }
    .page-meta {
        text-align: left;
        width: 100%;
    }

    /* Toolbar en móvil: ENVOLVER en vez de scroll horizontal.
       El scroll-x dejaba botones como "Generar recurrentes" fuera de
       pantalla sin indicación visible. Con wrap todos quedan accesibles. */
    .toolbar {
        flex-wrap: wrap;
        overflow-x: visible;
        padding-bottom: 0;
    }
    .toolbar .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        justify-content: center;
        white-space: normal;
    }

    /* Stat cards (mes individual, etc.) */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Tablas: scroll horizontal con borde indicativo */
    .data-table-wrap,
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Cualquier .data-table sin envoltorio (p. ej. Usuarios) se convierte en
       su propio contenedor con scroll horizontal en móvil, así no desborda
       el viewport en pantallas estrechas. */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Detail user button no se ve solo en topbar móvil */
    .detail-topbar .detail-user {
        margin-left: 0;
    }
}

/* ---- AÚN MÁS PEQUEÑO: <420px ---- */
@media (max-width: 420px) {
    .bubbles-grid {
        grid-template-columns: 1fr !important;
    }
    .tfhome-tab {
        font-size: 12px;
        padding: 9px 4px;
    }
    .tfhome-tab-count {
        display: none;
    }
    .detail-sidebar-item {
        padding: 7px 11px;
        font-size: 12px;
    }
    .detail-pane-title {
        font-size: 20px;
    }
    .tfcard-name {
        font-size: 20px;
    }

    /* Topbar muy compacto: ocultamos botones de acción
       (siguen disponibles en el header de cada pane) */
    .detail-topbar-actions { display: none; }
    .detail-topbar { gap: 6px; padding: 8px 10px; }
    .detail-back { width: 28px; height: 28px; }
    .detail-crumb-current { font-size: 13px; }
}

/* ---- AÚN MÁS GRANDE: tablets entre 720 y 1024 ---- */
@media (min-width: 721px) and (max-width: 1024px) {
    .tfhome-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .detail-sidebar {
        width: 220px;
    }
    .detail-main {
        padding: 28px 28px 56px;
    }
}


/* ====================================================================
 * CUENTAS CUADRADAS (estilo Typeform card, no círculo)
 * Sobreescribe el .bubble redondo para usar el mismo lenguaje que las
 * tarjetas de empresa.
 * ==================================================================== */

.bubble {
    aspect-ratio: auto !important;
    border-radius: 12px !important;
    max-width: none !important;
    padding: 22px !important;
    text-align: left !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    background: var(--tf-surface, var(--moss)) !important;
    transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s !important;
}

.bubble:hover {
    transform: translateY(-2px) !important;
    border-color: var(--tf-text-3, var(--border-hover)) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04) !important;
}

.bubble::before { display: none !important; }

.bubble-label {
    font-family: 'Inter', sans-serif !important;
    font-size: 10px !important;
    color: var(--tf-text-3, var(--cream-dim)) !important;
    letter-spacing: 1.2px !important;
    text-transform: uppercase !important;
    margin-bottom: 6px !important;
    font-weight: 500 !important;
}

.bubble-title {
    font-family: var(--font-title, 'Inter', sans-serif) !important;
    font-size: 22px !important;
    font-weight: 600 !important;
    color: var(--tf-text, var(--cream)) !important;
    line-height: 1.2 !important;
    margin-bottom: 4px !important;
    letter-spacing: -0.3px !important;
}

.bubble-title em {
    font-style: normal !important;
    color: var(--tf-accent, var(--gold)) !important;
    font-weight: inherit !important;
}

.bubble-divider {
    margin: 14px 0 12px !important;
    background: var(--tf-border, var(--border)) !important;
    width: 100% !important;
    height: 1px !important;
}

.bubble-stats {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    width: 100% !important;
    text-align: left !important;
}
.bubble-stat {
    display: flex !important;
    align-items: baseline !important;
    justify-content: space-between !important;
    gap: 8px !important;
    font-size: 12px !important;
    color: var(--tf-text-2, var(--cream-dim)) !important;
}
.bubble-stat strong {
    color: var(--tf-text, var(--cream)) !important;
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums !important;
}

/* Botones de acción dentro de la card de cuenta */
.bubble-actions {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.bubble:hover .bubble-actions { opacity: 1; }
.bubble-action {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--tf-border, var(--border));
    background: var(--tf-surface, var(--moss));
    color: var(--tf-text-2, var(--cream-dim));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.bubble-action:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
    border-color: var(--tf-text-3, var(--border-hover));
}
.bubble-action.danger:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--tf-danger, var(--danger));
    border-color: var(--tf-danger, var(--danger));
}

/* Grid: ahora pueden caber más por fila al ser rectangulares */
.bubbles-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: 14px !important;
}

/* En móvil: 1 columna, acciones siempre visibles */
@media (max-width: 720px) {
    .bubbles-grid {
        grid-template-columns: 1fr !important;
    }
    .bubble {
        padding: 18px !important;
    }
    .bubble-actions { opacity: 1 !important; }
}

/* Variantes especiales antiguas: las desactivo */
.bubble--small {
    padding: 22px !important;
    max-width: none !important;
}
.bubble--small .bubble-title { font-size: 22px !important; }


/* Header del pane: stat + CTA juntos a la derecha */
.detail-pane-head-right {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}
.pane-head-cta {
    align-self: center;
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .detail-pane-head-right {
        width: 100%;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    .pane-head-cta {
        flex-shrink: 0;
    }
}


/* ====================================================================
 * Sidebar nav: flechas de scroll + fade en móvil/tablet
 * ==================================================================== */
.detail-sidebar-nav-wrap {
    position: relative;
    /* Ancho completo del sidebar (que no se vea afectado por padding) */
}

/* Por defecto en escritorio el wrap es solo un contenedor — no aplica nada */
.detail-sidebar-arrow {
    display: none;
}

/* En móvil/tablet: nav horizontal con flechas y fade */
@media (max-width: 900px) {
    .detail-sidebar-nav-wrap {
        position: relative;
        margin: 0 -12px; /* contrarresta padding del sidebar para que el fade llegue al borde */
    }
    .detail-sidebar-nav-wrap .detail-sidebar-nav {
        scroll-behavior: smooth;
        padding: 4px 12px;     /* aire para que la primera y última píldora no toquen el borde */
        scroll-padding: 12px;
    }

    /* Fade lateral con gradiente — solo cuando hay overflow */
    .detail-sidebar-nav-wrap.has-overflow::before,
    .detail-sidebar-nav-wrap.has-overflow::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 32px;
        pointer-events: none;
        z-index: 1;
        opacity: 0;
        transition: opacity 0.2s;
    }
    .detail-sidebar-nav-wrap.has-overflow::before {
        left: 0;
        background: linear-gradient(to right, var(--tf-surface-2, var(--forest-light)) 0%, transparent 100%);
    }
    .detail-sidebar-nav-wrap.has-overflow::after {
        right: 0;
        background: linear-gradient(to left, var(--tf-surface-2, var(--forest-light)) 0%, transparent 100%);
    }
    /* Mostrar fade solo si la flecha correspondiente está visible */
    .detail-sidebar-nav-wrap:has(.detail-sidebar-arrow--left.is-visible)::before {
        opacity: 1;
    }
    .detail-sidebar-nav-wrap:has(.detail-sidebar-arrow--right.is-visible)::after {
        opacity: 1;
    }

    /* Flechas: solo visibles cuando hay scroll a ese lado */
    .detail-sidebar-arrow {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: var(--tf-surface, var(--moss));
        border: 1px solid var(--tf-border-2, var(--border-hover));
        color: var(--tf-text, var(--cream));
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s, background 0.15s;
        z-index: 2;
        padding: 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    }
    .detail-sidebar-arrow.is-visible {
        opacity: 1;
        pointer-events: auto;
    }
    .detail-sidebar-arrow:hover {
        background: var(--tf-surface-2, var(--forest-light));
    }
    .detail-sidebar-arrow:active {
        transform: translateY(-50%) scale(0.94);
    }
    .detail-sidebar-arrow--left { left: 4px; }
    .detail-sidebar-arrow--right { right: 4px; }

    /* Animación pulse sutil en la flecha derecha al cargar (insinúa que hay más) */
    .detail-sidebar-arrow--right.is-visible {
        animation: arrow-pulse 1.6s ease-in-out 0.4s 2;
    }
    @keyframes arrow-pulse {
        0%, 100% { transform: translateY(-50%) translateX(0); }
        50%      { transform: translateY(-50%) translateX(3px); }
    }
}

/* Tema claro: el fade usa el color del fondo del sidebar */
:root[data-theme="light"] .detail-sidebar-nav-wrap.has-overflow::before {
    background: linear-gradient(to right, var(--tf-surface-2) 0%, transparent 100%);
}
:root[data-theme="light"] .detail-sidebar-nav-wrap.has-overflow::after {
    background: linear-gradient(to left, var(--tf-surface-2) 0%, transparent 100%);
}
:root[data-theme="light"] .detail-sidebar-arrow {
    background: #fff;
    border-color: var(--tf-border-2);
    color: var(--tf-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
:root[data-theme="light"] .detail-sidebar-arrow:hover {
    background: var(--tf-surface-2);
}



/* ====================================================================
 * MÓDULO TAREAS MENSUALES
 * Lista checklist tipo ClickUp con plantillas e instancias por mes.
 * ==================================================================== */
.tasks-page {
    max-width: 980px;
    margin: 0 auto;
    padding: 40px 32px 80px;
}

.tasks-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--tf-border, var(--border));
}
.tasks-header-left { flex: 1; min-width: 0; }
.tasks-header-left .eyebrow {
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 500;
    margin: 0 0 6px;
}
.tasks-header-left h1 {
    margin: 0 0 4px;
    font-size: 38px;
    line-height: 1.05;
    letter-spacing: -0.5px;
    font-weight: 600;
}
.tasks-header-left h1 em {
    font-style: normal;
    color: var(--tf-accent, var(--gold));
    font-weight: inherit;
}
.tasks-header-sub {
    margin: 0;
    font-size: 14px;
    color: var(--tf-text-2, var(--cream-dim));
}

/* Progreso del mes */
.tasks-progress {
    text-align: right;
    min-width: 200px;
}
.tasks-progress-label {
    font-size: 10px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 500;
    margin-bottom: 4px;
}
.tasks-progress-value {
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--tf-text, var(--cream));
    margin-bottom: 6px;
}
.tasks-progress-bar {
    height: 6px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 4px;
}
.tasks-progress-fill {
    height: 100%;
    background: var(--tf-success, var(--success));
    border-radius: 999px;
    transition: width 0.4s ease;
}
.tasks-progress-pct {
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Toolbar */
.tasks-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.tasks-toolbar-spacer { flex: 1; }
/* Filtro de empresa en la barra de Tareas fijas. */
.tasks-company-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--cream-dim);
}
.tasks-company-filter svg { flex: 0 0 auto; opacity: .8; }
.field-input--sm {
    height: 32px;
    padding: 4px 28px 4px 10px;
    font-size: 13px;
    width: auto;
    min-width: 150px;
    max-width: 220px;
}
.tasks-month-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 999px;
}
.tasks-nav-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    color: var(--tf-text, var(--cream));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}
.tasks-nav-btn:hover {
    background: var(--tf-surface-3, var(--forest));
}
.tasks-nav-btn:active { transform: scale(0.94); }
.tasks-month-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--tf-text, var(--cream));
    padding: 0 8px;
    min-width: 120px;
    text-align: center;
}
.tasks-month-today {
    margin-left: 4px;
    padding: 4px 10px;
    font-size: 12px;
    background: var(--tf-accent-soft, rgba(184, 151, 106, 0.15));
    color: var(--tf-accent, var(--gold));
    border-radius: 999px;
    text-decoration: none;
    font-weight: 500;
}

/* Secciones */
.tasks-section {
    margin-bottom: 32px;
}
.tasks-section-head {
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--tf-border, var(--border));
}
.tasks-section-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.tasks-section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 6px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

/* Subsecciones de plantillas (Pagos / Cobros / Tareas) */
.tpl-group .tasks-section-head {
    flex-wrap: wrap;
    gap: 4px 12px;
}
.tpl-group .tpl-group-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tpl-accent, var(--moss));
    flex: 0 0 auto;
}
.tpl-group .tasks-section-title {
    color: var(--tpl-accent, var(--cream-dim));
}
.tpl-group-sub {
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--tf-text-3, var(--cream-dim));
    opacity: .85;
    margin-left: auto;
}
@media (max-width: 640px) {
    .tpl-group-sub { margin-left: 0; flex-basis: 100%; }
}

/* Lista de tareas */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.task-row {
    display: grid;
    grid-template-columns: 28px 1fr auto 30px;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: background 0.12s, border-color 0.12s;
}
.task-row:hover {
    background: var(--tf-surface-2, var(--forest-light));
    border-color: var(--tf-border, var(--border));
}

/* Tareas como tarjetas separadas (borde visible + espacio entre cada una) */
.task-card {
    border-color: var(--tf-border, var(--border)) !important;
    border-radius: 12px !important;
    margin-bottom: 9px !important;
    padding: 14px 16px !important;
    background: var(--tf-surface, rgba(255,255,255,0.02)) !important;
}
.task-card:hover {
    border-color: var(--gold) !important;
    background: var(--tf-surface, rgba(255,255,255,0.02)) !important;
}

/* Checkbox circular */
.task-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.8px dashed var(--tf-border-2, var(--border-hover));
    background: transparent;
    color: var(--tf-text, var(--cream));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    flex-shrink: 0;
}
.task-check:hover {
    border-style: solid;
    border-color: var(--tf-accent, var(--gold));
    background: var(--tf-accent-soft, rgba(184, 151, 106, 0.15));
}
.task-row.is-done .task-check {
    background: var(--tf-success, var(--success));
    border: none;
    color: #fff;
}
.task-row.is-done .task-check:hover {
    background: var(--tf-accent-2, var(--gold-dark));
}

.task-main { min-width: 0; }
.task-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.task-emoji {
    font-size: 16px;
    line-height: 1;
}
.task-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    overflow: hidden;
    text-overflow: ellipsis;
}
.task-row.is-done .task-name {
    text-decoration: line-through;
    color: var(--tf-text-3, var(--cream-dim));
}
.task-tag {
    display: inline-block;
    padding: 1px 7px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text-3, var(--cream-dim));
    border-radius: 999px;
    font-weight: 500;
}
/* Cruz para cancelar una etiqueta (importe, día, empresa, factura, cobro/pago)
   directamente desde la fila del fijo. */
.task-tag-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 13px;
    height: 13px;
    margin-left: 4px;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    vertical-align: -1px;
    color: inherit;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity .12s ease, background .12s ease;
}
.task-tag-x:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.18);
}
.task-tag-x:disabled {
    opacity: 0.3;
    cursor: default;
}
/* Distintivo de aviso: «Pendiente de añadir datos» en tareas de pago/cobro
   sin cliente enlazado. Tono ámbar para que destaque sin alarmar. */
.task-tag--warn {
    background: color-mix(in srgb, var(--gold, #b8976a) 22%, transparent);
    color: var(--gold, #b8976a);
}
/* Pago/cobro atrasado: rojo, para que salte a la vista. */
.task-tag--danger {
    background: color-mix(in srgb, #dc7878 24%, transparent);
    color: #e89595;
}
/* «Vinculada a deuda» / «Vinculada a tareas fijas»: tono verde para indicar
   que la sincronización deuda ↔ fija está activa. */
.task-tag--link {
    display: inline-flex;
    align-items: center;
    background: color-mix(in srgb, #78b48c 22%, transparent);
    color: #8fcaa3;
}
/* Tipo de tarea: acento lateral para distinguir de un vistazo cobros (verde,
   entra dinero), pagos (rojo, sale dinero) y tareas genéricas (neutro). */
.task-card--cobro   { border-left: 3px solid #78b48c !important; }
.task-card--pago    { border-left: 3px solid #dc7878 !important; }
.task-card--generic { border-left: 3px solid var(--tf-border, var(--border)) !important; }

/* Chip de tipo (Cobro / Pago) al inicio del título. */
.task-type-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    border-radius: 999px;
}
.task-type-chip .task-type-dot {
    width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
}
.task-type-chip--cobro {
    background: color-mix(in srgb, #78b48c 18%, transparent);
    color: #8fcaa3;
}
.task-type-chip--cobro .task-type-dot { background: #78b48c; }
.task-type-chip--pago {
    background: color-mix(in srgb, #dc7878 18%, transparent);
    color: #e89595;
}
.task-type-chip--pago .task-type-dot { background: #dc7878; }

.task-notes {
    font-size: 12px;
    color: var(--tf-text-3, var(--cream-dim));
    margin-top: 4px;
    white-space: pre-wrap;
}

.task-due {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    color: var(--tf-text-2, var(--cream-dim));
    font-variant-numeric: tabular-nums;
}
.task-due.is-today {
    background: var(--tf-accent-soft, rgba(184, 151, 106, 0.15));
    color: var(--tf-accent, var(--gold));
}
.task-due.is-overdue {
    background: rgba(220, 38, 38, 0.1);
    color: var(--tf-danger, var(--danger));
}

.task-edit {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--tf-text-3, var(--cream-dim));
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.task-row:hover .task-edit { opacity: 1; }
.task-edit:hover {
    background: var(--tf-surface, var(--moss));
    color: var(--tf-text, var(--cream));
    border-color: var(--tf-border, var(--border));
}

/* Empty state */
.tasks-empty {
    text-align: center;
    padding: 80px 20px;
    border: 1px dashed var(--tf-border, var(--border));
    border-radius: 12px;
    background: var(--tf-surface-2, var(--forest-light));
}
.tasks-empty h2 {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--tf-text, var(--cream));
    font-weight: 600;
}
.tasks-empty p {
    margin: 0 0 20px;
    color: var(--tf-text-2, var(--cream-dim));
    font-size: 14px;
}

/* Móvil */
@media (max-width: 720px) {
    .tasks-page {
        padding: 20px 14px 60px;
    }
    .tasks-header {
        flex-direction: column;
        gap: 16px;
    }
    .tasks-header-left h1 {
        font-size: 26px;
    }
    .tasks-progress {
        text-align: left;
        width: 100%;
    }
    .tasks-toolbar {
        gap: 8px;
    }
    .tasks-month-nav {
        flex: 1;
    }
    .tasks-month-label {
        flex: 1;
        font-size: 13px;
        min-width: 0;
    }
    .task-row {
        grid-template-columns: 24px 1fr auto;
        padding: 10px 12px;
        gap: 10px;
    }
    .task-edit {
        grid-column: 3;
        grid-row: 1;
        opacity: 1;
    }
    .task-due {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
        margin-top: 4px;
    }
}

/* Tema claro */
:root[data-theme="light"] .tasks-progress-bar,
:root[data-theme="light"] .tasks-month-nav,
:root[data-theme="light"] .tasks-section-count,
:root[data-theme="light"] .task-tag,
:root[data-theme="light"] .task-due,
:root[data-theme="light"] .tasks-empty {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .tasks-nav-btn {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .task-row:hover {
    background: var(--tf-surface-2);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .task-edit:hover {
    background: var(--tf-surface);
}


/* ====================================================================
 * Fila de PLANTILLA (sin checkbox)
 * Sobreescribe el grid de .task-row que asume columna de checkbox
 * ==================================================================== */
.tpl-row {
    grid-template-columns: 1fr auto !important;
    padding: 14px 18px !important;
    background: var(--tf-surface, var(--moss)) !important;
    border: 1px solid var(--tf-border, var(--border)) !important;
}
.tpl-row:hover {
    border-color: var(--tf-text-3, var(--border-hover)) !important;
}
.tpl-row .task-main {
    min-width: 0;
    grid-column: 1;
    grid-row: 1;
}
.tpl-row .task-edit {
    opacity: 1;
    grid-column: 2;
    grid-row: 1;
}
.tpl-row .task-emoji {
    font-size: 20px;
    line-height: 1;
}
.tpl-row .task-name {
    font-size: 15px;
    font-weight: 500;
}

/* Móvil */
@media (max-width: 720px) {
    .tpl-row {
        padding: 12px 14px !important;
    }
}

/* Tema claro */
:root[data-theme="light"] .tpl-row {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .tpl-row:hover {
    border-color: var(--tf-border-2);
    background: var(--tf-surface-2);
}


/* ====================================================================
 * MÓDULO DEUDAS
 * Lista de deudas (yo debo / me deben) con totales y toggle de estado.
 * Reutiliza estilos de .task-row del módulo de tareas mensuales.
 * ==================================================================== */

/* Balance neto en header */
.debts-net {
    text-align: right;
    min-width: 220px;
}
.debts-net-label {
    font-size: 10px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 500;
    margin-bottom: 4px;
}
.debts-net-value {
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--tf-text, var(--cream));
    margin-bottom: 4px;
    line-height: 1.1;
}
.debts-net-value.is-positive { color: var(--tf-success, var(--success)); }
.debts-net-value.is-negative { color: var(--tf-danger, var(--danger)); }
.debts-net-meta {
    font-size: 11px;
    color: var(--tf-text-3, var(--cream-dim));
    font-variant-numeric: tabular-nums;
}

/* Tabs Debo / Me deben */
.debts-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.debts-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 999px;
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.debts-tab:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
}
.debts-tab.is-active {
    background: var(--tf-text, var(--cream));
    color: var(--tf-bg, var(--moss));
    border-color: var(--tf-text, var(--cream));
}
.debts-tab-icon {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}
.debts-tab-amount {
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 999px;
}
.debts-tab.is-active .debts-tab-amount {
    background: rgba(255, 255, 255, 0.18);
}
.debts-tab.is-active .debts-tab-amount.is-positive,
.debts-tab.is-active .debts-tab-amount.is-negative {
    color: inherit;
}
.debts-tab-amount.is-positive { color: var(--tf-success, var(--success)); }
.debts-tab-amount.is-negative { color: var(--tf-danger, var(--danger)); }

/* Toggle de dirección dentro del modal */
.debts-direction-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.debts-direction-option {
    cursor: pointer;
}
.debts-direction-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.debts-direction-option span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: var(--tf-surface, var(--moss));
    border: 1.5px solid var(--tf-border, var(--border));
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--tf-text-2, var(--cream-dim));
    transition: all 0.15s;
}
.debts-direction-option:hover span {
    border-color: var(--tf-text-3, var(--border-hover));
}
.debts-direction-option input:checked + span {
    border-color: var(--tf-accent, var(--gold));
    background: var(--tf-accent-soft, rgba(184, 151, 106, 0.1));
    color: var(--tf-accent, var(--gold));
}

/* Fila de deuda — grid con columna de importe */
.debt-row {
    grid-template-columns: 28px 1fr !important;
    align-items: start !important;
    padding: 15px 17px !important;
    border: 1px solid var(--tf-border, var(--border)) !important;
    border-radius: 14px !important;
    margin-bottom: 10px !important;
    background: var(--tf-surface, rgba(255,255,255,0.02)) !important;
    transition: border-color 0.15s !important;
}
.debt-row:hover {
    border-color: var(--gold) !important;
}
.debt-row .task-check {
    margin-top: 2px;
}

/* Notas de la deuda: recortadas por defecto si son largas */
.debt-notes {
    margin-top: 6px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--cream-dim, #c8c3b5);
}
.debt-notes-text {
    white-space: normal;
}
.debt-notes.is-clamped .debt-notes-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.debt-notes.is-expanded .debt-notes-text {
    -webkit-line-clamp: unset;
    overflow: visible;
}
.debt-notes-toggle {
    margin-top: 4px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--gold-bright, #d4b084);
    text-transform: uppercase;
}
.debt-notes-toggle:hover { text-decoration: underline; }

/* Pie de la tarjeta: importe en globo + acciones agrupadas */
.debt-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;            /* nunca se solapan: si no caben, bajan de línea */
}
/* Grupo de botones (historial / pago / editar) siempre junto y a la derecha */
.debt-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;          /* empuja las acciones al lado opuesto del importe */
}
/* Chip del plan de pagos en la fila de deuda. El mensual se resalta en oro
 * porque indica que hay una tarea fija sincronizada. */
.debt-plan-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 320px;
}
.debt-plan-chip svg { flex: 0 0 auto; opacity: .8; }
.debt-plan-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.debt-plan-chip.is-monthly {
    color: var(--gold, #c9a86a);
    border-color: color-mix(in srgb, var(--gold, #c9a86a) 45%, transparent);
    background: color-mix(in srgb, var(--gold, #c9a86a) 12%, transparent);
}

.debt-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    padding: 7px 15px;
    border-radius: 999px;
    border: 1px solid var(--tf-border, var(--border));
    background: color-mix(in srgb, var(--gold) 7%, transparent);
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    letter-spacing: 0.2px;
    /* Fuente del sistema garantizada: el signo y el € nunca saldrán como "tofu" */
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.debt-badge.is-positive {
    color: var(--tf-success, var(--success));
    border-color: color-mix(in srgb, var(--success) 45%, var(--border));
    background: color-mix(in srgb, var(--success) 10%, transparent);
}
.debt-badge.is-negative {
    color: var(--tf-danger, var(--danger));
    border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
    background: color-mix(in srgb, var(--danger) 9%, transparent);
}
.debt-badge-cur { font-size: 13px; opacity: 0.85; }
.debt-row.is-done .debt-badge {
    text-decoration: line-through;
    opacity: 0.55;
}
.debt-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: none;
    cursor: pointer;
    color: var(--cream-dim, #c8c3b5);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: border-color 0.15s, color 0.15s;
}
.debt-edit-btn:hover {
    border-color: var(--gold);
    color: var(--gold-bright, #d4b084);
}

/* ── DESKTOP (>720px): pie en flujo normal, sin solapamientos ── */
@media (min-width: 721px) {
    .debt-foot {
        margin-top: 14px;
    }
    /* El botón editar, discreto hasta hover (como el resto de filas) */
    .debt-edit-btn {
        opacity: 0.6;
        transition: opacity 0.15s, border-color 0.15s, color 0.15s;
    }
    .debt-row:hover .debt-edit-btn { opacity: 1; }
}

/* Móvil */
@media (max-width: 720px) {
    .debts-net {
        text-align: left;
        width: 100%;
    }
    .debts-tabs {
        gap: 4px;
    }
    .debts-tab {
        flex: 1;
        justify-content: center;
        padding: 9px 12px;
        font-size: 13px;
    }
    .debts-tab-amount {
        display: none;
    }
    .debt-row {
        gap: 10px;
    }
}

/* Tema claro */
:root[data-theme="light"] .debts-tab {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .debts-tab:hover {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .debts-tab.is-active {
    background: var(--tf-text);
    color: var(--tf-bg);
    border-color: var(--tf-text);
}
:root[data-theme="light"] .debts-tab-amount {
    background: rgba(0, 0, 0, 0.04);
}
:root[data-theme="light"] .debts-direction-option span {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .debts-direction-option input:checked + span {
    background: var(--tf-accent-soft);
    border-color: var(--tf-accent);
    color: var(--tf-accent);
}


/* Estado "próxima" (7 días) para fechas de deudas */
.task-due.is-soon {
    background: rgba(234, 179, 8, 0.12);
    color: #ca8a04;
}
:root[data-theme="light"] .task-due.is-soon {
    background: #fef9c3;
    color: #854d0e;
}


/* ====================================================================
 * BUSCADOR GLOBAL (/search)
 * Vista estilo Google: hero con input grande y resultados agrupados.
 * ==================================================================== */

.search-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 60px 32px 80px;
}

/* Hero con input grande */
.search-hero {
    text-align: center;
    margin-bottom: 40px;
}
.search-hero-title {
    font-size: 38px;
    margin: 0 0 8px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--tf-text, var(--cream));
}
.search-hero-sub {
    margin: 0 0 28px;
    font-size: 14px;
    color: var(--tf-text-2, var(--cream-dim));
}

.search-form {
    max-width: 640px;
    margin: 0 auto;
}
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.search-input-icon {
    position: absolute;
    left: 18px;
    color: var(--tf-text-3, var(--cream-dim));
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 18px 50px 18px 50px;
    font-size: 17px;
    border: 1.5px solid var(--tf-border, var(--border));
    background: var(--tf-surface, var(--moss));
    color: var(--tf-text, var(--cream));
    border-radius: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    font-weight: 450;
}
.search-input:focus {
    outline: none;
    border-color: var(--tf-accent, var(--gold));
    box-shadow: 0 0 0 4px rgba(14, 124, 90, 0.10);
}
.search-input-clear {
    position: absolute;
    right: 16px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.search-input-clear:hover {
    background: var(--tf-surface-3, var(--forest));
    color: var(--tf-text, var(--cream));
}

/* Sugerencias cuando no hay query */
.search-tips {
    max-width: 560px;
    margin: 0 auto;
    padding: 24px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 12px;
}
.search-tips-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--tf-text-3, var(--cream-dim));
    font-weight: 600;
    margin: 0 0 12px;
}
.search-tips-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--tf-text-2, var(--cream-dim));
    line-height: 1.8;
}
.search-tips-list strong {
    color: var(--tf-text, var(--cream));
    font-weight: 600;
    margin-right: 4px;
}

/* Empty state */
.search-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--tf-text-2, var(--cream-dim));
}
.search-empty h2 {
    margin: 0 0 8px;
    font-size: 22px;
    color: var(--tf-text, var(--cream));
    font-weight: 600;
}
.search-empty p {
    margin: 0;
    font-size: 14px;
}

/* Chips de filtro (Todos / Empresa-Proyecto / Cuenta) */
.search-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.search-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--cream-dim);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}

.search-chip:hover {
    color: var(--cream);
    border-color: var(--border-hover);
}

.search-chip.is-active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--moss-deep);
}

.search-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--cream-dim) 20%, transparent);
    color: inherit;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0;
}

.search-chip.is-active .search-chip-count {
    background: color-mix(in srgb, var(--moss-deep) 25%, transparent);
    color: var(--moss-deep);
}

/* Summary "N resultados en X categorías" */
.search-summary {
    font-size: 12px;
    color: var(--tf-text-3, var(--cream-dim));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 24px;
    text-align: center;
}

/* Grupo de resultados */
.search-group {
    margin-bottom: 32px;
}
.search-group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--tf-border, var(--border));
    margin-bottom: 8px;
}
.search-group-icon {
    display: inline-flex;
    align-items: center;
    color: var(--tf-text-3, var(--cream-dim));
}
.search-group-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--tf-text, var(--cream));
    text-transform: uppercase;
    letter-spacing: 1.2px;
    flex: 1;
}
.search-group-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text-2, var(--cream-dim));
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

/* Resultados (lista) */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.search-result {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.12s, border-color 0.12s, transform 0.1s;
}
.search-result:hover {
    background: var(--tf-surface-2, var(--forest-light));
    border-color: var(--tf-border, var(--border));
}
.search-result:active {
    transform: scale(0.995);
}
.search-result-main {
    min-width: 0;
}
.search-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--tf-text, var(--cream));
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-sub {
    font-size: 12px;
    color: var(--tf-text-3, var(--cream-dim));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-amount {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--tf-text, var(--cream));
    white-space: nowrap;
}
.search-result-amount.is-positive { color: var(--tf-success, var(--success)); }
.search-result-amount.is-negative { color: var(--tf-danger, var(--danger)); }
.search-result-arrow {
    color: var(--tf-text-3, var(--cream-dim));
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
}
.search-result:hover .search-result-arrow {
    opacity: 1;
    transform: translateX(2px);
}

/* Resaltado de coincidencias */
.search-match {
    background: var(--tf-accent-soft, rgba(184, 151, 106, 0.25));
    color: inherit;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 3px;
}
:root[data-theme="light"] .search-match {
    background: #fef9c3;
    color: #854d0e;
}

/* Botón de búsqueda en topbar */
.tfnav-search {
    text-decoration: none;
}

/* Móvil */
@media (max-width: 720px) {
    .search-page {
        padding: 32px 16px 60px;
    }
    .search-hero-title {
        font-size: 28px;
    }
    .search-hero-sub {
        font-size: 13px;
    }
    .search-input {
        font-size: 16px;
        padding: 14px 44px;
    }
    .search-input-icon {
        left: 14px;
        width: 18px;
        height: 18px;
    }
    .search-result {
        padding: 10px 12px;
    }
    .search-result-arrow {
        display: none;
    }
    .search-result-amount {
        font-size: 13px;
    }
}

/* Tema claro */
:root[data-theme="light"] .search-input {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}
:root[data-theme="light"] .search-input:focus {
    border-color: var(--tf-accent);
}
:root[data-theme="light"] .search-input-clear {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .search-tips,
:root[data-theme="light"] .search-group-count {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .search-result:hover {
    background: var(--tf-surface-2);
    border-color: var(--tf-border);
}


/* ====================================================================
 * RESPONSABLES DE TAREAS — pestañas, chips, pills selector
 * ==================================================================== */

/* Pestañas Todas / Vero / Susin */
.tasks-assignee-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--tf-border, var(--border));
    flex-wrap: wrap;
}
.tasks-assignee-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 999px;
    color: var(--tf-text-2, var(--cream-dim));
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tasks-assignee-tab:hover {
    background: var(--tf-surface-2, var(--forest-light));
    color: var(--tf-text, var(--cream));
}
.tasks-assignee-tab.is-active {
    background: var(--tf-text, var(--cream));
    color: var(--tf-bg, var(--moss));
    border-color: var(--tf-text, var(--cream));
}
/* Cuando un tab de persona está activo, usar SU color como acento sutil */
.tasks-assignee-tab.is-active[style*="assignee-color"] {
    background: var(--assignee-color);
    border-color: var(--assignee-color);
    color: #fff;
}
.tasks-assignee-tab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--assignee-color, var(--tf-text-3, #737373));
    flex-shrink: 0;
}
.tasks-assignee-tab.is-active .tasks-assignee-tab-dot {
    background: #fff;
}
.tasks-assignee-tab-count {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    background: var(--tf-surface-2, var(--forest-light));
    border-radius: 999px;
}
.tasks-assignee-tab.is-active .tasks-assignee-tab-count {
    background: rgba(255, 255, 255, 0.22);
}

/* Chip de responsable dentro de la fila de tarea */
.assignee-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px 2px 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--assignee-color, var(--tf-text-2));
    background: color-mix(in srgb, var(--assignee-color, #737373) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--assignee-color, #737373) 28%, transparent);
    border-radius: 999px;
    line-height: 1.4;
}
.assignee-chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--assignee-color, var(--tf-text-3));
    flex-shrink: 0;
}
/* Cruz para quitar el responsable directamente desde la fila */
.assignee-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    margin-left: 2px;
    padding: 0;
    font-size: 13px;
    line-height: 1;
    color: var(--assignee-color, var(--tf-text-2));
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity .12s ease, background .12s ease;
}
.assignee-chip-x:hover {
    opacity: 1;
    background: color-mix(in srgb, var(--assignee-color, #737373) 22%, transparent);
}
.assignee-chip-x:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Fallback para navegadores sin color-mix() */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .assignee-chip {
        background: var(--tf-surface-2, var(--forest-light));
        border-color: var(--tf-border, var(--border));
        color: var(--tf-text-2, var(--cream-dim));
    }
}

/* Pills selector multi-checkbox dentro de modales */
.assignee-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.assignee-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1.5px solid var(--tf-border, var(--border));
    background: var(--tf-surface, var(--moss));
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--tf-text-2, var(--cream-dim));
    transition: all 0.15s;
    user-select: none;
}
.assignee-pill:hover {
    border-color: var(--assignee-color, var(--tf-text-3));
    color: var(--tf-text, var(--cream));
}
.assignee-pill-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.assignee-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--assignee-color, var(--tf-text-3));
}
.assignee-pill:has(.assignee-pill-input:checked) {
    border-color: var(--assignee-color, var(--tf-accent));
    background: color-mix(in srgb, var(--assignee-color, var(--tf-accent)) 14%, transparent);
    color: var(--assignee-color, var(--tf-accent));
}
/* Fallback */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .assignee-pill:has(.assignee-pill-input:checked) {
        background: var(--tf-surface-2, var(--forest-light));
        color: var(--tf-text, var(--cream));
    }
}

/* Tema claro */
:root[data-theme="light"] .tasks-assignee-tab {
    border-color: var(--tf-border);
}
:root[data-theme="light"] .tasks-assignee-tab:hover {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .tasks-assignee-tab-count {
    background: var(--tf-surface-2);
}
:root[data-theme="light"] .assignee-pill {
    background: var(--tf-surface);
    border-color: var(--tf-border);
}

/* Móvil */
@media (max-width: 720px) {
    .tasks-assignee-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 4px;
        scrollbar-width: none;
    }
    .tasks-assignee-tabs::-webkit-scrollbar { display: none; }
    .tasks-assignee-tab {
        flex-shrink: 0;
        padding: 7px 12px;
        font-size: 12px;
    }
    .assignee-pill {
        padding: 7px 12px;
    }
    .assignee-pills {
        gap: 6px;
    }
}

/* ============================================================
   CHAT ASISTENTE IA (Claude) — widget flotante esquina inferior
   Solo visible para rol root. Render condicional desde footer.php.
   ============================================================ */

.ai-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1.5px solid var(--gold);
    background: var(--moss-deep);
    color: var(--gold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    transition: transform 0.2s, opacity 0.2s, background 0.2s;
    z-index: 1000;
}
.ai-chat-toggle:hover {
    transform: translateY(-2px);
    background: var(--moss);
}
.ai-chat-toggle.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}
.ai-chat-toggle-pulse {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 1.5px solid var(--gold);
    opacity: 0;
    animation: ai-pulse 2.4s ease-out infinite;
    pointer-events: none;
}
@keyframes ai-pulse {
    0%   { opacity: 0.4; transform: scale(0.95); }
    70%  { opacity: 0;   transform: scale(1.25); }
    100% { opacity: 0;   transform: scale(1.25); }
}

.ai-chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    height: min(620px, calc(100vh - 48px));
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.98);
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 1001;
    overflow: hidden;
}
.ai-chat-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--moss-deep) 60%, var(--moss));
}
.ai-chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-chat-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--moss-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ai-chat-header-name {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--cream);
    line-height: 1.1;
}
.ai-chat-header-sub {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    color: var(--cream-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 2px;
}
.ai-chat-header-actions {
    display: flex;
    gap: 4px;
}
.ai-chat-icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--cream-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.ai-chat-icon-btn:hover {
    color: var(--cream);
    border-color: var(--border);
    background: color-mix(in srgb, var(--cream) 6%, transparent);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
}
.ai-chat-messages::-webkit-scrollbar { width: 6px; }
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.ai-chat-welcome {
    color: var(--cream-dim);
    font-size: 13px;
    line-height: 1.5;
    padding: 4px 8px;
}
.ai-chat-welcome p { margin: 0 0 10px; }
.ai-chat-welcome ul {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-chat-welcome li {
    padding: 0;
    background: none;
    border: none;
}
/* FAQ clickable: pill con hover dorado */
.ai-chat-faq {
    width: 100%;
    display: block;
    padding: 9px 13px;
    background: color-mix(in srgb, var(--gold) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold) 14%, var(--border));
    border-radius: 8px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream);
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
}
.ai-chat-faq:hover {
    background: color-mix(in srgb, var(--gold) 14%, transparent);
    border-color: var(--gold);
    color: var(--cream);
    transform: translateX(2px);
}
.ai-chat-faq:active {
    transform: translateX(2px) scale(0.98);
}
.ai-chat-welcome-note {
    font-size: 11px !important;
    color: var(--cream-dim);
    opacity: 0.7;
    font-style: italic;
}

.ai-msg {
    display: flex;
    max-width: 100%;
}
.ai-msg--user {
    justify-content: flex-end;
}
.ai-msg--assistant {
    justify-content: flex-start;
}
.ai-msg--error {
    justify-content: center;
}
.ai-msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    color: var(--cream);
}
.ai-msg--user .ai-msg-bubble {
    background: var(--gold);
    color: var(--moss-deep);
    border-bottom-right-radius: 4px;
}
.ai-msg--assistant .ai-msg-bubble {
    background: color-mix(in srgb, var(--cream) 7%, transparent);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.ai-msg--error .ai-msg-bubble {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
    color: var(--danger);
    font-size: 12px;
    text-align: center;
    max-width: 90%;
}

/* "Escribiendo..." */
.ai-msg-bubble--typing {
    display: inline-flex;
    gap: 4px;
    padding: 14px 14px;
}
.ai-msg-bubble--typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cream-dim);
    animation: ai-bounce 1.2s ease-in-out infinite;
}
.ai-msg-bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-msg-bubble--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* Acción ejecutada (tarjeta debajo del mensaje del assistant) */
.ai-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 4px 10px 4px 8px;
    border-radius: 99px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-left: 2px;
    max-width: 80%;
}
.ai-action--ok {
    background: color-mix(in srgb, var(--success, #6a9c5a) 12%, transparent);
    color: var(--success, #6a9c5a);
    border: 1px solid color-mix(in srgb, var(--success, #6a9c5a) 25%, var(--border));
}
.ai-action--ko {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--border));
}
.ai-action-icon {
    font-weight: bold;
    font-size: 11px;
}

/* Input area */
.ai-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--moss-deep) 60%, var(--moss));
}
.ai-chat-input {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    color: var(--cream);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    resize: none;
    min-height: 38px;
    max-height: 160px;
    transition: border-color 0.15s, background 0.15s;
}
.ai-chat-input::placeholder {
    color: var(--cream-dim);
    opacity: 0.6;
}
.ai-chat-input:focus {
    outline: none;
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 4%, transparent);
}
.ai-chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ai-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--gold);
    color: var(--moss-deep);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.15s, background 0.15s;
    flex-shrink: 0;
}
.ai-chat-send:hover:not(:disabled) {
    transform: translateY(-1px);
}
.ai-chat-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Tema claro */
:root[data-theme="light"] .ai-chat-panel {
    background: #fff;
    border-color: var(--tf-border, #e3e1da);
}
:root[data-theme="light"] .ai-chat-header {
    background: var(--tf-surface-2, #faf8f3);
}
:root[data-theme="light"] .ai-msg--assistant .ai-msg-bubble {
    background: var(--tf-surface-2, #f5f1e8);
    color: var(--tf-text, #2a2a28);
    border-color: var(--tf-border, #e3e1da);
}
:root[data-theme="light"] .ai-chat-toggle {
    background: #fff;
    border-color: var(--gold);
}

/* Responsive móvil: panel ocupa toda la pantalla.
   La tab bar inferior aparece a ≤768px, así que el panel full-screen debe
   cubrir el mismo rango para no solapar con ella en 541-768px. */
@media (max-width: 768px) {
    .ai-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }
    /* Respetar notch y barra de inicio del iPhone: la cabecera no queda bajo
       el notch y el campo de escribir no queda bajo el indicador de inicio. */
    .ai-chat-header {
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }
    .ai-chat-input-wrap {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
}

/* El asistente IA flota POR ENCIMA de la barra inferior (tab bar),
   no pegado al borde, para que no tape la pestaña "Más". La barra
   inferior aparece a ≤768px, así que el botón debe elevarse en ese
   mismo rango (no solo a ≤540px). */
@media (max-width: 768px) {
    .ai-chat-toggle {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        width: 50px;
        height: 50px;
    }
}

/* ============================================================
   IMPORTACIÓN DE EXTRACTOS BANCARIOS (chat IA)
   ============================================================ */

.ai-chat-import-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--cream-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    align-self: flex-end;
}
.ai-chat-import-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.modal--import { max-width: 480px; }

.modal--preview {
    max-width: 880px;
    width: 95vw;
}

.ai-import-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 12px;
}
.ai-import-toolbtn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
}
.ai-import-toolbtn:hover {
    border-color: var(--gold);
    color: var(--gold);
}
.ai-import-counter {
    margin-left: auto;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim);
}

.ai-import-preview {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--moss-deep) 30%, transparent);
}

.ai-import-grid {
    display: flex;
    flex-direction: column;
}
.ai-import-row {
    display: grid;
    grid-template-columns: 40px 100px 1fr 180px 140px;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.ai-import-row:last-child { border-bottom: none; }
.ai-import-row--head {
    background: color-mix(in srgb, var(--moss-deep) 60%, var(--moss));
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cream-dim);
    position: sticky;
    top: 0;
    z-index: 2;
}

.ai-import-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--gold);
}
.ai-import-date {
    font-family: 'DM Mono', monospace;
    color: var(--cream-dim);
    font-size: 11px;
}
.ai-import-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--cream);
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.15s;
}
.ai-import-input:hover { border-color: var(--border); }
.ai-import-input:focus {
    outline: none;
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 5%, transparent);
}
.ai-import-amount {
    text-align: right;
    font-family: 'DM Mono', monospace;
    font-weight: 500;
}
.ai-import-amount.is-income  { color: var(--success, #6a9c5a); }
.ai-import-amount.is-expense { color: var(--danger); }

@media (max-width: 720px) {
    .ai-import-row {
        grid-template-columns: 32px 80px 1fr 100px;
        font-size: 11px;
    }
    .ai-import-row > div:nth-child(4) { display: none; } /* ocultar categoría en móvil */
}

/* ============================================================
   FACTURAS — todo con prefijo .fact- para no tocar otras vistas.
   Reutiliza variables del tema (--gold, --cream, --border, etc).
   ============================================================ */

/* Tabla de facturas dentro del pane */
.fact-table {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
/* En móvil, las columnas de la factura (fijas) no caben: permitimos scroll
   horizontal en lugar de aplastar la descripción o desbordar el viewport. */
@media (max-width: 720px) {
    .fact-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .fact-table .fact-row {
        min-width: 560px;
    }
    /* Al hacer scroll-x, fijamos la 1ª columna (nº de factura) para no perder
       el contexto de qué fila estamos mirando. Fondo opaco + z-index para
       que el resto de columnas pasen por debajo. */
    .fact-table .fact-row > :first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--moss, #fff);
    }
    .fact-table .fact-row--head > :first-child {
        background: color-mix(in srgb, var(--moss-deep, #0f1a0b) 50%, var(--moss, #fff));
    }
    /* Resumen de deudas: fijar la 1ª columna (empresa) igual que arriba. */
    .debts-summary th:first-child,
    .debts-summary td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--moss, #fff);
    }
    /* Portal cliente: fijar la 1ª columna (nº factura) en su tabla scroll-x. */
    .client-invoices-row > :first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--moss, #fff);
    }
    /* Correo: la rejilla fija (380px + 1fr) no cabe en móvil; la apilamos.
       !important porque el ancho base va en estilo en línea. */
    .mail-layout {
        grid-template-columns: 1fr !important;
    }
    /* Apilada, 72vh de lista empuja el detalle demasiado abajo: la acortamos. */
    .mail-list {
        max-height: 48vh !important;
    }
    /* Resumen de deudas: aún tiene scroll-x, pero apretamos celdas para que
       las 4 columnas quepan sin desplazar en la mayoría de teléfonos. */
    .debts-summary table { font-size: .8rem !important; }
    .debts-summary th,
    .debts-summary td { padding: 7px 9px !important; }
}
.fact-row {
    display: grid;
    grid-template-columns: 110px 90px 1fr 120px 90px 70px;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.fact-row:last-child { border-bottom: none; }
.fact-row--head {
    background: color-mix(in srgb, var(--moss-deep, #0f1a0b) 50%, transparent);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cream-dim, #999);
}
.fact-row:not(.fact-row--head):hover { background: color-mix(in srgb, var(--gold) 4%, transparent); }
.fact-code a {
    color: var(--gold);
    text-decoration: none;
    font-family: 'DM Mono', monospace;
    font-weight: 600;
}
.fact-code a:hover { text-decoration: underline; }
.fact-date { color: var(--cream-dim, #999); font-family: 'DM Mono', monospace; font-size: 11px; }
.fact-amount { text-align: right; font-variant-numeric: tabular-nums; }

.fact-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 99px;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--cream-dim, #999);
}
.fact-badge--issued    { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, var(--border)); }
.fact-badge--paid      { color: #6a9c5a; border-color: color-mix(in srgb, #6a9c5a 40%, var(--border)); }
.fact-badge--cancelled { color: var(--danger, #c0556a); text-decoration: line-through; }

/* Líneas en el modal de creación */
.fact-line {
    display: grid;
    grid-template-columns: 1fr 70px 100px 90px 28px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.fact-line-desc { resize: vertical; min-height: 38px; }
.fact-line-total {
    text-align: right;
    font-family: 'DM Mono', monospace;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
}
.fact-line-x {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--cream-dim, #999);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.fact-line-x:hover { color: var(--danger, #c0556a); border-color: var(--danger, #c0556a); }

/* ============================================================
   FORMULARIO CREAR FACTURA (views/invoices/new.php)
   ============================================================ */
.form-card { padding: 0; }
.form-section {
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }
.form-section-title {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 16px;
}

.invoice-lines {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}
.invoice-line {
    display: grid;
    grid-template-columns: 1fr 90px 120px 110px 32px;
    gap: 10px;
    align-items: end;
}
.invoice-line .field-label { margin-bottom: 4px; }
.invoice-line-total { text-align: right; }
.line-total-display {
    font-family: 'DM Mono', monospace;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    text-align: right;
    padding: 10px 0;
    white-space: nowrap;
}
.invoice-line-remove {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--cream-dim, #999);
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    margin-bottom: 4px;
}
.invoice-line-remove:hover { color: var(--danger, #c0556a); border-color: var(--danger, #c0556a); }

.invoice-totals-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    width: 300px;
    max-width: 100%;
    margin-left: auto;
    padding: 14px 16px;
    background: color-mix(in srgb, var(--gold) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold) 14%, var(--border));
    border-radius: 10px;
}
.invoice-totals-preview > div {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    font-size: 13px;
    color: var(--cream-dim, #999);
}
.invoice-totals-preview strong {
    font-family: 'DM Mono', monospace;
    font-variant-numeric: tabular-nums;
    color: var(--cream, #f5f1e8);
}
.invoice-totals-grand {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid color-mix(in srgb, var(--gold) 20%, var(--border));
    font-size: 15px !important;
    color: var(--cream, #f5f1e8) !important;
}
.invoice-totals-grand strong { color: var(--gold) !important; font-size: 16px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 20px 22px;
}

/* En escritorio, las etiquetas solo en la primera línea (aspecto tabla) */
@media (min-width: 721px) {
    .invoice-line:not(:first-child) .field-label { display: none; }
}
/* En móvil, cada línea se apila a una columna con todas sus etiquetas */
@media (max-width: 720px) {
    .invoice-line {
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
    }
    .invoice-line-desc { grid-column: 1 / -1; }
    .invoice-line-total { text-align: left; }
    .line-total-display { text-align: left; padding: 8px 0; }
    .invoice-line-remove {
        grid-column: 1 / -1;
        justify-self: end;
        margin: 0;
    }
    .invoice-totals-preview { width: 100%; }
    .form-actions { justify-content: stretch; }
    .form-actions .btn { flex: 1; min-width: 0; }
}

/* Acciones de formulario SIEMPRE alcanzables en móvil: ancladas abajo.
   En una página normal flotan sobre la tab-bar inferior; dentro de un modal
   a pantalla completa (que cubre la tab-bar) se pegan al fondo. */
@media (max-width: 768px) {
    .form-actions {
        position: sticky;
        bottom: calc(64px + var(--safe-bottom, 0px));
        z-index: 50;
        margin-top: 12px;
        padding: 12px 16px 12px;
        background: color-mix(in srgb, var(--moss, #fff) 92%, transparent);
        -webkit-backdrop-filter: saturate(160%) blur(10px);
        backdrop-filter: saturate(160%) blur(10px);
        border-top: 1px solid var(--border);
    }
    .modal .form-actions,
    .modal-backdrop .form-actions {
        bottom: 0;
        padding-bottom: 12px;
    }
}

/* Totales (modal y detalle) */
.fact-totals {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
    width: 280px;
    max-width: 100%;
    margin: 12px 0 12px auto;
    padding: 14px 16px;
    background: color-mix(in srgb, var(--gold) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold) 14%, var(--border));
    border-radius: 10px;
}
.fact-totals > div {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    font-size: 13px;
    color: var(--cream, #f5f1e8);
}
.fact-totals strong { font-variant-numeric: tabular-nums; }
.fact-totals-grand {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 17px !important;
    color: var(--gold) !important;
}

/* Vista detalle de factura */
.fact-show { max-width: 860px; margin: 0 auto; padding: 24px 16px; }
.fact-show-bar { display: flex; align-items: center; margin-bottom: 16px; }
.fact-show-card {
    background: color-mix(in srgb, var(--cream, #f5f1e8) 4%, transparent);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
}
.fact-show-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.fact-show-code {
    font-family: 'DM Mono', monospace;
    font-size: 22px;
    font-weight: 600;
    color: var(--gold);
}
.fact-show-date { color: var(--cream-dim, #999); font-size: 12px; margin-top: 4px; }
.fact-show-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 20px;
}
.fact-show-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}
.fact-show-name { font-weight: 600; margin-bottom: 4px; color: var(--cream, #f5f1e8); }
.fact-show-parties > div > div:not(.fact-show-label):not(.fact-show-name) {
    font-size: 13px;
    color: var(--cream-dim, #999);
    line-height: 1.5;
}
.fact-show-notes {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--cream, #f5f1e8);
}
.fact-show-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.fact-danger { color: var(--danger, #c0556a) !important; }

/* Modal más ancho para facturas */
.modal--wide { max-width: 640px; width: 95vw; }

@media (max-width: 640px) {
    /* La tabla de facturas ya tiene scroll horizontal (.fact-table, regla
       <=720px), así que el listado conserva cantidad/precio/total/estado/PDF.
       Para un .fact-row suelto (fuera de .fact-table) sí compactamos columnas;
       la tabla de DETALLE (.fact-table .fact-row) mantiene todas con scroll. */
    .fact-row { grid-template-columns: 90px 1fr 80px; }
    .fact-row > div:nth-child(2),
    .fact-row > div:nth-child(5),
    .fact-row > div:nth-child(6) { display: none; }
    .fact-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .fact-table .fact-row { grid-template-columns: 110px 90px 1fr 120px 90px 70px; min-width: 560px; }
    .fact-table .fact-row > div { display: block; }
    .fact-line { grid-template-columns: 1fr; }
    .fact-show-parties { grid-template-columns: 1fr; }
}

/* ----- Switch "Mejorar con IA" + preview ----- */
.fact-ai-switch {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    margin: 4px 0 16px;
    border: 1px solid color-mix(in srgb, var(--gold) 20%, var(--border));
    border-radius: 10px;
    background: color-mix(in srgb, var(--gold) 4%, transparent);
    cursor: pointer;
}
.fact-ai-switch input { display: none; }
.fact-ai-switch-track {
    flex-shrink: 0;
    width: 42px;
    height: 24px;
    border-radius: 99px;
    background: var(--border);
    position: relative;
    transition: background 0.2s;
    margin-top: 2px;
}
.fact-ai-switch-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--cream, #f5f1e8);
    transition: transform 0.2s;
}
.fact-ai-switch input:checked + .fact-ai-switch-track { background: var(--gold); }
.fact-ai-switch input:checked + .fact-ai-switch-track .fact-ai-switch-thumb {
    transform: translateX(18px);
    background: var(--moss-deep, #0f1a0b);
}
.fact-ai-switch-text strong { display: block; font-size: 13px; color: var(--cream, #f5f1e8); }
.fact-ai-switch-text small { display: block; font-size: 11px; color: var(--cream-dim, #999); margin-top: 3px; line-height: 1.4; }

.fact-ai-preview-body { max-height: 55vh; overflow-y: auto; margin: 16px 0; }
.fact-ai-section { margin-bottom: 18px; }
.fact-ai-section-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 10px;
}
.fact-ai-line {
    display: grid;
    grid-template-columns: 1fr 24px 1fr;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.fact-ai-line-before { color: var(--cream-dim, #999); }
.fact-ai-line-arrow { text-align: center; color: var(--gold); }
.fact-ai-line-after { color: var(--cream, #f5f1e8); }
.fact-ai-notes {
    padding: 12px;
    background: color-mix(in srgb, var(--cream, #f5f1e8) 4%, transparent);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--cream, #f5f1e8);
    line-height: 1.5;
}
@media (max-width: 640px) {
    .fact-ai-line { grid-template-columns: 1fr; gap: 4px; }
    .fact-ai-line-arrow { display: none; }
}

.fact-ai-sec-head {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gold);
    margin: 12px 0 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}
.fact-ai-sec-head:first-child { border-top: none; padding-top: 0; }

/* ----- Selector de modo de factura ----- */
.fact-mode-tabs { display: flex; gap: 6px; }
.fact-mode-tab {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--cream-dim, #999);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.fact-mode-tab.is-active {
    border-color: var(--gold);
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, transparent);
}
.fact-mode-hint {
    font-size: 11px;
    color: var(--cream-dim, #999);
    margin-top: 8px;
    line-height: 1.5;
}
.fact-ai-single-item {
    padding: 4px 0 4px 4px;
    font-size: 13px;
    color: var(--cream, #f5f1e8);
}

/* Líneas en la edición de factura (sección visible como input) */
#edit-lines .fact-line {
    grid-template-columns: 1fr 140px 70px 100px 28px;
}
#edit-lines .fact-line-section-edit {
    font-size: 11px;
}
@media (max-width: 640px) {
    #edit-lines .fact-line { grid-template-columns: 1fr; }
}

/* ============================================================
   MANUAL DE USUARIO
   ============================================================ */
.manual {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    align-items: start;
}
.manual-sidebar {
    position: sticky;
    top: 90px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: color-mix(in srgb, var(--cream, #f5f1e8) 4%, transparent);
}
.manual-sidebar-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 12px;
}
.manual-nav { display: flex; flex-direction: column; gap: 2px; }
.manual-nav-item {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--cream-dim, #999);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
}
.manual-nav-item:hover { color: var(--cream, #f5f1e8); background: color-mix(in srgb, var(--cream, #f5f1e8) 5%, transparent); }
.manual-nav-item.is-active {
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 10%, transparent);
}
.manual-add-btn { width: 100%; margin-top: 12px; }

.manual-content { min-width: 0; }
.manual-content-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.manual-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 30px;
    font-weight: 600;
    color: var(--cream, #f5f1e8);
    margin: 0;
}
.manual-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.manual-body { color: var(--cream, #f5f1e8); line-height: 1.7; max-width: 720px; }
.manual-body .manual-h {
    font-family: 'DM Sans', system-ui, sans-serif;
    color: var(--gold);
    margin: 24px 0 10px;
    font-weight: 600;
}
.manual-body h3.manual-h { font-size: 22px; }
.manual-body h4.manual-h { font-size: 18px; }
.manual-body .manual-p { margin: 0 0 14px; font-size: 15px; }
.manual-body .manual-ul { margin: 0 0 14px; padding-left: 22px; }
.manual-body .manual-ul li { margin-bottom: 6px; font-size: 15px; }
.manual-body strong { color: var(--cream, #f5f1e8); font-weight: 600; }

@media (max-width: 820px) {
    .manual { grid-template-columns: 1fr; }
    .manual-sidebar { position: static; }
}

/* ----- Tutor del manual ----- */
.manual-tutor-cta { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.manual-tutor-btn {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--gold);
    border-radius: 8px;
    background: color-mix(in srgb, var(--gold) 10%, transparent);
    color: var(--gold);
    font-size: 13px; cursor: pointer;
    transition: all 0.15s;
}
.manual-tutor-btn:hover { background: color-mix(in srgb, var(--gold) 18%, transparent); }

.tutor-intro {
    font-size: 13px; color: var(--cream-dim, #999);
    margin-bottom: 16px; line-height: 1.6;
    padding: 12px 14px;
    border-left: 2px solid var(--gold);
    background: color-mix(in srgb, var(--gold) 4%, transparent);
    border-radius: 0 8px 8px 0;
}
.tutor-messages {
    display: flex; flex-direction: column; gap: 12px;
    min-height: 280px; max-height: 52vh; overflow-y: auto;
    padding: 8px 4px 16px;
    margin-bottom: 14px;
}
.tutor-msg { display: flex; }
.tutor-msg--user { justify-content: flex-end; }
.tutor-msg--bot { justify-content: flex-start; }
.tutor-bubble {
    max-width: 78%;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px; line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.tutor-msg--user .tutor-bubble {
    background: var(--gold); color: var(--moss-deep, #0f1a0b);
    border-bottom-right-radius: 4px;
}
.tutor-msg--bot .tutor-bubble {
    background: color-mix(in srgb, var(--cream, #f5f1e8) 7%, transparent);
    color: var(--cream, #f5f1e8);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.tutor-bubble.is-thinking { opacity: 0.6; font-style: italic; }
.tutor-input-row { display: flex; gap: 8px; }
.tutor-input-row .field-input { flex: 1; }

/* Duplicados en el preview de importación con IA */
.ai-import-row.is-duplicate { opacity: 0.7; }
.ai-import-dup {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 99px;
    font-size: 10px;
    font-family: 'DM Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: color-mix(in srgb, var(--danger, #c0563f) 18%, transparent);
    color: var(--danger, #c0563f);
    vertical-align: middle;
}

/* ============================================================
   MODO PRIVACIDAD — oculta importes para capturas de pantalla
   ============================================================ */
/* El texto de cada importe lo intercambia el JS (privacy.js) entre el valor
   real y "**** €". Aquí solo damos un matiz visual a los importes ocultos. */
body.privacy-on .money-mask {
    letter-spacing: 1px;
    opacity: 0.85;
}

/* Estado activo del botón de ojo en el nav */
#privacy-toggle .ic-eye-off { display: none; }
#privacy-toggle.is-active .ic-eye { display: none; }
#privacy-toggle.is-active .ic-eye-off { display: inline; }
#privacy-toggle.is-active { color: var(--gold); }

/* Estado activo del botón de ojo en el nav */
#privacy-toggle .ic-eye-off { display: none; }
#privacy-toggle.is-active .ic-eye { display: none; }
#privacy-toggle.is-active .ic-eye-off { display: inline; }
#privacy-toggle.is-active { color: var(--gold); }

/* Cantidad opcional en tareas (chip dorado) */
.task-amount {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 9px;
    border-radius: 99px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    background: color-mix(in srgb, var(--gold) 16%, transparent);
    color: var(--gold);
    border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
    vertical-align: middle;
    white-space: nowrap;
}
.task-row.is-done .task-amount { opacity: 0.5; }


/* ============================================================
   PANE ARCHIVO — documentos agrupados (no se repiten)
   ============================================================ */
.archive-docs { display: flex; flex-direction: column; gap: 10px; }

.archive-doc {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface, rgba(255,255,255,0.02));
}
.archive-doc-head {
    display: grid;
    grid-template-columns: 44px 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.archive-doc-head:hover { background: color-mix(in srgb, var(--gold) 6%, transparent); }
.archive-doc-icon {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: color-mix(in srgb, var(--gold) 12%, transparent);
    color: var(--gold-bright, #d4b084);
}
.archive-doc-main { min-width: 0; }
.archive-doc-name {
    font-size: 14px; font-weight: 600; color: var(--cream);
    display: flex; align-items: center; min-width: 0;
}
.archive-doc-fname {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Chip Emitida / Recibida / Mixto en cada comprobante */
.archive-tag {
    flex: none;
    display: inline-block;
    margin-right: 7px;
    padding: 1px 8px;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: 10px; font-weight: 600;
    letter-spacing: .4px; text-transform: uppercase;
    border: 1px solid transparent;
}
.archive-tag--issued {
    color: #7fae6f;
    background: color-mix(in srgb, #7fae6f 14%, transparent);
    border-color: color-mix(in srgb, #7fae6f 35%, transparent);
}
.archive-tag--received {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}
.archive-tag--mixed {
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 12%, transparent);
    border-color: color-mix(in srgb, var(--gold) 35%, transparent);
}
.archive-doc-meta {
    font-family: 'DM Mono', monospace;
    font-size: 11px; color: var(--cream-dim);
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px;
}
.archive-doc-net {
    font-family: 'DM Mono', monospace;
    font-size: 14px; white-space: nowrap;
}
.archive-doc-net.is-positive { color: #7fae6f; }
.archive-doc-net.is-negative { color: var(--danger); }
.archive-doc-actions { display: flex; align-items: center; gap: 10px; }
.archive-doc-chevron {
    font-size: 16px; color: var(--cream-dim);
    transition: transform 0.2s;
    display: inline-block;
}

/* Cuerpo desplegable con los movimientos del documento */
.archive-doc-body {
    border-top: 1px solid var(--border);
    padding: 6px 16px 10px;
    background: rgba(0,0,0,0.12);
}
.archive-mov {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.archive-mov:last-child { border-bottom: none; }
.archive-mov-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.archive-mov-concept { font-size: 13px; color: var(--cream); }
.archive-mov-meta { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--cream-dim); }
.archive-mov-amount { font-family: 'DM Mono', monospace; font-size: 13px; white-space: nowrap; }
.archive-mov-amount.is-positive { color: #7fae6f; }
.archive-mov-amount.is-negative { color: var(--danger); }

/* Paginación del archivo */
.archive-pagination {
    display: flex; gap: 6px; flex-wrap: wrap;
    justify-content: center;
    margin-top: 22px;
}
.archive-page {
    min-width: 34px; height: 34px;
    display: inline-grid; place-items: center;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'DM Mono', monospace; font-size: 13px;
    color: var(--cream-dim);
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}
.archive-page:hover { border-color: var(--gold); color: var(--gold-bright); }
.archive-page.is-current {
    background: var(--gold); color: var(--moss-deep, #0f1a0b);
    border-color: var(--gold); font-weight: 600;
}

@media (max-width: 640px) {
    .archive-doc-head { grid-template-columns: 36px 1fr auto; }
    .archive-doc-net { grid-column: 2; grid-row: 2; justify-self: start; }
    .archive-doc-actions { grid-column: 3; grid-row: 1 / span 2; flex-direction: column; }
    .archive-doc-icon { width: 36px; height: 36px; }
}

/* ============================================================
   TOAST — avisos flotantes con estética propia
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: grid;
    grid-template-columns: 28px 1fr 24px;
    align-items: start;
    gap: 11px;
    padding: 13px 14px;
    border-radius: 12px;
    background: var(--moss-deep, #0f1a0b);
    border: 1px solid var(--border);
    box-shadow: 0 10px 34px rgba(0,0,0,0.13);
    color: var(--cream);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s, transform 0.25s;
}
.toast.is-visible { opacity: 1; transform: translateX(0); }
.toast-icon {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 50%;
    font-family: 'DM Mono', monospace;
    font-size: 14px; font-weight: 700;
}
.toast--error   { border-color: color-mix(in srgb, var(--danger) 60%, var(--border)); }
.toast--error   .toast-icon { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }
.toast--success { border-color: color-mix(in srgb, #7fae6f 55%, var(--border)); }
.toast--success .toast-icon { background: color-mix(in srgb, #7fae6f 22%, transparent); color: #7fae6f; }
.toast--info    { border-color: color-mix(in srgb, var(--gold) 55%, var(--border)); }
.toast--info    .toast-icon { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold-bright, #d4b084); }
.toast-text {
    font-size: 13px; line-height: 1.45;
    padding-top: 4px;
    white-space: pre-line;
    word-break: break-word;
}
.toast-close {
    background: none; border: none; cursor: pointer;
    color: var(--cream-dim); font-size: 20px; line-height: 1;
    padding: 0; width: 24px; height: 24px;
    transition: color 0.15s;
}
.toast-close:hover { color: var(--cream); }

@media (max-width: 640px) {
    .toast-container { left: 12px; right: 12px; top: 12px; max-width: none; }
}

/* ============================================
 * MODAL genérico (reutilizable)
 * Activado vía data-open-modal="X" + JS minimal.
 * ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(2px);
    z-index: 1000;
    /* Centrado real: si el contenido cabe, se centra; si es más alto que
       el viewport, el overlay hace scroll y el dialog se alinea arriba
       (gracias a margin auto + flex con min-height auto en el item). */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease-out);
}
.modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}
.modal-dialog {
    background: var(--moss-deep);
    border: 1px solid var(--moss);
    border-radius: 8px;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
    /* "Pop" al abrir: escala sutil + curva fuerte (emil) */
    transform: translateY(-8px) scale(.985);
    transition: transform var(--dur-modal) var(--ease-out);
    color: var(--cream);
    display: flex;
    flex-direction: column;
    /* margin: auto + max-height: calc da el comportamiento "centra si cabe,
       scroll si no". 32px = padding del overlay (16+16). */
    margin: auto;
    max-height: calc(100vh - 32px);
}
.modal-overlay.is-open .modal-dialog {
    transform: translateY(0) scale(1);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--moss);
}
.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    font-family: 'DM Sans', system-ui, sans-serif;
    color: var(--cream);
}
.modal-close-x {
    background: none;
    border: 0;
    color: var(--cream-dim);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}
.modal-close-x:hover { color: var(--cream); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 20px;
    border-top: 1px solid var(--moss);
}

.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--cream-dim);
    font-family: 'DM Mono', monospace;
    font-size: 13px;
}
.modal-loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid var(--moss);
    border-top-color: var(--gold);
    border-radius: 50%;
    margin-right: 10px;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
    .modal-overlay { padding: 8px; }
    .modal-dialog { max-height: calc(100vh - 16px); }
}

/* ================================================================
   Módulo: Clientes
   ================================================================ */

.page--clients .page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.page--clients .page-title {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 48px;
    font-weight: 400;
    margin: 0 0 6px;
    color: var(--cream, #f5f1e8);
    line-height: 1;
}

.page--clients .page-sub {
    margin: 0;
    color: var(--cream-dim, #999);
    font-size: 14px;
    max-width: 540px;
}

/* Grid responsivo de tarjetas */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.client-card {
    display: block;
    background: var(--moss, #11201a);
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 8px;
    padding: 18px 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .15s, background .15s;
    position: relative;
}

.client-card:hover {
    border-color: var(--gold, #b8976a);
    transform: translateY(-2px);
    background: color-mix(in srgb, var(--gold, #b8976a) 4%, var(--moss, #11201a));
}

.client-card-name {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--cream, #f5f1e8);
    margin-bottom: 10px;
    line-height: 1.15;
    padding-right: 28px; /* sitio para el → */
}

.client-card::after {
    content: "→";
    position: absolute;
    top: 18px;
    right: 18px;
    color: var(--gold, #b8976a);
    opacity: 0;
    transition: opacity .15s, transform .15s;
    font-size: 16px;
}

.client-card:hover::after {
    opacity: 1;
    transform: translateX(2px);
}

.client-card-meta {
    font-size: 12px;
    color: var(--cream-dim, #999);
    line-height: 1.55;
    font-family: 'DM Mono', ui-monospace, monospace;
    word-break: break-word;
}

.client-card-meta + .client-card-meta {
    margin-top: 2px;
}

/* Agrupación por empresa */
.client-group {
    margin-bottom: 32px;
}

.client-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-family: 'DM Sans', Georgia, serif;
    font-size: 24px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--cream, #f4efe6);
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.client-group-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 11px;
    background: rgba(255,255,255,.06);
    color: var(--cream-dim, #999);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 12px;
    font-weight: 500;
}

.client-card-invoices {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,.05);
    font-size: 11px;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--cream-dim, #999);
    font-family: 'DM Mono', ui-monospace, monospace;
}

/* Estado vacío */
.page--clients .empty-state {
    text-align: center;
    padding: 80px 24px;
    background: var(--moss, #11201a);
    border-radius: 8px;
    border: 1px dashed rgba(255,255,255,.08);
}

.page--clients .empty-state p {
    color: var(--cream-dim, #999);
    margin: 0 0 16px;
    font-size: 15px;
}

/* Mobile */
@media (max-width: 640px) {
    .page--clients .page-title { font-size: 36px; }
    .clients-grid { grid-template-columns: 1fr; }
    .client-card { padding: 16px; }
    .client-card-name { font-size: 19px; }
}

/* ================================================================
   Portal del cliente (en /clients/{id})
   ================================================================ */

.client-portal {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.client-portal-head {
    margin-bottom: 22px;
}

.client-portal-title {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 30px;
    font-weight: 500;
    margin: 0 0 6px;
    color: var(--cream, #f5f1e8);
    line-height: 1.1;
}

.client-portal-sub {
    margin: 0;
    color: var(--cream-dim, #999);
    font-size: 13px;
}

/* Grid de estadísticas */
.client-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.client-stat {
    background: var(--moss, #11201a);
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 6px;
    padding: 14px 16px;
}

.client-stat-label {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cream-dim, #999);
    margin-bottom: 8px;
}

.client-stat-value {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--cream, #f5f1e8);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.client-stat-value--warn {
    color: var(--gold, #b8976a);
}

.client-stat-value--small {
    font-size: 16px;
}

/* Tabla de facturas */
.client-invoices {
    background: var(--moss, #11201a);
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 6px;
    overflow: hidden;
}

.client-invoices-row {
    display: grid;
    grid-template-columns: 120px 90px 1fr 130px 100px 70px;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.05));
    font-size: 13px;
}

.client-invoices-row:last-child {
    border-bottom: none;
}

.client-invoices-row--head {
    background: color-mix(in srgb, var(--moss-deep, #0f1a0b) 50%, transparent);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cream-dim, #999);
}

.client-invoices-row:not(.client-invoices-row--head):hover {
    background: color-mix(in srgb, var(--gold, #b8976a) 4%, transparent);
}

.client-invoices-code a {
    color: var(--gold, #b8976a);
    text-decoration: none;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
}

.client-invoices-code a:hover {
    text-decoration: underline;
}

.client-invoices-date {
    color: var(--cream-dim, #999);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
}

.client-invoices-company {
    color: var(--cream, #f5f1e8);
}

.client-invoices-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--cream, #f5f1e8);
    font-weight: 500;
}

.client-invoices-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid;
}

.client-invoices-badge.is-draft {
    color: var(--cream-dim, #999);
    border-color: rgba(255,255,255,.15);
}

.client-invoices-badge.is-issued {
    color: var(--gold, #b8976a);
    border-color: rgba(184, 151, 106, .35);
}

.client-invoices-badge.is-paid {
    color: #7ea86a;
    border-color: rgba(126, 168, 106, .35);
}

.client-invoices-badge.is-cancelled {
    color: #dc3545;
    border-color: rgba(220, 53, 69, .35);
    text-decoration: line-through;
}

/* Estado vacío */
.client-portal-empty {
    background: var(--moss, #11201a);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 32px 24px;
    text-align: center;
    color: var(--cream-dim, #999);
    font-size: 13px;
    line-height: 1.5;
}

/* Mobile */
@media (max-width: 768px) {
    .client-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .client-portal-title { font-size: 24px; }
    /* En móvil no ocultamos columnas: scroll horizontal para conservar
       fecha, empresa, estado y el botón PDF. */
    .client-invoices { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .client-invoices-row { min-width: 560px; }
}

/* ================================================================
   Bóveda de credenciales
   ================================================================ */

.page--vault .vault-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page--vault .page-title {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 44px;
    font-weight: 400;
    margin: 0 0 4px;
    color: var(--cream, #f5f1e8);
    line-height: 1.05;
}

.page--vault .page-title em {
    font-style: italic;
    color: var(--gold, #b8976a);
}

.page--vault .page-sub {
    margin: 0;
    color: var(--cream-dim, #999);
    font-size: 13px;
    max-width: 640px;
    line-height: 1.5;
}

/* Banner de warning si no hay clave */
.vault-warn {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.35);
    border-radius: 6px;
    padding: 16px 20px;
    color: var(--cream, #f5f1e8);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.vault-warn code {
    background: rgba(0, 0, 0, 0.25);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
}

/* Banner informativo (cifrado OK) */
.vault-notice {
    background: rgba(184, 151, 106, 0.06);
    border: 1px solid rgba(184, 151, 106, 0.18);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--cream-dim, #999);
    font-size: 12px;
    margin-bottom: 20px;
}

/* Grid de cards */
.vault-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

.vault-card {
    background: var(--moss, #11201a);
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 8px;
    padding: 18px;
    transition: border-color .15s;
}

.vault-card:hover {
    border-color: rgba(184, 151, 106, 0.25);
}

.vault-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.vault-card-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.vault-card-title-wrap {
    flex: 1;
    min-width: 0;
}

.vault-card-title {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 20px;
    font-weight: 500;
    color: var(--cream, #f5f1e8);
    line-height: 1.15;
    margin-bottom: 2px;
}

.vault-card-url {
    color: var(--gold, #b8976a);
    text-decoration: none;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

.vault-card-url:hover { text-decoration: underline; }

.vault-card-edit {
    background: transparent;
    border: 1px solid rgba(255,255,255,.1);
    color: var(--cream-dim, #999);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
    transition: border-color .15s, color .15s;
}

.vault-card-edit:hover {
    border-color: var(--gold, #b8976a);
    color: var(--gold, #b8976a);
}

.vault-card-row {
    display: grid;
    grid-template-columns: 80px 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 13px;
}

.vault-card-label {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cream-dim, #999);
}

.vault-card-value {
    color: var(--cream, #f5f1e8);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    word-break: break-all;
    overflow-wrap: anywhere;
    min-width: 0;
}

.vault-pwd {
    letter-spacing: 0.05em;
}

.vault-pwd[data-revealed="1"] {
    color: var(--gold, #b8976a);
}

.vault-eye, .vault-copy {
    background: transparent;
    border: none;
    color: var(--cream-dim, #999);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 3px;
    transition: background .15s, color .15s;
}

.vault-eye:hover, .vault-copy:hover {
    background: rgba(255,255,255,.06);
    color: var(--gold, #b8976a);
}

.vault-card-foot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.vault-share-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,.1);
    color: var(--cream, #f5f1e8);
    padding: 5px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: border-color .15s, color .15s;
}

.vault-share-btn:hover {
    border-color: var(--gold, #b8976a);
    color: var(--gold, #b8976a);
}

.vault-share-count {
    display: inline-block;
    background: var(--gold, #b8976a);
    color: var(--moss-deep, #0f1a0b);
    border-radius: 999px;
    padding: 0 6px;
    font-weight: 600;
    font-size: 10px;
    margin-left: 4px;
}

.vault-shared-with {
    color: var(--cream-dim, #999);
    font-size: 11px;
    font-style: italic;
}

.vault-empty {
    text-align: center;
    padding: 60px 24px;
    background: var(--moss, #11201a);
    border: 1px dashed rgba(255,255,255,.08);
    border-radius: 8px;
    color: var(--cream-dim, #999);
}

/* Modal de compartir: filas de share actual */
.vault-share-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: rgba(0,0,0,.2);
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
}

/* Auditoría */
.vault-audit-table {
    background: var(--moss, #11201a);
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 6px;
    overflow: hidden;
}

.vault-audit-row {
    display: grid;
    grid-template-columns: 140px 180px 130px 1fr 1.5fr;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,.05);
    font-size: 12px;
    align-items: center;
}

.vault-audit-row:last-child { border-bottom: none; }

.vault-audit-row--head {
    background: color-mix(in srgb, var(--moss-deep, #0f1a0b) 50%, transparent);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cream-dim, #999);
}

.vault-audit-date {
    color: var(--cream-dim, #999);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
}

.vault-audit-service {
    color: var(--cream, #f5f1e8);
    font-weight: 500;
}

.vault-audit-detail {
    color: var(--cream-dim, #999);
    font-size: 11px;
}

.vault-audit-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid;
}

.vault-audit-badge.is-create  { color:#7ea86a; border-color:rgba(126,168,106,.35); }
.vault-audit-badge.is-read    { color: var(--gold); border-color: rgba(184,151,106,.35); }
.vault-audit-badge.is-update  { color: var(--cream); border-color: rgba(255,255,255,.15); }
.vault-audit-badge.is-delete  { color:#dc3545; border-color: rgba(220,53,69,.35); }
.vault-audit-badge.is-share,
.vault-audit-badge.is-unshare { color:#5d9cff; border-color: rgba(93,156,255,.35); }

/* Mobile */
@media (max-width: 640px) {
    .page--vault .page-title { font-size: 32px; }
    .vault-grid { grid-template-columns: 1fr; }
    .vault-card-row { grid-template-columns: 60px 1fr auto auto; gap: 6px; font-size: 12px; }
    .vault-audit-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .vault-audit-row > div:nth-child(4),
    .vault-audit-row > div:nth-child(5) { grid-column: 1 / -1; }
}


/* ================================================================
   Deudas — pagos parciales e historial (módulo introducido en 034-036)
   ================================================================ */

/* Barra de progreso cuando hay pagos parciales */
.debt-progress {
    margin: 10px 0 4px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.debt-progress-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}
.debt-progress-fill {
    height: 100%;
    min-width: 6px;              /* pagos pequeños siguen siendo visibles */
    background: linear-gradient(90deg,
        var(--gold, #b8976a) 0%,
        color-mix(in srgb, var(--gold, #b8976a) 70%, white 30%) 100%);
    border-radius: 999px;
    transition: width .25s ease-out;
}
.debt-progress-text {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: .04em;
    color: var(--cream-dim, #999);
    white-space: nowrap;
}
.debt-progress-paid  { color: var(--gold, #b8976a); font-weight: 500; }
.debt-progress-sep   { opacity: .55; margin: 0 4px; }
.debt-progress-total { opacity: .85; }

/* Botones nuevos del pie de la deuda */
.debt-pay-btn,
.debt-history-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--cream-dim, #999);
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    letter-spacing: .04em;
    text-transform: uppercase;
    transition: border-color .15s, color .15s, background .15s;
}
.debt-pay-btn:hover {
    border-color: rgba(126, 168, 106, 0.45);
    color: #9bc18a;
}
.debt-history-btn:hover {
    border-color: var(--gold, #b8976a);
    color: var(--gold, #b8976a);
}
.debt-history-chev {
    font-size: 9px;
    opacity: .75;
}

/* ----------------------------------------------------------------
   FORM DE PAGO (inline, debajo de la fila de la deuda)
   ---------------------------------------------------------------- */

.debt-pay-form {
    margin-top: 12px;
    padding: 18px 18px 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(184, 151, 106, 0.20);
    border-radius: 8px;
}

.debt-pay-row {
    display: grid;
    gap: 14px;
    align-items: end;
}
.debt-pay-row + .debt-pay-row { margin-top: 12px; }

.debt-pay-row--main {
    grid-template-columns: 140px 150px 160px 1fr;
}
.debt-pay-row--target {
    grid-template-columns: 1fr 1fr;
}

.debt-pay-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.debt-pay-field label {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--cream-dim, #999);
    line-height: 1.2;
}
.debt-pay-opt {
    text-transform: none;
    letter-spacing: 0;
    font-size: 10px;
    color: var(--cream-dim, #999);
    opacity: .6;
    margin-left: 2px;
}

.debt-pay-field input,
.debt-pay-field select {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    color: var(--cream, #f5f1e8);
    padding: 9px 11px;
    font-family: inherit;
    font-size: 13px;
    width: 100%;
    transition: border-color .15s, background .15s;
}
.debt-pay-field input:hover,
.debt-pay-field select:hover {
    border-color: rgba(255, 255, 255, 0.16);
}
.debt-pay-field input:focus,
.debt-pay-field select:focus {
    outline: none;
    border-color: var(--gold, #b8976a);
    background: rgba(0, 0, 0, 0.5);
}
.debt-pay-field input[type="date"] {
    /* date inputs en dark theme se ven raros si no forzamos color del icono */
    color-scheme: dark;
}

.debt-pay-hint {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--cream-dim, #999);
    opacity: .7;
    margin-top: 1px;
}

/* Caja informativa "Se registrará un gasto en..." */
.debt-pay-explain {
    margin-top: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(184, 151, 106, 0.06);
    border: 1px solid rgba(184, 151, 106, 0.15);
    border-radius: 5px;
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--cream, #f5f1e8);
}
.debt-pay-explain svg {
    color: var(--gold, #b8976a);
    flex-shrink: 0;
    margin-top: 1px;
}

.debt-pay-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Mobile: collapsar el grid */
@media (max-width: 900px) {
    .debt-pay-row--main { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
    .debt-pay-row--target { grid-template-columns: 1fr; }
    .debt-pay-field--grow { grid-column: 1 / -1; }
}
@media (max-width: 460px) {
    .debt-pay-row--main { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------------
   HISTORIAL DE PAGOS
   ---------------------------------------------------------------- */

.debt-history {
    margin-top: 12px;
    padding: 12px 14px 10px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}
.debt-history-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.debt-history-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cream-dim, #999);
}
.debt-history-sub {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--gold, #b8976a);
}
.debt-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.debt-history-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}
.debt-history-item:last-child { border-bottom: none; }
.debt-history-item-main { flex: 1; min-width: 0; }
.debt-history-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 12px;
    font-size: 13px;
}
.debt-history-amount {
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    color: var(--cream, #f5f1e8);
}
.debt-history-date {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--cream-dim, #999);
}
.debt-history-account {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--cream-dim, #999);
    flex-wrap: wrap;
}
.debt-history-account svg { opacity: .65; flex-shrink: 0; }
.debt-history-account strong {
    color: var(--cream, #f5f1e8);
    font-weight: 500;
}
.debt-history-company {
    opacity: .7;
    font-style: italic;
}
.debt-history-detail,
.debt-history-notes {
    font-size: 11.5px;
    color: var(--cream-dim, #999);
    margin-top: 3px;
}
.debt-history-notes { font-style: italic; opacity: .85; }

.debt-history-del button {
    background: transparent;
    border: 1px solid rgba(220, 53, 69, 0.2);
    color: rgba(220, 53, 69, 0.8);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, background .15s;
}
.debt-history-del button:hover {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.5);
}

/* Input file con UI custom (oculta el feo input nativo) */
.debt-pay-row--attach {
    grid-template-columns: 1fr;
}
.debt-pay-file {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    cursor: pointer;
}
.debt-pay-file input[type="file"] {
    /* Ocultamos el input nativo, pero accesible (clickeable) */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.debt-pay-file-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(184, 151, 106, 0.12);
    border: 1px solid rgba(184, 151, 106, 0.3);
    border-radius: 5px;
    color: var(--gold, #b8976a);
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    letter-spacing: .04em;
    text-transform: uppercase;
    transition: background .15s, border-color .15s;
}
.debt-pay-file:hover .debt-pay-file-btn {
    background: rgba(184, 151, 106, 0.2);
    border-color: var(--gold, #b8976a);
}
.debt-pay-file-name {
    font-size: 12px;
    color: var(--cream-dim, #999);
    font-style: italic;
}
.debt-pay-file-name.has-file {
    color: var(--cream, #f5f1e8);
    font-style: normal;
}

/* Link a justificante en historial */
.debt-history-attach {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--gold, #b8976a);
    text-decoration: none;
    transition: color .15s;
}
.debt-history-attach:hover {
    color: color-mix(in srgb, var(--gold, #b8976a) 70%, white 30%);
    text-decoration: underline;
}

/* "Registrado por X" en historial */
.debt-history-payer {
    margin-top: 3px;
    font-size: 10.5px;
    color: var(--cream-dim, #999);
    opacity: .6;
    font-style: italic;
}

/* "Pagar todo" — el hint del input importe ahora es un botón */
.debt-pay-hint--btn {
    background: transparent;
    border: 1px dashed rgba(184, 151, 106, 0.3);
    color: var(--gold, #b8976a);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: .03em;
    text-align: left;
    width: 100%;
    transition: border-color .15s, background .15s, color .15s;
}
.debt-pay-hint--btn:hover {
    border-color: var(--gold, #b8976a);
    background: rgba(184, 151, 106, 0.08);
    color: color-mix(in srgb, var(--gold, #b8976a) 70%, white 30%);
}
.debt-pay-hint--btn:active {
    background: rgba(184, 151, 106, 0.15);
}


/* ================================================================
   Documentos por empresa/proyecto (módulo 037 — vista cartitas v2)
   ================================================================ */

/* ----------------------------------------------------------------
   Buscador (compartido entre pane y página detalle)
   ---------------------------------------------------------------- */
.doc-search {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.doc-search--local { margin-bottom: 16px; }

.doc-search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 260px;
    max-width: 520px;
}
.doc-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cream-dim, #999);
    opacity: .6;
    pointer-events: none;
}
.doc-search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: var(--cream, #f5f1e8);
    padding: 10px 36px 10px 36px;
    font-family: inherit;
    font-size: 13px;
    transition: border-color .15s, background .15s;
}
.doc-search-input:focus {
    outline: none;
    border-color: var(--gold, #b8976a);
    background: rgba(0, 0, 0, 0.5);
}
.doc-search-input::placeholder { color: var(--cream-dim, #999); opacity: .55; }
.doc-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.doc-search-clear {
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--cream-dim, #999);
    font-size: 22px; line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    border-radius: 4px;
    transition: color .15s, background .15s;
}
.doc-search-clear:hover { color: var(--cream, #f5f1e8); background: rgba(255,255,255,0.05); }

.doc-search-stats {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: .04em;
    color: var(--gold, #b8976a);
    text-transform: uppercase;
}
.doc-search-stats.is-empty { color: var(--cream-dim, #999); opacity: .65; }

/* ----------------------------------------------------------------
   Grid de cartitas de secciones
   ---------------------------------------------------------------- */
.doc-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.doc-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    background: var(--moss, #11201a);
    border: 1px solid var(--border, rgba(255,255,255,.06));
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .15s, background .15s;
    cursor: pointer;
}
.doc-card:hover {
    border-color: var(--gold, #b8976a);
    transform: translateY(-1px);
    background: rgba(184, 151, 106, 0.04);
}

.doc-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(184, 151, 106, 0.12);
    border-radius: 8px;
    color: var(--gold, #b8976a);
    flex-shrink: 0;
}
.doc-card-icon svg { width: 22px; height: 22px; }

.doc-card-body { flex: 1; min-width: 0; }
.doc-card-title {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--cream, #f5f1e8);
    margin: 0 0 4px;
    line-height: 1.15;
}
.doc-card-desc {
    margin: 0 0 8px;
    font-size: 12.5px;
    color: var(--cream-dim, #999);
    line-height: 1.4;
    /* Limitar a 2 líneas para que las cartitas tengan altura uniforme */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.doc-card-count {
    margin: 0;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gold, #b8976a);
    opacity: .85;
}

.doc-card-arrow {
    color: var(--cream-dim, #999);
    opacity: .5;
    flex-shrink: 0;
    align-self: center;
    transition: opacity .15s, transform .15s;
}
.doc-card:hover .doc-card-arrow {
    opacity: 1;
    color: var(--gold, #b8976a);
    transform: translateX(2px);
}

@media (max-width: 600px) {
    .doc-cards { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------------
   Resultados aplanados de búsqueda (en pane principal)
   ---------------------------------------------------------------- */
.doc-search-results { margin-top: 4px; }
.doc-search-results-title {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cream-dim, #999);
    margin: 0 0 10px;
}
.doc-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.doc-search-result {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    transition: border-color .15s;
}
.doc-search-result:hover { border-color: rgba(184, 151, 106, 0.18); }
.doc-search-result-icon { color: var(--gold, #b8976a); flex-shrink: 0; margin-top: 2px; }
.doc-search-result-icon svg { width: 16px; height: 16px; }
.doc-search-result-body { flex: 1; min-width: 0; }
.doc-search-result-title {
    font-size: 14px;
    color: var(--cream, #f5f1e8);
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word;
}
.doc-search-result-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 11.5px;
}
.doc-search-result-section {
    color: var(--gold, #b8976a);
    text-decoration: none;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 2px 8px;
    background: rgba(184, 151, 106, 0.1);
    border-radius: 3px;
    transition: background .15s;
}
.doc-search-result-section:hover { background: rgba(184, 151, 106, 0.2); }

.doc-search-result-action {
    color: var(--gold, #b8976a);
    text-decoration: none;
    transition: color .15s;
}
.doc-search-result-action:hover {
    color: color-mix(in srgb, var(--gold, #b8976a) 70%, white 30%);
    text-decoration: underline;
}
.doc-search-result-notes {
    margin: 5px 0 0;
    font-size: 11.5px;
    color: var(--cream-dim, #999);
    font-style: italic;
    line-height: 1.4;
}
.doc-search-results-empty {
    text-align: center;
    padding: 30px;
    color: var(--cream-dim, #999);
    font-size: 13px;
    font-style: italic;
    opacity: .65;
    margin: 0;
}

/* ----------------------------------------------------------------
   Página detalle de una sección (/companies/{id}/documents/{sid})
   ---------------------------------------------------------------- */
.doc-detail-wrap {
    max-width: 880px;
    margin: 32px auto;
    padding: 0 20px 60px;
}

.doc-detail-head {
    margin-bottom: 28px;
}
.doc-detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--cream-dim, #999);
    text-decoration: none;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 18px;
    transition: color .15s;
}
.doc-detail-back:hover { color: var(--gold, #b8976a); }

.doc-detail-title-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.doc-detail-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(184, 151, 106, 0.12);
    border-radius: 10px;
    color: var(--gold, #b8976a);
    flex-shrink: 0;
}
.doc-detail-icon svg { width: 26px; height: 26px; }
.doc-detail-title-wrap { flex: 1; min-width: 0; }
.doc-detail-title {
    font-family: 'DM Sans', Georgia, serif;
    font-size: 34px;
    font-weight: 500;
    color: var(--cream, #f5f1e8);
    margin: 0 0 4px;
    line-height: 1.1;
}
.doc-detail-desc {
    margin: 0 0 6px;
    color: var(--cream-dim, #999);
    font-size: 13px;
    line-height: 1.4;
}
.doc-detail-meta {
    margin: 0;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--cream-dim, #999);
    opacity: .65;
}
.doc-detail-delete-section { align-self: center; }

.doc-detail-empty {
    text-align: center;
    padding: 60px 30px;
    color: var(--cream-dim, #999);
    font-size: 14px;
}
.doc-detail-empty p { margin: 0 0 8px; }
.doc-detail-empty-hint { font-size: 12px; opacity: .7; }

/* ----------------------------------------------------------------
   Form añadir documento (compartido entre pane y detalle)
   ---------------------------------------------------------------- */
.doc-section-add {
    padding: 16px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px dashed rgba(184, 151, 106, 0.25);
    border-radius: 8px;
    margin-bottom: 22px;
    margin-top: 22px;
}
.doc-section-add--standalone {
    margin-top: 0;
}
.doc-add-tab {
    background: transparent;
    border: 1px solid rgba(255,255,255,.1);
    color: var(--cream-dim, #999);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    letter-spacing: .04em;
    margin-right: 6px;
    transition: border-color .15s, color .15s, background .15s;
}
.doc-add-tab:hover { border-color: rgba(184, 151, 106, 0.5); color: var(--gold, #b8976a); }
.doc-add-tab.is-active {
    background: rgba(184, 151, 106, 0.15);
    border-color: var(--gold, #b8976a);
    color: var(--gold, #b8976a);
}
.doc-add-form {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.doc-add-input,
.doc-add-notes {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 5px;
    color: var(--cream, #f5f1e8);
    padding: 9px 11px;
    font-family: inherit;
    font-size: 13px;
    width: 100%;
    transition: border-color .15s;
}
.doc-add-input:focus,
.doc-add-notes:focus { outline: none; border-color: var(--gold, #b8976a); }
.doc-add-notes { resize: vertical; min-height: 60px; }
.doc-add-hint {
    font-size: 10.5px;
    color: var(--cream-dim, #999);
    opacity: .7;
    margin-top: 2px;
    display: block;
}
.doc-add-file {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    cursor: pointer;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 5px;
}
.doc-add-file input[type="file"] {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}
.doc-add-file-btn {
    display: inline-block;
    padding: 5px 12px;
    background: rgba(184, 151, 106, 0.12);
    border: 1px solid rgba(184, 151, 106, 0.3);
    border-radius: 4px;
    color: var(--gold, #b8976a);
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    letter-spacing: .04em;
    text-transform: uppercase;
    transition: background .15s;
}
.doc-add-file:hover .doc-add-file-btn { background: rgba(184, 151, 106, 0.22); }
.doc-add-file-name { font-size: 12px; color: var(--cream-dim, #999); font-style: italic; }
.doc-add-file-name.has-file { color: var(--cream, #f5f1e8); font-style: normal; }
.doc-add-submit { align-self: flex-end; margin-top: 4px; }

/* ----------------------------------------------------------------
   Lista de items en página detalle
   ---------------------------------------------------------------- */
/* Navegación tipo Drive: migas de pan + carpetas */
.doc-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin: 4px 0 12px;
    font-size: 13px;
}
.doc-crumb {
    border: none;
    background: transparent;
    color: var(--cream-dim, #999);
    padding: 3px 6px;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
}
.doc-crumb:hover { background: rgba(184, 151, 106, .1); color: var(--gold-bright, #d4b483); }
.doc-crumb:last-of-type { color: var(--cream, #eee); font-weight: 600; }
.doc-crumb-sep { color: var(--cream-dim, #777); opacity: .6; }
.doc-folders {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin: 0 0 14px;
}
.doc-folder-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 13px;
    border: 1px solid var(--border, #3a3f33);
    border-radius: 11px;
    background: var(--moss, #23291f);
    color: var(--cream, #eee);
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: border-color .15s, background .15s;
}
.doc-folder-card:hover {
    border-color: rgba(184, 151, 106, .35);
    background: rgba(184, 151, 106, .07);
}
.doc-folder-card svg { color: var(--gold, #b8976a); flex: 0 0 auto; }
.doc-folder-name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.doc-folder-count {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--cream-dim, #999);
    background: rgba(255, 255, 255, .05);
    border-radius: 9px;
    padding: 1px 7px;
}
.doc-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.doc-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    transition: border-color .15s;
}
.doc-item:hover { border-color: rgba(184, 151, 106, 0.18); }
.doc-item-icon { color: var(--gold, #b8976a); flex-shrink: 0; margin-top: 2px; }
.doc-item-icon svg { width: 16px; height: 16px; }
.doc-item-body { flex: 1; min-width: 0; }
.doc-item-title {
    font-size: 14px;
    color: var(--cream, #f5f1e8);
    font-weight: 500;
    margin-bottom: 3px;
    word-break: break-word;
}
.doc-item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    color: var(--cream-dim, #999);
}
.doc-item-link {
    color: var(--gold, #b8976a);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color .15s;
}
.doc-item-link:hover {
    color: color-mix(in srgb, var(--gold, #b8976a) 70%, white 30%);
    text-decoration: underline;
}
.doc-item-size { font-family: 'DM Mono', monospace; font-size: 10px; opacity: .7; margin-left: 3px; }
.doc-item-date, .doc-item-uploader { font-family: 'DM Mono', monospace; font-size: 10px; opacity: .65; }
.doc-item-uploader { font-style: italic; }
.doc-item-notes {
    margin: 6px 0 0;
    font-size: 11.5px;
    color: var(--cream-dim, #999);
    font-style: italic;
    line-height: 1.4;
}
.doc-item-delete button {
    background: transparent;
    border: 1px solid rgba(220, 53, 69, 0.2);
    color: rgba(220, 53, 69, 0.7);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
}
.doc-item-delete button:hover {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.5);
}

.doc-section-empty {
    text-align: center;
    padding: 24px;
    color: var(--cream-dim, #999);
    font-size: 12.5px;
    font-style: italic;
    opacity: .65;
    margin: 14px 0 0;
}

/* ----------------------------------------------------------------
   Selector de icono en modal nueva sección
   ---------------------------------------------------------------- */
.doc-icon-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-top: 4px;
}
@media (max-width: 600px) { .doc-icon-picker { grid-template-columns: repeat(4, 1fr); } }
.doc-icon-option { cursor: pointer; display: block; }
.doc-icon-option input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.doc-icon-swatch {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 6px;
    color: var(--cream-dim, #999);
    transition: border-color .15s, color .15s, background .15s;
}
.doc-icon-swatch svg { width: 18px; height: 18px; }
.doc-icon-option:hover .doc-icon-swatch {
    border-color: rgba(184, 151, 106, 0.4);
    color: var(--gold, #b8976a);
}
.doc-icon-option input[type="radio"]:checked + .doc-icon-swatch {
    background: rgba(184, 151, 106, 0.15);
    border-color: var(--gold, #b8976a);
    color: var(--gold, #b8976a);
}

@media (max-width: 600px) {
    .doc-detail-title { font-size: 26px; }
    .doc-detail-icon { width: 44px; height: 44px; }
    .doc-item { gap: 8px; padding: 10px; }
}

/* Ajustes del modal "Añadir documento" en la página detalle de sección */
.doc-detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: center;
    flex-wrap: wrap;
}
.doc-detail-actions .doc-detail-delete-section {
    margin: 0;
}

/* Pestañas Subir archivo / Pegar URL dentro del modal */
.doc-add-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Cuando el form está dentro de un modal, los inputs heredan estilo de .field-input
   del sistema y no necesitamos los estilos legacy .doc-add-input. Reset puntual: */
.modal-body .doc-add-form .field { margin-bottom: 14px; }
.modal-body .doc-add-form .field:last-child { margin-bottom: 0; }
.modal-body .doc-add-file { margin-top: 4px; }

@media (max-width: 600px) {
    .doc-detail-actions {
        align-self: stretch;
        justify-content: flex-start;
    }
}

/* Link secundario: descargar (en oposición a ver/preview, que es primario) */
.doc-item-link--secondary,
.doc-search-result-action--secondary {
    color: var(--cream-dim, #999);
    opacity: .75;
}
.doc-item-link--secondary:hover,
.doc-search-result-action--secondary:hover {
    color: var(--gold, #b8976a);
    opacity: 1;
}

/* FIX CRÍTICO: `.doc-item` y `.doc-search-result` tienen `display:flex` que
   gana al atributo `hidden` nativo del HTML (que por defecto es display:none).
   Resultado: el buscador filtraba pero los items "ocultos" se veían igual.
   Forzamos display:none cuando el item tiene el atributo `hidden`. */
.doc-item[hidden],
.doc-search-result[hidden],
.doc-card[hidden],
.doc-section[hidden] {
    display: none !important;
}

/* CTA "Hazme un tour" en la pantalla de bienvenida del chat */
.ai-chat-tour-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    margin: 4px 0 14px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(184, 151, 106, .35);
    background: linear-gradient(135deg, rgba(184, 151, 106, .12), rgba(184, 151, 106, .04));
    color: var(--cream, #f5f1e8);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.ai-chat-tour-cta:hover {
    border-color: var(--gold);
    background: linear-gradient(135deg, rgba(184, 151, 106, .2), rgba(184, 151, 106, .08));
}
.ai-chat-tour-cta-icon { font-size: 20px; line-height: 1; }
.ai-chat-tour-cta small { color: var(--cream-dim, #c8c3b5); }

/* ============================================================
   Tour guiado de Calma — spotlight + tarjeta serena
   ============================================================ */
.calma-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    /* El "hueco" del spotlight se dibuja con box-shadow del recuadro */
    pointer-events: none;
}
.calma-tour-overlay.is-active { pointer-events: auto; }

/* Capa oscura que captura clics fuera del foco */
.calma-tour-scrim {
    position: fixed;
    inset: 0;
    background: transparent;
    pointer-events: auto;
}

/* Recuadro que rodea el elemento enfocado. El gran box-shadow exterior
   crea el oscurecido de todo lo demás sin tapar el elemento. */
.calma-tour-spot {
    /* Por defecto OCULTO: el oscurecido (box-shadow gigante) solo debe
       aparecer cuando position() ha colocado el foco sobre un elemento
       real. Así, si el tour se rompe a medio render, la página NUNCA
       queda tapada por un velo sin tarjeta. */
    display: none;
    position: absolute;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(16, 48, 45, .62);
    outline: 3px solid var(--gold);
    outline-offset: 4px;
    filter: drop-shadow(0 0 10px color-mix(in srgb, var(--gold) 55%, transparent));
    transition: all .35s cubic-bezier(.4, 0, .2, 1);
    pointer-events: none;
}
/* Latido suave del foco para llamar la atención (se desactiva con
   .calma-tour-noanim cuando el usuario pide menos movimiento). */
.calma-tour-spot {
    animation: calmaTourPulse 1.8s ease-in-out infinite;
}
@keyframes calmaTourPulse {
    0%, 100% { outline-color: var(--gold); outline-offset: 4px; }
    50%      { outline-color: color-mix(in srgb, var(--gold) 55%, transparent); outline-offset: 9px; }
}
.calma-tour-overlay.calma-tour-noanim .calma-tour-spot { animation: none; }

/* Zona transparente y tocable justo encima del foco: al tocarla, el
   tour AVANZA (cómodo en móvil: "toca el círculo para seguir"). */
.calma-tour-hotspot {
    display: none;
    position: absolute;
    z-index: 9999;            /* por encima del scrim, bajo la tarjeta */
    border-radius: 12px;
    cursor: pointer;
    background: transparent;
    pointer-events: auto;
}

/* Barra de progreso fina arriba de la tarjeta. */
.calma-tour-progress {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: 16px 16px 0 0;
    background: rgba(184, 151, 106, .18);
    overflow: hidden;
}
.calma-tour-progress-bar {
    display: block;
    height: 100%;
    background: var(--gold, #c9a86a);
    border-radius: 16px 0 0 0;
    transition: width .35s cubic-bezier(.4, 0, .2, 1);
}
.calma-tour-overlay.calma-tour-noanim .calma-tour-progress-bar { transition: none; }

.calma-tour-card {
    position: absolute;
    z-index: 9999;
    width: 320px;
    max-width: calc(100vw - 32px);
    background: var(--moss, #1a2614);
    border: 1px solid rgba(184, 151, 106, .35);
    border-radius: 16px;
    padding: 18px 18px 14px;
    color: var(--cream, #f5f1e8);
    transition: top .35s cubic-bezier(.4, 0, .2, 1), left .35s cubic-bezier(.4, 0, .2, 1);
}
:root[data-theme="light"] .calma-tour-card {
    background: #ffffff;
    border-color: rgba(79, 70, 229, .22);
}
/* La tarjeta nunca debe ser más alta que la pantalla: si el contenido no
   cabe (móvil, texto largo), se desplaza por dentro en vez de salirse. */
.calma-tour-card {
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Flecha/conector entre la tarjeta y el elemento iluminado. Es un cuadrado
   girado 45° con el mismo fondo/borde que la tarjeta; se le tapan dos lados
   con la propia tarjeta, dejando solo la "punta" hacia el foco. */
.calma-tour-arrow {
    display: none;
    position: absolute;
    z-index: 9999;
    width: 14px;
    height: 14px;
    background: var(--moss, #1a2614);
    border: 1px solid rgba(184, 151, 106, .35);
    transform: rotate(45deg);
    pointer-events: none;
}
:root[data-theme="light"] .calma-tour-arrow {
    background: #ffffff;
    border-color: rgba(79, 70, 229, .22);
}
/* Apuntando hacia ARRIBA (tarjeta debajo del foco): ocultamos el borde
   inferior-derecho con la tarjeta, dejando visible la esquina superior. */
.calma-tour-arrow.is-up   { border-right: 0; border-bottom: 0; }
/* Apuntando hacia ABAJO (tarjeta encima del foco). */
.calma-tour-arrow.is-down { border-left: 0; border-top: 0; }
/* Tarjeta centrada (intro / cierre): más ancha y con más aire. */
.calma-tour-card--center {
    width: 420px;
    padding: 26px 26px 20px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.calma-tour-card--center .calma-tour-title { font-size: 25px; }
.calma-tour-card--center .calma-tour-body { font-size: 14.5px; }
/* Avatar guía del tour: foto circular con anillo dorado. */
.calma-tour-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    flex: 0 0 auto;
}
.calma-tour-avatar img,
.calma-tour-avatar svg {
    width: 64%;
    height: 64%;
    display: block;
}
.calma-tour-card--center .calma-tour-avatar {
    width: 84px;
    height: 84px;
    margin: 0 auto 16px;
}
.calma-tour-step {
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--gold-bright, #d4b084);
    margin: 0 0 6px;
    font-weight: 600;
}
.calma-tour-title {
    margin: 0 0 8px;
    font-family: 'DM Sans', Georgia, serif;
    font-size: 21px;
    font-weight: 600;
    line-height: 1.2;
}
.calma-tour-body {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--cream-dim, #c8c3b5);
}
.calma-tour-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.calma-tour-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    /* Fila propia a lo ancho: con 15 pasos no caben junto a los botones,
       así que los puntos van arriba y "Atrás/Siguiente" debajo, a la derecha. */
    flex: 1 0 100%;
    justify-content: center;
    margin: 0 0 10px;
}
.calma-tour-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(184, 151, 106, .3);
    transition: background .2s, transform .2s;
}
.calma-tour-dot.is-current {
    background: var(--gold);
    transform: scale(1.3);
}
.calma-tour-btn {
    border: 1px solid rgba(184, 151, 106, .35);
    background: transparent;
    color: var(--cream, #f5f1e8);
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.calma-tour-btn:hover { border-color: var(--gold); }
.calma-tour-btn--primary {
    background: var(--gold);
    border-color: var(--gold);
    color: #16302d;
    font-weight: 600;
}
:root[data-theme="light"] .calma-tour-btn--primary { color: #fff; }
.calma-tour-btn--primary:hover { background: var(--gold-bright, #d4b084); }
.calma-tour-skip {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    color: var(--cream-dim, #c8c3b5);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
}
.calma-tour-skip:hover { color: var(--cream, #f5f1e8); }
@media (prefers-reduced-motion: reduce) {
    .calma-tour-spot,
    .calma-tour-card { transition: none; }
}

/* --- Tour en móvil: la tarjeta ocupa el ancho como una hoja nativa --- */
@media (max-width: 768px) {
    .calma-tour-card {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        padding: 16px 16px 12px;
        box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
    }
    .calma-tour-card--center {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        padding: 22px 20px 16px;
    }
    .calma-tour-card--center .calma-tour-title { font-size: 22px; }
    .calma-tour-title { font-size: 19px; }
    .calma-tour-body { font-size: 14px; }
    /* Botones más grandes para el pulgar (mín. 44px de alto táctil). */
    .calma-tour-btn {
        padding: 11px 18px;
        font-size: 14px;
        min-height: 44px;
    }
    .calma-tour-skip {
        top: 10px;
        right: 10px;
        font-size: 22px;
        padding: 8px;
        min-width: 40px;
        min-height: 40px;
    }
    /* El foco debe quedar por encima de la barra inferior fija. */
    .calma-tour-overlay { z-index: 9998; }
}

/* ================================================================
 * Pantalla previa de bienvenida del tour ("gate")
 * Una pantalla limpia y luminosa que aparece ANTES del paso 1, para
 * que nadie entre al recorrido sin querer: "¿te enseñamos cómo va?".
 * Va por encima del propio tour (z-index > overlay) y se desvanece
 * suavemente al entrar.
 * ================================================================ */
.calma-gate {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    /* "Pantalla blanca": fondo claro y limpio, con un velo de color muy
       sutil para dar profundidad sin parecer un folio plano. */
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(201, 168, 106, .10) 0%, rgba(255, 255, 255, 0) 55%),
        #ffffff;
    opacity: 0;
    transition: opacity .28s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.calma-gate.is-in { opacity: 1; }

.calma-gate-inner {
    width: 100%;
    max-width: 480px;
    text-align: center;
    transform: translateY(18px) scale(.985);
    opacity: 0;
    transition: transform .42s cubic-bezier(.22, 1, .36, 1), opacity .42s ease;
}
.calma-gate.is-in .calma-gate-inner { transform: none; opacity: 1; }
.calma-gate--noanim,
.calma-gate--noanim .calma-gate-inner { transition: none; }

.calma-gate-avatar {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    box-shadow: 0 14px 38px rgba(0, 0, 0, .3);
}
.calma-gate-avatar img,
.calma-gate-avatar svg {
    width: 62%;
    height: 62%;
    display: block;
}
.calma-gate-kicker {
    margin: 0 0 10px;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
    color: #b8976a;
}
.calma-gate-title {
    margin: 0 0 14px;
    font-family: 'DM Sans', Georgia, serif;
    font-size: 30px;
    line-height: 1.15;
    font-weight: 700;
    color: #16302d;
}
.calma-gate-text {
    margin: 0 auto 26px;
    max-width: 400px;
    font-size: 16px;
    line-height: 1.6;
    color: #5b6660;
}
.calma-gate-text strong { color: #16302d; font-weight: 700; }
.calma-gate-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
}
.calma-gate-start {
    min-width: 240px;
    padding: 15px 28px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #d4b084, #c9a86a);
    color: #16302d;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(201, 168, 106, .38);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.calma-gate-start:hover { transform: translateY(-2px); box-shadow: 0 16px 38px rgba(201, 168, 106, .46); filter: brightness(1.03); }
.calma-gate-start:active { transform: translateY(0); }
.calma-gate-skip {
    padding: 8px 14px;
    border: none;
    background: none;
    color: #8a938d;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: color .15s ease;
}
.calma-gate-skip:hover { color: #16302d; }
.calma-gate-hint {
    margin: 0;
    font-size: 12.5px;
    color: #a7afa9;
}
@media (max-width: 768px) {
    .calma-gate-title { font-size: 25px; }
    .calma-gate-text { font-size: 15px; }
    .calma-gate-avatar { width: 80px; height: 80px; }
    .calma-gate-start { width: 100%; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .calma-gate,
    .calma-gate-inner { transition: none; }
}

/* ================================================================
 * Panel de inicio (dashboard) — companies/index.php
 * ================================================================ */
.dash { margin: 4px 0 28px; }

.dash-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
@media (max-width: 880px) { .dash-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .dash-cards { grid-template-columns: 1fr; } }

.dash-card {
    display: block;
    text-decoration: none;
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    transition: border-color .15s ease, transform .15s ease;
}
.dash-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.dash-card-k { font-size: 12px; color: var(--cream-dim); letter-spacing: .01em; }
.dash-card-v {
    font-size: 28px;
    font-weight: 600;
    color: var(--cream);
    margin: 6px 0 2px;
    line-height: 1.1;
}
.dash-card-s { font-size: 12px; color: var(--cream-dim); }

.dash-lists {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
@media (max-width: 980px) { .dash-lists { grid-template-columns: 1fr; } }

.dash-list {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px 4px 8px;
}
.dash-list-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--cream);
    letter-spacing: .02em;
}
.dash-list-h a { font-size: 11px; font-weight: 500; color: var(--gold); text-decoration: none; }
.dash-list-h a:hover { text-decoration: underline; }

.dash-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 14px;
    text-decoration: none;
    border-radius: 9px;
    transition: background .12s ease;
}
.dash-row:hover { background: var(--border); }
.dash-row-main { font-size: 13px; color: var(--cream); display: flex; align-items: center; gap: 6px; }
.dash-row-sub { font-size: 11.5px; color: var(--cream-dim); }

/* ---- Filas que "piden atención": dato clave a la derecha + urgencia por color ---- */
.dash-row--attn { flex-direction: row; align-items: center; gap: 10px; }
.dash-row--attn .dash-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* ===== ANTI-DESBORDAMIENTO BLINDADO (Cobros/Vencimientos) =====
   El problema: un nombre largo no truncaba y ensanchaba toda la lista más que
   la pantalla (importes cortados). Garantía dura en cadena:
   1) .dash-list con overflow:hidden + min-width:0 → el panel NUNCA se sale de su
      columna (aunque una fila se pase, se recorta ahí y no arrastra la página).
   2) grid items shrinkeables (min-width:0) → la rejilla no se ensancha.
   3) truncado forzado del texto (display:block + ellipsis; flex rompe ellipsis).
   4) importe/fecha con flex:0 0 auto → no se deforman. */
.dash-lists, .dash-cards { min-width: 0; }
.dash-list { min-width: 0; max-width: 100%; overflow: hidden; }
.dash-row--attn { min-width: 0; max-width: 100%; }
.dash-row--attn .dash-row-body { flex: 1 1 0; min-width: 0; overflow: hidden; }
.dash-row--attn .dash-row-main,
.dash-row--attn .dash-row-sub {
    display: block !important;
    max-width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dash-row--attn .dash-row-amount,
.dash-row--attn .dash-row-when { flex: 0 0 auto; }
.dash-row-marker {
    flex: 0 0 3px; align-self: stretch; min-height: 26px; border-radius: 99px;
    background: var(--tf-accent, var(--gold)); opacity: .4;
    transition: opacity var(--dur) var(--ease-out);
}
.dash-row-amount {
    font-size: 14px; font-weight: 600; white-space: nowrap;
    color: var(--tf-text, var(--cream)); font-variant-numeric: tabular-nums;
}
.dash-row-when {
    display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
    font-size: 12px; font-weight: 600; white-space: nowrap; text-align: right;
    color: var(--tf-text-2, var(--cream-dim));
}
.dash-row-when small { font-size: 10.5px; font-weight: 500; opacity: .85; }
/* Urgencia: rojo (vencido / ≤7 días) y ámbar (≤15 días) */
.dash-row.is-urgent .dash-row-marker { background: var(--tf-danger, #dc2626); opacity: 1; }
.dash-row.is-urgent .dash-row-when,
.dash-row.is-urgent .dash-row-amount { color: var(--tf-danger, #dc2626); }
.dash-row.is-urgent .dash-row-sub    { color: var(--tf-danger, #dc2626); opacity: .8; }
.dash-row.is-soon   .dash-row-marker { background: var(--tf-warn, #ca8a04); opacity: 1; }
.dash-row.is-soon   .dash-row-when   { color: var(--tf-warn, #ca8a04); }
.dash-row--attn:hover { background: var(--tf-surface-2, var(--border)); }
.dash-row--attn:hover .dash-row-marker { opacity: 1; }

/* ============ CSELECT — desplegable propio (reemplaza la lista nativa del <select>) ============ */
/* El <select> real se conserva oculto (formularios/teclado); el trigger hereda
   el look de field-input y la lista se estiliza 100% como Calma. */
.cselect { position: relative; display: inline-flex; vertical-align: middle; max-width: 100%; }
.cselect-native {
    position: absolute; width: 1px; height: 1px; opacity: 0;
    pointer-events: none; margin: 0; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0);
}
.cselect-trigger {
    width: 100%; cursor: pointer; text-align: left;
    -webkit-appearance: none; appearance: none; background-image: none;
    display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
    transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.cselect-trigger .cselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect.is-placeholder .cselect-label { color: var(--tf-text-3, var(--cream-dim)); }
.cselect-arrow { flex: 0 0 auto; opacity: .55; transition: transform var(--dur) var(--ease-out); }
.cselect.is-open .cselect-arrow { transform: rotate(180deg); }
.cselect.is-open .cselect-trigger { border-color: var(--tf-accent, var(--gold)); }

.cselect-menu {
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 100%; width: max-content; max-width: min(360px, 90vw);
    background: var(--tf-surface, var(--moss));
    border: 1px solid var(--tf-border, var(--border-hover));
    border-radius: 12px; padding: 5px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .16);
    max-height: 300px; overflow-y: auto; z-index: 200;
    opacity: 0; pointer-events: none;
    transform: translateY(-6px) scale(0.97); transform-origin: top left;
    transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.cselect.is-open .cselect-menu { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.cselect-menu--up { top: auto; bottom: calc(100% + 6px); transform-origin: bottom left; }
.cselect-group {
    padding: 9px 12px 4px; font-size: 10px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--tf-text-3, var(--cream-dim));
}
.cselect-option {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 8px;
    font-size: 13.5px; color: var(--tf-text, var(--cream));
    cursor: pointer; white-space: nowrap;
    transition: background var(--dur-fast) var(--ease-out);
}
.cselect-option:hover, .cselect-option.is-active { background: var(--tf-surface-2, var(--forest-light)); }
.cselect-option.is-selected { color: var(--tf-accent, var(--gold)); font-weight: 600; }
.cselect-option.is-selected::after { content: '✓'; margin-left: auto; font-size: 12px; }
.cselect-option.is-disabled { opacity: .4; cursor: default; }

.dash-tag {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gold);
    border: 1px solid var(--border-hover);
    border-radius: 5px;
    padding: 0 5px;
    line-height: 15px;
}

.dash-empty {
    background: var(--moss);
    border: 1px dashed var(--border-hover);
    border-radius: 14px;
    padding: 22px;
    text-align: center;
    color: var(--cream-dim);
    font-size: 14px;
}

/* Cola de revisión (invoices/drafts.php) */
.btn--sm { padding: 5px 12px; font-size: 12px; }

.dq-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 9px;
    transition: background .12s ease;
    flex-wrap: wrap;
}
.dq-row:hover { background: var(--border); }
.dq-main { display: flex; flex-direction: column; gap: 2px; text-decoration: none; flex: 1 1 220px; min-width: 0; }
.dq-title { font-size: 13.5px; color: var(--cream); display: flex; align-items: center; gap: 7px; font-weight: 500; }
.dq-sub { font-size: 12px; color: var(--cream-dim); }
.dq-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ================================================================
 * Paleta de comandos (Cmd/Ctrl+K) — partials/footer.php
 * ================================================================ */
.cmdk {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    align-items: flex-start;
    justify-content: center;
}
.cmdk.is-open { display: flex; }
.cmdk-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}
.cmdk-panel {
    position: relative;
    width: min(620px, calc(100vw - 32px));
    margin-top: 12vh;
    background: var(--moss);
    border: 1px solid var(--border-hover);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14);
    overflow: hidden;
    animation: cmdk-in .12s ease;
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.cmdk-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--cream-dim);
}
.cmdk-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--cream);
    font-size: 16px;
}
.cmdk-input::placeholder { color: var(--cream-dim); }
.cmdk-kbd, .cmdk-foot kbd {
    font-size: 10px;
    color: var(--cream-dim);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 6px;
    line-height: 16px;
}

.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.cmdk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    cursor: pointer;
}
.cmdk-row.is-active { background: var(--border); }
.cmdk-row-label { font-size: 14px; color: var(--cream); }
.cmdk-row-hint { font-size: 11px; color: var(--cream-dim); text-transform: uppercase; letter-spacing: .04em; }

.cmdk-foot {
    display: flex;
    gap: 16px;
    padding: 9px 14px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--cream-dim);
}
.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* ================================================================
   SOPORTE · Bugs / Mejoras + Registro de cambios (migración 049)
   ================================================================ */
.bug-tabs {
    display: flex;
    gap: 6px;
    margin: 10px 0 18px;
    flex-wrap: wrap;
}
.bug-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s, border-color .15s;
}
.bug-tab:hover { border-color: var(--border-hover); color: var(--cream); }
.bug-tab.is-active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--moss-deep);
}
.bug-tab svg { opacity: .85; }

.bug-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 22px;
    align-items: start;
}
@media (max-width: 880px) {
    .bug-grid { grid-template-columns: 1fr; }
}

.bug-form-wrap {
    position: sticky;
    top: 16px;
}
.bug-form {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
}
.bug-form-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--cream);
    margin: 0 0 12px;
}
.bug-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--cream-dim);
    margin: 10px 0 5px;
    display: block;
}
.bug-hint { font-weight: 400; opacity: .65; }
.bug-input, .bug-textarea {
    width: 100%;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--cream);
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color .15s;
    box-sizing: border-box;
}
.bug-input:focus, .bug-textarea:focus {
    outline: none;
    border-color: var(--gold);
}
.bug-textarea { resize: vertical; line-height: 1.45; }
.bug-input--mini { width: auto; padding: 5px 8px; font-size: 12px; }
.bug-submit { margin-top: 14px; }

.bug-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.bug-card {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
}
.bug-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.bug-card-meta {
    font-size: 12px;
    color: var(--cream-dim);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.bug-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--cream);
    margin: 0 0 6px;
    line-height: 1.3;
}
.bug-card-body {
    font-size: 13.5px;
    color: var(--cream-dim);
    line-height: 1.55;
    margin: 0 0 10px;
    white-space: pre-line;
}
.bug-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.bug-badge--abierto  { background: rgba(220,38,38,.16); color: #f0a3a3; }
.bug-badge--en_curso { background: rgba(184,151,106,.18); color: var(--gold-bright); }
.bug-badge--resuelto { background: rgba(34,160,90,.16); color: #8fdcae; }
.bug-prio { background: var(--moss-deep); color: var(--cream-dim); border: 1px solid var(--border); }
.bug-prio--alta  { color: #f0a3a3; border-color: rgba(220,38,38,.4); }
.bug-prio--media { color: var(--gold-bright); }
.bug-prio--baja  { opacity: .7; }

.bug-links { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.bug-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--gold-bright);
    text-decoration: none;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
}
.bug-link:hover { border-color: var(--border-hover); }

.bug-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.bug-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bug-actions form { margin: 0; }
.bug-del { color: #f0a3a3; }

.bug-thread { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.bug-thread-toggle {
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--cream-dim);
    list-style: none;
}
.bug-thread-toggle::-webkit-details-marker { display: none; }
.bug-thread-toggle:hover { color: var(--cream); }
.bug-comment {
    margin: 10px 0;
    padding-left: 10px;
    border-left: 2px solid var(--border);
}
.bug-comment-author { font-size: 12.5px; font-weight: 600; color: var(--cream); }
.bug-comment-date { font-size: 11px; color: var(--cream-dim); margin-left: 6px; }
.bug-comment-body { font-size: 13px; color: var(--cream-dim); line-height: 1.5; margin-top: 3px; white-space: pre-line; }
.bug-comment-form { display: flex; gap: 7px; margin-top: 10px; }
.bug-comment-form .bug-input { flex: 1; }

/* Registro de cambios */
.changelog {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-left: 2px solid var(--border);
    margin-left: 8px;
    padding-left: 0;
}
.changelog-item {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 16px;
    padding: 14px 0 14px 18px;
    position: relative;
}
.changelog-item::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 20px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--moss-deep);
}
.changelog-date {
    font-size: 12px;
    color: var(--cream-dim);
    text-transform: uppercase;
    letter-spacing: .4px;
    padding-top: 2px;
}
.changelog-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--cream);
    margin: 0 0 5px;
    line-height: 1.35;
}
.changelog-summary { font-size: 13.5px; color: var(--cream-dim); line-height: 1.55; margin: 0 0 6px; white-space: pre-line; }
.changelog-author { font-size: 11.5px; color: var(--cream-dim); opacity: .75; }
@media (max-width: 620px) {
    .changelog-item { grid-template-columns: 1fr; gap: 4px; }
}

/* ================================================================
   Chat de empresa (canal compartido por organización)
   ================================================================ */
.chat-wrap {
    display: grid;
    grid-template-columns: 230px 1fr 260px;
    gap: 18px;
    align-items: stretch;
}
.chat-channels {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    overflow-y: auto;
    max-height: calc(100vh - 230px);
}
.chat-channel {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 9px;
    border-radius: 9px;
    text-decoration: none;
    color: var(--cream);
    font-size: 13.5px;
    font-weight: 500;
}
.chat-channel:hover { background: rgba(184, 151, 106, .08); }
.chat-channel.is-active {
    background: rgba(184, 151, 106, .16);
    border: 1px solid var(--border);
    color: var(--gold-bright);
    font-weight: 600;
}
.chat-channel-icon {
    flex: 0 0 auto;
    width: 18px;
    text-align: center;
    color: var(--cream-dim);
    font-size: 12px;
}
.chat-channel.is-active .chat-channel-icon { color: var(--gold); }
.chat-channel-name {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-channel-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--gold);
    color: var(--moss-deep);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}
/* Fila de canal: el enlace + (para admin) el botón de opciones. */
.chat-channel-row {
    position: relative;
    display: flex;
    align-items: center;
}
.chat-channel-row .chat-channel { flex: 1 1 auto; min-width: 0; }
.chat-channel-tag {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    color: var(--cream-dim);
    opacity: .7;
}
.chat-channel.is-disabled .chat-channel-name { opacity: .6; }
/* Botón engranaje de opciones (solo Propietario/Administrador). */
.chat-channel-admin { position: relative; flex: 0 0 auto; }
.chat-channel-admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--cream-dim);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.chat-channel-row:hover .chat-channel-admin-btn,
.chat-channel-admin.open .chat-channel-admin-btn { opacity: 1; }
.chat-channel-admin-btn:hover {
    background: rgba(184, 151, 106, .14);
    color: var(--gold-bright);
}
/* Menú desplegable de acciones del canal. */
.chat-channel-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 20;
    display: none;
    flex-direction: column;
    min-width: 200px;
    padding: 6px;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}
.chat-channel-admin.open .chat-channel-menu { display: flex; }
.chat-channel-menu form { margin: 0; }
.chat-channel-menu button {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--cream);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.chat-channel-menu button:hover { background: rgba(184, 151, 106, .12); color: var(--gold-bright); }
/* Cabecera de la sección «Archivados». */
.chat-side-h--archived {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--cream-dim);
    opacity: .75;
}
/* Aviso de canal desactivado (solo lectura) en lugar del formulario. */
.chat-disabled-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: rgba(184, 151, 106, .06);
    color: var(--cream-dim);
    font-size: 13.5px;
    line-height: 1.45;
}
.chat-disabled-notice svg { flex: 0 0 auto; color: var(--gold); }
.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    min-height: 520px;
    height: calc(100vh - 230px);
}
.chat-stream {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 18px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-empty {
    margin: auto;
    color: var(--cream-dim);
    font-size: 14px;
    text-align: center;
    opacity: .8;
}
.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 9px;
    max-width: 78%;
}
.chat-msg--mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-msg-avatar {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    color: var(--gold-bright);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}
.chat-bubble-wrap { display: flex; flex-direction: column; min-width: 0; }
.chat-msg--mine .chat-bubble-wrap { align-items: flex-end; }
.chat-msg-author {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--gold);
    margin: 0 0 3px 2px;
}
.chat-bubble {
    background: var(--moss-deep);
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 9px 13px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--cream);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.chat-msg--mine .chat-bubble {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--moss-deep);
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}
.chat-msg-time {
    font-size: 10.5px;
    color: var(--cream-dim);
    opacity: .7;
    margin: 3px 2px 0;
}
.chat-form {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--moss-deep);
}
.chat-input {
    flex: 1 1 auto;
    resize: none;
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--cream);
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    padding: 9px 12px;
    max-height: 140px;
    overflow-y: auto;
}
.chat-input:focus { outline: none; border-color: var(--gold); }
.chat-send { flex: 0 0 auto; white-space: nowrap; }
.chat-side {
    background: var(--moss);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    overflow-y: auto;
    max-height: calc(100vh - 230px);
}
.chat-side-h {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--cream-dim);
    margin: 0 0 12px;
    font-weight: 600;
}
.chat-member {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 6px;
    border-radius: 9px;
}
.chat-member--contable {
    background: rgba(184, 151, 106, .1);
    border: 1px solid var(--border);
}
.chat-member-avatar {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--moss-deep);
    border: 1px solid var(--border);
    color: var(--gold-bright);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}
.chat-member-info { display: flex; flex-direction: column; min-width: 0; }
.chat-member-name {
    font-size: 13.5px;
    color: var(--cream);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-member-role { font-size: 11px; color: var(--cream-dim); }
.chat-member--contable .chat-member-role { color: var(--gold); }

/* Badge numérico en la pestaña de nav (Chat) */
.tfnav-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    margin-left: 5px;
    border-radius: 9px;
    background: var(--gold);
    color: var(--moss-deep);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

/* Unificado a 768px: coincide con el resto del chrome móvil (tabbar inferior
   aparece en ≤768px). A 820px el chat se apilaba mientras la nav seguía en
   modo escritorio, dejando una franja incoherente 769–820px. */
@media (max-width: 768px) {
    .chat-wrap { grid-template-columns: 1fr; }
    .chat-channels { max-height: none; order: -2; display: flex; flex-wrap: wrap; gap: 6px; }
    .chat-channels .chat-side-h { flex: 1 0 100%; }
    .chat-channel { flex: 0 0 auto; }
    .chat-side { max-height: none; order: -1; }
    .chat-main { height: 70vh; }
}
@media (max-width: 480px) {
    /* En móvil pequeño, con canales+lateral apilados encima, 70vh desborda. */
    .chat-main { height: 62vh; }
}

/* ============================================================
   MODO "VER COMO" — banner persistente de solo lectura
   ============================================================ */
.preview-banner {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 18px;
    background: var(--gold);
    color: var(--moss-deep);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}
.preview-banner__icon { font-size: 15px; line-height: 1; }
.preview-banner__text { flex: 1; min-width: 200px; }
.preview-banner__text strong { font-weight: 700; }
.preview-banner__exit {
    flex: 0 0 auto;
    padding: 5px 14px;
    border-radius: 40px;
    background: var(--moss-deep);
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
    transition: opacity .15s ease;
}
.preview-banner__exit:hover { opacity: .85; }

/* ==========================================================================
   Panel de personas (Usuarios + Trabajadores) — antes inline en
   views/users/index.php; movido aquí para que /trabajadores y las fichas
   de trabajador rendericen igual (compartían las clases .usr-*).
   ========================================================================== */
.usr-avatar {
    width:34px; height:34px; border-radius:10px; flex:0 0 auto;
    overflow:hidden; background:var(--moss-deep); border:1px solid var(--border);
    display:flex; align-items:center; justify-content:center;
    font-size:13px; font-weight:600; color:var(--gold);
}
.usr-avatar--lg { width:46px; height:46px; border-radius:12px; font-size:16px; }
.usr-avatar img { width:100%; height:100%; object-fit:cover; display:block; }
.acc-chips { display:inline-flex; flex-wrap:wrap; gap:6px; vertical-align:middle; }
.acc-chip {
    display:inline-flex; align-items:center; gap:6px;
    padding:2px 9px; border-radius:999px; font-size:12px;
    border:1px solid var(--border); background:color-mix(in srgb, var(--cream) 3%, transparent);
}
.acc-chip-dot { width:9px; height:9px; border-radius:3px; flex:0 0 auto; display:inline-block; }

/* Referencia de roles */
.roles-ref { padding:20px 22px; margin-bottom:24px; }
.roles-ref-head h2 { margin:0 0 4px; font-size:16px; font-weight:600; }
.roles-ref-head p  { margin:0 0 16px; font-size:13px; color:var(--cream-dim); line-height:1.5; }
.roles-ref-grid {
    display:grid; gap:12px;
    grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
}
.role-ref-card {
    position:relative; border:1px solid var(--border); border-radius:14px; padding:16px;
    background:color-mix(in srgb, var(--cream) 2%, transparent);
    display:flex; flex-direction:column;
    transition:border-color .15s ease, transform .15s ease;
}
.role-ref-card:hover { transform:translateY(-2px); }
.role-ref-card--root    { border-color:color-mix(in srgb, var(--gold) 35%, var(--border)); }
.role-ref-card--root:hover    { border-color:var(--gold); }
.role-ref-card--contador:hover { border-color:color-mix(in srgb, var(--gold) 45%, var(--border)); }
.role-ref-top { display:flex; align-items:center; gap:10px; }
.role-ref-icon {
    width:34px; height:34px; flex:0 0 auto; border-radius:10px;
    display:inline-flex; align-items:center; justify-content:center;
    background:color-mix(in srgb, var(--cream) 8%, transparent);
    color:var(--cream-dim);
}
.role-ref-icon--root     { background:color-mix(in srgb, var(--gold) 16%, transparent); color:var(--gold); }
.role-ref-icon--contador { background:color-mix(in srgb, var(--gold) 10%, transparent); color:var(--gold); }
.role-ref-card p { margin:12px 0 0; font-size:12.5px; line-height:1.5; color:var(--cream-dim); }
.role-ref-caps { list-style:none; margin:12px 0 0; padding:0; display:flex; flex-direction:column; gap:6px; }
.role-ref-caps li { display:flex; align-items:flex-start; gap:7px; font-size:12px; line-height:1.4; color:var(--cream); }
.role-ref-caps li svg { flex:0 0 auto; margin-top:1px; color:var(--gold); opacity:.85; }
.role-ref-caps li span { opacity:.85; }
.role-ref-preview {
    display:inline-flex; align-items:center; gap:6px; cursor:pointer;
    margin-top:auto; padding:7px 12px; border-radius:9px; font-size:12.5px; font-weight:600;
    background:color-mix(in srgb, var(--gold) 12%, transparent);
    color:var(--gold); border:1px solid color-mix(in srgb, var(--gold) 30%, transparent);
    transition:background .15s ease;
}
.role-ref-preview:hover { background:color-mix(in srgb, var(--gold) 20%, transparent); }
.role-ref-actions { margin-top:auto; padding-top:12px; display:flex; flex-direction:column; gap:8px; }
.role-link-pop { position:relative; }
.role-link-pop > summary { list-style:none; }
.role-link-pop > summary::-webkit-details-marker { display:none; }
.role-ref-genlink {
    display:inline-flex; align-items:center; justify-content:center; gap:6px; cursor:pointer; width:100%;
    padding:7px 12px; border-radius:9px; font-size:12.5px; font-weight:600;
    background:color-mix(in srgb, var(--cream) 6%, transparent);
    color:var(--cream); border:1px solid var(--border);
    transition:border-color .15s ease, background .15s ease;
}
.role-ref-genlink:hover { border-color:color-mix(in srgb, var(--gold) 45%, var(--border)); }
.role-link-pop[open] > summary { border-color:color-mix(in srgb, var(--gold) 45%, var(--border)); }
.role-link-body {
    margin-top:8px; padding:14px; border:1px solid var(--border); border-radius:12px;
    background:var(--moss-deep, #14201a);
}
.role-link-group { font-size:11px; text-transform:uppercase; letter-spacing:.5px; opacity:.6; margin:10px 0 4px; }
.field-input--sm { padding:6px 10px; font-size:13px; }

/* Tarjetas de miembros / trabajadores */
.usr-section-label {
    font-size:11px; letter-spacing:.12em; text-transform:uppercase;
    font-weight:600; color:var(--cream-dim); margin:6px 0 12px;
}
.usr-cards { display:flex; flex-direction:column; gap:10px; }
.usr-card {
    display:flex; align-items:center; justify-content:space-between; gap:16px;
    flex-wrap:wrap; padding:14px 18px; border:1px solid var(--border);
    border-radius:14px; background:var(--panel, rgba(255,255,255,.02));
}
.usr-card-main { display:flex; align-items:center; gap:14px; min-width:240px; flex:1; }
.usr-card-name { display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:15px; }
.usr-card-meta { font-size:12.5px; color:var(--cream-dim); margin-top:3px; }
.usr-card-meta a { color:inherit; text-decoration:none; }
.usr-card-meta a:hover { text-decoration:underline; }
.usr-card-sep { opacity:.4; margin:0 6px; }
.usr-card-access { font-size:12.5px; margin-top:7px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.usr-card-access-label { color:var(--cream-dim); opacity:.7; }
.usr-card-access-all { color:var(--cream-dim); }
.usr-card-access-none { color:#e0b34d; font-weight:600; }
.usr-card-sections { font-size:12.5px; margin-top:7px; display:flex; align-items:flex-start; gap:6px; flex-wrap:wrap; }
.usr-sec-chips { display:flex; gap:5px; flex-wrap:wrap; }
.usr-sec-chip {
    font-size:11px; padding:2px 8px; border-radius:6px; font-weight:600;
    background:color-mix(in srgb, var(--gold) 14%, transparent);
    color:var(--cream); border:1px solid color-mix(in srgb, var(--gold) 30%, transparent);
}
.usr-sec-chip--off {
    background:transparent; color:var(--cream-dim);
    border:1px dashed color-mix(in srgb, var(--cream-dim) 35%, transparent);
    opacity:.5; text-decoration:line-through;
}
.usr-tag-self {
    font-size:10px; padding:2px 7px; border-radius:5px; font-weight:700;
    letter-spacing:.06em; text-transform:uppercase;
    background:color-mix(in srgb, var(--gold) 18%, transparent); color:var(--gold);
}
.usr-card-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.usr-owner-tag { opacity:.55; font-size:.85em; }
.usr-role-select { width:auto; padding:5px 28px 5px 10px; font-size:.85em; }
.btn.btn--sm { padding:5px 12px; font-size:.82em; }

/* Popovers (acceso / datos) */
.usr-pop { position:relative; }
.usr-pop > summary { list-style:none; cursor:pointer; }
.usr-pop > summary::-webkit-details-marker { display:none; }
.usr-pop-body {
    position:absolute; right:0; top:calc(100% + 6px); z-index:20;
    width:280px; max-width:80vw; padding:14px 16px;
    border:1px solid var(--border); border-radius:12px;
    background:var(--moss-deep, #14201a); box-shadow:0 12px 36px rgba(0,0,0,.45);
}
.usr-pop-hint { margin:0 0 6px; font-size:12px; color:var(--cream-dim); }
.usr-pop-group { font-size:11px; text-transform:uppercase; letter-spacing:.5px; opacity:.6; margin:10px 0 4px; }
.usr-pop-check { display:flex; gap:8px; align-items:center; padding:4px 0; font-size:13px; cursor:pointer; }
@media (max-width:640px) {
    .usr-pop-body { right:auto; left:0; }
    .usr-card-actions { width:100%; }
}

/* ============================================================
   PREMIUM VISUAL LAYER  ·  (entrada, glass, skeletons,
   micro-interacciones, estados vacíos, barras de proporción)
   Todo respeta prefers-reduced-motion.
   ============================================================ */

/* --- 1) Animación de entrada (fade + subida escalonada) --- */
@keyframes premFadeRise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tfhome .dash-card,
.tfhome .tfcard,
.tfhome .dash-list {
    animation: premFadeRise var(--dur-modal, 280ms) var(--ease-out, cubic-bezier(0.23,1,0.32,1)) both;
}
.tfhome .dash-cards .dash-card:nth-child(1) { animation-delay: 40ms; }
.tfhome .dash-cards .dash-card:nth-child(2) { animation-delay: 90ms; }
.tfhome .dash-cards .dash-card:nth-child(3) { animation-delay: 140ms; }
.tfhome .dash-cards .dash-card:nth-child(4) { animation-delay: 190ms; }
.tfhome .dash-cards .dash-card:nth-child(5) { animation-delay: 240ms; }
.tfhome .tfhome-grid .tfcard:nth-child(1) { animation-delay: 60ms; }
.tfhome .tfhome-grid .tfcard:nth-child(2) { animation-delay: 110ms; }
.tfhome .tfhome-grid .tfcard:nth-child(3) { animation-delay: 160ms; }
.tfhome .tfhome-grid .tfcard:nth-child(4) { animation-delay: 210ms; }
.tfhome .tfhome-grid .tfcard:nth-child(5) { animation-delay: 260ms; }
.tfhome .tfhome-grid .tfcard:nth-child(6) { animation-delay: 310ms; }
.tfhome .tfhome-grid .tfcard:nth-child(n+7) { animation-delay: 360ms; }

/* --- 2) Glassmorphism en barra de navegación y modales --- */
.tfnav {
    background: color-mix(in srgb, var(--tf-surface, var(--moss)) 78%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
}
.modal-backdrop {
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .tfnav { background: var(--tf-surface, var(--moss)); }
}

/* --- 3) Skeleton loaders (shimmer) --- */
@keyframes premShimmer {
    0%   { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}
.skeleton {
    display: block;
    border-radius: 8px;
    background: var(--border, #e2e8f0);
    background-image: linear-gradient(
        90deg,
        color-mix(in srgb, var(--border) 60%, transparent) 0%,
        color-mix(in srgb, var(--cream) 8%, var(--border)) 50%,
        color-mix(in srgb, var(--border) 60%, transparent) 100%
    );
    background-size: 800px 100%;
    animation: premShimmer 1.4s linear infinite;
}
.skeleton--text { height: 12px; margin: 6px 0; }
.skeleton--title { height: 20px; width: 50%; }
.skeleton--card { height: 120px; border-radius: 14px; }

/* --- 4) Micro-interacciones (pulsado, elevación) --- */
.btn, .tfhome-cta, .tfcard-action, .dash-card, .tfcard {
    transition: transform var(--dur-fast, 140ms) var(--ease-out, ease),
                box-shadow var(--dur-fast, 140ms) var(--ease-out, ease),
                border-color var(--dur-fast, 140ms) var(--ease-out, ease),
                background var(--dur-fast, 140ms) var(--ease-out, ease);
}
.btn:active, .tfhome-cta:active { transform: scale(0.97); }
.tfcard-action:active { transform: scale(0.9); }
.dash-card:active, .tfcard:active { transform: translateY(0) scale(0.995); }

/* --- 5) Estados vacíos ilustrados --- */
.dash-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}
.dash-empty::before {
    content: "";
    width: 52px; height: 52px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--success, #10b981) 16%, transparent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='%2310b981' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}
.tfhome-empty { text-align: center; }

/* --- 6) Barra de proporción ingresos/gastos en tarjetas --- */
.tfcard-propbar {
    display: flex;
    height: 6px;
    width: 100%;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 10px;
    background: color-mix(in srgb, var(--border) 70%, transparent);
}
.tfcard-propbar > span { display: block; height: 100%; }
.tfcard-propbar .prop-in  { background: var(--success, #10b981); }
.tfcard-propbar .prop-out { background: var(--danger, #ef4444); }
.tfcard-proplegend {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
    color: var(--cream-dim, var(--muted));
    margin-top: 5px;
    letter-spacing: .2px;
}
.tfcard-proplegend .pl-in  { color: var(--success, #10b981); }
.tfcard-proplegend .pl-out { color: var(--danger, #ef4444); }

/* --- 7) Saludo dinámico de la home --- */
.tfhome-greet {
    font-size: 13px;
    color: var(--cream-dim, var(--muted));
    margin: 2px 0 0;
}
.tfhome-greet strong { color: var(--cream, inherit); font-weight: 650; }

/* --- 8) Confeti de celebración --- */
.prem-confetti {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* --- Respeto a usuarios con movimiento reducido --- */
@media (prefers-reduced-motion: reduce) {
    .tfhome .dash-card,
    .tfhome .tfcard,
    .tfhome .dash-list { animation: none !important; }
    .skeleton { animation: none !important; }
    .btn, .tfhome-cta, .tfcard-action, .dash-card, .tfcard { transition: none !important; }
    .btn:active, .tfhome-cta:active, .tfcard-action:active,
    .dash-card:active, .tfcard:active { transform: none !important; }
    .tfnav { -webkit-backdrop-filter: none; backdrop-filter: none; }
    .prem-confetti { display: none !important; }
}

/* ============================================================
   PREMIUM VISUAL LAYER · 2ª tanda (solo estética, sin funciones)
   #1 enfoque al hover · #2 acento de color por empresa
   #4 hero del balance con degradado vivo · #5 avatares de color
   ============================================================ */

/* --- #2) Acento de color por empresa (borde lateral) --- */
.tfcard::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--card-color, var(--gold, #4f46e5));
    opacity: .55;
    transition: opacity var(--dur-fast, 140ms) var(--ease-out, ease),
                width var(--dur-fast, 140ms) var(--ease-out, ease);
}
.tfcard:hover::before { opacity: 1; width: 4px; }

/* --- #5) Avatar de color con iniciales --- */
.tfcard-avatar {
    box-shadow: 0 2px 8px color-mix(in srgb, var(--card-color, #4f46e5) 45%, transparent);
    transition: transform var(--dur-fast, 140ms) var(--ease-out, ease);
}
.tfcard:hover .tfcard-avatar { transform: scale(1.06) rotate(-2deg); }

/* --- #1) Modo enfoque: al pasar el ratón, el resto se atenúa --- */
.tfhome-grid:hover .tfcard:not(:hover) {
    opacity: .5;
    filter: saturate(.7);
}
.tfhome-grid .tfcard {
    transition: border-color .18s, transform .18s, box-shadow .18s,
                opacity var(--dur, 200ms) var(--ease-out, ease),
                filter var(--dur, 200ms) var(--ease-out, ease);
}

/* --- #4) Hero del balance con degradado animado --- */
@keyframes premHeroShift {
    0%   { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}
.tfhome-stat-value {
    background-image: linear-gradient(
        100deg,
        var(--cream, #0f172a) 0%,
        var(--gold, #4f46e5) 35%,
        var(--success, #10b981) 55%,
        var(--gold, #4f46e5) 75%,
        var(--cream, #0f172a) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: premHeroShift 6s linear infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
    .tfcard::before,
    .tfcard:hover .tfcard-avatar { transition: none !important; transform: none !important; }
    .tfhome-grid:hover .tfcard:not(:hover) { opacity: 1 !important; filter: none !important; }
    .tfhome-stat-value {
        animation: none !important;
        background: none !important;
        -webkit-text-fill-color: currentColor;
        color: var(--cream, #0f172a) !important;
    }
}

/* ============================================================
   PREMIUM SCROLL LAYER · 3ª tanda (efectos al hacer scroll)
   Optimizado para MÓVIL: solo transform/opacity, scroll pasivo,
   parallax/spotlight solo en escritorio, todo con
   prefers-reduced-motion. Clases activadas por JS (footer.php).
   ============================================================ */

/* --- #1) Reveal al hacer scroll --- */
.prem-reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity .6s var(--ease-out, cubic-bezier(0.23,1,0.32,1)),
                transform .6s var(--ease-out, cubic-bezier(0.23,1,0.32,1));
    will-change: transform, opacity;
}
.prem-reveal.is-in {
    opacity: 1;
    transform: none;
    will-change: auto;
}
/* En móvil NO hay reveal al scroll (dejaba huecos blancos mientras bajabas:
   secciones enteras con opacity:0 hasta que el observer disparaba). El JS ya
   no añade la clase en ≤768px; esto es el cinturón por si llegara puesta
   (resize, PWA restaurada): contenido siempre visible. */
@media (max-width: 768px) {
    .prem-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* --- #2) Nav que se encoge y se vuelve más cristal al bajar --- */
.tfnav {
    transition: padding .25s var(--ease-out, ease),
                background .25s var(--ease-out, ease),
                box-shadow .25s var(--ease-out, ease);
}
.tfnav.is-scrolled {
    padding-top: calc(8px + var(--safe-top, 0px));
    padding-bottom: 8px;
    background: color-mix(in srgb, var(--tf-surface, var(--moss)) 70%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    box-shadow: 0 6px 24px rgba(0,0,0,.07);
}
.tfnav .tfnav-brand-mark,
.tfnav .tfnav-brand-text {
    transition: transform .25s var(--ease-out, ease), opacity .25s var(--ease-out, ease);
}
.tfnav.is-scrolled .tfnav-brand-mark { transform: scale(.86); }
/* En móvil, al bajar ocultamos el texto del logo para ganar sitio */
@media (max-width: 640px) {
    .tfnav.is-scrolled .tfnav-brand-text { opacity: 0; width: 0; overflow: hidden; }
}

/* FIX layout: en escritorio (sidebar vertical) el `backdrop-filter` del nav
   creaba un BLOQUE CONTENEDOR, así que el grupo flotante .tfnav-right
   (campana + ojo "Ver como"), que es position:fixed, se anclaba al sidebar de
   248px en vez de a la ventana y se montaba encima del chip de cuenta.
   El sidebar es opaco y el cristal no se aprecia, así que lo quitamos en
   escritorio (incluido el estado .is-scrolled) y dejamos fondo sólido. En
   móvil/tablet (<=900px) el nav es barra superior y .tfnav-right va en flujo
   (static), por lo que ahí el cristal se conserva sin romper nada. */
@media (min-width: 901px) {
    .layout .tfnav,
    .layout .tfnav.is-scrolled {
        background: var(--tf-surface, var(--moss));
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

/* --- #3) Barra de progreso de lectura --- */
.prem-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    z-index: 9998;
    background: linear-gradient(90deg, var(--gold, #4f46e5), var(--success, #10b981));
    box-shadow: 0 0 8px color-mix(in srgb, var(--gold, #4f46e5) 60%, transparent);
    transition: width .08s linear;
    pointer-events: none;
}
@media (max-width: 640px) { .prem-progress { height: 2.5px; } }

/* --- #4) Parallax del hero (solo puntero fino = escritorio) --- */
@media (pointer: fine) and (min-width: 880px) {
    .tfhome-stat { will-change: transform; }
}

/* --- #5) Cabeceras de sección pegajosas --- */
.tfhome-section-title {
    position: sticky;
    top: 64px;
    z-index: 8;
    padding: 8px 0;
    margin-bottom: 8px;
    background: transparent;
    transition: background .2s var(--ease-out, ease),
                box-shadow .2s var(--ease-out, ease),
                padding-left .2s var(--ease-out, ease);
    border-radius: 10px;
}
.tfhome-section-title.is-stuck {
    background: color-mix(in srgb, var(--moss-deep, #f8fafc) 82%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding-left: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,.05);
}
@media (max-width: 640px) { .tfhome-section-title { top: 56px; } }

/* --- #6) Spotlight que sigue al cursor (escritorio) --- */
@media (pointer: fine) {
    .tfcard::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: radial-gradient(
            220px circle at var(--mx, 50%) var(--my, 0%),
            color-mix(in srgb, var(--card-color, #4f46e5) 18%, transparent),
            transparent 60%
        );
        opacity: 0;
        transition: opacity .25s var(--ease-out, ease);
        pointer-events: none;
        z-index: 0;
    }
    .tfcard:hover::after { opacity: 1; }
    .tfcard > * { position: relative; z-index: 1; }
}

/* --- #7) Borde con degradado animado al hover (escritorio) --- */
@media (pointer: fine) {
    @keyframes premBorderSpin { to { --premAngle: 360deg; } }
    @property --premAngle {
        syntax: '<angle>'; initial-value: 0deg; inherits: false;
    }
    .tfcard:hover {
        border-color: transparent;
        background:
            linear-gradient(var(--tf-surface, var(--moss)), var(--tf-surface, var(--moss))) padding-box,
            conic-gradient(from var(--premAngle, 0deg),
                var(--card-color, #4f46e5),
                color-mix(in srgb, var(--card-color, #4f46e5) 30%, var(--success, #10b981)),
                var(--card-color, #4f46e5)) border-box;
        animation: premBorderSpin 4s linear infinite;
    }
}

/* --- #8) Aurora de fondo muy sutil --- */
.tfhome { position: relative; }
.tfhome::before {
    content: "";
    position: fixed;
    inset: -20vmax;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(38vmax 38vmax at 12% 8%,  color-mix(in srgb, var(--gold, #4f46e5) 16%, transparent), transparent 60%),
        radial-gradient(34vmax 34vmax at 88% 22%, color-mix(in srgb, var(--success, #10b981) 14%, transparent), transparent 60%),
        radial-gradient(30vmax 30vmax at 60% 95%, color-mix(in srgb, var(--warning, #f59e0b) 12%, transparent), transparent 60%);
    filter: blur(10px);
    animation: premAurora 24s ease-in-out infinite alternate;
}
@keyframes premAurora {
    0%   { transform: translate3d(0,0,0) scale(1); }
    50%  { transform: translate3d(2%, -2%, 0) scale(1.06); }
    100% { transform: translate3d(-2%, 2%, 0) scale(1.03); }
}
/* En móvil reducimos coste: menos opacidad y sin blur pesado */
@media (max-width: 640px) {
    .tfhome::before { opacity: .7; filter: blur(4px); }
}

/* --- #9) Cifras tabulares + color por signo --- */
.tfhome-stat-value, .dash-card-v,
.tfcard-stat-value, .dash-row-amount {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}
.tfcard-stat-value.is-positive { text-shadow: 0 0 14px color-mix(in srgb, var(--success, #10b981) 35%, transparent); }
.tfcard-stat-value.is-negative { text-shadow: 0 0 14px color-mix(in srgb, var(--danger, #ef4444) 28%, transparent); }

/* --- #10) Barrido de luz en títulos al revelarse --- */
@keyframes premTitleSheen {
    0%   { background-position: 200% 0; }
    100% { background-position: -50% 0; }
}
.prem-sheen.is-in {
    background-image: linear-gradient(
        100deg,
        currentColor 0%, currentColor 38%,
        #ffffff 50%,
        currentColor 62%, currentColor 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: premTitleSheen 1.1s ease-out 1;
    animation-fill-mode: forwards;
}

/* --- Movimiento reducido: lo apagamos todo --- */
@media (prefers-reduced-motion: reduce) {
    .prem-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    .tfnav { transition: none !important; }
    .prem-progress { display: none !important; }
    .tfcard::after { display: none !important; }
    .tfcard:hover { animation: none !important; }
    .tfhome::before { animation: none !important; }
    .prem-sheen.is-in {
        animation: none !important; background: none !important;
        -webkit-text-fill-color: currentColor; color: inherit !important;
    }
}

/* ============================================================
   PREMIUM MOBILE LAYER · experiencia tipo app nativa
   Barra inferior, FAB, bottom sheets, ripple, tipografía fluida,
   pull-to-refresh, header colapsable, carrusel, swipe y
   transiciones de página. Casi todo bajo @media (max-width:768px).
   ============================================================ */

/* Transiciones de página entre navegaciones (Chrome y compatibles) */
@view-transition { navigation: auto; }

/* Por defecto, los elementos solo-móvil están ocultos */
.mtab-bar, .mfab, .msheet-backdrop { display: none; }

@media (max-width: 768px) {
    /* --- Ocultar la tira de iconos superior: la sustituye la barra inferior --- */
    .layout .tfnav-tabs { display: none !important; }

    /* Espacio para que el contenido no quede tapado por la barra inferior.
       La barra mide ~64px + safe-area; dejamos margen de sobra. */
    .app, .page { padding-bottom: calc(84px + var(--safe-bottom, 0px)); }

    /* --- #1) BARRA INFERIOR (tab bar) --- */
    .mtab-bar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 900;
        padding: 6px 6px calc(6px + var(--safe-bottom, 0px));
        gap: 2px;
        /* Fondo OPACO a propósito. Un `backdrop-filter: blur` sobre un elemento
           position:fixed hace que iOS Safari recalcule el desenfoque tarde
           durante el scroll con inercia y la barra "salta / se sube". Con fondo
           sólido + capa de composición propia (translateZ) la barra queda
           clavada abajo mientras se hace scroll. */
        background: var(--moss, #fff);
        border-top: 1px solid var(--border);
        box-shadow: 0 -6px 24px rgba(0,0,0,.06);
        transform: translateZ(0);
        will-change: transform;
    }
    .mtab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 52px;
        padding: 4px 2px;
        border: none;
        background: none;
        color: var(--cream-dim, #64748b);
        text-decoration: none;
        font: inherit;
        cursor: pointer;
        border-radius: 12px;
        position: relative;
        -webkit-tap-highlight-color: transparent;
        transition: color .18s var(--ease-out, ease), background .18s var(--ease-out, ease);
    }
    .mtab:active { background: color-mix(in srgb, var(--gold, #4f46e5) 10%, transparent); }
    .mtab.is-active { color: var(--gold, #4f46e5); }
    .mtab-ic { position: relative; line-height: 0; }
    .mtab-ic svg { width: 23px; height: 23px; }
    /* (Quitado) El punto de "activo" iba a bottom:-7px del icono, justo donde
       está la etiqueta → se solapaba con el texto ("Ini•cio", "Ch•at"). El
       estado activo ya se distingue por el color del icono + texto. */
    .mtab-lbl { font-size: 10.5px; font-weight: 600; letter-spacing: .1px; }
    .mtab-badge {
        position: absolute; top: -5px; right: 0;
        min-width: 16px; height: 16px; padding: 0 4px;
        border-radius: 999px; background: var(--danger, #ef4444); color: #fff;
        font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
    }

    /* --- #3) BOTÓN FLOTANTE (FAB) ---
       DESACTIVADO en móvil: chocaba con la burbuja del Asistente IA y tapaba
       la pestaña "Más". Cada pantalla ya tiene su propio botón "+" visible,
       así que el FAB era redundante. Dejamos solo un flotante: el asistente. */
    .mfab { display: none !important; }
    .mfab--keep {
        display: flex; align-items: center; justify-content: center;
        position: fixed; right: 16px; bottom: calc(80px + var(--safe-bottom, 0px));
        z-index: 901; width: 56px; height: 56px; border-radius: 18px; border: none;
        background: linear-gradient(135deg, var(--gold, #4f46e5), color-mix(in srgb, var(--gold,#4f46e5) 60%, var(--success,#10b981)));
        color: #fff; cursor: pointer;
        box-shadow: 0 10px 26px color-mix(in srgb, var(--gold, #4f46e5) 45%, transparent);
        -webkit-tap-highlight-color: transparent;
        transition: transform .16s var(--ease-out, ease), box-shadow .16s var(--ease-out, ease);
        animation: mfabPop .3s var(--ease-out, cubic-bezier(0.23,1,0.32,1)) both;
    }
    .mfab[hidden] { display: none; }
    .mfab:active { transform: scale(.9); }
    .mfab svg { width: 26px; height: 26px; }
    @keyframes mfabPop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }

    /* --- #5) Tipografía fluida + evitar zoom de iOS en inputs --- */
    .tfhome-stat-value { font-size: clamp(26px, 8vw, 40px); }
    .tfhome-header h1  { font-size: clamp(22px, 6.5vw, 30px); }
    input, select, textarea { font-size: 16px !important; } /* iOS no hace zoom */
    /* Override de inputs con font-size <16px fijado por ID/clase (especificidad)
       para que tampoco disparen el auto-zoom de iOS. */
    #edit-lines .fact-line-section-edit { font-size: 16px !important; }

    /* --- #6) Áreas de toque grandes --- */
    .btn, .tfhome-cta, .tfcard-action, .nav-dropdown-item, .dash-card { min-height: 44px; }
    .modal-close { min-height: 44px; min-width: 44px; }

    /* --- #9) HEADER colapsable de la home --- */
    .tfhome-header { transition: padding .25s var(--ease-out, ease); }
    .tfhome-header.is-compact { padding-top: 4px; padding-bottom: 4px; }
    .tfhome-header.is-compact .tfhome-greet,
    .tfhome-header.is-compact .tfhome-header-sub { display: none; }
    .tfhome-header.is-compact .tfhome-stat-value { font-size: clamp(20px, 6vw, 26px); }
    .tfhome-header.is-compact h1 { font-size: clamp(18px, 5vw, 22px); }

    /* --- #8) CARRUSEL horizontal de tarjetas de empresa --- */
    .tfhome-grid {
        display: grid;
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: 82%;
        gap: 12px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 16px;
        margin: 0 -16px;
        padding: 4px 16px 8px;
        scrollbar-width: none;
    }
    .tfhome-grid::-webkit-scrollbar { display: none; }
    .tfhome-grid .tfcard { scroll-snap-align: center; }
}

/* --- #2) BOTTOM SHEETS (hoja "Más" + modales como hoja) --- */
.msheet-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,15,15,.45);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    opacity: 0; transition: opacity .25s var(--ease-out, ease);
}
.msheet-backdrop.is-open { display: block; opacity: 1; }
.msheet {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--moss, #fff);
    border-radius: 22px 22px 0 0;
    padding: 10px 18px calc(20px + var(--safe-bottom, 0px));
    box-shadow: 0 -16px 48px rgba(0,0,0,.22);
    transform: translateY(100%);
    transition: transform .32s var(--ease-drawer, cubic-bezier(0.32,0.72,0,1));
    max-height: 86vh; overflow-y: auto;
}
.msheet-backdrop.is-open .msheet { transform: translateY(0); }
.msheet-grip {
    width: 40px; height: 4px; border-radius: 999px;
    background: var(--border); margin: 2px auto 14px;
}
.msheet-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--cream-dim); margin: 0 0 12px 2px; }
.msheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 360px) { .msheet-grid { grid-template-columns: repeat(3, 1fr); } }
.msheet-item {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    padding: 14px 6px; border-radius: 14px; text-decoration: none;
    color: var(--cream, #0f172a); background: color-mix(in srgb, var(--cream) 4%, transparent);
    border: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
    transition: transform .14s var(--ease-out, ease), background .14s;
}
.msheet-item:active { transform: scale(.94); background: color-mix(in srgb, var(--gold,#4f46e5) 10%, transparent); }
.msheet-item-ic { color: var(--gold, #4f46e5); line-height: 0; }
.msheet-item-lbl { font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.2; }
.msheet-logout-form { margin: 16px 0 0; }

/* ===================== SECTION EMPTY STATE ===================== */
.section-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 52px 24px; gap: 12px;
}
.section-empty-icon {
    width: 72px; height: 72px; border-radius: 20px;
    background: color-mix(in srgb, var(--gold, #4f46e5) 10%, transparent);
    color: var(--gold, #4f46e5);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 4px;
}
.section-empty-title { font-size: 18px; font-weight: 700; margin: 0; color: var(--cream); }
.section-empty-sub {
    font-size: 14px; color: var(--cream-dim); max-width: 360px;
    line-height: 1.5; margin: 0;
}
.section-empty .btn, .section-empty .btn--primary { margin-top: 8px; }

/* ===================== AYUDA EN CAMPOS (microcopy) ===================== */
.field-hint {
    display: block; font-size: 12px; line-height: 1.4;
    color: var(--cream-dim); margin: 5px 2px 0;
}
.field-hint strong { color: var(--cream); font-weight: 600; }

/* ===================== AYUDA "?" (tooltip) ===================== */
.help-tip {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; margin-left: 6px; border-radius: 50%;
    background: color-mix(in srgb, var(--gold,#4f46e5) 16%, transparent);
    color: var(--gold,#4f46e5); font-size: 11px; font-weight: 700;
    cursor: help; vertical-align: middle; -webkit-tap-highlight-color: transparent;
}
.help-tip-q { line-height: 1; }
.help-tip-bubble {
    position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
    width: max-content; max-width: 240px; padding: 9px 11px; border-radius: 9px;
    background: var(--surface, #1c1c1c); border: 1px solid var(--border);
    color: var(--cream); font-size: 12px; font-weight: 400; line-height: 1.45; text-align: left;
    opacity: 0; visibility: hidden; transition: opacity .14s; z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,.3); pointer-events: none;
}
.help-tip-bubble::after {
    content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--border);
}
.help-tip:hover .help-tip-bubble,
.help-tip:focus .help-tip-bubble,
.help-tip:focus-within .help-tip-bubble { opacity: 1; visibility: visible; }

/* ===================== HOME QUICKSTART ===================== */
.qs-card {
    background: color-mix(in srgb, var(--gold,#4f46e5) 7%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold,#4f46e5) 28%, transparent);
    border-radius: 18px; padding: 22px 22px 18px; margin: 0 0 28px; position: relative;
}
.qs-card-head { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; }
.qs-card-badge {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    background: var(--gold,#4f46e5); color: #fff;
    display: flex; align-items: center; justify-content: center; line-height: 0;
}
.qs-card-title { font-size: 16px; font-weight: 700; color: var(--cream); margin: 0; }
.qs-card-sub { font-size: 13px; color: var(--cream-dim); margin: 0 0 16px; }
.qs-steps { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .qs-steps { grid-template-columns: 1fr 1fr; } }
.qs-step {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--surface, color-mix(in srgb, var(--cream) 4%, transparent));
    border: 1px solid var(--border); border-radius: 13px;
    padding: 13px 15px; text-decoration: none; color: inherit;
    transition: transform .12s, border-color .12s;
}
.qs-step:hover { border-color: color-mix(in srgb, var(--gold,#4f46e5) 50%, var(--border)); transform: translateY(-1px); }
.qs-step:active { transform: scale(.99); }
.qs-step-num {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
    background: color-mix(in srgb, var(--gold,#4f46e5) 18%, transparent);
    color: var(--gold,#4f46e5); font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.qs-step-body { flex: 1; min-width: 0; }
.qs-step-lbl { font-size: 13.5px; font-weight: 600; line-height: 1.25; color: var(--cream); }
.qs-step-desc { font-size: 12px; color: var(--cream-dim); margin-top: 2px; line-height: 1.35; }
.qs-card-close {
    position: absolute; top: 14px; right: 16px; background: none; border: none;
    padding: 5px; cursor: pointer; color: var(--cream-dim); line-height: 0; border-radius: 7px;
}
.qs-card-close:hover { color: var(--cream); background: color-mix(in srgb, var(--cream) 8%, transparent); }
/* Secciones en lista con descripción (Más sheet) */
.msheet-list { display: flex; flex-direction: column; gap: 4px; }
.msheet-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 14px; text-decoration: none;
    color: var(--cream, #0f172a); background: color-mix(in srgb, var(--cream) 4%, transparent);
    border: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
    transition: transform .14s, background .14s;
}
.msheet-list-item:active { transform: scale(.97); background: color-mix(in srgb, var(--gold,#4f46e5) 8%, transparent); }
.msheet-list-ic { color: var(--gold, #4f46e5); line-height: 0; flex-shrink: 0; }
.msheet-list-body { flex: 1; min-width: 0; }
.msheet-list-lbl { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.msheet-list-desc { display: block; font-size: 11.5px; color: var(--cream-dim); margin-top: 1px; line-height: 1.3; }
.msheet-list-arrow { color: var(--cream-dim); line-height: 0; flex-shrink: 0; }
.msheet-logout {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 13px; border-radius: 14px; border: 1px solid var(--border);
    background: none; color: var(--danger, #ef4444); font: inherit; font-weight: 600;
    cursor: pointer;
}

/* Convertir los modales normales en hojas inferiores en móvil */
@media (max-width: 640px) {
    .modal-backdrop.is-open { align-items: flex-end; }
    .modal {
        width: 100%; max-width: 100%;
        border-radius: 22px 22px 0 0;
        animation: msheetUp .32s var(--ease-drawer, cubic-bezier(0.32,0.72,0,1));
    }
    .modal::before {
        content: ""; display: block; width: 40px; height: 4px; border-radius: 999px;
        background: var(--border); margin: -6px auto 14px;
    }
    @keyframes msheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
}

/* --- #4) SWIPE en filas (framework; se activa con .swipe-row) --- */
.swipe-row { position: relative; overflow: hidden; touch-action: pan-y; }
.swipe-row-content { position: relative; background: var(--moss, #fff); transition: transform .2s var(--ease-out, ease); will-change: transform; z-index: 1; }
.swipe-row-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; align-items: stretch; z-index: 0; }
.swipe-row-actions button { border: none; color: #fff; font: inherit; font-weight: 600; padding: 0 18px; cursor: pointer; }
.swipe-row-actions .swa-done { background: var(--success, #10b981); }
.swipe-row-actions .swa-del  { background: var(--danger, #ef4444); }
.swipe-row.is-swiped .swipe-row-content { transform: translateX(-96px); }
@media (max-width: 768px) {
    /* En móvil la acción "marcar leída" se hace deslizando: ocultamos el ✓ inline */
    .swipe-row .notif-mark-form { display: none; }
}
@media (min-width: 769px) {
    /* En escritorio no hay swipe: las acciones laterales quedan ocultas */
    .swipe-row-actions { display: none; }
}

/* --- #4b) Ripple en pulsaciones --- */
.ripple { position: absolute; border-radius: 50%; transform: scale(0); pointer-events: none;
    background: rgba(255,255,255,.45); animation: rippleGo .55s ease-out; }
@keyframes rippleGo { to { transform: scale(2.4); opacity: 0; } }

/* --- #6/#10) Pull-to-refresh --- */
.ptr-spin {
    position: fixed; top: 0; left: 50%; transform: translate(-50%, -44px);
    z-index: 950; width: 34px; height: 34px; border-radius: 50%;
    background: var(--moss, #fff); box-shadow: 0 4px 14px rgba(0,0,0,.15);
    display: flex; align-items: center; justify-content: center;
    transition: transform .2s var(--ease-out, ease); pointer-events: none;
}
.ptr-spin svg { width: 18px; height: 18px; color: var(--gold, #4f46e5); }
.ptr-spin.is-loading svg { animation: ptrSpin .8s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .mfab, .msheet, .modal { animation: none !important; }
    .ripple { display: none !important; }
    .ptr-spin.is-loading svg { animation: none !important; }
}

/* ============================================================
   FIX DEFINITIVO · Posición de los menús del nav (cuenta, etc.)
   ------------------------------------------------------------
   Había DOS problemas distintos según el ancho:

   1) MÓVIL (<=900px, barra superior): el menú se "teletransporta"
      a <body> (portal) y se ve como hoja flotante. Lo fijamos a
      izq/der con márgenes seguros para que nunca se salga.

   2) ESCRITORIO (>=901px, sidebar vertical): el chip de cuenta
      vive en la barra lateral izquierda (~248px). La regla
      `.layout #nav-dropdown-user .nav-dropdown-menu { right:0 }`
      (mayor especificidad) anclaba el menú al borde DERECHO del
      chip; como mide 280px, se extendía hacia la IZQUIERDA y se
      salía de la pantalla (texto cortado: "egacy", "ANIZACIÓN").
      Solución: que abra alineado a la IZQUIERDA (hacia el
      contenido), con !important para ganar a esa regla.

   Va al final del archivo para ganar por orden + !important.
   ============================================================ */
@media (max-width: 900px) {
    .layout .tfnav,
    .layout .tfnav.is-scrolled {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }
    .layout #nav-dropdown-user .nav-dropdown-menu,
    .layout #nav-dropdown-preview .nav-dropdown-menu,
    .layout #lang-switcher .nav-dropdown-menu,
    body > .nav-dropdown-menu--portal {
        position: fixed !important;
        top: calc(56px + var(--safe-top, 0px)) !important;
        left: 12px !important;
        right: 12px !important;
        bottom: auto !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        transform: none !important;
        max-height: calc(100dvh - 76px) !important;
        overflow-y: auto !important;
    }
}

/* Escritorio (sidebar): el sidebar tiene overflow-y:auto, lo que obliga al
   navegador a RECORTAR también en horizontal (regla de CSS: si un eje no es
   visible, el otro 'visible' pasa a 'auto'). Por eso un menú de 280px se sale
   y se corta vaya a izquierda o derecha. Solución: que el menú ocupe el ANCHO
   del sidebar (left:0 + right:0, sin min-width de 280px) → cabe dentro y nunca
   se recorta. Queda como un desplegable a lo ancho de la barra lateral. */
@media (min-width: 901px) {
    .layout #nav-dropdown-user .nav-dropdown-menu {
        left: 0 !important;
        right: 0 !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        transform-origin: top left;
    }
}

/* ============================================================
   BUSCADORES UNIFICADOS · estilo "monospace técnico" (estilo B,
   como el de Ingresos). El usuario eligió que TODOS se vean igual:
   fuente DM Mono 12px, caja transparente, borde var(--border), 8px.
   Va al final con !important para ganar a los estilos previos.
   ============================================================ */
.tfhome-search-input,
.doc-search-input,
.acct-mov-search input[type="search"],
.tx-search-input {
    font-family: 'DM Mono', ui-monospace, monospace !important;
    font-size: 12px !important;
    letter-spacing: 0.3px !important;
}
/* En móvil, 16px obligatorio: a 12px iOS hace auto-zoom al enfocar.
   Va después de la regla anterior para ganar en cascada. */
@media (max-width: 600px) {
    .tfhome-search-input,
    .doc-search-input,
    .acct-mov-search input[type="search"],
    .tx-search-input {
        font-size: 16px !important;
    }
}
.tfhome-search-input::placeholder,
.doc-search-input::placeholder,
.acct-mov-search input[type="search"]::placeholder,
.tx-search-input::placeholder {
    font-family: 'DM Mono', ui-monospace, monospace !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    opacity: .6 !important;
}
/* La "caja" de cada buscador, igualada (borde + radio + fondo) */
.tfhome-search,
.doc-search-input,
.acct-mov-search > div,
.tx-search-input {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    background: transparent !important;
}

/* Clip de adjunto en los resultados del buscador general: abre la factura /
   comprobante del movimiento en una pestaña nueva, sin abrir el modal. */
.search-result-clip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
    color: var(--tf-accent, #0e7c5a); cursor: pointer;
    transition: background .15s ease, transform .12s ease;
}
.search-result-clip:hover { background: color-mix(in srgb, var(--tf-accent, #0e7c5a) 13%, transparent); }
.search-result-clip:active { transform: scale(.92); }

/* ============================================================
   NATIVE FEEL — sensación de app nativa (iPhone-grade)
   Bloque autocontenido y degradable: si el navegador no soporta
   algo, simplemente no pasa nada (navegación normal).
   ============================================================ */

/* (#1) Transiciones entre páginas (View Transitions, multi-página).
   Navegadores modernos animan el cambio de página; el resto navega
   igual que siempre. Sutil fundido + leve desplazamiento. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root) { animation: ntFadeOut .16s ease both; }
    ::view-transition-new(root) { animation: ntFadeIn  .26s cubic-bezier(0.23,1,0.32,1) both; }
}
@keyframes ntFadeOut { to   { opacity: 0; transform: translateY(-4px); } }
@keyframes ntFadeIn  { from { opacity: 0; transform: translateY(8px);  } }

/* (#2) Barra de carga superior tipo app al navegar / enviar formularios. */
#nt-progress {
    position: fixed; top: 0; left: 0; height: 2.5px; width: 0;
    z-index: 10000; pointer-events: none; border-radius: 0 3px 3px 0;
    background: linear-gradient(90deg, var(--gold, #d4b084), #7fae6f);
    box-shadow: 0 0 10px color-mix(in srgb, var(--gold, #d4b084) 65%, transparent);
    opacity: 0; transition: width .2s ease, opacity .3s ease;
}
#nt-progress.is-active { opacity: 1; }

/* (#6/#7) Toasts en móvil: arriba de la barra inferior, a lo ancho,
   y deslizables para descartar. */
@media (max-width: 768px) {
    .toast-container {
        top: auto; right: 12px; left: 12px;
        bottom: calc(80px + var(--safe-bottom, 0px));
        max-width: none;
    }
    .toast { transform: translateY(22px); }
    .toast.is-visible { transform: translateY(0); }
    .toast.is-swiping { transition: none; }
}

@media (max-width: 640px) { .hide-mobile { display: none !important; } }

/* Buscador general: enlace "Ver todos (N)" del grupo + paginación del drill-down.
   Usa tokens legacy (--cream/--border/--gold), que SÍ adaptan a claro y oscuro
   (los --tf-* solo existen en tema claro y dejaban el texto negro sobre fondo
   oscuro). */
.search-group-all {
    margin-left: auto;
    font-family: 'DM Mono', monospace;
    font-size: 11px; letter-spacing: .5px;
    color: var(--gold); text-decoration: none; white-space: nowrap;
    transition: opacity .15s var(--ease-out, ease);
}
.search-group-all:hover { text-decoration: underline; }

.search-pager {
    display: flex; align-items: center; gap: 12px;
    margin: 28px 2px 8px; flex-wrap: wrap;
    font-family: 'DM Mono', monospace;
    border-top: 1px solid var(--border);
    padding-top: 18px;
}
.search-pager-spacer { flex: 1 1 auto; }

/* Botones Anterior/Siguiente: píldoras coherentes con .btn pero compactas. */
.search-pager a:not(.search-pager-back),
.search-pager .is-disabled {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 40px;
    border: 1px solid var(--border);
    color: var(--cream); text-decoration: none;
    font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
    transition: border-color .15s var(--ease-out, ease), color .15s var(--ease-out, ease);
}
.search-pager a:not(.search-pager-back):hover { border-color: var(--gold); color: var(--gold); }
.search-pager .is-disabled { opacity: .35; cursor: default; }

.search-pager-info { color: var(--cream); opacity: .6; font-size: 12px; letter-spacing: .5px; }

.search-pager-back {
    color: var(--cream); opacity: .65; text-decoration: none;
    font-size: 12px; letter-spacing: .3px;
    transition: opacity .15s var(--ease-out, ease), color .15s var(--ease-out, ease);
}
.search-pager-back:hover { opacity: 1; color: var(--gold); }

/* ===== Deudas · tarjetas de totales en la ficha de empresa/proyecto =====
   Reemplaza el grid inline de 3 columnas (se aplastaba en móvil). Tokens del
   tema para que funcione en claro y oscuro. */
.debts-net-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 6px 0 22px;
}
.debts-net-card {
    position: relative;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e6e6e6);
    border-radius: 14px;
    padding: 14px 16px;
    overflow: hidden;
}
.debts-net-card::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--border, #e6e6e6);
}
.debts-net-card.is-negative::before { background: var(--danger, #c0392b); }
.debts-net-card.is-positive::before { background: var(--success, #1e8449); }
.debts-net-card-label {
    font-size: .72rem; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted, #888);
    margin-bottom: 6px;
}
.debts-net-card-value {
    font-size: 1.3rem; font-weight: 700; line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.debts-net-card-value.is-negative { color: var(--danger, #c0392b); }
.debts-net-card-value.is-positive { color: var(--success, #1e8449); }
@media (max-width: 640px) {
    .debts-net-cards { grid-template-columns: 1fr; gap: 10px; }
    .debts-net-card { padding: 12px 14px; }
    .debts-net-card-value { font-size: 1.15rem; }
}

/* ============ MÓVIL PREMIUM · hojas inferiores + microfeedback ============
   Los modales en móvil pasan de pantalla-completa a HOJA INFERIOR estilo app
   nativa (asa superior, esquinas redondeadas, animación de subida, respeta el
   home indicator). Va al final del fichero: gana a los bloques móviles
   anteriores por orden, sin !important. */
@media (max-width: 720px) {
    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
        background: rgba(12, 12, 12, 0.45);
        -webkit-backdrop-filter: blur(3px);
        backdrop-filter: blur(3px);
    }
    .modal {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 0;
        max-height: calc(100dvh - 32px - var(--safe-top, 0px));
        margin: 0;
        border-radius: 22px 22px 0 0;
        border-bottom: none;
        padding: 32px 18px calc(26px + var(--safe-bottom, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0.33, 1);
    }
    /* Asa de la hoja (grip) */
    .modal::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 42px;
        height: 4px;
        border-radius: 999px;
        background: var(--border-hover, rgba(128, 128, 128, 0.35));
    }
    /* Feedback táctil en tarjetas y navegación de ficha */
    .dash-card:active,
    .detail-sidebar-item:active,
    .debts-net-card:active {
        transform: scale(0.98);
        transition: transform 0.08s ease;
    }
}
@keyframes sheetUp {
    from { transform: translateY(28px); opacity: 0.55; }
    to   { transform: translateY(0);    opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .modal { animation: none; }
}

/* ============ MÓVIL · márgenes compactos y arreglos de home ============
   1) El hueco superior de 84px de .page compensaba la tira de pestañas de
      escritorio; en móvil esa tira está oculta y el hueco quedaba muerto.
   2) El sangrado horizontal acumulaba 52px por lado (24+14+14): en un iPhone
      de 390px era un 27%% de pantalla. Se compacta a ~24px por lado.
   3) input[type="search"] (0,1,1) pisaba el hueco de la lupa de
      .tx-search-input (0,1,0); se restaura con más especificidad. */
@media (max-width: 768px) {
    .layout .page {
        padding-top: 12px;
        padding-left: 10px;
        padding-right: 10px;
    }
    .page-inner {
        padding-left: 0;
        padding-right: 0;
    }
    .tx-search-wrap .tx-search-input {
        padding: 11px 36px 11px 38px;
    }
}
/* Balance consolidado de la home con color por signo (antes siempre neutro) */
/* :root delante para ganar al override del tema claro
   (:root[data-theme="light"] .tfhome-stat-value → 0,2,1). */
:root .tfhome-stat-value.is-negative { color: var(--danger, #c0392b); }
:root .tfhome-stat-value.is-positive { color: var(--success, #1e8449); }

/* ==================================================================
 * NAV POR INTENCIONES · piezas nuevas
 * 1) .qa-row / .qa-btn — acciones rápidas del inicio (hacer > leer).
 * 2) .dash-head — el panel accionable se titula "Hoy".
 * 3) .tswitch — conmutador Del mes / Puntuales dentro de las páginas
 *    de tareas (sustituye a la hoja selectora del móvil).
 * ================================================================== */
.qa-row {
    display: flex;
    gap: 10px;
    margin: 0 0 22px;
    flex-wrap: wrap;
}
.qa-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 18px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    background: var(--moss, #fff);
    color: var(--tf-text, var(--cream, #0f172a));
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.qa-btn svg { width: 18px; height: 18px; color: var(--gold, #4f46e5); flex: 0 0 auto; }
.qa-btn:hover { border-color: var(--gold, #4f46e5); }
.qa-btn:active { transform: scale(.97); }
@media (max-width: 768px) {
    .qa-row { gap: 8px; }
    /* Tres botones a lo ancho: objetivo táctil grande, texto legible */
    .qa-btn { flex: 1 1 0; justify-content: center; padding: 13px 8px; font-size: 12.5px; }
}

.dash-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 14px;
    flex-wrap: wrap;
}
.dash-title {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--tf-text, var(--cream, #0f172a));
}
.dash-subtitle {
    font-size: 13px;
    color: var(--tf-text-3, var(--cream-dim, #64748b));
}

.tswitch {
    display: flex;
    gap: 6px;
    margin: 0 0 18px;
    padding: 4px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 13px;
    background: color-mix(in srgb, var(--cream, #0f172a) 4%, transparent);
    max-width: 520px;
}
.tswitch-tab {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 9px 14px;
    border-radius: 10px;
    text-decoration: none;
    text-align: center;
    color: var(--tf-text-3, var(--cream-dim, #64748b));
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease, color .15s ease;
}
.tswitch-tab .tswitch-lbl { font-size: 14px; font-weight: 700; letter-spacing: -0.1px; }
.tswitch-tab .tswitch-sub { font-size: 11px; opacity: .75; }
.tswitch-tab.is-active {
    background: var(--moss, #fff);
    color: var(--tf-text, var(--cream, #0f172a));
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.tswitch-tab.is-active .tswitch-sub { opacity: .65; }
@media (max-width: 768px) {
    .tswitch { max-width: none; }
    .tswitch-tab { padding: 10px 8px; }
}

/* ==================================================================
 * HISTORIAL · pestaña "Cambios del sistema" (release notes)
 * Timeline agrupada por día; cada cambio = tarjeta con badge por tipo
 * (Nuevo / Mejora / Arreglo). Publicación y borrado solo superadmin.
 * ================================================================== */
.clog-form {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 14px;
    padding: 16px 18px;
    margin: 0 0 26px;
    background: color-mix(in srgb, var(--cream, #0f172a) 3%, transparent);
}
.clog-form-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.1px;
}
.clog-form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.clog-form-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.clog-form-field > span { opacity: .7; }
.clog-form-field textarea { resize: vertical; }

.clog-timeline { display: flex; flex-direction: column; gap: 26px; }
.clog-day-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .3px;
    font-variant-numeric: tabular-nums;
    color: var(--tf-text-3, var(--cream-dim, #64748b));
    text-transform: uppercase;
}
.clog-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    margin-bottom: 8px;
}
.clog-badge {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    margin-top: 1px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}
.clog-badge--feature {
    color: var(--success, #1e8449);
    border-color: color-mix(in srgb, var(--success, #1e8449) 40%, transparent);
    background: color-mix(in srgb, var(--success, #1e8449) 10%, transparent);
}
.clog-badge--improvement {
    color: var(--gold, #4f46e5);
    border-color: color-mix(in srgb, var(--gold, #4f46e5) 40%, transparent);
    background: color-mix(in srgb, var(--gold, #4f46e5) 10%, transparent);
}
.clog-badge--fix {
    color: var(--tf-warn, #b45309);
    border-color: color-mix(in srgb, var(--tf-warn, #b45309) 40%, transparent);
    background: color-mix(in srgb, var(--tf-warn, #b45309) 10%, transparent);
}
.clog-item-body { flex: 1 1 auto; min-width: 0; }
.clog-item-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.clog-item-summary {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--tf-text-2, var(--cream-dim, #64748b));
    word-break: break-word;
}
.clog-item-meta { margin-top: 6px; font-size: 11.5px; opacity: .55; }
.clog-item-del { flex: 0 0 auto; }
.clog-del-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: none;
    color: var(--tf-text-3, var(--cream-dim, #64748b));
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease;
}
.clog-del-btn:hover { color: var(--danger, #c0392b); border-color: var(--danger, #c0392b); }
@media (max-width: 768px) {
    .clog-item { flex-wrap: wrap; }
    .clog-badge { order: -1; }
    .clog-item-body { flex-basis: 100%; }
}

/* ==================================================================
 * ASOCIAR MOVIMIENTO A PROYECTO (banco → proyecto)
 * Chip por fila dentro de la celda de concepto + hoja compartida.
 * ================================================================== */
.tx-project { margin-top: 6px; }
.tx-proj-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 9px;
    border: 1px dashed var(--border, #d7dfda);
    border-radius: 999px;
    background: none;
    color: var(--cream-dim, #6b7a72);
    font: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.tx-proj-btn svg { width: 12px; height: 12px; flex: 0 0 auto; }
.tx-proj-btn:hover { border-color: var(--gold, #4f46e5); color: var(--gold, #4f46e5); }
.tx-proj-btn.is-linked {
    border-style: solid;
    border-color: color-mix(in srgb, var(--gold, #4f46e5) 30%, transparent);
    background: color-mix(in srgb, var(--gold, #4f46e5) 8%, transparent);
    color: var(--cream, #10241a);
}
.tx-proj-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.tx-proj-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

/* --- Traspasos: chip neutro + acción "Es un traspaso" + importe neutro --- */
.tx-transfer-mark {
    margin-left: 8px;
    padding: 3px 8px;
    border: none;
    background: none;
    color: var(--cream-dim, #6b7a72);
    font: inherit;
    font-size: 11px;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tx-transfer-mark:hover { color: var(--cream, #10241a); }
.tx-transfer-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid var(--border, #d7dfda);
    border-radius: 999px;
    background: color-mix(in srgb, var(--cream, #0f172a) 5%, transparent);
    color: var(--cream-dim, #6b7a72);
    font: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s ease, color .15s ease;
}
.tx-transfer-chip svg { width: 12px; height: 12px; flex: 0 0 auto; }
.tx-transfer-chip:hover { border-color: var(--cream-dim, #6b7a72); color: var(--cream, #10241a); }
.tx-transfer-x { opacity: .55; font-weight: 700; margin-left: 2px; }
/* Importe de un traspaso: NEUTRO, nunca verde (ingreso) ni rojo (gasto). */
.tx-amount.tx-amount--transfer { color: var(--cream-dim, #64748b) !important; }

/* ===== Financiación entre proyectos (ficha del proyecto, pane Rentabilidad) =====
   Carril aparte de la rentabilidad: TODO en neutro, sin verdes ni rojos. */
.prof-financing {
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem 1rem;
    border: 1px solid var(--tf-border, rgba(255,255,255,0.08));
    border-radius: 12px;
    background: var(--tf-surface-2, rgba(255,255,255,0.03));
}
.prof-financing-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cream-dim, #64748b);
}
.prof-financing-note {
    margin: 0.35rem 0 0.75rem;
    font-size: 0.8rem;
    color: var(--cream-dim, #64748b);
}
.prof-financing-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.prof-financing-stat {
    flex: 1 1 120px;
    min-width: 0;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--tf-border, rgba(255,255,255,0.08));
    border-radius: 10px;
}
.prof-financing-stat-label {
    font-size: 0.72rem;
    color: var(--cream-dim, #64748b);
    margin-bottom: 0.2rem;
}
.prof-financing-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.prof-financing-partners {
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.prof-financing-partners li {
    font-size: 0.82rem;
    color: var(--cream-dim, #64748b);
}

/* ===== Extractos a tope (F1-F9): ficha, sugerencias, traspasos, IA ===== */
.projsheet--wide { max-width: 640px; }
.tx-concept--click { cursor: pointer; }
.tx-concept--click:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Mes a mes: ingresos/gastos/balance de cada mes en la cuenta */
.monthly-card {
    margin: 0 0 18px;
    border: 1px solid var(--border, rgba(255,255,255,.1));
    border-radius: 14px;
    padding: 14px 16px 10px;
}
.monthly-head {
    font-size: 11.5px; font-weight: 800; text-transform: uppercase;
    letter-spacing: .05em; color: var(--cream-dim, #64748b); margin-bottom: 8px;
}
.monthly-scroll { overflow-x: auto; }
.monthly-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.monthly-table th {
    text-align: right; font-size: 10.5px; font-weight: 800; text-transform: uppercase;
    letter-spacing: .04em; color: var(--cream-dim, #64748b); padding: 6px 10px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
}
.monthly-table th:first-child { text-align: left; }
.monthly-table td { padding: 7px 10px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--border, rgba(255,255,255,.05)); }
.monthly-table tr:last-child td { border-bottom: none; }
.monthly-mes { text-align: left !important; font-weight: 700; }
.monthly-in  { color: var(--tf-success, #16a34a); }
.monthly-out { color: var(--tf-danger, #dc2626); }
.monthly-bal { font-weight: 800; }
.monthly-bal.pos { color: var(--tf-success, #16a34a); }
.monthly-bal.neg { color: var(--tf-danger, #dc2626); }

/* Chip "Fijo": se repite cada mes / ya contado en los fijos del proyecto */
.tx-fijo-chip {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--border, rgba(255,255,255,.15));
    background: transparent; color: var(--cream-dim, #64748b);
    border-radius: 999px; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    padding: 3px 9px; cursor: help;
}

/* Sugerencia de proyecto por patrón (F5) */
.tx-suggest-chip {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px dashed var(--border, rgba(255,255,255,.18));
    background: transparent; color: var(--cream-dim, #64748b);
    border-radius: 999px; font: inherit; font-size: 11.5px; font-weight: 600;
    padding: 3px 10px; cursor: pointer;
}
.tx-suggest-chip:hover { color: inherit; border-style: solid; }

/* Banner + hoja de posibles traspasos (F6) */
.tc-banner {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 14px; padding: 10px 14px;
    border: 1px solid var(--border, rgba(255,255,255,.12));
    border-radius: 12px; font-size: 13px;
    color: var(--cream-dim, #64748b);
}
.tc-banner-btn {
    margin-left: auto; border: 1px solid var(--border, rgba(255,255,255,.18));
    background: transparent; color: inherit; border-radius: 9px;
    font: inherit; font-size: 12.5px; font-weight: 700; padding: 6px 14px; cursor: pointer;
}
.tc-list { display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 4px; }
.tc-pair {
    display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--border, rgba(255,255,255,.1));
    border-radius: 12px; padding: 10px 12px;
}
.tc-pair-info { flex: 1; min-width: 0; }
.tc-pair-line { font-size: 12.5px; line-height: 1.5; }
.tc-pair-concept { opacity: .6; margin-left: 6px; }
.tc-pair-go { flex: 0 0 auto; }

/* Ficha del movimiento (F3) */
.ficha-body { padding: 4px 2px 8px; }
.ficha-block {
    border: 1px solid var(--border, rgba(255,255,255,.1));
    border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
}
.ficha-block-head { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; }
.ficha-block-sub { font-size: 11.5px; color: var(--cream-dim, #64748b); margin: 2px 0 8px; }
.ficha-lock { color: var(--cream-dim, #64748b); display: inline-flex; }
.ficha-amount { font-size: 1.3rem; font-weight: 800; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.ficha-amount.in { color: var(--tf-success, #16a34a); }
.ficha-amount.out { color: var(--tf-danger, #dc2626); }
.ficha-amount--neutral { color: var(--cream-dim, #64748b); }
.ficha-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ficha-table th {
    text-align: left; vertical-align: top; white-space: nowrap;
    font-size: 11px; font-weight: 700; color: var(--cream-dim, #64748b);
    padding: 5px 12px 5px 0; width: 1%;
}
.ficha-table td { padding: 5px 0; word-break: break-word; }
.ficha-noraw, .ficha-import { font-size: 11.5px; color: var(--cream-dim, #64748b); margin-top: 8px; }

/* Subir extracto con IA (F8) */
.ia-sub { font-size: 12.5px; color: var(--cream-dim, #64748b); margin: 0 4px 12px; }
.ia-msg { font-size: 12.5px; margin-top: 8px; min-height: 16px; }
.ia-msg.err { color: var(--tf-danger, #dc2626); }
.ia-review-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; font-size: 13px; }
.ia-cuadre { font-size: 12px; color: var(--cream-dim, #64748b); }
.ia-cuadre.ok { color: var(--tf-success, #16a34a); }
.ia-cuadre.err { color: var(--tf-danger, #dc2626); font-weight: 700; }
.ia-avisos { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.ia-aviso { font-size: 12px; color: var(--tf-danger, #dc2626); }
.ia-table-wrap { max-height: 44vh; overflow-y: auto; border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 10px; }
.ia-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ia-table th {
    position: sticky; top: 0; background: var(--moss, #fff); text-align: left;
    font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
    color: var(--cream-dim, #64748b); padding: 8px 10px;
}
.ia-table td { padding: 3px 6px; border-top: 1px solid var(--border, rgba(255,255,255,.06)); }
.ia-table input {
    width: 100%; background: transparent; border: 1px solid transparent; color: inherit;
    font: inherit; font-size: 12.5px; border-radius: 6px; padding: 5px 7px;
}
.ia-table input:focus { border-color: var(--border, rgba(255,255,255,.2)); outline: none; }
.ia-row-x { background: none; border: none; color: var(--cream-dim, #64748b); font-size: 15px; cursor: pointer; padding: 2px 6px; }
.ia-row-x:hover { color: var(--tf-danger, #dc2626); }

/* Chat IA (F9) */
.ia-chat {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
    width: min(400px, 100vw);
    display: flex; flex-direction: column;
    background: var(--moss, #fff);
    border-left: 1px solid var(--border, rgba(255,255,255,.12));
    box-shadow: -18px 0 48px rgba(0, 0, 0, .24);
}
.ia-chat[hidden] { display: none; }
.ia-chat-head {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 14px 16px 10px; border-bottom: 1px solid var(--border, rgba(255,255,255,.1));
}
.ia-chat-title { font-size: 14px; font-weight: 800; }
.ia-chat-sub { font-size: 11.5px; color: var(--cream-dim, #64748b); margin-top: 2px; }
.ia-chat-head .projsheet-close { margin-left: auto; }
.ia-chat-msgs { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 8px; }
.ia-bubble {
    max-width: 88%; padding: 8px 12px; border-radius: 14px;
    font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.ia-bubble--user { align-self: flex-end; background: var(--gold, #4f46e5); color: #fff; border-bottom-right-radius: 4px; }
.ia-bubble--assistant { align-self: flex-start; border: 1px solid var(--border, rgba(255,255,255,.12)); border-bottom-left-radius: 4px; }
.ia-bubble.err { color: var(--tf-danger, #dc2626); }
.ia-proposal {
    align-self: stretch; border: 1px dashed var(--border, rgba(255,255,255,.2));
    border-radius: 12px; padding: 10px 12px; font-size: 12.5px;
}
.ia-proposal.is-done { border-style: solid; opacity: .7; }
.ia-proposal-what { font-weight: 700; }
.ia-proposal-concept { color: var(--cream-dim, #64748b); margin: 3px 0; }
.ia-proposal-motivo { font-size: 12px; margin-bottom: 8px; }
.ia-proposal-btns { display: flex; gap: 8px; }
.ia-proposal-btns .btn { padding: 5px 12px; font-size: 12px; }
.ia-done { font-size: 12px; color: var(--tf-success, #16a34a); font-weight: 700; }
.ia-chat-input {
    display: flex; gap: 8px; align-items: flex-end;
    padding: 10px 12px calc(12px + var(--safe-bottom, 0px));
    border-top: 1px solid var(--border, rgba(255,255,255,.1));
}
.ia-chat-input textarea {
    flex: 1; resize: none; background: transparent; color: inherit;
    border: 1px solid var(--border, rgba(255,255,255,.15));
    border-radius: 10px; font: inherit; font-size: 13px; padding: 8px 11px;
}
.ia-chat-input .btn { padding: 8px 14px; }

/* Hoja de selección de proyecto — funciona en escritorio y móvil (slide-up) */
.projsheet-backdrop {
    position: fixed; inset: 0; z-index: 1200;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(15, 20, 17, .45);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .22s ease;
}
/* CRÍTICO: el `display:flex` de arriba (estilo de autor) anula el atributo
   `hidden` del navegador, dejando un overlay invisible (opacity:0) a pantalla
   completa que se COME todos los clics de la página. Con [hidden] gana la
   especificidad y la hoja queda realmente oculta hasta abrirla. */
.projsheet-backdrop[hidden] { display: none !important; }
.projsheet-backdrop.is-open { opacity: 1; }
.projsheet {
    width: 100%; max-width: 440px;
    max-height: 78vh; overflow-y: auto;
    background: var(--moss, #fff);
    border: 1px solid var(--border, #e3ebe6);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    padding: 10px 16px calc(18px + var(--safe-bottom, 0px));
    box-shadow: 0 -18px 48px rgba(0, 0, 0, .24);
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.32, .72, 0, 1);
}
.projsheet-backdrop.is-open .projsheet { transform: translateY(0); }
.projsheet-backdrop.is-busy { pointer-events: none; }
@media (min-width: 720px) {
    /* En escritorio la centramos como tarjeta flotante, no pegada abajo */
    .projsheet-backdrop { align-items: center; }
    .projsheet { border-radius: 16px; border-bottom: 1px solid var(--border, #e3ebe6); max-height: 70vh; }
    .projsheet-grip { display: none; }
}
.projsheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--border, #d7dfda); margin: 2px auto 12px; }
.projsheet-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--cream-dim, #6b7a72); margin: 2px 4px 10px; }
.projsheet-list { display: flex; flex-direction: column; gap: 2px; }
.proj-opt {
    display: flex; align-items: center; gap: 11px;
    width: 100%;
    padding: 12px 12px;
    border: none; border-radius: 11px;
    background: none;
    color: var(--cream, #10241a);
    font: inherit; font-size: 14px; font-weight: 600;
    text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .14s ease;
}
.proj-opt:hover, .proj-opt:active { background: color-mix(in srgb, var(--gold, #4f46e5) 9%, transparent); }
.proj-opt-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.proj-opt-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-opt-check { flex: 0 0 auto; color: var(--gold, #4f46e5); opacity: 0; }
.proj-opt.is-current .proj-opt-check { opacity: 1; }
.proj-opt.is-current { background: color-mix(in srgb, var(--gold, #4f46e5) 7%, transparent); }
.proj-opt-empty { padding: 18px 12px; text-align: center; color: var(--cream-dim, #6b7a72); font-size: 13px; }
.proj-opt--remove {
    margin-top: 6px;
    border-top: 1px solid var(--border, #e3ebe6);
    border-radius: 0 0 11px 11px;
    color: var(--danger, #c0392b);
    font-size: 13px;
}
.proj-opt--remove:hover { background: color-mix(in srgb, var(--danger, #c0392b) 8%, transparent); }
.proj-opt--remove svg { flex: 0 0 auto; }
