/* ============================================================ tokens */
/* Panel de comovos: la misma marca que la portada (papel, tinta, cartón y un solo rojo), en versión prolija para trabajar.
   Sin inclinaciones ni cinta: eso queda para la vidriera. Siempre en claro, aunque el sistema esté en modo oscuro. */
:root {
  --bg: #f4ede0;
  --surface: #fffdf8;
  --surface-2: #f1e9da;
  --text: #1e1b16;
  --muted: #65584a;
  --border: #e3d5bd;
  --accent: #7d5527;          /* cartón perforado: links, pestañas, interruptores, progreso */
  --accent-strong: #5c3d1a;
  --accent-soft: #f3e4c9;
  --accent-text: #ffffff;
  --primary: #c9302c;         /* el único rojo: la acción principal */
  --primary-strong: #a6231f;
  --on-primary: #ffffff;
  --danger: #a6231f;
  --danger-soft: #fbe6e2;
  --on-danger: #fff;
  --warn: #7a5200;
  --warn-soft: #fbefcf;
  --ok: #1d6b43;
  --ok-soft: #e3f1e4;
  --bubble-in: #ffffff;
  --bubble-out: #e7d3b0;
  --chat-bg: #f1e9da;
  --bar: #b98a50;             /* barra superior: cartón */
  --bar-text: #1e1b16;
  --bar-hover: rgb(255 255 255 / 0.22);
  --bar-active: #fbf7ef;
  --shadow: 0 1px 2px rgb(30 27 22 / 0.06), 0 8px 18px -12px rgb(30 27 22 / 0.35);
  --shadow-hover: 0 2px 4px rgb(30 27 22 / 0.08), 0 16px 28px -14px rgb(30 27 22 / 0.45);
  --shadow-lg: 0 28px 56px -20px rgb(10 14 12 / 0.55), 0 6px 12px -4px rgb(10 14 12 / 0.25);
  --shadow-red: 0 8px 16px -8px rgb(166 35 31 / 0.7);
  --radius: 10px;
  --radius-sm: 8px;
  --focus-color: #1e1b16;
  --focus: 0 0 0 3px rgb(125 85 39 / 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-marker: 'Permanent Marker', 'Comic Sans MS', cursive;
  color-scheme: only light;
}

/* ============================================================ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15.5px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
/* El fibrón es para gritar: solo el título de cada sección. */
h1 { font-family: var(--font-marker); font-weight: 400; font-size: clamp(26px, 3.2vw, 32px); letter-spacing: 0.01em; line-height: 1.1; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-weight: 700; }
p { margin: 0 0 8px; }
a { color: var(--accent); text-underline-offset: 2px; transition: color .15s; }
a:hover { color: var(--accent-strong); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: var(--radius-sm); transition: top .2s var(--ease); }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============================================================ iconos (SVG en máscara) */
.ico { display: inline-block; width: 18px; height: 18px; flex: none; background: currentColor; vertical-align: -3px;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ico.big { width: 28px; height: 28px; color: var(--accent); }

/* ============================================================ botones */
.btn, button {
  font: inherit; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none;
  transition: background-color .18s, border-color .18s, color .18s, box-shadow .2s var(--ease), transform .2s var(--ease);
}
.btn:hover, button:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.btn:active, button:active { transform: translateY(1px) scale(0.98); transition-duration: .06s; }
.btn.primary, button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-red); }
.btn.primary:hover, button.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); transform: translateY(-1px); }
.btn.primary:active, button.primary:active { transform: translateY(1px) scale(0.98); box-shadow: none; }
.btn.danger, button.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover, button.ghost:hover { background: var(--surface-2); }
.btn.small, button.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.icon { min-height: 36px; width: 36px; padding: 0; }
.btn.block { width: 100%; }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .8s linear infinite; }
.btn.primary.is-busy::after { border-color: var(--on-primary) transparent var(--on-primary) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
label.btn { margin: 0; }

/* ============================================================ formularios */
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; min-width: 0; flex: 1 1 180px; }
.field.grow { flex: 3 1 260px; }
.field.end { justify-content: flex-end; flex: 0 0 auto; }
.field.compact { margin: 0; flex: 0 0 auto; }
.field > label, .field label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text); }
input, textarea, select {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; min-height: 40px;
}
input, textarea, select { transition: border-color .18s, box-shadow .18s, background-color .18s; }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
input[type=file] { padding: 7px; }
input[type=range] { padding: 0; min-height: 28px; accent-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1.3em; margin: 0 0 8px; }
label.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-weight: 500; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { width: 260px; max-width: 100%; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled { opacity: .55; }

/* Interruptor accesible (checkbox con role="switch") */
.switch { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 42px; height: 24px; flex: none; border-radius: 99px; background: var(--border); position: relative; transition: background-color .25s var(--ease); }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); transition: transform .35s var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--focus-color); outline-offset: 2px; }

