*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body, system-ui, -apple-system, 'Segoe UI', sans-serif); color: var(--text); background: var(--bg); line-height: 1.5; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.no-scroll { overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.gap { gap: .6rem; }
.stack > * + * { margin-top: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .7rem 1.15rem; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; line-height: 1.1;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease, opacity .2s;
  background: var(--surface-2); color: var(--text);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--on-primary, #fff); }
.btn.primary:hover { box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: #c0392b; color: #fff; }
.btn.sm { padding: .45rem .8rem; font-size: .85rem; }
.btn.block { width: 100%; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: .35rem; border-radius: 8px; font-size: 1.05rem; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); }

/* Formularios */
label.field { display: block; }
label.field > span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.input, input:not([type]), input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=url],
input[type=datetime-local], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: .7rem .85rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
textarea { resize: vertical; min-height: 90px; }
input[type=color] { width: 48px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 12, 10, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .2s ease;
}
.modal-backdrop.in { opacity: 1; }
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--surface); color: var(--text); border-radius: 22px; padding: 28px 24px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .3); transform: translateY(14px) scale(.98); transition: transform .25s ease;
}
.modal.wide { width: min(980px, 100%); }
.modal-backdrop.in .modal { transform: none; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 1.7rem; line-height: 1; cursor: pointer; color: var(--muted); }
.confirm-text { font-size: 1.05rem; margin: 0 0 1.2rem; }

/* Toast */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: #1d1d1f; color: #fff; padding: .75rem 1rem; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: toastIn .25s ease; transition: opacity .4s, transform .4s; font-size: .93rem; }
.toast-error { background: #b3261e; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: #e3f4e8; color: #1e7b3a; }
.badge.warn { background: #fff3d6; color: #8a5a00; }
.badge.bad { background: #fde4e1; color: #a52a1a; }
.badge.info { background: #e3edfb; color: #1f4f9a; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen { min-height: 100dvh; display: grid; place-items: center; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
