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

:root {
    --bg: #161616;
    --bg2: #0f0f0f;
    --bg3: #161616;
    --surface: #1a1a1a;
    --wine: #8B1535;
    --wine-glow: rgba(139, 21, 53, 0.15);
    --wine-border: rgba(139, 21, 53, 0.35);
    --text: #ededed;
    --muted: #737373;
    --subtle: #404040;
    --border: rgba(255, 255, 255, 0.07);
    --border2: rgba(255, 255, 255, 0.12);
    --blue: #1d6fa3;
    --blue-bg: rgba(29, 111, 163, 0.1);
    --blue-border: rgba(29, 111, 163, 0.3);
    --red: #8B1535;
    --red-bg: rgba(139, 21, 53, 0.1);
    --red-border: rgba(139, 21, 53, 0.3);
    --amber: #b07d20;
    --amber-bg: rgba(176, 125, 32, 0.1);
    --amber-border: rgba(176, 125, 32, 0.3);
    --green: #1a7a4a;
    --green-bg: rgba(26, 122, 74, 0.1);
    --green-border: rgba(26, 122, 74, 0.3);
    --purple: #6642a6;
    --purple-bg: rgba(102, 66, 166, 0.1);
    --purple-border: rgba(102, 66, 166, 0.3);
    --display: 'Bricolage Grotesque', sans-serif;
    --body: 'Instrument Sans', system-ui, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface);
    border-radius: 10px;
}

/* NAV */
nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5%;
    height: 56px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 8, 8, 0.9);
    backdrop-filter: blur(20px);
}

.nav-logo {
    font-family: var(--display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wine);
    box-shadow: 0 0 8px var(--wine);
}

/* MAIN */
main {
    flex: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 3rem 5% 4rem;
    width: 100%;
}

/* PAGE HEADER */
.page-header {
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-family: var(--display);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-bottom: 0.3rem;
}

.page-header p {
    font-size: 0.88rem;
    color: var(--muted);
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.73rem;
    font-weight: 500;
    background: rgba(26, 122, 74, 0.12);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.25);
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
}

.live-badge .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    animation: blink 2.2s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0.3
    }
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

#last-update {
    font-size: 0.78rem;
    color: var(--muted);
}

/* BTN */
.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text);
    font-family: var(--body);
    font-size: 0.82rem;
    border: 1px solid var(--border2);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-refresh:hover {
    background: var(--bg3);
}

.btn-refresh:active {
    transform: scale(0.97);
}

.btn-refresh:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-refresh svg {
    width: 14px;
    height: 14px;
}

/* CARDS GRID */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.tipo-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.1rem 1.2rem;
    transition: border-color 0.2s, transform 0.2s;
    cursor: default;
}

.tipo-card:hover {
    transform: translateY(-2px);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.card-badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    border-radius: 5px;
    border: 1px solid;
}

.card-icon {
    font-size: 0.85rem;
    color: var(--subtle);
}

.card-venta-label {
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 0.1rem;
}

.card-venta {
    font-size: 1.45rem;
    font-weight: 700;
    font-family: var(--display);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 0.6rem;
}

.card-compra {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.card-margen {
    font-size: 0.78rem;
    color: var(--subtle);
    font-family: 'Courier New', monospace;
}

/* Skeleton */
.skeleton {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    height: 130px;
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0.35
    }
}

/* CONVERTER */
.converter {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.converter-title {
    font-family: var(--display);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.conv-toggle {
    display: flex;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.conv-toggle-btn {
    font-family: var(--body);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.conv-toggle-btn.active {
    background: var(--wine);
    color: #fff;
}

.converter-input-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.1rem;
    flex-wrap: wrap;
}

.currency-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--wine);
    background: var(--wine-glow);
    border: 1px solid var(--wine-border);
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.currency-label.usd {
    color: #60a5fa;
    background: rgba(29, 111, 163, 0.12);
    border-color: rgba(29, 111, 163, 0.3);
}

.converter-input {
    flex: 1;
    max-width: 260px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    font-family: var(--display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.converter-input:focus {
    border-color: var(--wine-border);
}

.converter-input::placeholder {
    color: var(--subtle);
    font-weight: 300;
}

/* Ocultar flechas nativas del input number */
.converter-input::-webkit-outer-spin-button,
.converter-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.converter-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.conv-hint {
    font-size: 0.8rem;
    color: var(--subtle);
}

.conv-note {
    font-size: 0.72rem;
    color: var(--subtle);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.conv-note span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--subtle);
    flex-shrink: 0;
}

.conv-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
}

.conv-item {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    transition: border-color 0.2s;
}

.conv-item:hover {
    border-color: var(--border2);
}

.conv-label {
    font-size: 0.7rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.conv-amount {
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.15rem;
}

.conv-rate {
    font-size: 0.7rem;
    color: var(--subtle);
}

/* ERROR */
.error-bar {
    background: rgba(139, 21, 53, 0.1);
    border: 1px solid var(--wine-border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    color: #e8a0b0;
    margin-bottom: 1rem;
    display: none;
}

/* FOOTER */
.page-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.page-footer span,
.page-footer a {
    font-size: 0.78rem;
    color: var(--subtle);
    text-decoration: none;
}

.page-footer a:hover {
    color: var(--muted);
}

@media (max-width: 600px) {
    .page-header {
        flex-direction: column;
    }

    .header-right {
        align-items: flex-start;
    }

    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg)
    }

    to {
        transform: rotate(360deg)
    }
}