/* ============================================================ superficies */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  transition: box-shadow .3s var(--ease), transform .3s var(--ease), border-color .3s; }
.card.instance:hover, .plan:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 14px 0; background: var(--surface); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.list > * + * { border-top: 1px solid var(--border); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; flex-wrap: wrap; }
.list-item .grow { flex: 1; min-width: 160px; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .ico.big { width: 40px; height: 40px; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 16px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--text); color: var(--bg); animation: badge-in .4s var(--ease); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--danger-soft); color: var(--danger); }
.callout { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; background: var(--accent-soft); }
.callout.warn { background: var(--warn-soft); }
.callout .grow { flex: 1; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .8s var(--ease); animation: grow-x .9s var(--ease) both; transform-origin: left; }
details.tips { margin: 12px 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
details.tips summary { cursor: pointer; font-weight: 700; }
details.tips[open] > *:not(summary) { animation: fade-down .3s var(--ease); }
details.tips li { margin: 6px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }

/* ============================================================ marca */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; color: var(--text); text-decoration: none; transition: transform .4s var(--ease); }
.brand:hover { transform: rotate(-2deg); }

/* ============================================================ planes */
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.plan { display: flex; flex-direction: column; gap: 10px; position: relative; }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan h3 { font-family: var(--font-marker); font-weight: 400; font-size: 24px; }
.plan .price { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 14px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; flex: 1; }
.plan li { display: flex; gap: 8px; align-items: center; }
.plan li .ico { color: var(--ok); width: 16px; height: 16px; }
.plan li.no { color: var(--muted); }
.plan li.no .ico { color: var(--muted); }
.plan .ribbon { position: absolute; top: -11px; right: 16px; }

/* ============================================================ app */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 8px 24px;
  background: var(--bar); color: var(--bar-text); box-shadow: 0 10px 20px -16px rgb(10 14 12 / 0.7); }
.topbar nav { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; padding: 4px 2px; }
.topbar nav a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; color: var(--bar-text); text-decoration: none; font-weight: 700; white-space: nowrap;
  transition: background-color .2s, box-shadow .3s var(--ease), transform .3s var(--ease), color .2s; }
.topbar nav a:hover { background: var(--bar-hover); color: var(--bar-text); }
.topbar nav a[aria-current="page"] { background: var(--bar-active); color: #1e1b16; box-shadow: 0 6px 12px -6px rgb(10 14 12 / 0.6); transform: translateY(-1px); }
.topbar .muted { color: var(--bar-text); opacity: .85; }
.topbar .btn.ghost { color: var(--bar-text); }
.topbar .btn.ghost:hover { background: var(--bar-hover); border-color: transparent; }
.user { display: flex; align-items: center; gap: 8px; }
.banner { padding: 10px 24px; background: var(--warn-soft); color: var(--text); font-size: 14px; }
main#main-app { max-width: 1160px; margin: 0 auto; padding: 28px 24px 64px; outline: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; }
.section-title { font-size: 18px; font-weight: 700; margin: 32px 0 12px; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .topbar nav { order: 3; flex-basis: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .topbar nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 13px; justify-content: center; }
  .user { margin-left: auto; }
  #me-email { display: none; }
  main#main-app { padding: 20px 16px 48px; }
  .inline-form input { width: 100%; }
  .inline-form { width: 100%; }
}

/* Primeros pasos */
.onboard { margin-bottom: 20px; }
.onboard ol { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 4px; }
.onboard li { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.onboard .check-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex: none; }
.onboard li.done .check-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.onboard li.done .check-dot .ico { width: 14px; height: 14px; }
.onboard li.done .label { color: var(--muted); text-decoration: line-through; }
.onboard .label { flex: 1; }

/* Tarjeta de número */
.instance { display: flex; flex-direction: column; gap: 14px; }
.instance > .actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.instance > .actions .btn { min-width: 0; white-space: normal; text-align: center; }
.instance > .actions [data-act=qr] { grid-column: 1 / -1; }
.instance > .actions .btn { justify-content: center; }
.instance-head { display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--font-marker); font-size: 20px; flex: none; }
.instance-head .grow { flex: 1; min-width: 0; }
.instance-head h3 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.meta .ico { width: 15px; height: 15px; }
.bot-toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.bot-toggle .switch { margin: 0; }
.more { position: relative; display: inline-block; margin-left: auto; }
.more summary { list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more .menu { position: absolute; right: 0; top: 42px; z-index: 5; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; transform-origin: top right; animation: menu-in .22s var(--ease); }
.more .menu button { width: 100%; justify-content: flex-start; border: 0; background: transparent; min-height: 36px; border-radius: var(--radius-sm); font-weight: 600; }
.more .menu button:hover { background: var(--surface-2); }

/* Estadísticas y tablas */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { padding: 16px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 28px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); white-space: nowrap; }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td.nowrap { white-space: nowrap; }
td input, td select { min-height: 34px; padding: 5px 8px; }

