/* ── Reset ──────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Design tokens ──────────────────────────── */
:root {
    --blue:       #3867F6;
    --blue-10:    rgba(56, 103, 246, 0.10);
    --blue-20:    rgba(56, 103, 246, 0.20);
    --blue-hover: #2d55e0;
    --black:      #0D0D0D;
    --white:      #FFFFFF;
    --bg:         #EEF1FB;
    --gray-1:     #64748B;
    --gray-2:     #94A3B8;
    --gray-3:     #E2E8F0;
    --gray-4:     #F8FAFC;
    --red:        #EF4444;
    --green:      #16A34A;

    --header-h:   58px;
    --radius:     20px;
    --radius-sm:  14px;
    --radius-xs:  10px;

    --shadow:      0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-blue: 0 4px 18px rgba(56, 103, 246, 0.32);
    --t:           0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base ───────────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--black);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Header ─────────────────────────────────── */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--white);
    border-bottom: 1px solid var(--gray-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    z-index: 200;
    box-shadow: 0 1px 0 var(--gray-3);
}

.app-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--black);
    letter-spacing: -0.03em;
}

.app-title::after {
    content: '.';
    color: var(--blue);
}

#sys-time {
    font-size: 13px;
    color: var(--gray-2);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ── Steps wrapper ──────────────────────────── */
.steps-wrapper {
    padding-top: var(--header-h);
}

/* ── Step layout ────────────────────────────── */
.step {
    display: none;
    flex-direction: column;
    min-height: calc(100vh - var(--header-h));
    max-width: 480px;
    margin: 0 auto;
    padding: 32px 20px 40px;
}

.step.active {
    display: flex;
    animation: step-enter 0.38s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.steps-wrapper.going-back .step.active {
    animation: step-enter-back 0.38s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes step-enter {
    from { opacity: 0; transform: translateX(28px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes step-enter-back {
    from { opacity: 0; transform: translateX(-28px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Step header ────────────────────────────── */
.step-meta {
    margin-bottom: 28px;
}

.step-num {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--blue);
    background: var(--blue-10);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.step-title {
    font-size: 30px;
    font-weight: 800;
    color: var(--black);
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.step-body { flex: 1; }

.step-desc {
    font-size: 14px;
    color: var(--gray-1);
    line-height: 1.65;
    margin-bottom: 28px;
}

/* ── Divider ────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--gray-3);
    margin: 20px 0;
}

/* ── Step nav ───────────────────────────────── */
.step-nav {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 28px;
}

.btn-nav {
    height: 52px;
    padding: 0 22px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--t);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.btn-next {
    flex: 1;
    background: var(--blue);
    color: var(--white);
    border: none;
    box-shadow: var(--shadow-blue);
}

.btn-next:hover {
    background: var(--blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(56, 103, 246, 0.42);
}

.btn-next:active { transform: translateY(0); box-shadow: var(--shadow-blue); }

.btn-back {
    background: var(--white);
    color: var(--gray-1);
    border: 1.5px solid var(--gray-3);
}

.btn-back:hover {
    background: var(--gray-4);
    border-color: var(--gray-2);
    color: var(--black);
}

.btn-nav:disabled { opacity: 0.4; cursor: default; transform: none !important; }

/* ── Cards / Panels ─────────────────────────── */
.panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.panel-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-2);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* ── Resultado rows ─────────────────────────── */
.resultado-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0;
    border-bottom: 1px solid var(--gray-3);
}

.resultado-item:last-of-type { border-bottom: none; }

.rl {
    font-size: 14px;
    color: var(--gray-1);
    font-weight: 500;
}

.dot-fill { display: none; }

.rv {
    font-size: 16px;
    font-weight: 700;
    color: var(--black);
    letter-spacing: -0.02em;
}

/* ── Inputs ─────────────────────────────────── */
.field-group { margin-bottom: 20px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-1);
    margin-bottom: 8px;
}

.input-row {
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--gray-3);
    display: flex;
    align-items: center;
    padding: 0 18px;
    transition: border-color var(--t), box-shadow var(--t);
    box-shadow: var(--shadow);
}

.input-row:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-10), var(--shadow);
}

.input-prefix {
    font-size: 20px;
    font-weight: 700;
    color: var(--blue);
    margin-right: 6px;
    user-select: none;
}

input.main-input {
    flex: 1;
    padding: 18px 0;
    background: transparent;
    border: none;
    color: var(--black);
    font-family: inherit;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.03em;
    outline: none;
}

input.main-input::placeholder {
    color: var(--gray-3);
    font-weight: 600;
}

/* ── Surplus preview ────────────────────────── */
.surplus-preview {
    background: var(--blue-10);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    margin-top: 14px;
    animation: fade-up 0.22s var(--t) both;
}

.surplus-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.surplus-line .dim {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    opacity: 0.75;
}

#surplus-preview-amt {
    font-size: 24px;
    font-weight: 800;
    color: var(--blue) !important;
    letter-spacing: -0.03em;
}

/* ── Step 3: surplus header ─────────────────── */
.surplus-header {
    font-size: 14px;
    color: var(--gray-1);
    font-weight: 500;
    line-height: 1.6;
    padding: 16px 18px;
    background: var(--blue-10);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

#surplus-display {
    color: var(--blue);
    font-weight: 800;
    font-size: 16px;
}

/* ── Step 3: strategy buttons ───────────────── */
.strategy-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.btn-strategy {
    flex: 1;
    padding: 14px 6px;
    background: var(--gray-4);
    border: 1.5px solid var(--gray-3);
    color: var(--gray-1);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all var(--t);
    letter-spacing: 0.01em;
}

.btn-strategy:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--blue-10);
}

.btn-strategy.active {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(56, 103, 246, 0.30);
}

/* ── Step 3: redistribution rows ────────────── */
.redist-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-3);
}

