/* ═══════════════════════════════════════════════════════════════════
   Finanzas Mega-Panel — nexo.einblick-ki.com/#finanzas
   Zero-Hardcode §5: Dark glassmorphism, 6-tab layout
═══════════════════════════════════════════════════════════════════ */

/* ─── Root ───────────────────────────────────────────────────────── */
.fn-root {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--color-bg, #0a0a0f);
    color: var(--color-text, #e2e8f0);
    font-family: 'Inter', system-ui, sans-serif;
}

/* ─── Header ─────────────────────────────────────────────────────── */
.fn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.08));
    border-bottom: 1px solid rgba(99,102,241,0.2);
    flex-shrink: 0;
}

.fn-header__title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fn-header__icon {
    font-size: 22px;
    line-height: 1;
}

.fn-header__name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #e2e8f0;
}

.fn-header__sub {
    font-size: 10px;
    color: rgba(99,102,241,0.9);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 1px;
}

.fn-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ─── Status bar ─────────────────────────────────────────────────── */
.fn-status {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 500;
    transition: opacity 0.3s;
    flex-shrink: 0;
}
.fn-status--hidden { opacity: 0; pointer-events: none; height: 0; padding: 0; }
.fn-status--success { background: rgba(16,185,129,0.15); color: #34d399; }
.fn-status--error   { background: rgba(239,68,68,0.15);  color: #f87171; }
.fn-status--info    { background: rgba(99,102,241,0.15); color: #818cf8; }

/* ─── Tabs nav ───────────────────────────────────────────────────── */
.fn-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    gap: 2px;
    padding: 0 8px;
}
.fn-tabs::-webkit-scrollbar { display: none; }

.fn-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(226,232,240,0.5);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
    min-width: 56px;
}
.fn-tab span:first-child { font-size: 16px; }
.fn-tab:hover { color: #e2e8f0; }
.fn-tab--active {
    color: #818cf8;
    border-bottom-color: #6366f1;
}

/* ─── Body scroll area ───────────────────────────────────────────── */
.fn-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(99,102,241,0.3) transparent;
}

/* ─── Section ────────────────────────────────────────────────────── */
.fn-section {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.fn-section__title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(99,102,241,0.9);
    margin-bottom: 12px;
}

/* ─── Grid ───────────────────────────────────────────────────────── */
.fn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

/* ─── Fields ─────────────────────────────────────────────────────── */
.fn-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fn-label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(226,232,240,0.55);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.fn-input {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 7px;
    padding: 7px 10px;
    color: #e2e8f0;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s, background 0.2s;
    -moz-appearance: textfield;
}
.fn-input::-webkit-outer-spin-button,
.fn-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.fn-input:focus {
    outline: none;
    border-color: rgba(99,102,241,0.6);
    background: rgba(99,102,241,0.08);
}
.fn-input--inline {
    width: 90px;
    padding: 4px 7px;
    font-size: 12px;
}

/* ─── Slider ─────────────────────────────────────────────────────── */
.fn-field--slider { grid-column: span 2; }

.fn-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fn-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.12);
    outline: none;
    cursor: pointer;
}
.fn-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6366f1;
    box-shadow: 0 0 6px rgba(99,102,241,0.6);
    cursor: pointer;
    transition: transform 0.1s;
}
.fn-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.fn-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
}

.fn-slider-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    color: #818cf8;
    min-width: 52px;
    text-align: right;
}

/* ─── Select ─────────────────────────────────────────────────────── */
.fn-select {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 7px;
    padding: 6px 10px;
    color: #e2e8f0;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    outline: none;
}
.fn-select:focus { border-color: rgba(99,102,241,0.6); }

/* ─── Buttons ────────────────────────────────────────────────────── */
.fn-btn {
    border: none;
    border-radius: 7px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.fn-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fn-btn:not(:disabled):active { transform: scale(0.97); }

.fn-btn--primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    box-shadow: 0 2px 10px rgba(99,102,241,0.35);
}
.fn-btn--primary:not(:disabled):hover {
    box-shadow: 0 4px 16px rgba(99,102,241,0.5);
}

