:root {
    --brand:       #F59E0B;
    --brand-dim:   #FEF3C7;
    --accent:      #10B981;
    --accent-dim:  #D1FAE5;
    --danger:      #EF4444;
    --danger-dim:  #FEE2E2;
    --text-1:      #111827;
    --text-2:      #374151;
    --text-3:      #9CA3AF;
    --border:      #E5E7EB;
    --surface:     #FFFFFF;
    --bg:          #F3F4F6;
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --shadow-sm:   0 1px 3px rgba(0,0,0,0.07);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-1);
    min-height: 100vh;
    padding-bottom: 60px;
    font-size: 17px;
}

/* ── Header ── */
.app-header {
    background: linear-gradient(135deg, #1F2937 0%, #111827 100%);
    padding: 24px 20px 28px;
    text-align: center;
}
.app-logo { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.app-logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--brand), #D97706);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2em;
    box-shadow: 0 4px 12px rgba(245,158,11,0.4);
}
.app-logo-name { font-size: 1.8em; font-weight: 700; color: white; letter-spacing: -0.5px; }
.app-tagline { font-size: 0.83em; color: rgba(255,255,255,0.5); margin-top: 2px; }

/* ── Layout ── */
.container { max-width: 900px; margin: 0 auto; padding: 20px 16px 0; }

/* ── Section ── */
.section {
    margin-top: 24px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}