.redist-row:last-of-type { border-bottom: none; }

.redist-row .rl { flex: 1; }

.redist-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

input.redist-input {
    width: 60px;
    padding: 8px 10px;
    background: var(--gray-4);
    border: 1.5px solid var(--gray-3);
    border-radius: var(--radius-xs);
    color: var(--black);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-align: right;
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
}

input.redist-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-10);
    background: var(--white);
}

input.redist-input--auto {
    color: var(--gray-2);
    cursor: default;
}

.redist-amount {
    min-width: 82px;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    color: var(--black);
}

/* ── Remove number spinners ─────────────────── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; }

/* ── Error messages ─────────────────────────── */
.error-msg {
    font-size: 12px;
    color: var(--red);
    font-weight: 500;
    min-height: 18px;
    margin-top: 6px;
}

/* ── Step 4: Charts ─────────────────────────── */
.chart-wrap {
    position: relative;
    width: 100%;
    height: 220px;
}

.chart-wrap--tall { height: 260px; }

/* ── Market data rows ───────────────────────── */
.market-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-3);
}

.market-row:last-of-type { border-bottom: none; }

.mkt-ticker {
    flex-shrink: 0;
    width: 42px;
    font-size: 13px;
    font-weight: 700;
    color: var(--black);
}

.mkt-name {
    flex: 1;
    font-size: 11px;
    color: var(--gray-2);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mkt-price {
    flex-shrink: 0;
    min-width: 88px;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    color: var(--black);
}

.mkt-chg {
    flex-shrink: 0;
    min-width: 64px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
}

.tag-ok   { color: var(--green); }
.tag-warn { color: var(--red); }

.mkt-divider {
    border-top: 1px solid var(--gray-3);
    margin: 14px 0 10px;
}

.market-legend {
    font-size: 11px;
    color: var(--gray-1);
    line-height: 2.1;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.lc { color: #94A3B8; font-size: 16px; line-height: 1; }
.ls { color: #3867F6; font-size: 16px; line-height: 1; }
.la { color: #0D0D0D; font-size: 16px; line-height: 1; }

.market-note {
    font-size: 10px;
    color: var(--gray-2);
    margin-top: 10px;
    line-height: 1.5;
}

.market-disclaimer {
    font-size: 10px;
    color: var(--gray-2);
    margin-top: 6px;
    line-height: 1.5;
    opacity: 0.65;
}

/* ── No-surplus message ─────────────────────── */
#no-surplus-msg {
    background: var(--gray-4);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 20px;
}

#no-surplus-msg .dim {
    color: var(--gray-1);
    font-size: 14px;
    line-height: 1.6;
}

/* ── Reset button ───────────────────────────── */
.reset-row {
    text-align: center;
    margin-top: 8px;
    margin-bottom: 4px;
}

.btn-clear {
    padding: 12px 28px;
    background: transparent;
    border: 1.5px solid #FCA5A5;
    color: var(--red);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all var(--t);
    letter-spacing: -0.01em;
}

.btn-clear:hover {
    background: #FEF2F2;
    border-color: var(--red);
}

/* ── Utilities ──────────────────────────────── */
.dim { color: var(--gray-2); }

.boot-line {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--gray-1);
    gap: 12px;
    line-height: 1.8;
}

/* ── Animations ─────────────────────────────── */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.blink { animation: blink 1s step-end infinite; }