/* ─── Badges ─────────────────────────────────────────────────────── */
.fn-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}
.fn-badge--ok   { background: rgba(16,185,129,0.2); color: #34d399; }
.fn-badge--warn { background: rgba(245,158,11,0.2); color: #fbbf24; }
.fn-badge--err  { background: rgba(239,68,68,0.2);  color: #f87171; }

/* ─── Actuals bar ────────────────────────────────────────────────── */
.fn-actuals-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(99,102,241,0.07);
    border-radius: 8px;
    border: 1px solid rgba(99,102,241,0.15);
    font-size: 11px;
    color: rgba(226,232,240,0.7);
    flex-wrap: wrap;
}
.fn-actuals__label strong { color: #e2e8f0; }

/* ─── Table ──────────────────────────────────────────────────────── */
.fn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.fn-table th {
    text-align: left;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(99,102,241,0.8);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.fn-td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: rgba(226,232,240,0.85);
    vertical-align: middle;
}
.fn-table tbody tr:hover td { background: rgba(255,255,255,0.03); }

/* ─── Funnel ─────────────────────────────────────────────────────── */
.fn-funnel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.fn-funnel-stage {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fn-funnel-bar {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    border-radius: 6px;
    opacity: 0.88;
    min-height: 34px;
}

.fn-funnel-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
}

.fn-funnel-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.fn-funnel-conv {
    font-size: 10px;
    font-weight: 700;
    color: rgba(226,232,240,0.45);
    min-width: 32px;
    text-align: right;
}

/* ─── Misc ───────────────────────────────────────────────────────── */
.fn-loading {
    text-align: center;
    padding: 40px;
    color: rgba(226,232,240,0.4);
    font-size: 14px;
    animation: fn-pulse 1.5s ease-in-out infinite;
}
@keyframes fn-pulse {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 0.9; }
}

.fn-empty {
    text-align: center;
    color: rgba(226,232,240,0.3);
    padding: 32px;
    font-size: 13px;
}

.fn-mt { margin-top: 16px; }

.fn-pie-hint {
    margin-top: 10px;
    font-size: 11px;
    color: rgba(226,232,240,0.3);
    text-align: center;
    font-style: italic;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 400px) {
    .fn-grid { grid-template-columns: 1fr; }
    .fn-field--slider { grid-column: span 1; }
    .fn-header__name { font-size: 14px; }
    .fn-tab { min-width: 48px; padding: 6px 8px; }
    .fn-kpi-cards { grid-template-columns: 1fr 1fr; }
}

/* ─── KPI Cards (valores derivados destacados) ───────────────────── */
.fn-kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.fn-kpi-card {
    background: rgba(99,102,241,0.07);
    border: 1px solid rgba(99,102,241,0.18);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.2s, background 0.2s;
}
.fn-kpi-card:hover {
    background: rgba(99,102,241,0.12);
    border-color: rgba(99,102,241,0.35);
}
.fn-kpi-card--positive {
    border-color: rgba(16,185,129,0.3);
    background: rgba(16,185,129,0.07);
}
.fn-kpi-card--negative {
    border-color: rgba(239,68,68,0.3);
    background: rgba(239,68,68,0.07);
}

.fn-kpi-card__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(226,232,240,0.5);
}
.fn-kpi-card__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: #e2e8f0;
    line-height: 1.2;
}
.fn-kpi-card__sub {
    font-size: 9px;
    color: rgba(226,232,240,0.35);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 2px;
}

/* ─── Derived fields (🔒 read-only) ──────────────────────────────── */
.fn-field--derived {
    opacity: 0.9;
}
.fn-label--derived {
    color: rgba(129,140,248,0.7);
}
.fn-derived {
    background: rgba(99,102,241,0.05);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 7px;
    padding: 7px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #a5b4fc;
    user-select: text;
    cursor: default;
}
.fn-derived-inline {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #a5b4fc;
    padding: 4px 7px;
    background: rgba(99,102,241,0.08);
    border-radius: 5px;
}

/* ─── Hints ──────────────────────────────────────────────────────── */
.fn-hint {
    font-size: 9px;
    color: rgba(226,232,240,0.35);
    font-style: italic;
    line-height: 1.3;
}
.fn-hint--block {
    display: block;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    border-left: 2px solid rgba(99,102,241,0.3);
    font-size: 10px;
    color: rgba(226,232,240,0.4);
    font-style: normal;
}

/* ─── Badge variants ─────────────────────────────────────────────── */
/* Añade --error que faltaba (--err existía) */
.fn-badge--error { background: rgba(239,68,68,0.2); color: #f87171; }

/* ─── Table cell helpers ─────────────────────────────────────────── */
.fn-td--name {
    font-weight: 600;
    color: #e2e8f0;
    min-width: 140px;
}
.fn-td--hint {
    font-size: 11px;
    color: rgba(226,232,240,0.4);
    font-style: italic;
}
.fn-td--readonly {
    text-align: center;
}
.fn-table tfoot td {
    border-top: 1px solid rgba(255,255,255,0.1);
    font-weight: 700;
    color: #e2e8f0;
    padding-top: 10px;
}

/* ─── Unit label ─────────────────────────────────────────────────── */
.fn-unit {
    font-size: 9px;
    font-weight: 400;
    color: rgba(226,232,240,0.4);
    text-transform: none;
    letter-spacing: 0;
}