.section-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1.5px solid var(--border);
}
.section-number {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82em; font-weight: 800; color: white; flex-shrink: 0;
}
.n1 { background: var(--brand);  box-shadow: 0 3px 8px rgba(245,158,11,0.4); }
.n2 { background: #6366F1;       box-shadow: 0 3px 8px rgba(99,102,241,0.4); }
.section-title    { font-size: 1em; font-weight: 700; color: var(--text-1); }
.section-subtitle { font-size: 0.75em; color: var(--text-3); margin-top: 2px; }

/* ── Price table ── */
.price-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 12px;
    align-items: center;
}
.price-label {
    font-size: 0.88em; font-weight: 500; color: var(--text-2);
}
.price-badge {
    font-size: 0.68em; font-weight: 700; padding: 2px 7px;
    border-radius: 20px; margin-left: 6px; vertical-align: middle;
}
.badge-acero   { background: #EFF6FF; color: #1D4ED8; }
.badge-inox    { background: #F0FDF4; color: #166534; }
.badge-plegado { background: #FEF3C7; color: #92400E; }
.price-input-wrap { display: flex; align-items: center; gap: 4px; }
.price-symbol { font-size: 0.85em; font-weight: 600; color: var(--text-3); }
.price-input {
    width: 90px; padding: 7px 10px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.9em; font-family: inherit; font-weight: 600;
    color: var(--text-1); text-align: right; outline: none;
    transition: border-color 0.15s;
}
.price-input:focus { border-color: var(--brand); }
.price-unit { font-size: 0.75em; color: var(--text-3); white-space: nowrap; }
.save-note {
    margin-top: 12px; font-size: 0.76em; color: var(--text-3);
    text-align: right;
}

/* ── Calc form ── */
.form-row { display: flex; gap: 12px; margin-bottom: 14px; }
.form-group { flex: 1; }
.form-group label {
    display: block; font-size: 0.78em; font-weight: 700;
    color: var(--text-3); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 6px;
}
.form-group input, .form-group select {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.92em; font-family: inherit; color: var(--text-1);
    background: var(--bg); outline: none; transition: all 0.15s;
    appearance: none;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--brand); background: white;
}
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239CA3AF' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

.calc-btn {
    width: 100%; padding: 13px;
    background: linear-gradient(135deg, var(--brand), #D97706);
    color: white; border: none; border-radius: var(--radius-md);
    font-size: 0.95em; font-weight: 700; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(245,158,11,0.35);
}
.calc-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(245,158,11,0.45); }
.calc-btn:active { transform: translateY(0); }

/* ── Result ── */
#result-box {
    margin-top: 18px; display: none;
    border-radius: var(--radius-md); overflow: hidden;
    border: 1.5px solid var(--border);
}
#result-box.visible { display: block; }
.result-header {
    background: linear-gradient(135deg, #1F2937, #111827);
    padding: 14px 18px; color: white;
    font-size: 0.82em; font-weight: 600; letter-spacing: 0.3px;
}
.result-body { padding: 16px 18px; background: white; }
.result-row {
    display: flex; justify-content: space-between;
    align-items: center; padding: 6px 0;
    border-bottom: 1px solid var(--bg);
    font-size: 0.85em;
}
.result-row:last-child { border-bottom: none; }
.result-row-label { color: var(--text-3); }
.result-row-value { font-weight: 600; color: var(--text-1); }
.result-total {
    margin-top: 12px; padding: 14px 16px;
    background: var(--brand-dim);
    border-radius: var(--radius-sm);
    display: flex; justify-content: space-between; align-items: center;
}
.result-total-label { font-size: 0.88em; font-weight: 700; color: #92400E; }
.result-total-value { font-size: 1.6em; font-weight: 800; color: #B45309; }

.result-error {
    padding: 12px 14px; background: var(--danger-dim);
    border-radius: var(--radius-sm); color: #991B1B;
    font-size: 0.84em; font-weight: 500;
}

/* ── Dolar widget ── */
.dolar-bar {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin-top: 14px; padding: 8px 16px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px; display: inline-flex;
}
.dolar-label { font-size: 0.75em; color: rgba(255,255,255,0.55); }
.dolar-value { font-size: 0.88em; font-weight: 700; color: var(--brand); }
.dolar-status { font-size: 0.7em; color: rgba(255,255,255,0.35); }
.dolar-refresh {
    background: none; border: none; color: rgba(255,255,255,0.4);
    cursor: pointer; font-size: 0.85em; padding: 0 2px;
    transition: color 0.15s;
}
.dolar-refresh:hover { color: var(--brand); }

.result-total-ars {
    margin-top: 8px; padding: 10px 16px;
    background: #EFF6FF;
    border-radius: var(--radius-sm);
    display: flex; justify-content: space-between; align-items: center;
}
.result-total-ars-label { font-size: 0.82em; font-weight: 700; color: #1E40AF; }
.result-total-ars-value { font-size: 1.2em; font-weight: 800; color: #1D4ED8; }
.result-total-ars-note  { font-size: 0.68em; color: #60A5FA; margin-top: 1px; text-align: right; }

/* ── Extras ── */
.extras-title {
    font-size: 0.78em; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 10px; margin-top: 20px;
    padding-top: 16px; border-top: 1.5px solid var(--border);
}
.extra-row {
    display: flex; gap: 10px; align-items: center; margin-bottom: 8px;
}
.extra-desc {
    flex: 1; padding: 9px 12px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.88em; font-family: inherit; color: var(--text-1);
    background: var(--bg); outline: none; transition: all 0.15s;
}
.extra-desc:focus { border-color: var(--brand); background: white; }
.extra-desc::placeholder { color: var(--text-3); }
.extra-amount-wrap { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.extra-symbol { font-size: 0.8em; font-weight: 600; color: var(--text-3); }
.extra-amount {
    width: 110px; padding: 9px 10px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.88em; font-family: inherit; font-weight: 600;
    color: var(--text-1); text-align: right; outline: none;
    background: var(--bg); transition: all 0.15s;
}
.extra-amount:focus { border-color: var(--brand); background: white; }

/* ── History ── */
.history-empty {
    text-align: center; padding: 28px 20px;
    font-size: 0.84em; color: var(--text-3);
}
.history-item {
    border: 1.5px solid var(--border); border-radius: var(--radius-md);
    margin-bottom: 10px; overflow: hidden; transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--brand); }
.history-item-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 12px 14px; background: var(--bg); cursor: pointer;
    gap: 12px;
}
.history-item-left { flex: 1; min-width: 0; }
.history-item-ref {
    font-weight: 700; font-size: 0.9em; color: var(--text-1);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item-meta { font-size: 0.74em; color: var(--text-3); margin-top: 2px; }
.history-item-right { text-align: right; flex-shrink: 0; }
.history-item-total-usd { font-size: 0.88em; font-weight: 700; color: #B45309; }
.history-item-total-ars { font-size: 0.76em; color: #1D4ED8; margin-top: 1px; }
.history-item-body {
    display: none; padding: 12px 14px;
    border-top: 1px solid var(--border); background: white;
    font-size: 0.82em; color: var(--text-2); line-height: 1.8;
}
.history-item-body.open { display: block; }
.history-item-actions {
    display: flex; gap: 8px; margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--bg);
}
.hist-btn {
    padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    font-size: 0.78em; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all 0.15s; background: var(--bg); color: var(--text-2);
}
.hist-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-dim); }
.hist-btn.del:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }
.hist-clear-btn {
    float: right; padding: 5px 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg);
    font-size: 0.75em; font-weight: 600; color: var(--text-3);
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.hist-clear-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }

/* ── Items cart ── */
#items-list {
    margin-top: 12px; margin-bottom: 4px;
}
.item-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 9px 12px;
    margin-bottom: 6px; transition: border-color 0.15s;
}
.item-chip:hover { border-color: var(--brand); }
.item-chip-num {
    background: var(--brand); color: white;
    font-size: 0.72em; font-weight: 800;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.item-chip-desc { flex: 1; font-size: 0.84em; color: var(--text-1); font-weight: 500; }
.item-chip-sub  { font-size: 0.74em; color: var(--text-3); margin-top: 1px; }
.item-chip-usd  { font-size: 0.82em; font-weight: 700; color: #B45309; white-space: nowrap; }
.item-chip-del  {
    background: none; border: none; color: var(--text-3);
    cursor: pointer; font-size: 0.9em; padding: 2px 4px;
    border-radius: 4px; flex-shrink: 0; transition: all 0.15s;
}
.item-chip-del:hover { color: var(--danger); background: var(--danger-dim); }
.items-total-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; background: var(--brand-dim);
    border-radius: var(--radius-sm); margin-top: 4px;
    font-size: 0.84em;
}
.items-total-label { font-weight: 600; color: #92400E; }
.items-total-value { font-weight: 800; color: #B45309; }
.btn-add-item {
    flex: 1; padding: 11px;
    background: white; border: 1.5px solid var(--brand);
    border-radius: var(--radius-md); color: var(--brand);
    font-size: 0.9em; font-weight: 700; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
}
.btn-add-item:hover { background: var(--brand-dim); }
.btn-calc-total {
    flex: 1; padding: 11px;
    background: linear-gradient(135deg, var(--brand), #D97706);
    border: none; border-radius: var(--radius-md); color: white;
    font-size: 0.9em; font-weight: 700; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(245,158,11,0.35);
}
.btn-calc-total:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(245,158,11,0.45); }
.btn-clear-items {
    padding: 11px 14px;
    background: white; border: 1.5px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-3);
    font-size: 0.9em; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all 0.15s; flex-shrink: 0;
}
.btn-clear-items:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }

/* ── Footer ── */
.app-footer {
    text-align: center; padding: 32px 20px 0;
    font-size: 0.72em; color: var(--text-3);
}

/* ── Toasts ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 350px;
    width: calc(100% - 48px);
}
.toast {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid var(--border);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.88em;
    font-weight: 600;
    color: var(--text-1);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transition: all 0.2s ease;
}
.toast.toast-success { border-color: var(--accent); background: rgba(209, 250, 229, 0.9); color: #065F46; }
.toast.toast-error { border-color: var(--danger); background: rgba(254, 226, 226, 0.9); color: #991B1B; }
.toast.toast-warning { border-color: var(--brand); background: rgba(254, 243, 199, 0.9); color: #92400E; }
.toast.toast-info { border-color: #3B82F6; background: rgba(239, 246, 255, 0.9); color: #1E40AF; }

.toast.toast-out {
    animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
    from { transform: translateY(30px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes toast-out {
    from { transform: translateY(0) scale(1); opacity: 1; }
    to { transform: translateY(-15px) scale(0.95); opacity: 0; }
}

