/* ==========================================================================
   Calculadora Bolivia — estilos
   ========================================================================== */

:root {
    --blue: #2563eb;
    --blue-bg: #eff6ff;
    --green: #16a34a;
    --green-bg: #f0fdf4;
    --text: #1e293b;
    --muted: #94a3b8;
    --border: #e5eaf0;
    --bg: #f4f6f9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: clamp(10px, 2vw, 28px);
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: auto;
    background: white;
    padding: clamp(18px, 3vw, 32px);
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}

/* ENCABEZADO */
.header {
    margin-bottom: clamp(16px, 2vw, 22px);
}

.header h1 {
    font-size: clamp(22px, 3vw, 30px);
    margin: 0;
    font-weight: 800;
    letter-spacing: -.5px;
}

/* ENTRADA Y BOTÓN */
.input-row {
    display: flex;
    align-items: stretch;
    gap: clamp(8px, 1vw, 12px);
}

.input-group {
    flex: 1;
    min-width: 0;
    position: relative;
}

.input-group input {
    width: 100%;
    height: clamp(52px, 6vw, 60px);
    border: 1px solid #dce2ea;
    border-radius: 9px;
    padding: 0 48px 0 14px;
    font-size: clamp(20px, 2.4vw, 26px);
    font-weight: 750;
    outline: none;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.input-group input:focus {
    border-color: var(--blue);
}

.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

.input-group span {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.calculate-btn {
    height: clamp(52px, 6vw, 60px);
    padding: 0 clamp(16px, 2vw, 28px);
    border: none;
    border-radius: 9px;
    background: var(--blue);
    color: white;
    font-size: clamp(13px, 1.4vw, 15px);
    font-weight: 800;
    letter-spacing: .2px;
    cursor: pointer;
    white-space: nowrap;
}

.calculate-btn:hover {
    background: #1d4ed8;
}

/* HISTORIAL */
.history {
    margin-top: clamp(20px, 3vw, 28px);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: clamp(10px, 1.4vw, 14px);
}

.history-title {
    font-size: clamp(13px, 1.4vw, 15px);
    font-weight: 800;
    letter-spacing: .4px;
}

.history-count {
    font-size: clamp(11px, 1.2vw, 12px);
    color: var(--muted);
    margin-left: 5px;
}

.clear-btn {
    border: none;
    background: transparent;
    color: #dc5555;
    font-size: clamp(11px, 1.2vw, 13px);
    font-weight: 650;
    cursor: pointer;
    padding: 6px;
}

/* TABLA */
.history-table {
    width: 100%;
}

.table-header,
.history-item {
    display: grid;
    grid-template-columns: clamp(48px, 6vw, 72px) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(4px, .8vw, 8px);
}

.table-header {
    padding: 0 clamp(5px, .8vw, 10px) clamp(8px, 1vw, 12px);
    border-bottom: 2px solid var(--border);
}

.table-header span {
    font-size: clamp(10px, 1.2vw, 13px);
    font-weight: 800;
    color: var(--muted);
    letter-spacing: .3px;
}

.table-header span small {
    display: block;
    margin-top: 2px;
    font-size: clamp(8px, 1vw, 10px);
    font-weight: 600;
    letter-spacing: 0;
    color: var(--muted);
    line-height: 1.2;
    text-wrap: balance;
}

.table-header .head-con {
    color: var(--blue);
}

.table-header .head-sin {
    color: var(--green);
}

/* FILAS */
.history-list {
    max-height: min(60vh, 640px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 5px;
}

.history-item {
    padding: clamp(7px, .9vw, 10px) clamp(6px, .9vw, 10px);
    min-height: clamp(40px, 4.5vw, 52px);
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s;
}

.history-item:hover {
    background: #f1f5f9;
}

/* ÚLTIMO REGISTRO */
.history-item.latest {
    background: var(--blue-bg);
    border-color: #c9dcff;
}

/* HORA */
.history-time {
    font-size: clamp(10px, 1.1vw, 12px);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* IMPORTES */
.history-value {
    font-size: clamp(15px, 1.8vw, 19px);
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.4px;
}

.history-value.con {
    color: var(--blue);
}

.history-value.sin {
    color: var(--green);
}

/* VACÍO */
.empty {
    padding: clamp(30px, 6vw, 56px) 10px;
    text-align: center;
    color: var(--muted);
    font-size: clamp(12px, 1.4vw, 15px);
}

/* SCROLLBAR */
.history-list::-webkit-scrollbar {
    width: clamp(4px, .5vw, 6px);
}

.history-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

/* ESCRITORIO: centra la tarjeta y usa el alto de la pantalla */
@media (min-width: 700px) {
    body {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
}

/* PANTALLAS PEQUEÑAS */
@media (max-width: 420px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 18px 16px;
        border-radius: 14px;
    }

    .header h1 {
        font-size: clamp(24px, 7vw, 28px);
    }

    .input-group input {
        font-size: clamp(21px, 6vw, 24px);
        padding-right: 44px;
    }

    .calculate-btn {
        padding: 0 15px;
        font-size: 15px;
    }

    .history-title {
        font-size: 16px;
    }

    .history-count {
        font-size: 13px;
    }

    .clear-btn {
        font-size: 14px;
    }

    .table-header,
    .history-item {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
        gap: 4px;
        padding-left: 5px;
        padding-right: 5px;
    }

    .table-header .head-hora,
    .history-time {
        display: none;
    }

    .history-item {
        align-items: start;
    }

    .table-header span {
        font-size: 12px;
    }

    .table-header span small {
        font-size: 11px;
    }

    .history-value {
        font-size: clamp(18px, 6vw, 24px);
        letter-spacing: -.6px;
    }

    .history-value.largo {
        font-size: clamp(15px, 4.6vw, 19px);
    }

    .history-value.base {
        position: relative;
        padding-bottom: 14px;
    }

    .history-value.base::after {
        content: attr(data-hora);
        position: absolute;
        left: 0;
        bottom: 0;
        font-size: 9px;
        font-weight: 600;
        letter-spacing: 0;
        color: var(--muted);
    }

    .empty {
        font-size: 15px;
    }
}

/* MÓVILES MUY ANGOSTOS */
@media (max-width: 350px) {
    .header h1 {
        font-size: 23px;
    }

    .input-group input {
        font-size: 22px;
    }

    .table-header,
    .history-item {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    }

    .table-header span {
        font-size: 11px;
    }

    .table-header span small {
        font-size: 10px;
    }

    .history-value.base {
        padding-bottom: 13px;
    }
}
