/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--tap); padding: 0 22px; border: 0; border-radius: var(--r-md); font: var(--fw-semibold) var(--fs-base) var(--font-sans); text-decoration: none; cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s; }
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--c-primary); color: #fff; box-shadow: 0 6px 18px rgba(10,92,255,.28); }
.btn--primary:hover { background: var(--c-primary-600); box-shadow: var(--sh-glow); }
.btn--primary:active { background: var(--c-primary-700); }
.btn--secondary { background: var(--c-primary-50); color: var(--c-primary-600); }
.btn--secondary:hover { background: var(--c-primary-100); }
.btn--ghost { background: transparent; color: var(--c-primary); border: 1.5px solid var(--c-primary-100); }
.btn--ghost:hover { background: var(--c-primary-50); }
.btn--light { background: #fff; color: var(--c-navy); }
.btn--danger { background: var(--c-danger-text); color: #fff; }
.btn--whatsapp { background: var(--c-whatsapp); color: #052E16; }
.btn--block { width: 100%; }
.btn--lg { min-height: 56px; font-size: 1.0625rem; border-radius: 14px; }
.btn--sm { min-height: 40px; padding: 0 14px; font-size: var(--fs-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn--ghost.is-loading::after, .btn--secondary.is-loading::after, .btn--light.is-loading::after { border-color: var(--c-primary-100); border-top-color: var(--c-primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.round-btn { width: 44px; height: 44px; flex: none; border: 1.5px solid var(--c-border); border-radius: 50%; background: var(--c-surface); color: var(--c-primary); font-size: 1.4rem; line-height: 1; cursor: pointer; }

/* Campos */
.field { margin-bottom: var(--sp-4); }
.field__label { display: block; margin-bottom: 6px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.field__input { display: block; width: 100%; min-height: 50px; padding: 0 14px; border: 1.5px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); font: var(--fw-medium) 16px var(--font-sans); }
textarea.field__input { min-height: 96px; padding-block: var(--sp-3); }
.field__input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 4px rgba(10,92,255,.14); }
.field__hint { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--c-text-muted); }
.field__error { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--c-danger-text); }
.field--error .field__input { border-color: var(--c-danger); }
.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.field-row--2 { grid-template-columns: repeat(2, 1fr); }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--fs-sm); }
.check input { flex: none; width: 22px; height: 22px; accent-color: var(--c-primary); }

/* Tarjetas de opción */
.choice-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.choice-cards--2 { grid-template-columns: repeat(2, 1fr); }
.choice-cards__item { position: relative; display: block; }
.choice-cards__item input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice-cards__box { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 56px; padding: var(--sp-2); border: 1.5px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); font-weight: var(--fw-bold); text-align: center; transition: .15s; }
.choice-cards__box small { font-size: .75rem; font-weight: var(--fw-medium); color: var(--c-text-muted); }
.choice-cards__item input:checked + .choice-cards__box { border-color: var(--c-primary); background: var(--c-primary-50); color: var(--c-primary-600); box-shadow: 0 0 0 3px rgba(10,92,255,.12); }
.choice-cards__item input:focus-visible + .choice-cards__box { outline: 3px solid var(--c-primary); outline-offset: 2px; }

/* Slider */
.range { --p: 0%; display: block; width: 100%; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 8px; border-radius: var(--r-full); background: linear-gradient(90deg, var(--c-primary) var(--p), var(--c-primary-100) var(--p)); }
.range::-moz-range-track { height: 8px; border-radius: var(--r-full); background: var(--c-primary-100); }
.range::-moz-range-progress { height: 8px; border-radius: var(--r-full); background: var(--c-primary); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border: 6px solid var(--c-primary); border-radius: 50%; background: #fff; box-shadow: var(--sh-md); }
.range::-moz-range-thumb { width: 18px; height: 18px; border: 6px solid var(--c-primary); border-radius: 50%; background: #fff; }
.range-legend { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--c-text-muted); }

/* Tarjeta */
.card { padding: var(--sp-5); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); box-shadow: var(--sh-sm); }
.card--elevated { border: 0; box-shadow: var(--sh-md); }
.card--dark { border: 0; background: var(--c-navy); color: #fff; }
.card--dark h2, .card--dark h3 { color: #fff; }
.card__title { margin-bottom: var(--sp-3); font-size: var(--fs-xl); }
.card > .cluster + *, .card > * + .btn--block { margin-top: var(--sp-3); }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 2px 10px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap; }
.badge--success { background: var(--c-success-50); color: var(--c-success-text); }
.badge--warning { background: var(--c-warning-50); color: var(--c-warning-text); }
.badge--danger { background: var(--c-danger-50); color: var(--c-danger-text); }
.badge--info { background: var(--c-primary-50); color: var(--c-primary-600); }
.badge--neutral { background: #EDF0F6; color: var(--c-text-muted); }

/* Stepper */
.progress-steps__row { display: flex; align-items: center; justify-content: space-between; min-height: 36px; font-size: .8125rem; color: var(--c-text-muted); }
.progress-steps__bar, .upload__progress { display: block; width: 100%; height: 6px; margin-top: 10px; border: 0; border-radius: var(--r-full); overflow: hidden; background: var(--c-primary-100); -webkit-appearance: none; appearance: none; }
.progress-steps__bar::-webkit-progress-bar, .upload__progress::-webkit-progress-bar { background: var(--c-primary-100); }
.progress-steps__bar::-webkit-progress-value { background: var(--g-brand); border-radius: var(--r-full); transition: width .2s var(--ease); }
.progress-steps__bar::-moz-progress-bar { background: var(--c-primary); border-radius: var(--r-full); }
.upload__progress::-webkit-progress-value { background: var(--c-primary); }
.upload__progress::-moz-progress-bar { background: var(--c-primary); }

/* Subida de documento */
.upload { margin-bottom: var(--sp-3); padding: 14px; border: 1.5px dashed var(--c-primary-100); border-radius: var(--r-lg); background: var(--c-surface); }
.upload__main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.upload__main > .btn { flex: 1 1 100%; }
.upload__thumb { display: grid; place-items: center; flex: none; width: 64px; height: 46px; overflow: hidden; border-radius: var(--r-sm); background: var(--c-primary-50); color: var(--c-primary); }
.upload__thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload__info { flex: 1 1 0; min-width: 0; }
.upload__title { display: block; font-size: .9375rem; font-weight: var(--fw-semibold); }
.upload__status { display: block; font-size: var(--fs-xs); color: var(--c-text-muted); }
.upload__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.upload__actions .btn { flex: 1 1 auto; }
.upload--done { border-style: solid; border-color: #BDEBD3; background: var(--c-success-50); }
.upload--done .upload__status { color: var(--c-success-text); }
.upload--error { border-style: solid; border-color: #F5BDBF; background: var(--c-danger-50); }
.upload--error .upload__status { color: var(--c-danger-text); }
.file-trigger { position: relative; overflow: hidden; }
.file-trigger input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.file-trigger:focus-within { outline: 3px solid var(--c-primary); outline-offset: 2px; }
.secure-note { display: flex; align-items: center; gap: var(--sp-2); padding: 10px 12px; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); font-size: var(--fs-xs); color: var(--c-text-muted); }

/* Alertas y avisos */
.alert { margin-bottom: var(--sp-4); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-size: var(--fs-sm); }
.alert--success { background: var(--c-success-50); color: var(--c-success-text); }
.alert--info { background: var(--c-primary-50); color: var(--c-primary-700); }
.alert--warning { background: var(--c-warning-50); color: var(--c-warning-text); }
.alert--error { background: var(--c-danger-50); color: var(--c-danger-text); }
.toasts { position: fixed; left: 50%; bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: var(--sp-2); width: min(92vw, 420px); transform: translateX(-50%); }
.toast { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--c-navy); color: #fff; font-size: var(--fs-sm); box-shadow: var(--sh-lg); animation: toast-in .2s var(--ease); }
.toast--success { background: var(--c-success-text); }
.toast--error { background: var(--c-danger-text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Acordeón */
.faq { display: grid; gap: 10px; }
.faq details { padding: 0 var(--sp-4); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 56px; font-weight: var(--fw-semibold); list-style: none; cursor: pointer; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; color: var(--c-primary); transition: .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding-bottom: var(--sp-4); font-size: .9375rem; color: var(--c-text-muted); }

/* WhatsApp flotante */
.fab-whatsapp { position: fixed; right: var(--sp-4); bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); z-index: 30; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--c-whatsapp); color: #fff; box-shadow: 0 10px 25px rgba(37,211,102,.45); }

/* Tabla: en móvil cada fila es una tarjeta (usa data-label) */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.table tr { display: block; margin-bottom: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); }
.table td { display: flex; justify-content: space-between; gap: var(--sp-4); padding: 6px 0; text-align: right; }
.table td::before { content: attr(data-label); font-weight: var(--fw-semibold); color: var(--c-text-muted); text-align: left; }
@media (min-width: 640px) {
  .table thead { position: static; width: auto; height: auto; clip: auto; display: table-header-group; }
  .table tr { display: table-row; margin: 0; padding: 0; border: 0; background: none; }
  .table th { padding: var(--sp-3); border-bottom: 2px solid var(--c-border); font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-align: left; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); }
  .table td { display: table-cell; padding: var(--sp-3); border-bottom: 1px solid var(--c-border); background: var(--c-surface); text-align: left; }
  .table td::before { content: none; }
}

/* KPI */
.kpi { padding: var(--sp-4); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); }
.kpi__label { font-size: var(--fs-xs); color: var(--c-text-muted); }
.kpi__value { font-size: var(--fs-xl); font-weight: var(--fw-bold); color: var(--c-navy); letter-spacing: -.02em; }
.kpi__delta { font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.kpi__delta--up { color: var(--c-success-text); }
.kpi__delta--down { color: var(--c-danger-text); }
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }

/* Resumen */
.summary { margin-bottom: 14px; padding: 14px; border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
.summary__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-1); font-weight: var(--fw-bold); }
.summary__row { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px 0; border-bottom: 1px dashed var(--c-border); font-size: var(--fs-sm); }
.summary__row:last-child { border-bottom: 0; }
.summary__row dd { margin: 0; text-align: right; }
.summary__row--total { font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--c-primary-600); }

/* Páginas de error */
.error-page { max-width: 480px; margin-inline: auto; padding-block: var(--sp-6); text-align: center; }
.error-page__code { font-size: var(--fs-3xl); font-weight: var(--fw-bold); color: var(--c-primary); }
.error-page__title { margin-bottom: var(--sp-2); font-size: var(--fs-xl); }
.error-page .btn { margin-top: var(--sp-5); }