/* ============================================================ diálogos */
dialog { border: 0; border-radius: 14px; background: var(--surface); color: var(--text); padding: 0; box-shadow: var(--shadow-lg);
  width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  opacity: 0; transform: translateY(14px) scale(0.98);
  transition: opacity .22s var(--ease), transform .32s var(--ease), overlay .32s allow-discrete, display .32s allow-discrete; }
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(14px) scale(0.98); } }
dialog::backdrop { background: rgb(16 12 6 / 0); transition: background-color .3s, overlay .32s allow-discrete, display .32s allow-discrete; }
dialog[open]::backdrop { background: rgb(16 12 6 / 0.55); }
@starting-style { dialog[open]::backdrop { background: rgb(16 12 6 / 0); } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 19px; }
#modal-body { padding: 20px; }
dialog.confirm { width: min(440px, calc(100vw - 24px)); padding: 22px; }
.qr { display: block; margin: 16px auto; width: 280px; max-width: 100%; background: #fff; padding: 10px; border-radius: 12px; }
.qr-steps { margin: 0; padding-left: 20px; color: var(--muted); }

/* Personalidad */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: -4px 0 18px; scrollbar-width: thin; }
.tabs button { border: 0; border-radius: 0; background: transparent; color: var(--muted); min-height: 42px; padding: 8px 12px; white-space: nowrap; border-bottom: 3px solid transparent; transition: color .2s, border-color .25s var(--ease); }
.tabs button:hover { background: transparent; color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.intro { color: var(--muted); margin: 0 0 16px; }
.sub { font-size: 15px; margin: 0 0 6px; }
.upload { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.upload > div { flex: 1; min-width: 220px; }
.form-foot { position: sticky; bottom: -20px; margin: 20px -20px -20px; padding: 14px 20px; display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  background: var(--surface); border-top: 1px solid var(--border); }
.form-foot .hint { flex: 1; }

/* Chat */
.chat { background: var(--chat-bg); border-radius: var(--radius); padding: 14px; height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.chat.review { height: auto; max-height: 360px; }
.chat.review .bubble { cursor: pointer; }
.bubble { align-self: flex-start; max-width: 80%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--bubble-in); white-space: pre-wrap; box-shadow: 0 1px 1px rgb(0 0 0 / 0.08); animation: bubble-in .35s var(--ease) both; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-radius: 14px 14px 4px 14px; }
.bubble.owner { align-self: flex-end; background: var(--bubble-out); outline: 1px dashed var(--accent); border-radius: 14px 14px 4px 14px; }
.bubble small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.bubble audio { display: block; max-width: 240px; height: 36px; }
.chat .typing { color: var(--muted); font-style: italic; }
.composer { display: flex; gap: 8px; }

/* Calibración */
.calib-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border); }
.calib-row audio { height: 36px; max-width: 260px; }
.calib-row .grow { flex: 1; min-width: 180px; }

/* ============================================================ avisos */
.toasts { position: fixed; z-index: 1000; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); animation: toast-in .45s var(--ease); }
.toast.leaving { animation: toast-out .3s var(--ease) forwards; }
.toast.error { background: var(--danger); color: var(--on-danger); }
.toast.ok .ico { color: var(--ok); }
.toast .ico { margin-top: 2px; }

