/* allfunds.html — dashboard look aligned with debts.html */
body { min-height: 100vh; display: flex; flex-direction: column; }
.page-wrap { max-width: 1400px; padding: 0.5rem 0.5rem 2rem; }
@media (min-width: 1200px) { .page-wrap { max-width: 95%; margin: 0 auto; } }
@media (max-width: 720px) { .page-wrap { padding: 0.4rem 0.4rem 1.8rem; } }

.af-title { font-weight: 700; color: #4ca585; margin: 0 0 8px; letter-spacing: -0.5px; text-align: center; }
.af-rule { border: none; border-top: 2px solid #e0e0e0; margin: 0 0 18px; }

/* Stats strip */
.stats { background: #f8f9fa; padding: 15px; margin-bottom: 20px; border-radius: 8px; display: flex; flex-wrap: wrap; gap: 30px; }
.stat-item { display: flex; flex-direction: column; }
.stat-label { font-size: 12px; color: #666; text-transform: uppercase; }
.stat-value { font-size: 24px; font-weight: bold; color: #2c3e50; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .stats { gap: 10px 24px; } .stat-value { font-size: 20px; } }

/* Filters card */
.filters { background: #fff; padding: 20px; margin-bottom: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 20px; align-items: end; }
.filter-group { min-width: 0; }
.filter-group label { display: block; margin-bottom: 5px; font-weight: bold; color: #333; font-size: 0.85rem; }
.filter-group select, .filter-group input { width: 100%; box-sizing: border-box; padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; background: #fff; color: #222; }
.filter-group select:focus, .filter-group input:focus { outline: 2px solid #4ca585; outline-offset: 1px; border-color: #4ca585; }
.filter-hint { display: block; margin-top: 3px; font-size: 0.7rem; color: #8a9ab0; }
.filter-actions { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-search { padding: 9px 18px; background: linear-gradient(135deg, #4ca585 0%, #3d8a6a 100%); color: #fff; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 8px rgba(76,165,133,0.3); transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.btn-search:hover { background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%); box-shadow: 0 4px 12px rgba(25,118,210,0.4); transform: translateY(-1px); }
.btn-clear { padding: 9px 16px; background: #fff; color: #29517d; border: 1px solid #c9d8e6; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.btn-clear:hover { background: #eef5fb; }
.active-filters { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.active-filters:empty { display: none; }
.af-pill { background: #eaf3fb; color: #1c4b7a; border: 1px solid #c9d8e6; border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; }

/* Summary chips */
.debts-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.debts-chip { background: #fff; border: 1px solid #e0e8f2; border-radius: 12px; padding: 10px 14px; box-shadow: 0 2px 8px rgba(60,120,200,0.06); min-width: 130px; max-width: 100%; }
.debts-chip .lbl { font-size: 0.68rem; font-weight: 700; color: #8a9ab0; text-transform: uppercase; letter-spacing: 0.04em; }
.debts-chip .val { font-size: 1.15rem; font-weight: 800; color: #1c2c3d; font-variant-numeric: tabular-nums; }
.debts-chip .val.dop { color: #1976d2; }
.debts-chip .val.usd { color: #388e3c; }
.debts-chip .sub { display: block; font-size: 0.72rem; font-weight: 600; color: #5c6b80; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* Valor Hoy chart */
.yield-chart-card { background: #fff; border: 1px solid #e0e8f2; border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(60,120,200,0.06); }
.yield-chart-card h2 { margin: 0 0 4px; color: #22314a; font-size: 0.95rem; font-weight: 700; }
.yield-chart-card h2 i { color: #4ca585; }
.chart-sub { margin: 0 0 8px; font-size: 0.75rem; color: #8a9ab0; }
.chart-scroll { max-height: 520px; overflow-y: auto; overflow-x: hidden; }
.chart-inner { position: relative; width: 100%; height: 320px; }

/* Table container */
.top-table-container.auto-fit { display: block; background: linear-gradient(135deg, #ffffff 0%, #fafbfd 100%); border-radius: 18px; box-shadow: 0 8px 32px rgba(26,35,126,0.12), 0 2px 8px rgba(26,35,126,0.08); padding: 1.5rem; border: 1px solid rgba(227,232,240,0.6); width: 100%; box-sizing: border-box; transition: box-shadow 0.3s ease; }
.top-table-container.auto-fit:hover { box-shadow: 0 12px 48px rgba(26,35,126,0.16), 0 4px 12px rgba(26,35,126,0.1); }
@media (max-width: 720px) { .top-table-container.auto-fit { padding: 0.8rem 0.5rem; } }

#all-funds-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; max-width: 100%; }
#all-funds-table { font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif; font-size: 0.95rem; border-collapse: separate; border-spacing: 0; width: 100%; table-layout: auto; }
#all-funds-table th { background: var(--table-header); color: var(--primary); font-weight: 600; text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--border); white-space: nowrap; text-transform: none; }
#all-funds-table thead tr:first-child th { position: sticky; top: 0; z-index: 2; }
#all-funds-table th.sortable { cursor: pointer; user-select: none; }
#all-funds-table th.sortable:hover { background: #e3eef8; }
#all-funds-table td { padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-secondary); font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }
#all-funds-table td.col-name { white-space: normal; min-width: 180px; max-width: 280px; }
#all-funds-table tbody tr:nth-child(even) { background: #f7fafd; }
#all-funds-table tbody tr:hover { background: linear-gradient(90deg, #eaf3fb 0%, #e8f4fb 100%) !important; }
#all-funds-table tbody tr.is-highlight { outline: 2px solid #4ca585; outline-offset: -2px; }
#all-funds-table tr.filter-row th { background: #f4f8fc; padding: 0.35rem 0.4rem; position: static; }
#all-funds-table select { width: 100%; max-width: 160px; font-size: 0.78rem; padding: 3px 4px; border: 1px solid #d6dee8; border-radius: 4px; background: #fff; }
#all-funds-table select.is-active { background: #e0e7ef; border-color: #1976d2; }
.arrow-up { color: #1fa463; }
.arrow-down { color: #d63939; }
.arrow-flat { color: #8a9ab0; }

/* Valor Hoy cell with inline bar */
.vcell { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.vcell b { min-width: 3.2em; text-align: right; color: #1c2c3d; }
.vbar { flex: 1; height: 6px; background: #e8eef5; border-radius: 3px; overflow: hidden; min-width: 40px; }
.vbar i { display: block; height: 100%; border-radius: 3px; background: rgba(25,118,210,0.6); }
.vbar i.usd { background: rgba(56,142,60,0.6); }

.af-state { text-align: center; padding: 40px 12px; color: #8a9ab0; }
.af-state.error { background: #ffebee; color: #c62828; border-radius: 8px; margin-bottom: 20px; padding: 16px; }
.af-state button { margin-left: 8px; }

/* Trend column (only once there is enough history) */
#all-funds-table:not(.has-trend) th:nth-child(11), #all-funds-table:not(.has-trend) td:nth-child(11) { display: none; }
#all-funds-table td.col-trend svg { display: block; }

/* Fund name cell: compare checkbox + detail link */
#all-funds-table td.col-name { display: table-cell; }
.name-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cmp-check { flex: none; width: 16px; height: 16px; margin: 0; padding: 0; cursor: pointer; accent-color: #1976d2; }
.fund-link, .fund-link:hover, .fund-link:active { display: inline; padding: 0; background: none; border-radius: 0; box-shadow: none; transform: none; font: inherit; font-weight: 700; color: #22314a; text-align: left; cursor: pointer; }
.fund-link:hover { color: #1976d2; text-decoration: underline; }
.cmp-chip-x, .cmp-chip-x:hover { background: transparent; box-shadow: none; transform: none; }
.fd-close, .fd-close:hover { box-shadow: none; transform: none; }
.fd-range-btn, .fd-range-btn:hover { box-shadow: none; transform: none; }
.fd-range-btn:hover { background: #eef5fb; }
.fd-range-btn.is-on, .fd-range-btn.is-on:hover { background: #1976d2; color: #fff; }
.table-hint { margin: 10px 4px 0; font-size: 0.78rem; color: #8a9ab0; }

/* Compare tray */
.cmp-tray { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 900; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; max-width: min(960px, calc(100% - 20px)); box-sizing: border-box; background: #fff; border: 1px solid #c9d8e6; border-radius: 14px; padding: 10px 14px; box-shadow: 0 10px 32px rgba(26,35,126,0.22); }
.cmp-tray[hidden] { display: none; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.cmp-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; background: #eaf3fb; color: #1c4b7a; border: 1px solid #c9d8e6; border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 0.78rem; font-weight: 600; }
.cmp-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-chip-x { border: 0; background: transparent; cursor: pointer; font-size: 1rem; line-height: 1; color: #1c4b7a; padding: 0 6px; }
.cmp-msg { font-size: 0.75rem; color: #b45309; font-weight: 600; }
.cmp-go[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Detail / compare dialog */
.fd-dialog { border: 0; padding: 0; border-radius: 16px; width: min(760px, calc(100% - 20px)); max-height: calc(100% - 24px); box-shadow: 0 20px 60px rgba(0,0,0,0.35); color: #22314a; }
.fd-dialog::backdrop { background: rgba(20, 30, 50, 0.55); }
.fd-inner { padding: 18px 20px 20px; }
.fd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.fd-title { margin: 0; font-size: 1.15rem; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.fd-close { flex: none; border: 0; background: #eef3f8; color: #29517d; width: 34px; height: 34px; border-radius: 50%; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.fd-close:hover { background: #dce7f2; }
.fd-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.fd-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.fd-kpi { background: #f7fafd; border: 1px solid #e0e8f2; border-radius: 12px; padding: 9px 12px; min-width: 0; }
.fd-kpi-l { font-size: 0.66rem; font-weight: 700; color: #8a9ab0; text-transform: uppercase; letter-spacing: 0.04em; }
.fd-kpi-v { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fd-kpi-v.fd-big { font-size: 1.5rem; color: #1976d2; }
.fd-kpi-s { font-size: 0.7rem; color: #5c6b80; margin-top: 2px; }
.fd-range { display: flex; gap: 6px; margin: 4px 0 8px; }
.fd-range-btn { border: 1px solid #c9d8e6; background: #fff; color: #29517d; font-weight: 600; font-size: 0.8rem; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.fd-range-btn.is-on { background: #1976d2; border-color: #1976d2; color: #fff; }
.fd-chart-holder { position: relative; height: 260px; }
.fd-empty { margin: 8px 0; padding: 18px 14px; background: #f7fafd; border: 1px dashed #c9d8e6; border-radius: 12px; color: #5c6b80; font-size: 0.85rem; text-align: center; }
.fd-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.fd-note { margin: 12px 0 0; font-size: 0.72rem; color: #8a9ab0; }
.fd-warn { margin: 0 0 10px; padding: 8px 12px; background: #fff4e5; color: #b45309; border: 1px solid #f2d08a; border-radius: 10px; font-size: 0.8rem; font-weight: 600; }
.fd-table-wrap { overflow-x: auto; margin-bottom: 10px; }
.fd-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.fd-table th, .fd-table td { padding: 7px 10px; border-bottom: 1px solid #e0e8f2; text-align: left; vertical-align: top; }
.fd-table thead th { background: #f4f8fc; font-weight: 700; }
.fd-table tbody th { color: #8a9ab0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.fd-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* Guides block under the table */
.af-guides { margin-top: 24px; padding: 18px 20px; background: #fff; border: 1px solid #e0e8f2; border-radius: 14px; box-shadow: 0 2px 8px rgba(60,120,200,0.06); }
.af-guides h2 { margin: 0 0 6px; font-size: 1.05rem; color: #22314a; }
.af-guides p { margin: 0 0 12px; font-size: 0.88rem; color: #5c6b80; line-height: 1.5; }
.af-guides-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.af-guides-grid a { display: block; padding: 12px 14px; background: #f7fafd; border: 1px solid #e0e8f2; border-radius: 12px; text-decoration: none; color: #22314a; }
.af-guides-grid a:hover { border-color: #4ca585; background: #f0faf5; }
.af-guides-grid strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }
.af-guides-grid span { font-size: 0.78rem; color: #5c6b80; }
@media (max-width: 620px) {
    .fd-inner { padding: 14px 14px 16px; }
    .fd-chart-holder { height: 230px; }
    .cmp-tray { bottom: 8px; }
}

/* Tablet: drop the least important columns, keep Valor Hoy */
@media (max-width: 900px) {
    #all-funds-table { font-size: 0.78rem; }
    #all-funds-table th, #all-funds-table td { padding: 0.4rem 0.3rem; }
    #all-funds-table th:nth-child(1), #all-funds-table td:nth-child(1),
    #all-funds-table th:nth-child(5), #all-funds-table td:nth-child(5),
    #all-funds-table th:nth-child(6), #all-funds-table td:nth-child(6),
    #all-funds-table th:nth-child(9), #all-funds-table td:nth-child(9),
    #all-funds-table th:nth-child(11), #all-funds-table td:nth-child(11) { display: none !important; }
    #all-funds-table td.col-name { min-width: 120px; max-width: 170px; }
    .vcell { min-width: 80px; }
}

/* Phone: stacked cards (column filters move to the filters card) */
@media (max-width: 620px) {
    #all-funds-table thead { display: none; }
    #all-funds-table, #all-funds-table tbody, #all-funds-table tr, #all-funds-table td { display: block; width: 100%; box-sizing: border-box; }
    #all-funds-table tr { border: 1px solid #e0e8f2; border-radius: 12px; margin-bottom: 10px; padding: 8px 12px; background: #fff !important; }
    #all-funds-table td { display: flex !important; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0 !important; border: 0 !important; font-size: 0.82rem !important; text-align: right; white-space: normal; }
    #all-funds-table td::before { content: attr(data-label); font-weight: 700; color: #8a9ab0; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em; text-align: left; flex: none; }
    #all-funds-table td.col-name { max-width: none; min-width: 0; font-size: 0.9rem !important; }
    #all-funds-table td.col-ticker, #all-funds-table td.is-empty { display: none !important; }
    #all-funds-table td.vcell-td .vbar { display: none; }
    .vcell { min-width: 0; }
    .chart-inner { height: 280px; }
}
