/* MapVocal UI: sistema de diseño sin dependencias. Claro/oscuro automático, accesible y responsive. */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #16182a;
  --muted: #5b6078;
  --border: #dde1ee;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #e9e8fd;
  --on-brand: #ffffff;
  --ok: #0f7b4b;
  --ok-soft: #dff5e9;
  --warn: #9a5b00;
  --warn-soft: #fdf0d5;
  --danger: #b3261e;
  --danger-soft: #fbe3e1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 24, 42, .06), 0 8px 24px rgba(22, 24, 42, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1120;
    --surface: #181b30;
    --surface-2: #20243e;
    --text: #eceffc;
    --muted: #a1a7c6;
    --border: #2c3153;
    --brand: #8b85ff;
    --brand-strong: #a7a2ff;
    --brand-soft: #262a52;
    --on-brand: #0f1120;
    --ok: #4ade9c;
    --ok-soft: #123326;
    --warn: #fbbf5a;
    --warn-soft: #382a10;
    --danger: #ff8a80;
    --danger-soft: #3c1a19;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--text); background: var(--bg); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--brand-strong); }
code, .mono { font-family: var(--mono); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--on-brand); padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* Cabecera y estructura */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px clamp(16px, 4vw, 40px); background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #22d3ee); display: grid; place-items: center; color: #fff; font-size: 1rem; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }
main { padding: clamp(20px, 5vw, 48px) clamp(16px, 4vw, 40px) 80px; max-width: 1080px; margin: 0 auto; }
.narrow { max-width: 640px; margin: 0 auto; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px; }

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.grid > .card + .card, .grid > * + * { margin-top: 0; }
.hero { text-align: center; padding: clamp(8px, 4vw, 32px) 0 28px; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 52ch; margin-inline: auto; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: .88rem; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], input[type="time"], input[type="email"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
input.code { font-family: var(--mono); font-size: 1.8rem; letter-spacing: .5em; text-align: center; }
.field { margin-bottom: 16px; }
form .alert { margin-bottom: 14px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.checks { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 600; margin: 0; background: var(--surface); }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; font: inherit; font-weight: 700; border-radius: 10px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not([disabled]) { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not([disabled]) { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--brand-strong); padding-inline: 8px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.spinner { width: 16px; height: 16px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: .8rem; font-weight: 700; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); }

.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.alert.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 22px; }
.steps li { flex: 1; text-align: center; font-size: .85rem; font-weight: 700; color: var(--muted); padding-top: 10px; border-top: 4px solid var(--border); }
.steps li.done { color: var(--ok); border-color: var(--ok); }
.steps li.active { color: var(--brand-strong); border-color: var(--brand); }

.result { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 16px; background: var(--surface); color: var(--text); font: inherit; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; }
.result:hover:not([disabled]) { border-color: var(--brand); background: var(--brand-soft); }
.result[disabled] { cursor: not-allowed; opacity: .7; }
.result strong { display: block; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tabs button { background: none; border: none; font: inherit; font-weight: 700; color: var(--muted); padding: 12px 16px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--brand-strong); border-bottom-color: var(--brand); }

.stat { padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat .value { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.split { display: flex; }
.bar.split > span { display: block; height: 100%; }
.bar.split > span.booked { background: var(--warn); }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: none; }
.tick { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 800; }
.tick.done { background: var(--ok-soft); color: var(--ok); }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }

.token-box { display: flex; gap: 8px; align-items: stretch; }
.token-box code { flex: 1; word-break: break-all; padding: 12px 14px; background: var(--surface-2); border: 1.5px dashed var(--border); border-radius: 10px; font-size: .9rem; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; max-width: min(92vw, 380px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; animation: pop .2s ease-out; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.danger { background: var(--danger); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 560px) {
  .steps li { font-size: .72rem; }
  input.code { font-size: 1.4rem; letter-spacing: .3em; }
  .topbar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.pad { padding: 24px; }

.flush { margin: 0; }
.mb { margin-bottom: 18px; }
.mt { margin-top: 14px; }
.my { margin: 18px 0; }
.cell-bar { min-width: 120px; }
.lang-select { width: auto; padding: 7px 10px; font-weight: 600; }

.prewrap { white-space: pre-wrap; margin: 4px 0 0; }
#lang-slot { display: inline-flex; align-items: center; }
.nowrap { white-space: nowrap; }