/* Pantallas táctiles: todo lo que se toca mide al menos 44px. */
@media (pointer: coarse) {
  .btn, .btn.small, button.small, .btn.icon, summary.btn, .topbar nav a, .tabs [role=tab], .banner a { min-height: 44px; }
  .btn.icon, summary.btn.icon { width: 44px; }
}

/* Encendido del bot */
.bot-state { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.bot-state > div:first-child { display: grid; gap: 2px; }
.bot-state.on { background: var(--ok-soft); }
.bot-state.night { background: #e4e9f5; }
.bot-state-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: middle; box-shadow: 0 0 0 0 rgb(31 157 102 / 0.5); animation: live 2s infinite; }
.bot-state.night .live-dot { background: #3b5ba9; animation: none; }
@keyframes live { 70% { box-shadow: 0 0 0 8px rgb(31 157 102 / 0); } 100% { box-shadow: 0 0 0 0 rgb(31 157 102 / 0); } }
.start-form { display: grid; gap: 16px; }
.start-form legend { font-weight: 700; margin-bottom: 8px; }
.option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 8px; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.option > span { display: grid; gap: 2px; }
.notify-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.notify-row > div { display: grid; gap: 2px; max-width: 46ch; }
.toast.info .ico { color: var(--accent); }
.brand-logo { display: block; height: 44px; width: auto; }

/* Acceso de soporte */
.support-log { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.contacts { display: grid; gap: 4px; max-height: 420px; overflow-y: auto; margin-top: 10px; }
.contacts .contact { justify-content: flex-start; text-align: left; flex-wrap: wrap; gap: 6px; }

/* ============================================================ movimiento */
/* Al entrar a una sección: la página sube apenas y las tarjetas aparecen escalonadas.
   Solo al cambiar de sección (clase .entering desde route()), no en cada redibujado. */
.view.entering { animation: view-in .4s var(--ease); }
.view.entering :is(.grid, .stats, .plans, #onboarding) > * { animation: rise .5s var(--ease) both; }
.view.entering :is(.grid, .stats, .plans) > :nth-child(2) { animation-delay: 50ms; }
.view.entering :is(.grid, .stats, .plans) > :nth-child(3) { animation-delay: 100ms; }
.view.entering :is(.grid, .stats, .plans) > :nth-child(4) { animation-delay: 150ms; }
.view.entering :is(.grid, .stats, .plans) > :nth-child(5) { animation-delay: 200ms; }
.view.entering :is(.grid, .stats, .plans) > :nth-child(6) { animation-delay: 250ms; }
.view.entering :is(.grid, .stats, .plans) > :nth-child(n+7) { animation-delay: 300ms; }
.view.entering .table-wrap { animation: rise .5s var(--ease) both; animation-delay: 120ms; }
.view.entering .page-head h1 { animation: marker-in .6s var(--ease) both; }
.callout, .banner:not(.hidden) { animation: fade-down .35s var(--ease); }

@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes marker-in { from { opacity: 0; transform: translateX(-6px) rotate(-1.2deg); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-4px); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.96); } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes badge-in { 0% { transform: scale(0.4); } 60% { transform: scale(1.15); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(0.98); } }

/* Un solo rojo por pantalla: dentro de tarjetas, la acción principal va en tinta.
   El rojo queda para la acción principal de la página y la de cada diálogo. */
.card .btn.primary, .card button.primary { background: var(--text); border-color: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.card .btn.primary:hover, .card button.primary:hover { background: color-mix(in srgb, var(--text) 85%, var(--accent)); border-color: transparent; }
.card .btn.primary.is-busy::after { border-color: var(--bg) transparent var(--bg) transparent; }

/* Tablas de administración: acciones en dos columnas y desplegables que no se cortan. */
td .actions { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px; }
td .actions .btn { min-height: 30px; padding: 3px 10px; font-size: 12.5px; }
td select { width: auto; min-width: 0; max-width: 140px; font-size: 13.5px; }
#users td:first-child { white-space: nowrap; }
#users th { white-space: normal; line-height: 1.25; }
#users th, #users td { padding: 10px; }
#users td select { max-width: 124px; }
@media (max-width: 720px) {
  .topbar nav a { border-radius: 14px; padding: 6px 8px; }
}
