/* Toque — sistema visual del panel.
   Fondo hueso, tinta marino y el azul de la tarjeta para las acciones. El naranja solo vive en el punto del logo.
   Una sola familia del sistema: la CSP del panel no admite fuentes externas ni atributos style="". */
:root {
  --bg: #F6F1E7;
  --surface: #FFFDF8;
  --soft: #EFE8DA;
  --line: #E4DCCD;
  --ink: #0A1633;
  --muted: #545B70;
  --blue: #1F4FE0;
  --blue-dark: #173DB3;
  --blue-soft: #E9EDFB;
  --orange: #FF7A1A;
  --good: #1F7A4D;
  --bad: #B3261E;
  --font: "Manrope", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --radius: 10px;
  --radius-lg: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 750; }
h3 { font-size: 0.95rem; font-weight: 700; }
p, figure { margin: 0; }
a { color: var(--blue); }
code { font-family: var(--mono); font-size: 0.85em; background: var(--soft); padding: 0.1em 0.45em; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.hint, .empty { color: var(--muted); font-size: 0.85rem; }

/* Marca */
.lm-bg { fill: var(--ink); }
.lm-wave { stroke: #fff; }
.lm-dot { fill: var(--orange); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; max-width: 1040px; margin: 0 auto; padding: 0.9rem 1.25rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.35rem; letter-spacing: -0.03em; }
.brand i { color: var(--orange); font-style: normal; }
.session { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; justify-content: flex-end; font-size: 0.85rem; color: var(--muted); }
#session-email { overflow: hidden; text-overflow: ellipsis; max-width: 26ch; white-space: nowrap; }
.plan-pill { font-size: 0.8rem; font-weight: 700; color: var(--ink); }

/* Botones */
.btn { font: inherit; font-weight: 700; cursor: pointer; border-radius: var(--radius); border: 1px solid transparent; padding: 0.7rem 1.2rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.line { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.line:hover { border-color: var(--blue); color: var(--blue); }
.btn.danger { background: transparent; border-color: var(--line); color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 0.42rem 0.85rem; font-size: 0.83rem; }
.btn.block { width: 100%; }

/* Formularios */
label { display: grid; gap: 0.35rem; font-size: 0.83rem; font-weight: 650; }
input:not([type="checkbox"]), textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.68rem 0.8rem; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:not([type="checkbox"]):focus-visible, textarea:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[type="checkbox"] { accent-color: var(--blue); width: 1.1rem; height: 1.1rem; margin: 0; flex: none; }
.switch { display: flex; align-items: center; gap: 0.6rem; font-weight: 500; font-size: 0.9rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

.toast { position: fixed; z-index: 20; bottom: 1.4rem; left: 50%; transform: translateX(-50%); margin: 0; width: max-content; max-width: min(92vw, 520px); background: var(--ink); color: #fff; padding: 0.7rem 1.2rem; border-radius: var(--radius); font-size: 0.9rem; }
.toast.error { background: var(--bad); }

/* Superficies */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.4rem; display: grid; gap: 1rem; align-content: start; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }

/* Acceso */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: center; max-width: 1040px; margin: 0 auto; padding: clamp(2rem, 7vw, 5rem) 1.25rem; }
.auth-hero { display: grid; gap: 1.2rem; }
.auth-single { grid-template-columns: minmax(0, 400px); justify-content: center; }
.auth-hero h1 { font-size: clamp(2.2rem, 1.4rem + 3vw, 3.6rem); line-height: 1.05; letter-spacing: -0.035em; }
.auth-hero p { color: var(--muted); font-size: 1.1rem; max-width: 36ch; }
.auth-hero ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.5rem; max-width: 42ch; }
.auth-hero li::marker { color: var(--blue); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: var(--radius); padding: 3px; }
.segmented button { font: inherit; font-weight: 700; border: 0; background: transparent; color: var(--muted); padding: 0.5rem; border-radius: 8px; cursor: pointer; }
.segmented button[aria-selected="true"] { background: #fff; color: var(--ink); }

/* App: selector de tarjeta, pestañas y área de trabajo */
.app { max-width: 1040px; margin: 0 auto; padding: 0.4rem 1.25rem 4rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; }
.picker { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.card-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.card-list:empty { display: none; }
.card-item { font: inherit; font-weight: 700; font-size: 0.88rem; cursor: pointer; display: inline-flex; align-items: center; gap: 0.5rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.9rem; }
.card-item::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--good); }
.card-item.off::before { background: var(--line); }
.card-item.selected { border-color: var(--blue); background: var(--blue-soft); }

.tabbar { display: flex; gap: 1.4rem; border-bottom: 1px solid var(--line); }
.tabbar button { font: inherit; font-weight: 700; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 0.6rem 0.1rem; margin-bottom: -1px; cursor: pointer; }
.tabbar button:hover { color: var(--ink); }
.tabbar button[aria-current="page"] { color: var(--blue); border-bottom-color: var(--blue); }

.workspace { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.overview { display: grid; gap: 1rem; }
.overview-text { display: grid; gap: 0.7rem; justify-items: start; }
.card-art svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 10px 18px rgba(10, 22, 51, 0.1)); }
.ca-brand { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.ca-main { font-size: 15px; }
.ca-sub { font-size: 11px; }
.ca-code { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; }
.now-line { display: flex; gap: 0.55rem; align-items: baseline; color: var(--muted); font-size: 0.9rem; }
.now-line b { color: var(--ink); overflow-wrap: anywhere; }
.now-dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--good); }
.views, .views > div { display: grid; gap: 1.1rem; min-width: 0; align-content: start; }

.presets { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip { font: inherit; font-size: 0.83rem; font-weight: 650; cursor: pointer; background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 0.45rem 0.8rem; border-radius: var(--radius); }
.chip:hover { border-color: var(--blue); color: var(--blue); }
.wa-helper { display: grid; gap: 0.8rem; background: var(--blue-soft); border-radius: var(--radius); padding: 1rem; }

/* Horarios */
.rules { list-style: none; padding: 0; margin: 0; display: grid; }
.rules:empty { display: none; }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 0; border-top: 1px solid var(--line); }
.rule > div { display: grid; min-width: 0; }
.rule .meta, .url { color: var(--muted); font-size: 0.83rem; }
.url { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details summary { cursor: pointer; font-weight: 700; color: var(--blue); }
.rule-form, .stack-form { display: grid; gap: 0.9rem; margin-top: 1rem; }
.days { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.days legend { font-size: 0.83rem; font-weight: 650; margin-bottom: 0.35rem; padding: 0; }
.days label { display: flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.65rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-weight: 500; }
.advanced > * + * { margin-top: 0.8rem; }

/* Resultados */
.big { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.chart { display: flex; align-items: end; gap: 3px; height: 150px; border-bottom: 1px solid var(--line); }
.bar { flex: 1; background: var(--blue); border-radius: 3px 3px 0 0; min-height: 3px; }
.bar:hover { background: var(--blue-dark); }
.bar.zero { background: var(--line); }
#stats-devices { margin-top: 0.8rem; }

/* Cuenta */
.account { display: grid; gap: 1rem; max-width: 620px; }
.sec-block { display: grid; gap: 0.7rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.ok-pill { font-size: 0.75rem; color: var(--good); border: 1px solid currentColor; border-radius: 6px; padding: 0.05rem 0.45rem; }
.secret { word-break: break-all; border-radius: var(--radius); padding: 0.6rem 0.75rem; display: block; letter-spacing: 0.08em; }
.recovery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.4rem; }
.recovery li { font-family: var(--mono); background: var(--soft); border-radius: var(--radius); padding: 0.4rem 0.7rem; text-align: center; }
.danger-zone summary { color: var(--bad); }
.legal-links { display: flex; gap: 1.2rem; }

/* Planes (apagados por defecto) */
.lockbox, .pro-pitch { background: var(--blue-soft); border-color: transparent; }
.lockbox { border-radius: var(--radius); padding: 0.85rem 1rem; display: flex; gap: 0.8rem; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 0.88rem; }
.lockbox b { margin-right: 0.5rem; color: var(--blue); }
.pro-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.4rem; }

/* Textos legales (/terminos, /privacidad) */
.doc { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem 5rem; display: grid; gap: 0.9rem; }
.doc h1 { font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.4rem); }
.doc h2 { margin-top: 1.1rem; }
.doc ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.4rem; }
.draft-banner { background: var(--blue-soft); border-radius: var(--radius); padding: 0.8rem 1rem; }
mark { background: var(--blue-soft); color: var(--ink); border-radius: 4px; padding: 0.05em 0.35em; }

/* Páginas públicas (/t/...) */
.center { display: grid; place-items: center; padding: 1.5rem; min-height: 100vh; }
.center .card { max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 2rem; text-align: center; display: grid; gap: 0.6rem; }

@media (max-width: 760px) {
  .auth, .auth-single { grid-template-columns: 1fr; }
  #session-email { display: none; }
  .app { padding-bottom: 6rem; }
  /* Pestañas al alcance del pulgar */
  .tabbar { position: fixed; z-index: 10; inset: auto 0 0 0; gap: 0; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar button { flex: 1; font-size: 0.82rem; padding: 0.9rem 0.2rem; margin: 0; border-bottom: 0; border-top: 3px solid transparent; }
  .tabbar button[aria-current="page"] { border-top-color: var(--blue); }
  .toast { bottom: 5rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  /* Tarjeta pequeña junto a su estado, para que el destino quede a la vista */
  .overview { grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 0.9rem; }
  .overview h1 { font-size: 1.15rem; }
  .overview-text { gap: 0.4rem; }
  .panel { padding: 1.1rem; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- Pantalla de acceso ---------- */
body:has(#auth-view:not([hidden])) .topbar { display: none; }
.gate { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

.stage { background: var(--blue); color: #fff; display: grid; grid-template-rows: auto 1fr auto; gap: 1.5rem; padding: clamp(1.5rem, 3.5vw, 3rem); overflow: hidden; }
.stage-brand { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.04em; }
.stage-brand i { color: var(--orange); font-style: normal; }
.stage-object { position: relative; display: grid; place-items: center; min-height: 0; }
.plate { position: relative; z-index: 1; width: min(78%, 430px); height: auto; border-radius: 16px; transform: rotate(-7deg); filter: drop-shadow(0 2px 0 #C9D4F6) drop-shadow(0 34px 30px rgba(5, 14, 54, 0.45)); animation: settle 900ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.plate-brand { font-size: 40px; font-weight: 800; letter-spacing: -1.5px; }
.plate-main { font-size: 18px; font-weight: 600; }
.plate-sub { font-size: 13px; }
.ring { position: absolute; top: 50%; left: 50%; width: min(60%, 340px); aspect-ratio: 1; border: 1.5px solid rgba(255, 255, 255, 0.5); border-radius: 50%; transform: translate(-50%, -50%) scale(0.4); opacity: 0; animation: ring 3.2s cubic-bezier(0.2, 0.6, 0.4, 1) 3; }
.ring:nth-child(2) { animation-delay: 0.45s; }
.ring:nth-child(3) { animation-delay: 0.9s; }

.stage-copy { display: grid; gap: 0.8rem; }
.stage-copy h1 { font-size: clamp(1.8rem, 0.8rem + 2.4vw, 3rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.035em; }
.rotator { display: grid; }
.rotator span { grid-area: 1 / 1; opacity: 0; animation: swap 2.4s both; }
.rotator span:nth-child(2) { animation-delay: 2.4s; }
.rotator span:nth-child(3) { animation-delay: 4.8s; }
.rotator span:nth-child(4) { animation: arrive 0.6s 7.2s both; }
.stage-copy p { max-width: 44ch; color: #DCE4FF; font-size: 1rem; }

.entry { background: var(--surface); display: grid; grid-template-rows: 1fr auto; padding: 2rem clamp(1.25rem, 4vw, 3.5rem) 1.25rem; }
.entry-inner { align-self: center; justify-self: center; width: min(100%, 380px); display: grid; gap: 0.4rem; }
.entry h2 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; }
.entry-lead { color: var(--muted); margin-bottom: 1.2rem; }
.auth-form { display: grid; gap: 1rem; }
.entry .segmented { background: none; border-radius: 0; padding: 0; border-bottom: 1px solid var(--line); }
.entry .segmented button { border-radius: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.entry .segmented button[aria-selected="true"] { background: none; color: var(--blue); border-bottom-color: var(--blue); }
.entry input:not([type="checkbox"]) { border-color: #CFC6B4; padding-block: 0.8rem; }
.entry .btn.block { padding-block: 0.85rem; }
.entry-legal { justify-self: center; display: flex; gap: 1.25rem; font-size: 0.8rem; }
.entry-legal a { color: var(--muted); }

.password { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 0; }
.password label { grid-column: 1 / -1; }
.password input { grid-column: 1 / -1; grid-row: 2; padding-right: 5rem; }
.password button { grid-column: 2; grid-row: 2; align-self: center; margin-right: 0.35rem; font: inherit; font-size: 0.8rem; font-weight: 700; color: var(--blue); background: none; border: 0; padding: 0.4rem 0.5rem; cursor: pointer; }

@keyframes settle { from { opacity: 0; transform: translateY(26px) rotate(0deg); } to { opacity: 1; transform: rotate(-7deg); } }
@keyframes ring { 0% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.4); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.7); } }
@keyframes swap { 0% { opacity: 0; transform: translateY(0.4em); } 12%, 86% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-0.4em); } }
@keyframes arrive { from { opacity: 0; transform: translateY(0.4em); } to { opacity: 1; transform: none; } }

/* Pantallas bajas: se reduce la tarjeta para que todo siga en una sola vista */
@media (max-height: 760px) and (min-width: 861px) {
  .stage { padding-block: 1.25rem; gap: 0.8rem; }
  .plate { width: min(58%, 330px); }
  .entry { padding-block: 1rem; }
  .entry-lead { margin-bottom: 0.6rem; }
}
@media (max-width: 860px) {
  .gate { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .stage { grid-template-rows: auto auto; grid-template-columns: minmax(0, 1fr) 118px; gap: 0.8rem; padding: 1.1rem 1.25rem 1.4rem; align-items: center; }
  .stage-brand { grid-column: 1 / -1; font-size: 1.35rem; }
  .stage-copy { grid-column: 1; grid-row: 2; }
  .stage-copy h1 { font-size: 1.45rem; }
  .stage-copy p { display: none; }
  .stage-object { grid-column: 2; grid-row: 2; }
  .plate { width: 112px; }
  .ring { width: 90px; }
  .entry { padding-top: 1.4rem; }
  .entry-inner { align-self: start; }
  .entry h2, .entry-lead { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .gate * { animation: none !important; }
  .rotator span:nth-child(4) { opacity: 1; }
}
