/* ===========================================
   Simulador de inversión
   Reusa los tokens de market.css y agrega lo propio
   =========================================== */

.sim-grid {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.simulator-page .eyebrow {
    display: inline-flex;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--color-brand-strong, #218838);
    background: var(--color-brand-soft, #e8f5e9);
    padding: 5px 11px;
    border-radius: 999px;
    margin-bottom: 12px;
}

html.dark .simulator-page .eyebrow {
    color: var(--color-brand, #28a745);
}

/* ==== Campos ==== */
.field {
    margin-top: 14px;
}

.field:first-of-type {
    margin-top: 12px;
}

.field label,
.field .field-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-muted, #6b7280);
    margin-bottom: 6px;
}

.input-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-line-strong, #d1d5db);
    border-radius: var(--radius-control, 10px);
    background: var(--color-surface, #fff);
    overflow: hidden;
}

.input-group:focus-within {
    border-color: var(--color-brand, #28a745);
    box-shadow: 0 0 0 3px var(--color-brand-soft, #e8f5e9);
}

.input-group input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--color-ink, #111827);
    font-size: 17px;
    font-weight: 700;
    padding: 10px 12px;
    width: 100%;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.input-group .suffix {
    padding: 0 12px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--color-faint, #9ca3af);
    border-left: 1px solid var(--color-line, #e5e7eb);
    align-self: stretch;
    display: grid;
    place-items: center;
    white-space: nowrap;
}

.simulator-page select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-line-strong, #d1d5db);
    border-radius: var(--radius-control, 10px);
    background: var(--color-surface, #fff);
    color: var(--color-ink, #111827);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    outline: none;
}

.simulator-page select:focus {
    border-color: var(--color-brand, #28a745);
    box-shadow: 0 0 0 3px var(--color-brand-soft, #e8f5e9);
}

.hint {
    font-size: 10.5px;
    color: var(--color-faint, #9ca3af);
    margin-top: 6px;
    line-height: 1.5;
}

/* Tres botones en columna estrecha: grid en lugar de scroll horizontal pegado. */
#frequencyControl.segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    overflow: visible;
    gap: 4px;
}

#frequencyControl .segmented-btn {
    white-space: normal;
    text-align: center;
    width: 100%;
}

.range-input {
    width: 100%;
    accent-color: var(--color-brand, #28a745);
}

/* ==== Pesos de la cartera ==== */
.weight-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px 42px;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-line, #e5e7eb);
}

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

.weight-name {
    font-size: 11.5px;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.weight-name small {
    color: var(--color-faint, #9ca3af);
    font-weight: 500;
}

.weight-row input[type="range"] {
    width: 92px;
    accent-color: var(--color-brand, #28a745);
}

.weight-value {
    font-size: 11px;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.weights-total {
    float: right;
    font-weight: 700;
}

.weights-total.ok {
    color: var(--color-success, #16a34a);
}

.weights-total.warn {
    color: var(--color-warning, #d97706);
}

/* ==== Resultado ==== */
.result-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    justify-content: space-between;
}

.result-figure {
    font-size: clamp(30px, 5vw, 42px);
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.result-figure.negative {
    color: var(--color-danger, #dc2626);
}

.result-caption {
    font-size: 12.5px;
    color: var(--color-muted, #6b7280);
    margin-top: 5px;
}

.result-delta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    padding: 5px 11px;
    border-radius: 999px;
    white-space: nowrap;
}

.result-delta.up {
    background: var(--color-success-bg, #dcfce7);
    color: var(--color-success, #16a34a);
}

.result-delta.down {
    background: var(--color-danger-bg, #fee2e2);
    color: var(--color-danger, #dc2626);
}

.up-text {
    color: var(--color-success, #16a34a);
}

.down-text {
    color: var(--color-danger, #dc2626);
}

.stat-row {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.stat-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chart-box {
    margin-top: 16px;
}

.sim-chart {
    width: 100%;
    height: 230px;
    display: block;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-muted, #6b7280);
}

.chart-legend i {
    display: inline-block;
    width: 16px;
    height: 3px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: middle;
}

/* ==== Tabla de aportes ==== */
.contrib-head {
    padding: 16px 20px 0;
}

.contrib-scroll {
    max-height: 280px;
    overflow-y: auto;
    border-top: 1px solid var(--color-line, #e5e7eb);
    margin-top: 12px;
}

.contrib-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.contrib-table th {
    text-align: left;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--color-muted, #6b7280);
    background: var(--color-surface-2, #f9fafb);
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-line, #e5e7eb);
    position: sticky;
    top: 0;
}

.contrib-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-line, #e5e7eb);
    font-variant-numeric: tabular-nums;
}

.contrib-table td.num {
    text-align: right;
}

.contrib-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==== Activos no incluidos ==== */
.discard-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--color-line, #e5e7eb);
}

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

.discard-row b {
    font-size: 12px;
}

.discard-row b small {
    color: var(--color-faint, #9ca3af);
    font-weight: 500;
}

.discard-row p {
    font-size: 11px;
    color: var(--color-muted, #6b7280);
    margin-top: 3px;
}

/* ==== Callouts ==== */
.callout {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-control, 10px);
    font-size: 12px;
    line-height: 1.5;
}

.callout-spaced {
    margin-top: 14px;
}

.callout strong {
    font-weight: 700;
}

.callout.warn {
    background: var(--color-warning-bg, #fef3c7);
    color: #92400e;
}

.callout.neutral {
    background: var(--color-surface-2, #f9fafb);
    border: 1px solid var(--color-line, #e5e7eb);
    color: var(--color-muted, #6b7280);
}

html.dark .callout.warn {
    color: var(--color-warning, #fbbf24);
}

.callout svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    margin-top: 2px;
}

/* ==== Comparación ==== */
.current-mark {
    color: var(--color-brand, #28a745);
}

/* ==== Responsive ==== */
@media (max-width: 920px) {
    .sim-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 560px) {
    .stat-row-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-row-3 .stat:last-child {
        grid-column: span 2;
    }

    .result-figure {
        font-size: 30px;
    }

    .weight-row {
        grid-template-columns: minmax(0, 1fr) 76px 38px;
    }

    .weight-row input[type="range"] {
        width: 76px;
    }
}
